-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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 1 commit
a6642d6
6fbd79b
5c2ba01
f8103b5
e5973b8
4c35296
3c32478
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Unfortunately, I didn't find a way to reuse the normal string literal type, so I had to extend the existing JSDoc type hierarchy. Otherwise, this feature is very simple.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| //// [in.js] | ||
| /** | ||
| * @param {'literal'} input | ||
| */ | ||
| function f(input) { | ||
| return input + '.'; | ||
| } | ||
|
|
||
|
|
||
| //// [out.js] | ||
| /** | ||
| * @param {'literal'} input | ||
| */ | ||
| function f(input) { | ||
| return input + '.'; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| === tests/cases/compiler/in.js === | ||
| /** | ||
| * @param {'literal'} input | ||
| */ | ||
| function f(input) { | ||
| >f : Symbol(f, Decl(in.js, 0, 0)) | ||
| >input : Symbol(input, Decl(in.js, 3, 11)) | ||
|
|
||
| return input + '.'; | ||
| >input : Symbol(input, Decl(in.js, 3, 11)) | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| === tests/cases/compiler/in.js === | ||
| /** | ||
| * @param {'literal'} input | ||
| */ | ||
| function f(input) { | ||
| >f : (input: "literal") => string | ||
| >input : "literal" | ||
|
|
||
| return input + '.'; | ||
| >input + '.' : string | ||
| >input : "literal" | ||
| >'.' : 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 + '.'; | ||
|
||
| } | ||
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