mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Regression test for GH #20727
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user