Skip to content

Type narrowing in comma operator inconsistent with 5.8 #1766

@jonmast

Description

@jonmast

Steps to reproduce

type Obj = {
  prop: string
}
function assertion(input: Obj | undefined): asserts input is Obj {}

function func(input: Obj | undefined): string {
  return assertion(input), input.prop;
}

Behavior with typescript@5.8

No type errors

Behavior with tsgo

main.ts(7,28): error TS18048: 'input' is possibly 'undefined'.

Metadata

Metadata

Assignees

Labels

Domain: Type CheckingRelated to type checking, grammar checkingbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions