Skip to content

Look for outer type parameters on VariableStatements #37819

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

Merged
merged 1 commit into from
Apr 7, 2020

Conversation

sandersn
Copy link
Member

@sandersn sandersn commented Apr 6, 2020

This only applies in JS, where @template tags can apply to initialisers of variable declarations:

/**
 * @template T
 * @returns {(b: T) => T}
 */
const seq = a => b => b

Fixes #36201

This only applies in JS, where `@template` tags can apply to
initialisers of variable declarations:

```js
/**
 * @template T
 * @returns {(b: T) => T}
 */
const seq = a => b => b
```

Fixes #36201
@sandersn sandersn merged commit 7ca6334 into master Apr 7, 2020
@sandersn sandersn deleted the instantiate-template-tags-on-variablestatements branch April 7, 2020 15:04
sandersn added a commit that referenced this pull request Feb 18, 2021
1. @template parsing may produce a template tag with a type parameter
whose name is the missing identifier. These tags should be skipped
in the checker because they receive an error in the parser.
2. The fix in #37819 was incorrect; there's no such thing as a type
parameter declared on a variable declaration. Instead, there needs to be a type
parameter declared on a jsdoc comment, because that's the scope for tags
like `@return` and `@typedef`.

There are 3 tests because either fix (1) and (2) fix the first test's
failure, but both are required to fix the last two tests' failures.
sandersn added a commit that referenced this pull request Feb 18, 2021
* Improve @template lookup and resilience

1. @template parsing may produce a template tag with a type parameter
whose name is the missing identifier. These tags should be skipped
in the checker because they receive an error in the parser.
2. The fix in #37819 was incorrect; there's no such thing as a type
parameter declared on a variable declaration. Instead, there needs to be a type
parameter declared on a jsdoc comment, because that's the scope for tags
like `@return` and `@typedef`.

There are 3 tests because either fix (1) and (2) fix the first test's
failure, but both are required to fix the last two tests' failures.

* remove containsParseError call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type inference with JSDoc, @template and curried functions
3 participants