Skip to content

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
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type inference with JSDoc, @template and curried functions

4 participants