Skip to content
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

Ignore silentNever in intersections with other meaningful constituents #60876

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

Conversation

Andarist
Copy link
Contributor

I'm not confident in this at all. I'm treating this as an experiment and I wonder if extended tests can reveal some missing test cases that should be added to the codebase.

The problem is that with a contextualType like V["someArg"] | ((number | Variable<number, any>) & V["someArg"]) when V gets instantiated with silentNeverType the whole thing becomes... well, silentNeverType. The repro in question is also somewhat interesting because all the involved types come from V:

type ExactArgNames<GenericType, Constraint> = GenericType & {
  [K in keyof GenericType]: K extends keyof Constraint ? GenericType[K] : never;
};

In the code above GenericType gets instantiated with V. In general, GenericType bit gets converted to its constraint when a contextual type of its~ property is requested. But the mapped type that iterated over stays somewhat deferred as V["someArg"] and further down the line that creates a problem.

fixes #60864

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Dec 29, 2024
Comment on lines +17828 to +17830
if (type === silentNeverType) {
return includes;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes silentNeverType behave more like unknown in intersections. Which is definitely not correct for a never type... but a silentNeverType is really just a special marker type so it doesn't quite have to obey the rules.

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.

Possible regression of intersection type inference in 5.7.2 compared to 5.6.3
2 participants