Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Accept new baselines
  • Loading branch information
ahejlsberg committed Jan 11, 2021
commit 8ac70306225ea6e15d487c92581690644b09a458
44 changes: 32 additions & 12 deletions tests/baselines/reference/conditionalTypes1.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,24 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(29,5): error TS23
tests/cases/conformance/types/conditional/conditionalTypes1.ts(30,9): error TS2322: Type 'T["x"]' is not assignable to type 'string'.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.
tests/cases/conformance/types/conditional/conditionalTypes1.ts(103,5): error TS2322: Type 'Pick<T, FunctionPropertyNames<T>>' is not assignable to type 'T'.
'T' could be instantiated with an arbitrary type which could be unrelated to 'Pick<T, FunctionPropertyNames<T>>'.
tests/cases/conformance/types/conditional/conditionalTypes1.ts(104,5): error TS2322: Type 'Pick<T, NonFunctionPropertyNames<T>>' is not assignable to type 'T'.
'T' could be instantiated with an arbitrary type which could be unrelated to 'Pick<T, NonFunctionPropertyNames<T>>'.
tests/cases/conformance/types/conditional/conditionalTypes1.ts(106,5): error TS2322: Type 'Pick<T, NonFunctionPropertyNames<T>>' is not assignable to type 'Pick<T, FunctionPropertyNames<T>>'.
tests/cases/conformance/types/conditional/conditionalTypes1.ts(103,5): error TS2322: Type 'FunctionProperties<T>' is not assignable to type 'T'.
'T' could be instantiated with an arbitrary type which could be unrelated to 'FunctionProperties<T>'.
tests/cases/conformance/types/conditional/conditionalTypes1.ts(104,5): error TS2322: Type 'NonFunctionProperties<T>' is not assignable to type 'T'.
'T' could be instantiated with an arbitrary type which could be unrelated to 'NonFunctionProperties<T>'.
tests/cases/conformance/types/conditional/conditionalTypes1.ts(106,5): error TS2322: Type 'NonFunctionProperties<T>' is not assignable to type 'FunctionProperties<T>'.
Type 'FunctionPropertyNames<T>' is not assignable to type 'NonFunctionPropertyNames<T>'.
tests/cases/conformance/types/conditional/conditionalTypes1.ts(108,5): error TS2322: Type 'Pick<T, FunctionPropertyNames<T>>' is not assignable to type 'Pick<T, NonFunctionPropertyNames<T>>'.
Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
Type 'string | number | symbol' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
Type 'string' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
Type 'keyof T' is not assignable to type 'never'.
Type 'string | number | symbol' is not assignable to type 'never'.
Type 'string' is not assignable to type 'never'.
tests/cases/conformance/types/conditional/conditionalTypes1.ts(108,5): error TS2322: Type 'FunctionProperties<T>' is not assignable to type 'NonFunctionProperties<T>'.
Type 'NonFunctionPropertyNames<T>' is not assignable to type 'FunctionPropertyNames<T>'.
Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
Type 'string | number | symbol' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
Type 'string' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
Type 'keyof T' is not assignable to type 'never'.
tests/cases/conformance/types/conditional/conditionalTypes1.ts(114,5): error TS2322: Type 'keyof T' is not assignable to type 'FunctionPropertyNames<T>'.
Type 'string | number | symbol' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
Type 'string' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
Expand Down Expand Up @@ -185,22 +195,32 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(288,43): error TS
function f7<T>(x: T, y: FunctionProperties<T>, z: NonFunctionProperties<T>) {
x = y; // Error
~
!!! error TS2322: Type 'Pick<T, FunctionPropertyNames<T>>' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Pick<T, FunctionPropertyNames<T>>'.
!!! error TS2322: Type 'FunctionProperties<T>' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'FunctionProperties<T>'.
x = z; // Error
~
!!! error TS2322: Type 'Pick<T, NonFunctionPropertyNames<T>>' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Pick<T, NonFunctionPropertyNames<T>>'.
!!! error TS2322: Type 'NonFunctionProperties<T>' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'NonFunctionProperties<T>'.
y = x;
y = z; // Error
~
!!! error TS2322: Type 'Pick<T, NonFunctionPropertyNames<T>>' is not assignable to type 'Pick<T, FunctionPropertyNames<T>>'.
!!! error TS2322: Type 'NonFunctionProperties<T>' is not assignable to type 'FunctionProperties<T>'.
!!! error TS2322: Type 'FunctionPropertyNames<T>' is not assignable to type 'NonFunctionPropertyNames<T>'.
!!! error TS2322: Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
!!! error TS2322: Type 'string' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'.
!!! error TS2322: Type 'keyof T' is not assignable to type 'never'.
!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'never'.
!!! error TS2322: Type 'string' is not assignable to type 'never'.
Comment on lines +209 to +214
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why's this happening? What was avoiding the elaboration before?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sounds like we can't avoid re-elaboration based on type IDs

z = x;
z = y; // Error
~
!!! error TS2322: Type 'Pick<T, FunctionPropertyNames<T>>' is not assignable to type 'Pick<T, NonFunctionPropertyNames<T>>'.
!!! error TS2322: Type 'FunctionProperties<T>' is not assignable to type 'NonFunctionProperties<T>'.
!!! error TS2322: Type 'NonFunctionPropertyNames<T>' is not assignable to type 'FunctionPropertyNames<T>'.
!!! error TS2322: Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
!!! error TS2322: Type 'string' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'.
!!! error TS2322: Type 'keyof T' is not assignable to type 'never'.
}

function f8<T>(x: keyof T, y: FunctionPropertyNames<T>, z: NonFunctionPropertyNames<T>) {
Expand Down
28 changes: 14 additions & 14 deletions tests/baselines/reference/conditionalTypes1.types
Original file line number Diff line number Diff line change
Expand Up @@ -247,38 +247,38 @@ type T31 = NonFunctionProperties<Part>;
function f7<T>(x: T, y: FunctionProperties<T>, z: NonFunctionProperties<T>) {
>f7 : <T>(x: T, y: FunctionProperties<T>, z: NonFunctionProperties<T>) => void
>x : T
>y : Pick<T, FunctionPropertyNames<T>>
>z : Pick<T, NonFunctionPropertyNames<T>>
>y : FunctionProperties<T>
>z : NonFunctionProperties<T>

x = y; // Error
>x = y : Pick<T, FunctionPropertyNames<T>>
>x = y : FunctionProperties<T>
>x : T
>y : Pick<T, FunctionPropertyNames<T>>
>y : FunctionProperties<T>

x = z; // Error
>x = z : Pick<T, NonFunctionPropertyNames<T>>
>x = z : NonFunctionProperties<T>
>x : T
>z : Pick<T, NonFunctionPropertyNames<T>>
>z : NonFunctionProperties<T>

y = x;
>y = x : T
>y : Pick<T, FunctionPropertyNames<T>>
>y : FunctionProperties<T>
>x : T

y = z; // Error
>y = z : Pick<T, NonFunctionPropertyNames<T>>
>y : Pick<T, FunctionPropertyNames<T>>
>z : Pick<T, NonFunctionPropertyNames<T>>
>y = z : NonFunctionProperties<T>
>y : FunctionProperties<T>
>z : NonFunctionProperties<T>

z = x;
>z = x : T
>z : Pick<T, NonFunctionPropertyNames<T>>
>z : NonFunctionProperties<T>
>x : T

z = y; // Error
>z = y : Pick<T, FunctionPropertyNames<T>>
>z : Pick<T, NonFunctionPropertyNames<T>>
>y : Pick<T, FunctionPropertyNames<T>>
>z = y : FunctionProperties<T>
>z : NonFunctionProperties<T>
>y : FunctionProperties<T>
}

function f8<T>(x: keyof T, y: FunctionPropertyNames<T>, z: NonFunctionPropertyNames<T>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export type Foo<Y> = Bar<any, Y>;
export const y = (x: Foo<string>) => 1
>y : (x: Foo<string>) => number
>(x: Foo<string>) => 1 : (x: Foo<string>) => number
>x : Bar<any, string>
>x : Foo<string>
>1 : 1

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export type Baa<Y> = Baz<boolean, Y>;
export const y = (x: Baa<number>) => 1
>y : (x: Baa<number>) => number
>(x: Baa<number>) => 1 : (x: Baa<number>) => number
>x : Bar<boolean, string, number>
>x : Baa<number>
>1 : 1

Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ declare type Foo<T, Y> = {
foo<U, J>(): Foo<U, J>;
};
declare type SubFoo<R> = Foo<string, R>;
declare function foo(): Foo<string, number>;
declare function foo(): SubFoo<number>;
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ type SubFoo<R> = Foo<string, R>;
>SubFoo : SubFoo<R>

function foo() {
>foo : () => Foo<string, number>
>foo : () => SubFoo<number>

return {} as SubFoo<number>;
>{} as SubFoo<number> : Foo<string, number>
>{} as SubFoo<number> : SubFoo<number>
>{} : {}
}

Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export type SubFoo<R> = Foo<string, R>;
>SubFoo : SubFoo<R>

function foo() {
>foo : () => Foo<string, number>
>foo : () => SubFoo<number>

return {} as SubFoo<number>;
>{} as SubFoo<number> : Foo<string, number>
>{} as SubFoo<number> : SubFoo<number>
>{} : {}
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ declare type Foo<T, Y> = {
foo<U, J>(): Foo<U, J>;
};
declare type SubFoo<R, S> = Foo<S, R>;
declare function foo(): Foo<string, number>;
declare function foo(): SubFoo<number, string>;
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ type SubFoo<R, S> = Foo<S, R>;
>SubFoo : SubFoo<R, S>

function foo() {
>foo : () => Foo<string, number>
>foo : () => SubFoo<number, string>

return {} as SubFoo<number, string>;
>{} as SubFoo<number, string> : Foo<string, number>
>{} as SubFoo<number, string> : SubFoo<number, string>
>{} : {}
}

8 changes: 4 additions & 4 deletions tests/baselines/reference/discriminantPropertyCheck.types
Original file line number Diff line number Diff line change
Expand Up @@ -464,18 +464,18 @@ type TypeBar2 = { type: BarEnum.bar2 };

function func3(value: Partial<UnionOfBar>) {
>func3 : (value: Partial<UnionOfBar>) => void
>value : Partial<TypeBar1> | Partial<TypeBar2>
>value : Partial<UnionOfBar>

if (value.type !== undefined) {
>value.type !== undefined : boolean
>value.type : BarEnum | undefined
>value : Partial<TypeBar1> | Partial<TypeBar2>
>value : Partial<UnionOfBar>
>type : BarEnum | undefined
>undefined : undefined

switch (value.type) {
>value.type : BarEnum
>value : Partial<TypeBar1> | Partial<TypeBar2>
>value : Partial<UnionOfBar>
>type : BarEnum

case BarEnum.bar1:
Expand All @@ -495,7 +495,7 @@ function func3(value: Partial<UnionOfBar>) {
>never(value.type) : never
>never : (value: never) => never
>value.type : never
>value : Partial<TypeBar1> | Partial<TypeBar2>
>value : Partial<UnionOfBar>
>type : never
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function mapValues<T, TResult>(
>null : null

callback: DictionaryIterator<T, TResult>
>callback : ObjectIterator<Dictionary<T>, TResult>
>callback : DictionaryIterator<T, TResult>

): Dictionary<TResult> {
return null as any;
Expand Down Expand Up @@ -73,7 +73,7 @@ export function fooToBar(
>null : null
>{} : {}
>mapValues(foos, f => f.foo) : Dictionary<string>
>mapValues : <T, TResult>(obj: Dictionary<T> | NumericDictionary<T>, callback: ObjectIterator<Dictionary<T>, TResult>) => Dictionary<TResult>
>mapValues : <T, TResult>(obj: Dictionary<T> | NumericDictionary<T>, callback: DictionaryIterator<T, TResult>) => Dictionary<TResult>
>foos : Record<string, Foo>
>f => f.foo : (f: Foo) => string
>f : Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function mapValues<T, TResult>(
>null : null

callback: DictionaryIterator<T, TResult>
>callback : ObjectIterator<Dictionary<T>, TResult>
>callback : DictionaryIterator<T, TResult>

): Dictionary<TResult> {
return null as any;
Expand Down Expand Up @@ -68,7 +68,7 @@ export function fooToBar(
const wat = mapValues(foos, f => f.foo);
>wat : Dictionary<string>
>mapValues(foos, f => f.foo) : Dictionary<string>
>mapValues : <T, TResult>(obj: Dictionary<T> | NumericDictionary<T>, callback: ObjectIterator<Dictionary<T>, TResult>) => Dictionary<TResult>
>mapValues : <T, TResult>(obj: Dictionary<T> | NumericDictionary<T>, callback: DictionaryIterator<T, TResult>) => Dictionary<TResult>
>foos : Record<string, Foo>
>f => f.foo : (f: Foo) => string
>f : Foo
Expand All @@ -84,7 +84,7 @@ export function fooToBar(
>null : null
>{} : {}
>mapValues(foos, f => f.foo) : Dictionary<string>
>mapValues : <T, TResult>(obj: Dictionary<T> | NumericDictionary<T>, callback: ObjectIterator<Dictionary<T>, TResult>) => Dictionary<TResult>
>mapValues : <T, TResult>(obj: Dictionary<T> | NumericDictionary<T>, callback: DictionaryIterator<T, TResult>) => Dictionary<TResult>
>foos : Record<string, Foo>
>f => f.foo : (f: Foo) => string
>f : Foo
Expand Down
12 changes: 6 additions & 6 deletions tests/baselines/reference/genericIsNeverEmptyObject.types
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
// Repro from #29067

function test<T extends { a: string }>(obj: T) {
>test : <T extends { a: string; }>(obj: T) => Pick<T, Exclude<keyof T, "a">> & { b: string; }
>test : <T extends { a: string; }>(obj: T) => Omit<T, "a"> & { b: string; }
>a : string
>obj : T

let { a, ...rest } = obj;
>a : string
>rest : Pick<T, Exclude<keyof T, "a">>
>rest : Omit<T, "a">
>obj : T

return { ...rest, b: a };
>{ ...rest, b: a } : Pick<T, Exclude<keyof T, "a">> & { b: string; }
>rest : Pick<T, Exclude<keyof T, "a">>
>{ ...rest, b: a } : Omit<T, "a"> & { b: string; }
>rest : Omit<T, "a">
>b : string
>a : string
}
Expand All @@ -30,7 +30,7 @@ let o2: { b: string, x: number } = test(o1);
>o2 : { b: string; x: number; }
>b : string
>x : number
>test(o1) : Pick<{ a: string; x: number; }, "x"> & { b: string; }
>test : <T extends { a: string; }>(obj: T) => Pick<T, Exclude<keyof T, "a">> & { b: string; }
>test(o1) : Omit<{ a: string; x: number; }, "a"> & { b: string; }
>test : <T extends { a: string; }>(obj: T) => Omit<T, "a"> & { b: string; }
>o1 : { a: string; x: number; }

16 changes: 8 additions & 8 deletions tests/baselines/reference/genericObjectRest.types
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@ function f1<T extends { a: string, b: number }>(obj: T) {
let { a: a1, ...r1 } = obj;
>a : any
>a1 : string
>r1 : Pick<T, Exclude<keyof T, "a">>
>r1 : Omit<T, "a">
>obj : T

let { a: a2, b: b2, ...r2 } = obj;
>a : any
>a2 : string
>b : any
>b2 : number
>r2 : Pick<T, Exclude<keyof T, "a" | "b">>
>r2 : Omit<T, "a" | "b">
>obj : T

let { 'a': a3, ...r3 } = obj;
>a3 : string
>r3 : Pick<T, Exclude<keyof T, "a">>
>r3 : Omit<T, "a">
>obj : T

let { ['a']: a4, ...r4 } = obj;
>'a' : "a"
>a4 : string
>r4 : Pick<T, Exclude<keyof T, "a">>
>r4 : Omit<T, "a">
>obj : T

let { [a]: a5, ...r5 } = obj;
>a : "a"
>a5 : string
>r5 : Pick<T, Exclude<keyof T, "a">>
>r5 : Omit<T, "a">
>obj : T
}

Expand All @@ -68,7 +68,7 @@ function f2<T extends { [sa]: string, [sb]: number }>(obj: T) {
>a1 : string
>sb : unique symbol
>b1 : number
>r1 : Pick<T, Exclude<keyof T, unique symbol | unique symbol>>
>r1 : Omit<T, unique symbol | unique symbol>
>obj : T
}

Expand All @@ -83,7 +83,7 @@ function f3<T, K1 extends keyof T, K2 extends keyof T>(obj: T, k1: K1, k2: K2) {
>a1 : T[K1]
>k2 : K2
>a2 : T[K2]
>r1 : Pick<T, Exclude<keyof T, K1 | K2>>
>r1 : Omit<T, K1 | K2>
>obj : T
}

Expand All @@ -104,7 +104,7 @@ function f4<K1 extends keyof Item, K2 extends keyof Item>(obj: Item, k1: K1, k2:
>a1 : Item[K1]
>k2 : K2
>a2 : Item[K2]
>r1 : Pick<Item, Exclude<"a", K1 | K2> | Exclude<"b", K1 | K2> | Exclude<"c", K1 | K2>>
>r1 : Omit<Item, K1 | K2>
>obj : Item
}

8 changes: 4 additions & 4 deletions tests/baselines/reference/infiniteConstraints.errors.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tests/cases/compiler/infiniteConstraints.ts(4,37): error TS2536: Type '"val"' cannot be used to index type 'B[Exclude<keyof B, K>]'.
tests/cases/compiler/infiniteConstraints.ts(31,43): error TS2322: Type 'Record<"val", "dup">' is not assignable to type 'never'.
tests/cases/compiler/infiniteConstraints.ts(31,63): error TS2322: Type 'Record<"val", "dup">' is not assignable to type 'never'.
tests/cases/compiler/infiniteConstraints.ts(31,43): error TS2322: Type 'Value<"dup">' is not assignable to type 'never'.
tests/cases/compiler/infiniteConstraints.ts(31,63): error TS2322: Type 'Value<"dup">' is not assignable to type 'never'.
tests/cases/compiler/infiniteConstraints.ts(36,71): error TS2536: Type '"foo"' cannot be used to index type 'T[keyof T]'.


Expand Down Expand Up @@ -39,10 +39,10 @@ tests/cases/compiler/infiniteConstraints.ts(36,71): error TS2536: Type '"foo"' c

const shouldBeError = ensureNoDuplicates({main: value("dup"), alternate: value("dup")});
~~~~
!!! error TS2322: Type 'Record<"val", "dup">' is not assignable to type 'never'.
!!! error TS2322: Type 'Value<"dup">' is not assignable to type 'never'.
!!! related TS6500 tests/cases/compiler/infiniteConstraints.ts:31:43: The expected type comes from property 'main' which is declared here on type '{ main: never; alternate: never; }'
~~~~~~~~~
!!! error TS2322: Type 'Record<"val", "dup">' is not assignable to type 'never'.
!!! error TS2322: Type 'Value<"dup">' is not assignable to type 'never'.
!!! related TS6500 tests/cases/compiler/infiniteConstraints.ts:31:63: The expected type comes from property 'alternate' which is declared here on type '{ main: never; alternate: never; }'

// Repro from #26448
Expand Down
Loading