diff --git a/tests/baselines/reference/undefinedAssignableToGenericMappedIntersection.js b/tests/baselines/reference/undefinedAssignableToGenericMappedIntersection.js new file mode 100644 index 0000000000..468344c3e9 --- /dev/null +++ b/tests/baselines/reference/undefinedAssignableToGenericMappedIntersection.js @@ -0,0 +1,16 @@ +//// [undefinedAssignableToGenericMappedIntersection.ts] +type Errors = { [P in keyof T]: string | undefined } & {all: string | undefined}; +function foo() { + let obj!: Errors + let x!: keyof T; + obj[x] = undefined; +} + + +//// [undefinedAssignableToGenericMappedIntersection.js] +"use strict"; +function foo() { + var obj; + var x; + obj[x] = undefined; +} diff --git a/tests/baselines/reference/undefinedAssignableToGenericMappedIntersection.symbols b/tests/baselines/reference/undefinedAssignableToGenericMappedIntersection.symbols new file mode 100644 index 0000000000..613b3bcc53 --- /dev/null +++ b/tests/baselines/reference/undefinedAssignableToGenericMappedIntersection.symbols @@ -0,0 +1,27 @@ +=== tests/cases/compiler/undefinedAssignableToGenericMappedIntersection.ts === +type Errors = { [P in keyof T]: string | undefined } & {all: string | undefined}; +>Errors : Symbol(Errors, Decl(undefinedAssignableToGenericMappedIntersection.ts, 0, 0)) +>T : Symbol(T, Decl(undefinedAssignableToGenericMappedIntersection.ts, 0, 12)) +>P : Symbol(P, Decl(undefinedAssignableToGenericMappedIntersection.ts, 0, 20)) +>T : Symbol(T, Decl(undefinedAssignableToGenericMappedIntersection.ts, 0, 12)) +>all : Symbol(all, Decl(undefinedAssignableToGenericMappedIntersection.ts, 0, 59)) + +function foo() { +>foo : Symbol(foo, Decl(undefinedAssignableToGenericMappedIntersection.ts, 0, 84)) +>T : Symbol(T, Decl(undefinedAssignableToGenericMappedIntersection.ts, 1, 13)) + + let obj!: Errors +>obj : Symbol(obj, Decl(undefinedAssignableToGenericMappedIntersection.ts, 2, 7)) +>Errors : Symbol(Errors, Decl(undefinedAssignableToGenericMappedIntersection.ts, 0, 0)) +>T : Symbol(T, Decl(undefinedAssignableToGenericMappedIntersection.ts, 1, 13)) + + let x!: keyof T; +>x : Symbol(x, Decl(undefinedAssignableToGenericMappedIntersection.ts, 3, 7)) +>T : Symbol(T, Decl(undefinedAssignableToGenericMappedIntersection.ts, 1, 13)) + + obj[x] = undefined; +>obj : Symbol(obj, Decl(undefinedAssignableToGenericMappedIntersection.ts, 2, 7)) +>x : Symbol(x, Decl(undefinedAssignableToGenericMappedIntersection.ts, 3, 7)) +>undefined : Symbol(undefined) +} + diff --git a/tests/baselines/reference/undefinedAssignableToGenericMappedIntersection.types b/tests/baselines/reference/undefinedAssignableToGenericMappedIntersection.types new file mode 100644 index 0000000000..1bf4aae019 --- /dev/null +++ b/tests/baselines/reference/undefinedAssignableToGenericMappedIntersection.types @@ -0,0 +1,22 @@ +=== tests/cases/compiler/undefinedAssignableToGenericMappedIntersection.ts === +type Errors = { [P in keyof T]: string | undefined } & {all: string | undefined}; +>Errors : Errors +>all : string | undefined + +function foo() { +>foo : () => void + + let obj!: Errors +>obj : Errors + + let x!: keyof T; +>x : keyof T + + obj[x] = undefined; +>obj[x] = undefined : undefined +>obj[x] : Errors[keyof T] +>obj : Errors +>x : keyof T +>undefined : undefined +} + diff --git a/tests/cases/compiler/undefinedAssignableToGenericMappedIntersection.ts b/tests/cases/compiler/undefinedAssignableToGenericMappedIntersection.ts new file mode 100644 index 0000000000..2b08916467 --- /dev/null +++ b/tests/cases/compiler/undefinedAssignableToGenericMappedIntersection.ts @@ -0,0 +1,7 @@ +// @strict: true +type Errors = { [P in keyof T]: string | undefined } & {all: string | undefined}; +function foo() { + let obj!: Errors + let x!: keyof T; + obj[x] = undefined; +}