-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
Bug Report
🔎 Search Terms
- asserts generic null
- asserts array null
🕗 Version & Regression Information
- This is the behavior in every version I tried (3.7 on the playground as asserts did appear in 3.7 IIRC), and I reviewed the FAQ for entries about null asserts
⏯ Playground Link
Playground link with relevant code
💻 Code
interface Generic<T> { value: T; }
type Ticket = {}
type TicketGeneric = null | Generic<string | Ticket>
function assertRelationIsNullOrGenericOfString(v: Generic<string | Ticket> | null): asserts v is Generic<string> | null {}
function testGeneric(ticketGeneric: TicketGeneric) {
assertRelationIsNullOrGenericOfString(ticketGeneric)
ticketGeneric; // expected type is `null | Generic<string>` but gave `null`
}🙁 Actual behavior
When an asserter return null or a Generic, it is reported as null.
It does this for every generic, even Array<string>. If the return type is not a generic, it does work fine (with null | string for exemple)
🙂 Expected behavior
It should be marked as null | Generic<string>
Thank you!
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created