Skip to content

Commit 129d192

Browse files
committed
Regression test for GH microsoft#20727
1 parent 9efab94 commit 129d192

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/harness/unittests/extractConstants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,12 @@ namespace N { // Force this test to be TS-only
262262
y = [#|this.x|];
263263
}
264264
}`);
265+
266+
// TODO (https://github.com/Microsoft/TypeScript/issues/20727): the extracted constant should have a type annotation.
267+
testExtractConstant("extractConstant_ContextualType", `
268+
interface I { a: 1 | 2 | 3 }
269+
let i: I = [#|{ a: 1 }|];
270+
`);
265271
});
266272

267273
function testExtractConstant(caption: string, text: string) {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// ==ORIGINAL==
2+
3+
interface I { a: 1 | 2 | 3 }
4+
let i: I = /*[#|*/{ a: 1 }/*|]*/;
5+
6+
// ==SCOPE::Extract to constant in enclosing scope==
7+
8+
interface I { a: 1 | 2 | 3 }
9+
const newLocal = { a: 1 };
10+
let i: I = /*RENAME*/newLocal;

0 commit comments

Comments
 (0)