-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Don't store @template constraint in a TypeParameterDeclaration node #26283
Changes from 1 commit
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 |
---|---|---|
|
@@ -759,6 +759,7 @@ namespace ts { | |
kind: SyntaxKind.TypeParameter; | ||
parent: DeclarationWithTypeParameterChildren | InferTypeNode; | ||
name: Identifier; | ||
// Note: Consider calling `getEffectiveConstraintOfTypeParameter` | ||
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. Hm. We should have these notes as jsdoc for lots of things now. Something for a separate PR though. |
||
constraint?: TypeNode; | ||
default?: TypeNode; | ||
|
||
|
@@ -2363,6 +2364,7 @@ namespace ts { | |
|
||
export interface JSDocTemplateTag extends JSDocTag { | ||
kind: SyntaxKind.JSDocTemplateTag; | ||
constraint: TypeNode | undefined; | ||
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. Only the first type parameter in a list is constrained by the constraint. Can you add a test for that? That is, 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. That was done in #24600 for the reason that reusing a node would be bad -- maybe not necessary now? 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. The test 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. I don't like applying the constraint to multiple parameters even if there's no implementation reason that it's easier. |
||
typeParameters: NodeArray<TypeParameterDeclaration>; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
/////** | ||
//// * @template {/**/ | ||
//// */ | ||
////function f() {} | ||
|
||
goTo.marker(""); | ||
edit.insert("n"); | ||
edit.insert("u"); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/// <reference path='fourslash.ts'/> | ||
|
||
// @allowJs: true | ||
// @checkJs: true | ||
// @Filename: /foo.js | ||
|
||
/////** | ||
//// * Doc | ||
//// * @template {new (...args: any[]) => any} T | ||
//// * @param {T} cls | ||
//// */ | ||
////function /**/myMixin(cls) { | ||
//// return class extends cls {} | ||
////} | ||
|
||
verify.quickInfoAt("", | ||
`function myMixin<T extends new (...args: any[]) => any>(cls: T): { | ||
new (...args: any[]): (Anonymous class); | ||
prototype: myMixin<any>.(Anonymous class); | ||
} & T`, | ||
"Doc"); |
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.
Can we have this function exposed as part of the public API to align with getEffectiveTypeParameterDeclarations?