GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Filter signatures by matching constraints when instantiating them for instantiation signatures by Andarist · Pull Request #51695 · microsoft/TypeScript

Conversation

@Andarist

@Andarist Mateusz Burzyński (Andarist) commented Nov 30, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

fixes #51694
fixes #63126

There are some open questions related to the design of instantiations expressions and how they relate to overloads etc. But since I was looking into the implementation to see why the reported issue doesn't type-check OK, I've figured out I can create a draft that would address that as the change was fairly easy to introduce.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

herjiict, apendua, louwers, and AFatNiBBa reacted with thumbs up emoji
All reactions
  • 👍 4 reactions
@Andarist
Filter signatures by matching constraints when instantiating them for…
9e02f09
… instantiation signatures
@typescript-bot TypeScript Bot (typescript-bot) added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 30, 2022
Andarist
Mateusz Burzyński (Andarist) commented Nov 30, 2022
View reviewed changes
Comment thread src/compiler/checker.ts
Comment on lines +33701 to +33704
const applicableSignatures = mapDefined(sameTypeAritySignatures, sig => {
const typeArgumentTypes = checkTypeArguments(sig, typeArguments!, /*reportErrors*/ false);
return typeArgumentTypes && getSignatureInstantiation(sig, typeArgumentTypes, isInJSFile(sig.declaration));
});

@Andarist Mateusz Burzyński (Andarist) Nov 30, 2022

Copy link
Copy Markdown
Contributor Author

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.

Note that this still doesn't exactly work like regular overload selection done by chooseOverload. I simply reject signatures that have non-matching constraints on their type params. When overloads are chosen for call expressions etc the first matching overload "wins".

I think that this is actually desirable - since here we still output an intersection of signatures (overloads) and we leave the final overload selection for the time the output type is being used as a call expression.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AFatNiBBa reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Andarist
Mateusz Burzyński (Andarist) commented Nov 30, 2022
View reviewed changes
Comment thread src/compiler/checker.ts
if (applicableSignatures.length) {
return applicableSignatures;
}
return sameMap(sameTypeAritySignatures, sig => {

@Andarist Mateusz Burzyński (Andarist) Nov 30, 2022

Copy link
Copy Markdown
Contributor Author

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.

I've preserved the old behavior here~. If there are some signatures for the given type argument arity but when none of them match... I still gonna report the same error. Perpahs this can be improved further.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AFatNiBBa reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@Andarist
Mateusz Burzyński (Andarist) marked this pull request as ready for review November 30, 2022 10:31
@Andarist Mateusz Burzyński (Andarist) mentioned this pull request Nov 30, 2022
Instantiation expressions don't filter signatures with non-matching constraints #51694
Open
@RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh) requested a review from Anders Hejlsberg (ahejlsberg) December 2, 2022 17:43
@sandersn Nathan Shively-Sanders (sandersn) assigned Anders Hejlsberg (ahejlsberg) Dec 20, 2022
@typescript-bot TypeScript Bot (typescript-bot) added For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Dec 20, 2022
@typescript-bot

TypeScript Bot (typescript-bot) commented Dec 20, 2022

Copy link
Copy Markdown
Contributor

The TypeScript team hasn't accepted the linked issue #51694. If you can get it accepted, this PR will have a better chance of being reviewed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

2 similar comments
@typescript-bot

TypeScript Bot (typescript-bot) commented Dec 20, 2022

Copy link
Copy Markdown
Contributor

The TypeScript team hasn't accepted the linked issue #51694. If you can get it accepted, this PR will have a better chance of being reviewed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Dec 20, 2022

Copy link
Copy Markdown
Contributor

The TypeScript team hasn't accepted the linked issue #51694. If you can get it accepted, this PR will have a better chance of being reviewed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Andarist
Merge remote-tracking branch 'origin/main' into andarist/filter-insta…
ba3e829
…ntiation-expressions-by-matching-constraints
@Andarist
Mateusz Burzyński (Andarist) force-pushed the andarist/filter-instantiation-expressions-by-matching-constraints branch from ff7f0c6 to ba3e829 Compare June 13, 2023 11:42
@Andarist
Merge remote-tracking branch 'origin/main' into andarist/filter-insta…
8d6ff85
…ntiation-expressions-by-matching-constraints
@Andarist Mateusz Burzyński (Andarist) mentioned this pull request Jul 17, 2024
Instantiation expressions don't reject incompatible signatures in situations with mixed call and construct signatures #59319
Open
@apendua Tomasz Lenarcik (apendua) mentioned this pull request Aug 22, 2024
Allow to explicitly pass type parameters via JSDoc #27387
Open
4 tasks done
@typescript-bot TypeScript Bot (typescript-bot) closed this Mar 24, 2026
@github-project-automation github-project-automation Bot moved this from Waiting on reviewers to Done in PR Backlog Mar 24, 2026
@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ahejlsberg Anders Hejlsberg (ahejlsberg) Awaiting requested review from ahejlsberg

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@ahejlsberg Anders Hejlsberg (ahejlsberg)

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

PR Backlog
Status: Done

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Instantiation expressions should filter overloads by type parameter constraints Instantiation expressions don't filter signatures with non-matching constraints

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@Andarist @typescript-bot @ahejlsberg
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.