-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Support for understanding some JSDoc annotations within JavaScript files. #2646
Conversation
…rly setting parents.
Conflicts: src/compiler/binder.ts src/compiler/checker.ts
Conflicts: src/compiler/binder.ts src/compiler/checker.ts src/services/services.ts
Conflicts: src/compiler/checker.ts
Conflicts: src/compiler/checker.ts
@DanielRosenwasser @RyanCavanaugh @billti @zhengbli plz review. |
// @type annotation might have been on the variable statement, try that instead. | ||
let typeTag = getJSDocTypeTag(declaration.parent.parent); | ||
if (typeTag) { | ||
return typeTag.typeExpression.type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will an invalid type tag, e.g. /** @type */
break the language service as the typeTag.typeExpression
is undefined
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. We'll return an missing node there which will result in the undefinedType being. If we see the undefined type, we'll fall back to normal TS inference.
@@ -538,7 +556,7 @@ namespace ts { | |||
} | |||
} | |||
|
|||
function bindFunctionOrConstructorType(node: SignatureDeclaration) { | |||
function bindFunctionOrConstructorTypeORJSDocFunctionType(node: SignatureDeclaration): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OR?
closing this in favor of https://github.com/Microsoft/TypeScript/tree/JSDocAndJSModules |
These will be used in .js files to help inform the type system of the types of JS vars and functions.