Erroneous "The '?' modifier can only be used in TypeScript files"
Closed this issue · 2 comments
Rich-Harris commented
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.
jakebailey commented
Most certainly caused by #1732. @ahejlsberg
ahejlsberg commented
Yup, this is #1732. An error is issued during speculative parsing, but our rewind logic doesn't reset JS diagnostics. Will put up a fix.