microsoft / microsoft/TypeScript

ScriptKind.Deferred treated as LanguageVariant.Standard

Open
#60,125 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Experimentation Needed Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

🔎 Search Terms

Deferred ScriptKind TSX
Deferred ScriptKind Standard

Vue, eslint, tsx parser error

🕗 Version & Regression Information

Currently looking at TypeScript 5.5+ likely affects most versions of typescript.

⏯ Playground Link

No response

💻 Code

Not specific to TS code but compiler and parsing.

🙁 Actual behavior

When using typescript-eslint with there new projectSettings option, along side vue with tsx. The file fails to parse

Component.vue
41:8  error  Parsing error: '>' expected

Deferred ScriptKinds are treated as LanguageVariant.Standard rather than LanguageVariant.JSX

https://github.com/microsoft/TypeScript/blob/main/src/compiler/parser.ts#L1746
https://github.com/microsoft/TypeScript/blob/main/src/compiler/utilities.ts#L8832

🙂 Expected behavior

Under the assumption that ScriptKind.Deferred could be treated as LanguageVariant.JSX then this resolves typescript-eslints issue with parsing extraFileExtensions such as vue files.

I'm unsure what the consequences and other use cases of ScriptKind.Deferred are so it could be as simple as adjusting getLanguageVariant.

Additional information about the issue

https://github.com/typescript-eslint/typescript-eslint/issues/9934

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked locations in src/compiler/parser.ts and src/compiler/utilities.ts, especially the language-variant handling for ScriptKind.Deferred. Reproduce the parsing failure through the related typescript-eslint issue using a Vue file with TSX, then assess the consequences of treating Deferred as JSX. Done means the reported Vue parsing error is resolved without breaking other Deferred ScriptKind use cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.