wrong type inference in Promise · Issue #31266 · microsoft/TypeScript (original) (raw)
Navigation Menu
- GitHub Copilot Write better code with AI
- GitHub Models New Manage and compare prompts
- GitHub Advanced Security Find and fix vulnerabilities
- Actions Automate any workflow
- Codespaces Instant dev environments
- Issues Plan and track work
- Code Review Manage code changes
- Discussions Collaborate outside of code
- Code Search Find more, search less
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
TypeScript Version: 3.4.3
Search Terms:
Code
let foo: string | undefined; if (!foo) foo = 'hello';
foo.length; // ok
new Promise(resolve => resolve(foo.length)); // ^ should be string, but inferred as string | undefined
Expected behavior:
Actual behavior:
Playground Link:
Related Issues:
Metadata
Metadata
Labels
Development
No branches or pull requests