Closed
Description
TypeScript Version: 3.7.0-dev.20190907
Search Terms: possibly undefined is:open
Code
function foo(value?: string) {
if (value === undefined) { value = "hello"; }
console.log(value.toUpperCase()); // OK
setTimeout(() => value.toUpperCase(), 1); // TS2532
}
Expected behavior: Successful compilation.
Actual behavior: Compilation failing with error TS2532: Object is possibly 'undefined'.
.
Playground Link: www.typescriptlang.org/play/#code/…
Related Issues: #31060
Metadata
Metadata
Assignees
Labels
No labels