mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Additional test case for contextual type check
This commit is contained in:
@@ -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,
|
||||
}
|
||||
Reference in New Issue
Block a user