Skip to content

Incorrect type in Unreachable code #61146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RedCMD opened this issue Feb 7, 2025 · 2 comments
Closed

Incorrect type in Unreachable code #61146

RedCMD opened this issue Feb 7, 2025 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@RedCMD
Copy link

RedCMD commented Feb 7, 2025

Unreachable code messes up type system

Steps to Reproduce:

  1. copy code snippet into TS file
  2. notice no errors ✅
    Image
  3. uncomment the 3rd line
  4. notice error on last return statement ❌
    Image
function foo(a: string | undefined): string {
	const b = 'c';
	// return b;
	if (!a) {
		return b;
	}
	return a;
}

my actual code:
Image
Image

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.97.0 (and insiders)
  • OS Version: Windows 11
@mjbvz mjbvz transferred this issue from microsoft/vscode Feb 7, 2025
@mjbvz mjbvz removed their assignment Feb 7, 2025
@MartinJohns
Copy link
Contributor

Duplicate of #26914.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Feb 7, 2025
@typescript-bot
Copy link
Collaborator

This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

5 participants