-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Suggest completions for type arguments of expressions #61758
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
base: main
Are you sure you want to change the base?
Suggest completions for type arguments of expressions #61758
Conversation
Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document them on our wiki's API Breaking Changes page. Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up. |
src/compiler/utilities.ts
Outdated
/** @internal @knipignore */ | ||
export function hasTypeArguments(node: Node): node is HasTypeArguments { | ||
return !!(node as HasTypeArguments).typeArguments; | ||
} |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
src/compiler/types.ts
Outdated
export type HasTypeArguments = | ||
| CallExpression | ||
| NewExpression | ||
| TaggedTemplateExpression | ||
| JsxOpeningElement | ||
| JsxSelfClosingElement; |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
d01431a
to
e4bac38
Compare
Previously, `getTypeArgumentConstraint` could only find constraints for type arguments of generic type instantiations. Now it additionally supports type arguments of the following expression kinds: - function calls - `new` expressions - tagged templates - JSX expressions - decorators - instantiation expressions
e4bac38
to
04bc7b4
Compare
After some consideration I removed 53d3f29 from this branch, since it's pretty tangential. If there's appetite for it I could submit another pull request. This means @typescript-bot's comment is no longer relevant. |
Completions are now suggested within type arguments of the following expression types (based on type parameter constraints):
f<…>()
)new
expressions (new Foo<…>()
)tag<…>`blah`
)<Component<…>/>
)@decorator<…> class {}
)f<…>
)Fixes #61751.
Limitations
:
in a type argument literal) still don't happen, so No completions fromtsserver
for property values in generic type arguments #56299 should remain open.I might take a stab at this, but it'll be a separate effort from the present changeset.EDIT: I took a stab at this and have something that works, but it's stacked atop this branch so I'll see where this pull request goes before opening another one.getCompletionData
incompletions.ts
). This needs fixing to fully address the specific examples in No string completions in type arguments where constrained to string literal union #52898 and No IntelliSense for generic literal types #34771. EDIT: I also have a (stacked) fix for this.This comment may also be useful reading.