diff --git a/tests/baselines/reference/mappedTypesAndObjects.js b/tests/baselines/reference/mappedTypesAndObjects.js index 53b39209693..f320cc9624e 100644 --- a/tests/baselines/reference/mappedTypesAndObjects.js +++ b/tests/baselines/reference/mappedTypesAndObjects.js @@ -12,26 +12,37 @@ function f2(x: Partial, y: Readonly) { obj = y; } +function f3(x: Partial) { + x = {}; +} + // Repro from #12900 interface Base { - foo: { [key: string]: any }; - bar: any; - baz: any; + foo: { [key: string]: any }; + bar: any; + baz: any; } interface E1 extends Base { - foo: T; + foo: T; } interface Something { name: string, value: string }; interface E2 extends Base { - foo: Partial; // or other mapped type + foo: Partial; // or other mapped type } interface E3 extends Base { - foo: Partial; // or other mapped type -} + foo: Partial; // or other mapped type +} + +// Repro from #13747 + +class Form { + private values: {[P in keyof T]?: T[P]} = {} +} + //// [mappedTypesAndObjects.js] function f1(x, y) { @@ -44,12 +55,23 @@ function f2(x, y) { obj = x; obj = y; } +function f3(x) { + x = {}; +} ; +// Repro from #13747 +var Form = (function () { + function Form() { + this.values = {}; + } + return Form; +}()); //// [mappedTypesAndObjects.d.ts] declare function f1(x: Partial, y: Readonly): void; declare function f2(x: Partial, y: Readonly): void; +declare function f3(x: Partial): void; interface Base { foo: { [key: string]: any; @@ -70,3 +92,6 @@ interface E2 extends Base { interface E3 extends Base { foo: Partial; } +declare class Form { + private values; +} diff --git a/tests/baselines/reference/mappedTypesAndObjects.symbols b/tests/baselines/reference/mappedTypesAndObjects.symbols index 1690f1b6b04..6fb5d720fb3 100644 --- a/tests/baselines/reference/mappedTypesAndObjects.symbols +++ b/tests/baselines/reference/mappedTypesAndObjects.symbols @@ -45,54 +45,80 @@ function f2(x: Partial, y: Readonly) { >y : Symbol(y, Decl(mappedTypesAndObjects.ts, 7, 29)) } +function f3(x: Partial) { +>f3 : Symbol(f3, Decl(mappedTypesAndObjects.ts, 11, 1)) +>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 13, 12)) +>x : Symbol(x, Decl(mappedTypesAndObjects.ts, 13, 15)) +>Partial : Symbol(Partial, Decl(lib.d.ts, --, --)) +>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 13, 12)) + + x = {}; +>x : Symbol(x, Decl(mappedTypesAndObjects.ts, 13, 15)) +} + // Repro from #12900 interface Base { ->Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 11, 1)) +>Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 15, 1)) - foo: { [key: string]: any }; ->foo : Symbol(Base.foo, Decl(mappedTypesAndObjects.ts, 15, 16)) ->key : Symbol(key, Decl(mappedTypesAndObjects.ts, 16, 11)) + foo: { [key: string]: any }; +>foo : Symbol(Base.foo, Decl(mappedTypesAndObjects.ts, 19, 16)) +>key : Symbol(key, Decl(mappedTypesAndObjects.ts, 20, 12)) - bar: any; ->bar : Symbol(Base.bar, Decl(mappedTypesAndObjects.ts, 16, 31)) + bar: any; +>bar : Symbol(Base.bar, Decl(mappedTypesAndObjects.ts, 20, 32)) - baz: any; ->baz : Symbol(Base.baz, Decl(mappedTypesAndObjects.ts, 17, 12)) + baz: any; +>baz : Symbol(Base.baz, Decl(mappedTypesAndObjects.ts, 21, 13)) } interface E1 extends Base { ->E1 : Symbol(E1, Decl(mappedTypesAndObjects.ts, 19, 1)) ->T : Symbol(T, Decl(mappedTypesAndObjects.ts, 21, 13)) ->Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 11, 1)) +>E1 : Symbol(E1, Decl(mappedTypesAndObjects.ts, 23, 1)) +>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 25, 13)) +>Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 15, 1)) - foo: T; ->foo : Symbol(E1.foo, Decl(mappedTypesAndObjects.ts, 21, 30)) ->T : Symbol(T, Decl(mappedTypesAndObjects.ts, 21, 13)) + foo: T; +>foo : Symbol(E1.foo, Decl(mappedTypesAndObjects.ts, 25, 30)) +>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 25, 13)) } interface Something { name: string, value: string }; ->Something : Symbol(Something, Decl(mappedTypesAndObjects.ts, 23, 1)) ->name : Symbol(Something.name, Decl(mappedTypesAndObjects.ts, 25, 21)) ->value : Symbol(Something.value, Decl(mappedTypesAndObjects.ts, 25, 35)) +>Something : Symbol(Something, Decl(mappedTypesAndObjects.ts, 27, 1)) +>name : Symbol(Something.name, Decl(mappedTypesAndObjects.ts, 29, 21)) +>value : Symbol(Something.value, Decl(mappedTypesAndObjects.ts, 29, 35)) interface E2 extends Base { ->E2 : Symbol(E2, Decl(mappedTypesAndObjects.ts, 25, 52)) ->Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 11, 1)) +>E2 : Symbol(E2, Decl(mappedTypesAndObjects.ts, 29, 52)) +>Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 15, 1)) - foo: Partial; // or other mapped type ->foo : Symbol(E2.foo, Decl(mappedTypesAndObjects.ts, 26, 27)) + foo: Partial; // or other mapped type +>foo : Symbol(E2.foo, Decl(mappedTypesAndObjects.ts, 30, 27)) >Partial : Symbol(Partial, Decl(lib.d.ts, --, --)) ->Something : Symbol(Something, Decl(mappedTypesAndObjects.ts, 23, 1)) +>Something : Symbol(Something, Decl(mappedTypesAndObjects.ts, 27, 1)) } interface E3 extends Base { ->E3 : Symbol(E3, Decl(mappedTypesAndObjects.ts, 28, 1)) ->T : Symbol(T, Decl(mappedTypesAndObjects.ts, 30, 13)) ->Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 11, 1)) +>E3 : Symbol(E3, Decl(mappedTypesAndObjects.ts, 32, 1)) +>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 34, 13)) +>Base : Symbol(Base, Decl(mappedTypesAndObjects.ts, 15, 1)) - foo: Partial; // or other mapped type ->foo : Symbol(E3.foo, Decl(mappedTypesAndObjects.ts, 30, 30)) + foo: Partial; // or other mapped type +>foo : Symbol(E3.foo, Decl(mappedTypesAndObjects.ts, 34, 30)) >Partial : Symbol(Partial, Decl(lib.d.ts, --, --)) ->T : Symbol(T, Decl(mappedTypesAndObjects.ts, 30, 13)) +>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 34, 13)) } + +// Repro from #13747 + +class Form { +>Form : Symbol(Form, Decl(mappedTypesAndObjects.ts, 36, 1)) +>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 40, 11)) + + private values: {[P in keyof T]?: T[P]} = {} +>values : Symbol(Form.values, Decl(mappedTypesAndObjects.ts, 40, 15)) +>P : Symbol(P, Decl(mappedTypesAndObjects.ts, 41, 22)) +>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 40, 11)) +>T : Symbol(T, Decl(mappedTypesAndObjects.ts, 40, 11)) +>P : Symbol(P, Decl(mappedTypesAndObjects.ts, 41, 22)) +} + diff --git a/tests/baselines/reference/mappedTypesAndObjects.types b/tests/baselines/reference/mappedTypesAndObjects.types index e6f8e53f558..75f71082f31 100644 --- a/tests/baselines/reference/mappedTypesAndObjects.types +++ b/tests/baselines/reference/mappedTypesAndObjects.types @@ -49,19 +49,32 @@ function f2(x: Partial, y: Readonly) { >y : Readonly } +function f3(x: Partial) { +>f3 : (x: Partial) => void +>T : T +>x : Partial +>Partial : Partial +>T : T + + x = {}; +>x = {} : {} +>x : Partial +>{} : {} +} + // Repro from #12900 interface Base { >Base : Base - foo: { [key: string]: any }; + foo: { [key: string]: any }; >foo : { [key: string]: any; } >key : string - bar: any; + bar: any; >bar : any - baz: any; + baz: any; >baz : any } @@ -70,7 +83,7 @@ interface E1 extends Base { >T : T >Base : Base - foo: T; + foo: T; >foo : T >T : T } @@ -84,7 +97,7 @@ interface E2 extends Base { >E2 : E2 >Base : Base - foo: Partial; // or other mapped type + foo: Partial; // or other mapped type >foo : Partial >Partial : Partial >Something : Something @@ -95,8 +108,24 @@ interface E3 extends Base { >T : T >Base : Base - foo: Partial; // or other mapped type + foo: Partial; // or other mapped type >foo : Partial >Partial : Partial >T : T } + +// Repro from #13747 + +class Form { +>Form : Form +>T : T + + private values: {[P in keyof T]?: T[P]} = {} +>values : { [P in keyof T]?: T[P] | undefined; } +>P : P +>T : T +>T : T +>P : P +>{} : {} +} +