-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
Experience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
Bug Report
π Search Terms
empty intersections, never, return type
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about types.
β― Playground Link
π» Code
type A = { p: "A" };
type B = { p: "B" };
function f1(): never {
return;
}
function f2(): A & B {
return;
}
function g1(): never {}
function g2(): A & B {}π Actual behavior
f1: Type 'undefined' is not assignable to type 'never'. (expected)
f2 w/ strictNullChecks: false: no error emitted
f2 w/ strictNullChecks: true: Type 'undefined' is not assignable to type 'never'. The intersection 'A & B' was reduced to 'never' because property 'p' has conflicting types in some constituents. (expected)
g1: A function returning 'never' cannot have a reachable end point. (expected)
g2: A function whose declared type is neither 'void' nor 'any' must return a value.
π Expected behavior
f2 and g2 should generate the same errors as f1 and g1 respectively other than elaboration on empty intersection types.
Note: I was suggested to separate fix from #47751 and I'm ready to submit another PR if this is really a bug.
shaman-apprentice and seanblonien
Metadata
Metadata
Assignees
Labels
Experience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsSuggestionAn idea for TypeScriptAn idea for TypeScript