GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — [Salsa] Support @typedef for jsdoc by zhengbli · Pull Request #8103 · microsoft/TypeScript ConversationThis PR adds support for the Format 1: /** @typedef { [Type Expression] } [Type Name] */Format 2: /** @typedef [Type Expression] */ var [Type Name]; Format 3: /** * @typedef {Object} [Type Name] * @property {[Type Expression]} [Property Name] * @property {[Type Expression]} [Property Name] * ... */ Format 4: /** * @typedef [Type Name] * @type {Object} * @property {[Type Expression]} [Property Name] * @property {[Type Expression]} [Property Name] * ... */ Current the "Type name" can only be an identifier. Dotted names (qualified names) support may be added in future updates. The types defined by the Basic support in language services like go to definition and rename is added as well. Fixes #6976
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
…as hydrated with jsdocComment nodes. … typedefForJsdoc # Conflicts: # src/compiler/diagnosticMessages.json # src/services/services.ts
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: what is the JSDocTypeLiteral?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A type T = { name: string, age: number} which is equivalent to the following jsdoc: /** * @typedef {Object} T * @property {string} name * @property {number} age */ So I defined the
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
|
|
What's the perf impact of parsing the extra comments? Any? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (includeJsDocComment) { | ||
| const jsDocChildren = ts.filter(current.getChildren(), isJSDocNode); | ||
| for (const jsDocChild of jsDocChildren) { | ||
| let start = allowPositionInLeadingTrivia ? jsDocChild.getFullStart() : jsDocChild.getStart(sourceFile, includeJsDocComment); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Should this be "const"
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I ran the following sample for the perf bench mark: The Setup:In an empty folder, do (I chose ember-cli because it is big enough to see the bind/parsing time difference) The bench mark script is: Write-Output "TSC runs:" 0..10 | % {tsc -p ".\jsconfig.json" --noEmit --diagnostics | Select-String "Bind Time|Parse Time"} Write-Output "PR runs:" 0..10 | % { node --max-old-space-size=2000 "C:\Users\lizhe\Documents\github\TypeScript\built\local\tsc.js" -p ".\jsconfig.json" --noEmit --diagnostics | Select-String "Bind Time|Parse Time"} The Result: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
… typedefForJsdoc # Conflicts: # src/services/services.ts
There was an error while loading. Please reload this page.
|
So it turns out that my previous benchmark wasn't very accurate at all, for several reasons:
I rerun the benchmarks with these factors fixed. The new environment is:
c) use node for both cases, the new script is: Param($count) Write-Output "PR runs:" 0..($count - 1) | % { node --max-old-space-size=2000 "C:\Users\lan\Documents\github\TypeScript\built\local\tsc.js" -p ".\jsconfig.json" --noEmit --diagnostics | Select-String "Bind Time"} Write-Output "Master runs:" 0..($count - 1) | % { node --max-old-space-size=2000 "C:\Program Files\nodejs\node_modules\typescript\lib\tsc.js" -p ".\jsconfig.json" --noEmit --diagnostics | Select-String "Bind Time" } d) use the latest nightly and merge the PR with master locally. Checked the diff of two And the benchmark result shows that the PR is not slower in binding time: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
👍 especially if it's somehow faster 😉 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
… typedefForJsdoc # Conflicts: # src/services/services.ts # tests/cases/unittests/jsDocParsing.ts
… typedefForJsdoc # Conflicts: # src/services/utilities.ts
95fd3a1 to
e69976c
Compare
|
|
||
| // @kind(SyntaxKind.JSDocTypedefTag) | ||
| export interface JSDocTypedefTag extends JSDocTag, Declaration { | ||
| name: Identifier; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
name, typeExpresion and type should be optional.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I would add a navigate to test for typedefs |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
👍 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
#8849 touches the same areas, can you merge this in after that ones goes in. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…Script into typedefForJsdoc # Conflicts: # src/compiler/binder.ts
… typedefForJsdoc
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.