FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Use jsdoc aliases if visible when printing types by weswigham · Pull Request #24153 · microsoft/TypeScript · GitHub

Use jsdoc aliases if visible when printing types - #24153

Merged
Wesley Wigham (weswigham) merged 4 commits into
microsoft:masterfrom
weswigham:use-jsdoc-aliases
May 16, 2018
Merged

Use jsdoc aliases if visible when printing types#24153
Wesley Wigham (weswigham) merged 4 commits into
microsoft:masterfrom
weswigham:use-jsdoc-aliases

Conversation

Copy link
Copy Markdown
Member

Fixes #24140

This avoids deeply structurally printing massive types which may have been defined in jsdoc. 😉

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
  1. This needs to handle @callback too.
  2. getEffectiveTypeParameterDeclarations needs a better implementation for jsdoc type aliases.

Comment thread src/compiler/checker.ts

function determineIfDeclarationIsVisible() {
switch (node.kind) {
case SyntaxKind.JSDocTypedefTag:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Need to handle SyntaxKind.CallbackTag too

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

#23947 isn't merged yet

Comment thread src/compiler/checker.ts
node.kind === SyntaxKind.ClassExpression || node.kind === SyntaxKind.TypeAliasDeclaration) {
const declaration = <InterfaceDeclaration | TypeAliasDeclaration>node;
node.kind === SyntaxKind.ClassExpression || node.kind === SyntaxKind.TypeAliasDeclaration || node.kind === SyntaxKind.JSDocTypedefTag) {
const declaration = <InterfaceDeclaration | TypeAliasDeclaration | JSDocTypedefTag>node;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

same. There is a predicate isJSDocTypeAlias that should maybe just be isTypeAlias and include SyntaxKind.TypeAliasDeclaration.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

#23947 isn't merged yet

Comment thread src/compiler/utilities.ts
*/
export function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters) {
return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : undefined);
export function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters | JSDocTypedefTag) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

there are a few other places that we get type parameter declarations of typedef and callback tags. They explicitly do not use getEffectiveTypeParameterDeclarations because it incorrectly (1) finds the host and (2) looks for @template in any jsdoc comment. Jsdoc type aliases only look for @template in their containing comment.

That said, it's probably the Right Thing to make getEffectiveTypeParameterDeclarations handle jsdoc type aliases, and have everybody call it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

That said, it's probably the Right Thing to make getEffectiveTypeParameterDeclarations handle jsdoc type aliases, and have everybody call it.

Do you not have such a fix in #23947 ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, along with the astonishing ability to forget what I did two weeks ago!

Copy link
Copy Markdown
Member Author

Nathan Shively-Sanders (@sandersn) Two of your comments don't seem to apply until your PR adding callback tag support is merged? How's this look as is?

Copy link
Copy Markdown
Member

Well, good, except that 50% of the code will have to change after it's merged and will have lurking type parameter lookup bugs if it's not. If you merge this, can you open a bug either on me or on you explaining that @callback won't have this fix, once it's merged?

Wesley Wigham (weswigham) commented May 16, 2018
edited
Loading

Copy link
Copy Markdown
Member Author

I'm not particularly inclined to duplicate your work fixing jsdoc alias type parameters (which'd have issues merging anyway), nor can I implement the fixes for @callback until we actually support @callback; so notes on you it is!

Wesley Wigham (weswigham) merged commit 5bf6e30 into microsoft:master May 16, 2018
Wesley Wigham (weswigham) deleted the use-jsdoc-aliases branch May 16, 2018 19:58
Microsoft (microsoft) locked and limited conversation to collaborators Jul 31, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL