-
-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entirely remake typia
for TS 5.2 transform API
#633
Comments
@jakebailey As you don't want to fill more question contents in the TS issue, I ask you in here issue. You told me to use This is not what I want, as Is there any other way to solve this problem cleary? Am I missing something? |
1st implementation without detailed testing. About the implementation, only `comment tags` are left. By the way, about the `comment tags`, need to consider how to efficiently implement.
Just to temper expectations, it's just me proposing this, and it may not actually happen at all. I would't spend too much time on testing this unless you're really bored.
Are you just looking to get the raw JSDoc text? |
const range: ts.TextRange = tsc.getCommentRange(node);
const text: string = TsNodeUtil.getSourceFile(tsc)(
node,
).text.substring(range.pos, range.end);
return filter(text).join("\n"); @jakebailey I'm getting raw comment text through
|
JSDoc is a property of the declaration, so you should be able to just call |
I tried the https://github.com/samchon/typia/blob/features/ts5.2/src/utils/TsSymbolUtil.ts |
I see, then if you want to get at the text, you could just slice the SourceFile based on |
Yes, as you say, I'm using Do you think erasing comment is a spec, or bug? If bug, I'll make a reproducable repo and report by writing issue on TS repo. |
The tags we handle are the ones we have types for and store, so I don't know if this is really a bug. @sandersn would know better. |
Succeeded to fully support TS 5.2 transform API. By the way, supporting both `ts-patch` and TS 5.2 transform API may be impossible. Also, supporting both TS 4.x and TS 5.x would be impossible, either. It's because too much TS 5 features are being used, and when install `ts-patch` on TS 5.2, TS compiler be broken. By the way, as current TS 5.2 (alpha) get wrong path from plugin path, I just hard coded to have wrong path following the TS 5.2 bug. It must be rolled backed when TS 5.2 get correct path.
Neither comments nor tags should be erased. Here's an example I tried: interface Foo {
/** @type int */
type: number
} and then at the REPL:
A few comments:
interface Foo {
/** @foundation int */
type: number
} and then at the REPL:
|
@sandersn I wrote same code with you, but the As you know, I can't controll the May I believe and just wait for @jakebailey to configure Or is there something else I should do to help?
const entire = tsc.getJSDocCommentsAndTags(node);
for (const elem of entire)
if (tsc.isJSDoc(elem)) {
const typeTag = elem.tags?.[0];
if (
typeTag &&
tsc.isJSDocTypeTag(typeTag) &&
tsc.isTypeReferenceNode(typeTag.typeExpression.type) &&
tsc.isIdentifier(typeTag.typeExpression.type.typeName)
)
console.log({
comment: typeTag.comment,
expression:
typeTag.typeExpression.type.typeName.escapedText.toString(),
});
}
|
I notice that you call |
Found Of course, if try to call
$ npm start
> [email protected] start
> npx tsc --allowPlugins
checker has getSemanticDiagnostics() method? false
Try to call ts.Program.getSemanticDiagnostics(ts.TypeChecker) function...
Error: Debug Failure. False expression.
at D:\github\contributions\reproduce-TS5.2-transform-API-comment-bug\node_modules\typescript\lib\tsc.js:119434:13
at runWithCancellationToken (D:\github\contributions\reproduce-TS5.2-transform-API-comment-bug\node_modules\typescript\lib\tsc.js:119411:14)
at getBindAndCheckDiagnosticsForFileNoCache (D:\github\contributions\reproduce-TS5.2-transform-API-comment-bug\node_modules\typescript\lib\tsc.js:119429:12)
at getAndCacheDiagnostics (D:\github\contributions\reproduce-TS5.2-transform-API-comment-bug\node_modules\typescript\lib\tsc.js:119712:20)
at getBindAndCheckDiagnosticsForFile (D:\github\contributions\reproduce-TS5.2-transform-API-comment-bug\node_modules\typescript\lib\tsc.js:119426:12)
at getSemanticDiagnosticsForFile (D:\github\contributions\reproduce-TS5.2-transform-API-comment-bug\node_modules\typescript\lib\tsc.js:119421:33)
at getDiagnosticsHelper (D:\github\contributions\reproduce-TS5.2-transform-API-comment-bug\node_modules\typescript\lib\tsc.js:119359:44)
at Object.getSemanticDiagnostics (D:\github\contributions\reproduce-TS5.2-transform-API-comment-bug\node_modules\typescript\lib\tsc.js:119372:12)
at Object.create (D:\github\contributions\reproduce-TS5.2-transform-API-comment-bug\lib\transform.js:29:21)
at D:\github\contributions\reproduce-TS5.2-transform-API-comment-bug\node_modules\typescript\lib\tsc.js:119324:21
--------------------------------------------------
[]
{ comment: undefined, expression: 'int' }
[]
{ comment: undefined, expression: 'uint' }
[]
{ comment: undefined, expression: 'int64' } |
Looks like I mis-remembered the API. If you pass a SourceFile to getSemanticDiagnostics, are the jsdoc tags in that source file available afterward. Here's some API examples: https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API |
@sandersn Tried, but Thanks for help, but I should just use |
microsoft/TypeScript#54276
TypeScript team had decided to support formal transform API since v5.2 update.However, as TS v5.2 transform API provides types of
typescript/lib/tsclibrary
instead oftypescript
,typia
must be entirely rewritten. Also, internal API oftypia
would be (not means global functions liketypia.assert<T>()
, but means internal modules likeAssertProgrammer
) entirely changed, therefore 3rd party libraries likenestia
also need break change, too.In such reason, supporting TS 5.2 transform API,
typia
would have another major versionv4
.Release date of TS 5.2 may
2023-08
, buttypia v4
would be released a little bit earlier. It's because nexttypia
will support bothts-patch
and TS 5.2 transform API. When you runnpx typia setup
, it will configuretsconfig.json
file properly considering TS version. If TS version is lower than 5.2,ts-patch
would be utilized. Otherwise, puretypescript
would be utilized.The text was updated successfully, but these errors were encountered: