Skip to content

Erroneous "The '?' modifier can only be used in TypeScript files" #1749

@Rich-Harris

Description

@Rich-Harris

Steps to reproduce

With allowJs and checkJs enabled:

const is_morning = new Date().getHours() < 12;

// prettier-ignore
const greeting = ([
  is_morning ? 'good morning' : 'good evening'
]);

Behavior with typescript@5.8

No errors

Behavior with tsgo

Error TS8009:

The '?' modifier can only be used in TypeScript files.


Some additional context: we have a TSGo CI check on the Svelte repo, and this check started failing overnight. The real code it's failing on uses a JSDoc annotation, hence the wrapping parens, without which it parses correctly.

Metadata

Metadata

Assignees

Labels

Domain: ParserRelated to the parserbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions