Open
Description
TypeScript Version: 4.1.0-dev.20200907
Search Terms: isContextSensitive
Code
declare function foo<T = number>(): T;
const result: string = foo();
Apply "Extract to constant in enclosing scope" refactor on foo()
expression
Expected behavior:
const newLocal: string = foo();
const result: string = newLocal;
Actual behavior:
const newLocal = foo();
const result: string = newLocal;
It doesn't seem to be intentional based on this code, and it works in this example:
const result: { x: (x: string) => string } = { x: (x) => x };
const newLocal: { x: (x: string) => string; } = { x: (x) => x };
const result: { x: (x: string) => string } = newLocal;
Related Issues: