Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3160,6 +3160,9 @@ namespace ts {
if (declaration.kind === SyntaxKind.ExportAssignment) {
return links.type = checkExpression((<ExportAssignment>declaration).expression);
}
if (declaration.flags & NodeFlags.JavaScriptFile && declaration.kind === SyntaxKind.JSDocPropertyTag && (<JSDocPropertyTag>declaration).typeExpression) {
Copy link
Copy Markdown
Contributor

@mhegazy mhegazy Jul 11, 2016

Choose a reason for hiding this comment

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

should not this be in getTypeForVariableLikeDeclarationFromJSDocComment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That method is originally for declarations written in the code whose type annotation in another seperated jsdoc comment, so other methods who call it all assumes VariableLikeDeclaration type of the declaration. It seems to be a lot of change to make all of them accept VariableLikeDeclaration | JSDocPropertyTag. What would be the benefit of doing that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nothing specifically. it is just where all our get-type-from-jsdoc code.

return links.type = getTypeFromTypeNode((<JSDocPropertyTag>declaration).typeExpression.type);
}
// Handle variable, parameter or property
if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) {
return unknownType;
Expand Down
34 changes: 29 additions & 5 deletions tests/cases/fourslash/server/jsdocTypedefTag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,24 @@
//// var numberLike; numberLike./*numberLike*/
////
//// /** @type {Person} */
//// var p;p./*person*/
//// var p;p./*person*/;
//// p.personName./*personName*/;
//// p.personAge./*personAge*/;
////
//// /** @type {Animal} */
//// var a;a./*animal*/
//// var a;a./*animal*/;
//// a.animalName./*animalName*/;
//// a.animalAge./*animalAge*/;
////
//// /** @type {Cat} */
//// var c;c./*cat*/
//// var c;c./*cat*/;
//// c.catName./*catName*/;
//// c.catAge./*catAge*/;
////
//// /** @type {Dog} */
//// var d;d./*dog*/
//// var d;d./*dog*/;
//// d.dogName./*dogName*/;
//// d.dogAge./*dogAge*/;

goTo.marker('numberLike');
verify.memberListContains('charAt');
Expand All @@ -50,15 +58,31 @@ verify.memberListContains('toExponential');
goTo.marker('person');
verify.memberListContains('personName');
verify.memberListContains('personAge');
goTo.marker('personName');
verify.memberListContains('charAt');
goTo.marker('personAge');
verify.memberListContains('toExponential');

goTo.marker('animal');
verify.memberListContains('animalName');
verify.memberListContains('animalAge');
goTo.marker('animalName');
verify.memberListContains('charAt');
goTo.marker('animalAge');
verify.memberListContains('toExponential');

goTo.marker('dog');
verify.memberListContains('dogName');
verify.memberListContains('dogAge');
goTo.marker('dogName');
verify.memberListContains('charAt');
goTo.marker('dogAge');
verify.memberListContains('toExponential');

goTo.marker('cat');
verify.memberListContains('catName');
verify.memberListContains('catAge');
verify.memberListContains('catAge');
goTo.marker('catName');
verify.memberListContains('charAt');
goTo.marker('catAge');
verify.memberListContains('toExponential');