Regression test for GH #20727

This commit is contained in:
Andrew Casey
2017-12-15 15:11:18 -08:00
parent 9efab94dfd
commit 129d1924be
2 changed files with 16 additions and 0 deletions
@@ -262,6 +262,12 @@ namespace N { // Force this test to be TS-only
y = [#|this.x|];
}
}`);
// TODO (https://github.com/Microsoft/TypeScript/issues/20727): the extracted constant should have a type annotation.
testExtractConstant("extractConstant_ContextualType", `
interface I { a: 1 | 2 | 3 }
let i: I = [#|{ a: 1 }|];
`);
});
function testExtractConstant(caption: string, text: string) {
@@ -0,0 +1,10 @@
// ==ORIGINAL==
interface I { a: 1 | 2 | 3 }
let i: I = /*[#|*/{ a: 1 }/*|]*/;
// ==SCOPE::Extract to constant in enclosing scope==
interface I { a: 1 | 2 | 3 }
const newLocal = { a: 1 };
let i: I = /*RENAME*/newLocal;