-
Notifications
You must be signed in to change notification settings - Fork 13.4k
JSDoc string literal types #9995
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
Changes from 3 commits
a6642d6
6fbd79b
5c2ba01
f8103b5
e5973b8
4c35296
3c32478
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //// [in.js] | ||
| /** | ||
| * @param {'literal'} p1 | ||
| * @param {"literal"} p2 | ||
| * @param {'literal' | 'other'} p3 | ||
| * @param {'literal' | number} p4 | ||
| */ | ||
| function f(p1, p2, p3, p4) { | ||
| return p1 + p2 + p3 + p4 + '.'; | ||
| } | ||
|
|
||
|
|
||
| //// [out.js] | ||
| /** | ||
| * @param {'literal'} p1 | ||
| * @param {"literal"} p2 | ||
| * @param {'literal' | 'other'} p3 | ||
| * @param {'literal' | number} p4 | ||
| */ | ||
| function f(p1, p2, p3, p4) { | ||
| return p1 + p2 + p3 + p4 + '.'; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| === tests/cases/conformance/jsdoc/in.js === | ||
| /** | ||
| * @param {'literal'} p1 | ||
| * @param {"literal"} p2 | ||
| * @param {'literal' | 'other'} p3 | ||
| * @param {'literal' | number} p4 | ||
| */ | ||
| function f(p1, p2, p3, p4) { | ||
| >f : Symbol(f, Decl(in.js, 0, 0)) | ||
| >p1 : Symbol(p1, Decl(in.js, 6, 11)) | ||
| >p2 : Symbol(p2, Decl(in.js, 6, 14)) | ||
| >p3 : Symbol(p3, Decl(in.js, 6, 18)) | ||
| >p4 : Symbol(p4, Decl(in.js, 6, 22)) | ||
|
|
||
| return p1 + p2 + p3 + p4 + '.'; | ||
| >p1 : Symbol(p1, Decl(in.js, 6, 11)) | ||
| >p2 : Symbol(p2, Decl(in.js, 6, 14)) | ||
| >p3 : Symbol(p3, Decl(in.js, 6, 18)) | ||
| >p4 : Symbol(p4, Decl(in.js, 6, 22)) | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| === tests/cases/conformance/jsdoc/in.js === | ||
| /** | ||
| * @param {'literal'} p1 | ||
| * @param {"literal"} p2 | ||
| * @param {'literal' | 'other'} p3 | ||
| * @param {'literal' | number} p4 | ||
| */ | ||
| function f(p1, p2, p3, p4) { | ||
| >f : (p1: "literal", p2: "literal", p3: "literal" | "other", p4: "literal" | number) => string | ||
| >p1 : "literal" | ||
| >p2 : "literal" | ||
| >p3 : "literal" | "other" | ||
| >p4 : "literal" | number | ||
|
|
||
| return p1 + p2 + p3 + p4 + '.'; | ||
| >p1 + p2 + p3 + p4 + '.' : string | ||
| >p1 + p2 + p3 + p4 : string | ||
| >p1 + p2 + p3 : string | ||
| >p1 + p2 : string | ||
| >p1 : "literal" | ||
| >p2 : "literal" | ||
| >p3 : "literal" | "other" | ||
| >p4 : "literal" | number | ||
| >'.' : string | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // @allowJs: true | ||
| // @filename: in.js | ||
| // @out: out.js | ||
| /** | ||
| * @param {'literal'} p1 | ||
| * @param {"literal"} p2 | ||
| * @param {'literal' | 'other'} p3 | ||
| * @param {'literal' | number} p4 | ||
| */ | ||
| function f(p1, p2, p3, p4) { | ||
| return p1 + p2 + p3 + p4 + '.'; | ||
|
Member
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. Does this test really do anything apart from test baselines? Why not write some tests that have observable characteristics from a usage standpoint? For instance, string completion when calling something that takes a union type of string literals.
Member
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. Good idea to add a string-literal-specific test. I didn't even know that we offered completions in strings. This test checks that the jsdoc parser gets the types right. It's in a JavaScript file so the parameter types would otherwise be any. That will produce a lot of observable differences in parameter help and quick info. But I trust those work if the checker can get the types right.
Member
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. Done. |
||
| } | ||
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.
You may need to update the
LastJSDocNodeandLastJSDocTagNodepointersThere 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.
Good catch!
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.
Updated