Add regression test for #25485 as it is already fixed (#27320)

This commit is contained in:
Wesley Wigham 2018-09-24 17:52:52 -07:00 committed by GitHub
parent 6957128341
commit 8e1cce4b8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 72 additions and 0 deletions

View file

@ -0,0 +1,16 @@
//// [undefinedAssignableToGenericMappedIntersection.ts]
type Errors<T> = { [P in keyof T]: string | undefined } & {all: string | undefined};
function foo<T>() {
let obj!: Errors<T>
let x!: keyof T;
obj[x] = undefined;
}
//// [undefinedAssignableToGenericMappedIntersection.js]
"use strict";
function foo() {
var obj;
var x;
obj[x] = undefined;
}

View file

@ -0,0 +1,27 @@
=== tests/cases/compiler/undefinedAssignableToGenericMappedIntersection.ts ===
type Errors<T> = { [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<T>() {
>foo : Symbol(foo, Decl(undefinedAssignableToGenericMappedIntersection.ts, 0, 84))
>T : Symbol(T, Decl(undefinedAssignableToGenericMappedIntersection.ts, 1, 13))
let obj!: Errors<T>
>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)
}

View file

@ -0,0 +1,22 @@
=== tests/cases/compiler/undefinedAssignableToGenericMappedIntersection.ts ===
type Errors<T> = { [P in keyof T]: string | undefined } & {all: string | undefined};
>Errors : Errors<T>
>all : string | undefined
function foo<T>() {
>foo : <T>() => void
let obj!: Errors<T>
>obj : Errors<T>
let x!: keyof T;
>x : keyof T
obj[x] = undefined;
>obj[x] = undefined : undefined
>obj[x] : Errors<T>[keyof T]
>obj : Errors<T>
>x : keyof T
>undefined : undefined
}

View file

@ -0,0 +1,7 @@
// @strict: true
type Errors<T> = { [P in keyof T]: string | undefined } & {all: string | undefined};
function foo<T>() {
let obj!: Errors<T>
let x!: keyof T;
obj[x] = undefined;
}