Add regression test

This commit is contained in:
Anders Hejlsberg 2017-07-26 07:16:26 -07:00
parent bd1f8c50a4
commit a14144be9c
4 changed files with 228 additions and 0 deletions

View file

@ -0,0 +1,54 @@
//// [typeInferenceWithExcessProperties.ts]
// Repro from #17041
interface Named {
name: string;
}
function parrot<T extends Named>(obj: T): T {
return obj;
}
parrot({
name: "TypeScript",
});
parrot({
name: "TypeScript",
age: 5,
});
parrot({
name: "TypeScript",
age: function () { },
});
parrot({
name: "TypeScript",
sayHello() {
},
});
//// [typeInferenceWithExcessProperties.js]
// Repro from #17041
function parrot(obj) {
return obj;
}
parrot({
name: "TypeScript"
});
parrot({
name: "TypeScript",
age: 5
});
parrot({
name: "TypeScript",
age: function () { }
});
parrot({
name: "TypeScript",
sayHello: function () {
}
});

View file

@ -0,0 +1,65 @@
=== tests/cases/compiler/typeInferenceWithExcessProperties.ts ===
// Repro from #17041
interface Named {
>Named : Symbol(Named, Decl(typeInferenceWithExcessProperties.ts, 0, 0))
name: string;
>name : Symbol(Named.name, Decl(typeInferenceWithExcessProperties.ts, 2, 17))
}
function parrot<T extends Named>(obj: T): T {
>parrot : Symbol(parrot, Decl(typeInferenceWithExcessProperties.ts, 4, 1))
>T : Symbol(T, Decl(typeInferenceWithExcessProperties.ts, 6, 16))
>Named : Symbol(Named, Decl(typeInferenceWithExcessProperties.ts, 0, 0))
>obj : Symbol(obj, Decl(typeInferenceWithExcessProperties.ts, 6, 33))
>T : Symbol(T, Decl(typeInferenceWithExcessProperties.ts, 6, 16))
>T : Symbol(T, Decl(typeInferenceWithExcessProperties.ts, 6, 16))
return obj;
>obj : Symbol(obj, Decl(typeInferenceWithExcessProperties.ts, 6, 33))
}
parrot({
>parrot : Symbol(parrot, Decl(typeInferenceWithExcessProperties.ts, 4, 1))
name: "TypeScript",
>name : Symbol(name, Decl(typeInferenceWithExcessProperties.ts, 11, 8))
});
parrot({
>parrot : Symbol(parrot, Decl(typeInferenceWithExcessProperties.ts, 4, 1))
name: "TypeScript",
>name : Symbol(name, Decl(typeInferenceWithExcessProperties.ts, 15, 8))
age: 5,
>age : Symbol(age, Decl(typeInferenceWithExcessProperties.ts, 16, 23))
});
parrot({
>parrot : Symbol(parrot, Decl(typeInferenceWithExcessProperties.ts, 4, 1))
name: "TypeScript",
>name : Symbol(name, Decl(typeInferenceWithExcessProperties.ts, 20, 8))
age: function () { },
>age : Symbol(age, Decl(typeInferenceWithExcessProperties.ts, 21, 23))
});
parrot({
>parrot : Symbol(parrot, Decl(typeInferenceWithExcessProperties.ts, 4, 1))
name: "TypeScript",
>name : Symbol(name, Decl(typeInferenceWithExcessProperties.ts, 25, 8))
sayHello() {
>sayHello : Symbol(sayHello, Decl(typeInferenceWithExcessProperties.ts, 26, 23))
},
});

View file

@ -0,0 +1,79 @@
=== tests/cases/compiler/typeInferenceWithExcessProperties.ts ===
// Repro from #17041
interface Named {
>Named : Named
name: string;
>name : string
}
function parrot<T extends Named>(obj: T): T {
>parrot : <T extends Named>(obj: T) => T
>T : T
>Named : Named
>obj : T
>T : T
>T : T
return obj;
>obj : T
}
parrot({
>parrot({ name: "TypeScript",}) : { name: string; }
>parrot : <T extends Named>(obj: T) => T
>{ name: "TypeScript",} : { name: string; }
name: "TypeScript",
>name : string
>"TypeScript" : "TypeScript"
});
parrot({
>parrot({ name: "TypeScript", age: 5,}) : { name: string; age: number; }
>parrot : <T extends Named>(obj: T) => T
>{ name: "TypeScript", age: 5,} : { name: string; age: number; }
name: "TypeScript",
>name : string
>"TypeScript" : "TypeScript"
age: 5,
>age : number
>5 : 5
});
parrot({
>parrot({ name: "TypeScript", age: function () { },}) : { name: string; age: () => void; }
>parrot : <T extends Named>(obj: T) => T
>{ name: "TypeScript", age: function () { },} : { name: string; age: () => void; }
name: "TypeScript",
>name : string
>"TypeScript" : "TypeScript"
age: function () { },
>age : () => void
>function () { } : () => void
});
parrot({
>parrot({ name: "TypeScript", sayHello() { },}) : { name: string; sayHello(): void; }
>parrot : <T extends Named>(obj: T) => T
>{ name: "TypeScript", sayHello() { },} : { name: string; sayHello(): void; }
name: "TypeScript",
>name : string
>"TypeScript" : "TypeScript"
sayHello() {
>sayHello : () => void
},
});

View file

@ -0,0 +1,30 @@
// Repro from #17041
interface Named {
name: string;
}
function parrot<T extends Named>(obj: T): T {
return obj;
}
parrot({
name: "TypeScript",
});
parrot({
name: "TypeScript",
age: 5,
});
parrot({
name: "TypeScript",
age: function () { },
});
parrot({
name: "TypeScript",
sayHello() {
},
});