Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Accept new baselines
- Loading branch information
1 parent
71fe8e8
commit 33c7e7f
Showing
9 changed files
with
229 additions
and
105 deletions.
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
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
76 changes: 44 additions & 32 deletions
76
...rcularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.errors.txt
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
100 changes: 100 additions & 0 deletions
100
tests/baselines/reference/conditionalTypesSimplifyWhenTrivial.errors.txt
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,100 @@ | ||
tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts(27,14): error TS2322: Type 'Pick<Params, ExcludeWithDefault<keyof Params, never, never>>' is not assignable to type 'Params'. | ||
'Pick<Params, ExcludeWithDefault<keyof Params, never, never>>' is assignable to the constraint of type 'Params', but 'Params' could be instantiated with a different subtype of constraint '{}'. | ||
tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts(31,5): error TS2322: Type 'T' is not assignable to type 'ExcludeWithDefault<T, never, never>'. | ||
tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts(36,14): error TS2322: Type 'Pick<Params, ExtractWithDefault<keyof Params, keyof Params, never>>' is not assignable to type 'Params'. | ||
'Pick<Params, ExtractWithDefault<keyof Params, keyof Params, never>>' is assignable to the constraint of type 'Params', but 'Params' could be instantiated with a different subtype of constraint '{}'. | ||
tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts(40,5): error TS2322: Type 'T' is not assignable to type 'ExtractWithDefault<T, T, never>'. | ||
tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts(47,14): error TS2322: Type 'Pick<Params, TemplatedConditional<keyof Params, never, never, keyof Params>>' is not assignable to type 'Params'. | ||
'Pick<Params, TemplatedConditional<keyof Params, never, never, keyof Params>>' is assignable to the constraint of type 'Params', but 'Params' could be instantiated with a different subtype of constraint '{}'. | ||
tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts(51,5): error TS2322: Type 'T' is not assignable to type 'TemplatedConditional<T, never, never, T>'. | ||
tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts(56,14): error TS2322: Type 'Pick<Params, TemplatedConditional<keyof Params, keyof Params, keyof Params, never>>' is not assignable to type 'Params'. | ||
'Pick<Params, TemplatedConditional<keyof Params, keyof Params, keyof Params, never>>' is assignable to the constraint of type 'Params', but 'Params' could be instantiated with a different subtype of constraint '{}'. | ||
tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts(60,5): error TS2322: Type 'T' is not assignable to type 'TemplatedConditional<T, T, T, never>'. | ||
|
||
|
||
==== tests/cases/compiler/conditionalTypesSimplifyWhenTrivial.ts (8 errors) ==== | ||
const fn1 = <Params>( | ||
params: Pick<Params, Exclude<keyof Params, never>>, | ||
): Params => params; | ||
|
||
function fn2<T>(x: Exclude<T, never>) { | ||
var y: T = x; | ||
x = y; | ||
} | ||
|
||
const fn3 = <Params>( | ||
params: Pick<Params, Extract<keyof Params, keyof Params>>, | ||
): Params => params; | ||
|
||
function fn4<T>(x: Extract<T, T>) { | ||
var y: T = x; | ||
x = y; | ||
} | ||
|
||
declare var x: Extract<number | string, any>; // Should be `numebr | string` and not `any` | ||
|
||
type ExtractWithDefault<T, U, D = never> = T extends U ? T : D; | ||
|
||
type ExcludeWithDefault<T, U, D = never> = T extends U ? D : T; | ||
|
||
const fn5 = <Params>( | ||
params: Pick<Params, ExcludeWithDefault<keyof Params, never>>, | ||
): Params => params; | ||
~~~~~~ | ||
!!! error TS2322: Type 'Pick<Params, ExcludeWithDefault<keyof Params, never, never>>' is not assignable to type 'Params'. | ||
!!! error TS2322: 'Pick<Params, ExcludeWithDefault<keyof Params, never, never>>' is assignable to the constraint of type 'Params', but 'Params' could be instantiated with a different subtype of constraint '{}'. | ||
|
||
function fn6<T>(x: ExcludeWithDefault<T, never>) { | ||
var y: T = x; | ||
x = y; | ||
~ | ||
!!! error TS2322: Type 'T' is not assignable to type 'ExcludeWithDefault<T, never, never>'. | ||
} | ||
|
||
const fn7 = <Params>( | ||
params: Pick<Params, ExtractWithDefault<keyof Params, keyof Params>>, | ||
): Params => params; | ||
~~~~~~ | ||
!!! error TS2322: Type 'Pick<Params, ExtractWithDefault<keyof Params, keyof Params, never>>' is not assignable to type 'Params'. | ||
!!! error TS2322: 'Pick<Params, ExtractWithDefault<keyof Params, keyof Params, never>>' is assignable to the constraint of type 'Params', but 'Params' could be instantiated with a different subtype of constraint '{}'. | ||
|
||
function fn8<T>(x: ExtractWithDefault<T, T>) { | ||
var y: T = x; | ||
x = y; | ||
~ | ||
!!! error TS2322: Type 'T' is not assignable to type 'ExtractWithDefault<T, T, never>'. | ||
} | ||
|
||
type TemplatedConditional<TCheck, TExtends, TTrue, TFalse> = TCheck extends TExtends ? TTrue : TFalse; | ||
|
||
const fn9 = <Params>( | ||
params: Pick<Params, TemplatedConditional<keyof Params, never, never, keyof Params>>, | ||
): Params => params; | ||
~~~~~~ | ||
!!! error TS2322: Type 'Pick<Params, TemplatedConditional<keyof Params, never, never, keyof Params>>' is not assignable to type 'Params'. | ||
!!! error TS2322: 'Pick<Params, TemplatedConditional<keyof Params, never, never, keyof Params>>' is assignable to the constraint of type 'Params', but 'Params' could be instantiated with a different subtype of constraint '{}'. | ||
|
||
function fn10<T>(x: TemplatedConditional<T, never, never, T>) { | ||
var y: T = x; | ||
x = y; | ||
~ | ||
!!! error TS2322: Type 'T' is not assignable to type 'TemplatedConditional<T, never, never, T>'. | ||
} | ||
|
||
const fn11 = <Params>( | ||
params: Pick<Params, TemplatedConditional<keyof Params, keyof Params, keyof Params, never>>, | ||
): Params => params; | ||
~~~~~~ | ||
!!! error TS2322: Type 'Pick<Params, TemplatedConditional<keyof Params, keyof Params, keyof Params, never>>' is not assignable to type 'Params'. | ||
!!! error TS2322: 'Pick<Params, TemplatedConditional<keyof Params, keyof Params, keyof Params, never>>' is assignable to the constraint of type 'Params', but 'Params' could be instantiated with a different subtype of constraint '{}'. | ||
|
||
function fn12<T>(x: TemplatedConditional<T, T, T, never>) { | ||
var y: T = x; | ||
x = y; | ||
~ | ||
!!! error TS2322: Type 'T' is not assignable to type 'TemplatedConditional<T, T, T, never>'. | ||
} | ||
|
||
declare var z: any; | ||
const zee = z!!!; // since x is `any`, `x extends null | undefined` should be both true and false - and thus yield `any` | ||
|
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
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
Oops, something went wrong.