Additional test case for contextual type check

This commit is contained in:
Andrew Casey
2017-12-15 16:37:09 -08:00
parent 08a9c61640
commit 804949f744
2 changed files with 17 additions and 0 deletions
@@ -267,6 +267,12 @@ namespace N { // Force this test to be TS-only
testExtractConstant("extractConstant_ContextualType", `
interface I { a: 1 | 2 | 3 }
let i: I = [#|{ a: 1 }|];
`);
testExtractConstant("extractConstant_ContextualType_Lambda", `
const myObj: { member(x: number, y: string): void } = {
member: [#|(x, y) => x + y|],
}
`);
});
@@ -0,0 +1,11 @@
// ==ORIGINAL==
const myObj: { member(x: number, y: string): void } = {
member: /*[#|*/(x, y) => x + y/*|]*/,
}
// ==SCOPE::Extract to constant in enclosing scope==
const newLocal: (x: number, y: string) => void = (x, y) => x + y;
const myObj: { member(x: number, y: string): void } = {
member: /*RENAME*/newLocal,
}