Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mkantor
Copy link
Contributor

@mkantor mkantor commented May 23, 2025

Completions are now suggested within type arguments of the following expression types (based on type parameter constraints):

  • function calls (f<…>())
  • new expressions (new Foo<…>())
  • tagged templates (tag<…>`blah`)
  • JSX elements (<Component<…>/>)
  • decorators (@decorator<…> class {})
  • instantiation expressions (f<…>)

Fixes #61751.

Limitations

This comment may also be useful reading.

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog May 23, 2025
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label May 23, 2025
@typescript-bot
Copy link
Collaborator

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.

Comment on lines 4754 to 4757
/** @internal @knipignore */
export function hasTypeArguments(node: Node): node is HasTypeArguments {
return !!(node as HasTypeArguments).typeArguments;
}

This comment was marked as outdated.

Comment on lines 1296 to 1301
export type HasTypeArguments =
| CallExpression
| NewExpression
| TaggedTemplateExpression
| JsxOpeningElement
| JsxSelfClosingElement;

This comment was marked as outdated.

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
@mkantor mkantor force-pushed the completions-of-type-arguments-in-more-places branch from e4bac38 to 04bc7b4 Compare June 2, 2025 18:03
@mkantor
Copy link
Contributor Author

mkantor commented Jun 2, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

Completions for type arguments of expressions
2 participants