-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Andarist
wants to merge
1
commit into
microsoft:main
Choose a base branch
from
Andarist:experiment/silent-never-in-intersections
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
tests/baselines/reference/silentNeverInIntersections1.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
//// [tests/cases/compiler/silentNeverInIntersections1.ts] //// | ||
|
||
=== silentNeverInIntersections1.ts === | ||
// https://github.com/microsoft/TypeScript/issues/60864 | ||
|
||
class Variable<U, S extends string> { | ||
>Variable : Symbol(Variable, Decl(silentNeverInIntersections1.ts, 0, 0)) | ||
>U : Symbol(U, Decl(silentNeverInIntersections1.ts, 2, 15)) | ||
>S : Symbol(S, Decl(silentNeverInIntersections1.ts, 2, 17)) | ||
|
||
constructor(public s: S) {} | ||
>s : Symbol(Variable.s, Decl(silentNeverInIntersections1.ts, 3, 14)) | ||
>S : Symbol(S, Decl(silentNeverInIntersections1.ts, 2, 17)) | ||
|
||
u!: U; | ||
>u : Symbol(Variable.u, Decl(silentNeverInIntersections1.ts, 3, 29)) | ||
>U : Symbol(U, Decl(silentNeverInIntersections1.ts, 2, 15)) | ||
} | ||
|
||
function mkGeneric<U, S extends string>(s: S) { | ||
>mkGeneric : Symbol(mkGeneric, Decl(silentNeverInIntersections1.ts, 5, 1)) | ||
>U : Symbol(U, Decl(silentNeverInIntersections1.ts, 7, 19)) | ||
>S : Symbol(S, Decl(silentNeverInIntersections1.ts, 7, 21)) | ||
>s : Symbol(s, Decl(silentNeverInIntersections1.ts, 7, 40)) | ||
>S : Symbol(S, Decl(silentNeverInIntersections1.ts, 7, 21)) | ||
|
||
return new Variable<U, S>(s); | ||
>Variable : Symbol(Variable, Decl(silentNeverInIntersections1.ts, 0, 0)) | ||
>U : Symbol(U, Decl(silentNeverInIntersections1.ts, 7, 19)) | ||
>S : Symbol(S, Decl(silentNeverInIntersections1.ts, 7, 21)) | ||
>s : Symbol(s, Decl(silentNeverInIntersections1.ts, 7, 40)) | ||
} | ||
|
||
type ExactArgNames<GenericType, Constraint> = GenericType & { | ||
>ExactArgNames : Symbol(ExactArgNames, Decl(silentNeverInIntersections1.ts, 9, 1)) | ||
>GenericType : Symbol(GenericType, Decl(silentNeverInIntersections1.ts, 11, 19)) | ||
>Constraint : Symbol(Constraint, Decl(silentNeverInIntersections1.ts, 11, 31)) | ||
>GenericType : Symbol(GenericType, Decl(silentNeverInIntersections1.ts, 11, 19)) | ||
|
||
[K in keyof GenericType]: K extends keyof Constraint ? GenericType[K] : never; | ||
>K : Symbol(K, Decl(silentNeverInIntersections1.ts, 12, 3)) | ||
>GenericType : Symbol(GenericType, Decl(silentNeverInIntersections1.ts, 11, 19)) | ||
>K : Symbol(K, Decl(silentNeverInIntersections1.ts, 12, 3)) | ||
>Constraint : Symbol(Constraint, Decl(silentNeverInIntersections1.ts, 11, 31)) | ||
>GenericType : Symbol(GenericType, Decl(silentNeverInIntersections1.ts, 11, 19)) | ||
>K : Symbol(K, Decl(silentNeverInIntersections1.ts, 12, 3)) | ||
|
||
}; | ||
|
||
type AllowVariables<T> = | ||
>AllowVariables : Symbol(AllowVariables, Decl(silentNeverInIntersections1.ts, 13, 2)) | ||
>T : Symbol(T, Decl(silentNeverInIntersections1.ts, 15, 20)) | ||
|
||
| Variable<T, any> | ||
>Variable : Symbol(Variable, Decl(silentNeverInIntersections1.ts, 0, 0)) | ||
>T : Symbol(T, Decl(silentNeverInIntersections1.ts, 15, 20)) | ||
|
||
| { [K in keyof T]: Variable<T[K], any> | T[K] }; | ||
>K : Symbol(K, Decl(silentNeverInIntersections1.ts, 17, 7)) | ||
>T : Symbol(T, Decl(silentNeverInIntersections1.ts, 15, 20)) | ||
>Variable : Symbol(Variable, Decl(silentNeverInIntersections1.ts, 0, 0)) | ||
>T : Symbol(T, Decl(silentNeverInIntersections1.ts, 15, 20)) | ||
>K : Symbol(K, Decl(silentNeverInIntersections1.ts, 17, 7)) | ||
>T : Symbol(T, Decl(silentNeverInIntersections1.ts, 15, 20)) | ||
>K : Symbol(K, Decl(silentNeverInIntersections1.ts, 17, 7)) | ||
|
||
type TestArgs = { | ||
>TestArgs : Symbol(TestArgs, Decl(silentNeverInIntersections1.ts, 17, 51)) | ||
|
||
someArg: number; | ||
>someArg : Symbol(someArg, Decl(silentNeverInIntersections1.ts, 19, 17)) | ||
|
||
}; | ||
|
||
type TestArgsWithVars = AllowVariables<TestArgs>; | ||
>TestArgsWithVars : Symbol(TestArgsWithVars, Decl(silentNeverInIntersections1.ts, 21, 2)) | ||
>AllowVariables : Symbol(AllowVariables, Decl(silentNeverInIntersections1.ts, 13, 2)) | ||
>TestArgs : Symbol(TestArgs, Decl(silentNeverInIntersections1.ts, 17, 51)) | ||
|
||
function takesGeneric<V extends AllowVariables<TestArgs>>( | ||
>takesGeneric : Symbol(takesGeneric, Decl(silentNeverInIntersections1.ts, 23, 49)) | ||
>V : Symbol(V, Decl(silentNeverInIntersections1.ts, 25, 22)) | ||
>AllowVariables : Symbol(AllowVariables, Decl(silentNeverInIntersections1.ts, 13, 2)) | ||
>TestArgs : Symbol(TestArgs, Decl(silentNeverInIntersections1.ts, 17, 51)) | ||
|
||
a: ExactArgNames<V, TestArgs>, | ||
>a : Symbol(a, Decl(silentNeverInIntersections1.ts, 25, 58)) | ||
>ExactArgNames : Symbol(ExactArgNames, Decl(silentNeverInIntersections1.ts, 9, 1)) | ||
>V : Symbol(V, Decl(silentNeverInIntersections1.ts, 25, 22)) | ||
>TestArgs : Symbol(TestArgs, Decl(silentNeverInIntersections1.ts, 17, 51)) | ||
|
||
): void {} | ||
|
||
let v = takesGeneric({ someArg: mkGeneric("x") }); | ||
>v : Symbol(v, Decl(silentNeverInIntersections1.ts, 29, 3)) | ||
>takesGeneric : Symbol(takesGeneric, Decl(silentNeverInIntersections1.ts, 23, 49)) | ||
>someArg : Symbol(someArg, Decl(silentNeverInIntersections1.ts, 29, 22)) | ||
>mkGeneric : Symbol(mkGeneric, Decl(silentNeverInIntersections1.ts, 5, 1)) | ||
|
89 changes: 89 additions & 0 deletions
89
tests/baselines/reference/silentNeverInIntersections1.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
//// [tests/cases/compiler/silentNeverInIntersections1.ts] //// | ||
|
||
=== silentNeverInIntersections1.ts === | ||
// https://github.com/microsoft/TypeScript/issues/60864 | ||
|
||
class Variable<U, S extends string> { | ||
>Variable : Variable<U, S> | ||
> : ^^^^^^^^^^^^^^ | ||
|
||
constructor(public s: S) {} | ||
>s : S | ||
> : ^ | ||
|
||
u!: U; | ||
>u : U | ||
> : ^ | ||
} | ||
|
||
function mkGeneric<U, S extends string>(s: S) { | ||
>mkGeneric : <U, S extends string>(s: S) => Variable<U, S> | ||
> : ^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^ | ||
>s : S | ||
> : ^ | ||
|
||
return new Variable<U, S>(s); | ||
>new Variable<U, S>(s) : Variable<U, S> | ||
> : ^^^^^^^^^^^^^^ | ||
>Variable : typeof Variable | ||
> : ^^^^^^^^^^^^^^^ | ||
>s : S | ||
> : ^ | ||
} | ||
|
||
type ExactArgNames<GenericType, Constraint> = GenericType & { | ||
>ExactArgNames : ExactArgNames<GenericType, Constraint> | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
[K in keyof GenericType]: K extends keyof Constraint ? GenericType[K] : never; | ||
}; | ||
|
||
type AllowVariables<T> = | ||
>AllowVariables : AllowVariables<T> | ||
> : ^^^^^^^^^^^^^^^^^ | ||
|
||
| Variable<T, any> | ||
| { [K in keyof T]: Variable<T[K], any> | T[K] }; | ||
|
||
type TestArgs = { | ||
>TestArgs : TestArgs | ||
> : ^^^^^^^^ | ||
|
||
someArg: number; | ||
>someArg : number | ||
> : ^^^^^^ | ||
|
||
}; | ||
|
||
type TestArgsWithVars = AllowVariables<TestArgs>; | ||
>TestArgsWithVars : TestArgsWithVars | ||
> : ^^^^^^^^^^^^^^^^ | ||
|
||
function takesGeneric<V extends AllowVariables<TestArgs>>( | ||
>takesGeneric : <V extends AllowVariables<TestArgs>>(a: ExactArgNames<V, TestArgs>) => void | ||
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ | ||
|
||
a: ExactArgNames<V, TestArgs>, | ||
>a : ExactArgNames<V, TestArgs> | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
): void {} | ||
|
||
let v = takesGeneric({ someArg: mkGeneric("x") }); | ||
>v : void | ||
> : ^^^^ | ||
>takesGeneric({ someArg: mkGeneric("x") }) : void | ||
> : ^^^^ | ||
>takesGeneric : <V extends AllowVariables<TestArgs>>(a: ExactArgNames<V, TestArgs>) => void | ||
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^ | ||
>{ someArg: mkGeneric("x") } : { someArg: Variable<number, "x">; } | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
>someArg : Variable<number, "x"> | ||
> : ^^^^^^^^^^^^^^^^^^^^^ | ||
>mkGeneric("x") : Variable<number, "x"> | ||
> : ^^^^^^^^^^^^^^^^^^^^^ | ||
>mkGeneric : <U, S extends string>(s: S) => Variable<U, S> | ||
> : ^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^ | ||
>"x" : "x" | ||
> : ^^^ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// @strict: true | ||
// @noEmit: true | ||
|
||
// https://github.com/microsoft/TypeScript/issues/60864 | ||
|
||
class Variable<U, S extends string> { | ||
constructor(public s: S) {} | ||
u!: U; | ||
} | ||
|
||
function mkGeneric<U, S extends string>(s: S) { | ||
return new Variable<U, S>(s); | ||
} | ||
|
||
type ExactArgNames<GenericType, Constraint> = GenericType & { | ||
[K in keyof GenericType]: K extends keyof Constraint ? GenericType[K] : never; | ||
}; | ||
|
||
type AllowVariables<T> = | ||
| Variable<T, any> | ||
| { [K in keyof T]: Variable<T[K], any> | T[K] }; | ||
|
||
type TestArgs = { | ||
someArg: number; | ||
}; | ||
|
||
type TestArgsWithVars = AllowVariables<TestArgs>; | ||
|
||
function takesGeneric<V extends AllowVariables<TestArgs>>( | ||
a: ExactArgNames<V, TestArgs>, | ||
): void {} | ||
|
||
let v = takesGeneric({ someArg: mkGeneric("x") }); |
Oops, something went wrong.
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.
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.
This makes
silentNeverType
behave more likeunknown
in intersections. Which is definitely not correct for a never type... but asilentNeverType
is really just a special marker type so it doesn't quite have to obey the rules.