Skip to content

4.1 RC crashes when new JSX factory is used with incremental mode #41410

@billyjanitsch

Description

@billyjanitsch

TypeScript Version: 4.1.1-rc (also reproduces in 4.2.0-dev.20201104)

Search Terms: JSX factory incremental

Code

index.tsx:

export default function Foo(): JSX.Element {
  return <div />;
}

tsconfig.json:

{
  "compilerOptions": {
    "incremental": true,
    "jsx": "react-jsx"
  }
}

package.json:

{
  "scripts": {
    "test": "tsc"
  },
  "devDependencies": {
    "typescript": "4.1.1-rc"
  },
  "dependencies": {
    "@types/react": "^16.9.55",
    "react": "^16.14.0"
  }
}

Expected behavior:

Running tsc shouldn't crash.

Actual behavior:

/Users/billy/work/ts-bug/node_modules/typescript/lib/tsc.js:8489
            throw new Error("start < 0");
            ^

Error: start < 0
    at createTextSpan (/Users/billy/work/ts-bug/node_modules/typescript/lib/tsc.js:8489:19)
    at Object.createTextSpanFromBounds (/Users/billy/work/ts-bug/node_modules/typescript/lib/tsc.js:8498:16)
    at getErrorSpanForNode (/Users/billy/work/ts-bug/node_modules/typescript/lib/tsc.js:10803:19)
    at Object.createDiagnosticForNodeFromMessageChain (/Users/billy/work/ts-bug/node_modules/typescript/lib/tsc.js:10711:20)
    at errorOrSuggestion (/Users/billy/work/ts-bug/node_modules/typescript/lib/tsc.js:36053:141)
    at errorOnImplicitAnyModule (/Users/billy/work/ts-bug/node_modules/typescript/lib/tsc.js:37798:13)
    at resolveExternalModule (/Users/billy/work/ts-bug/node_modules/typescript/lib/tsc.js:37757:21)
    at resolveExternalModuleNameWorker (/Users/billy/work/ts-bug/node_modules/typescript/lib/tsc.js:37711:19)
    at resolveExternalModuleName (/Users/billy/work/ts-bug/node_modules/typescript/lib/tsc.js:37706:20)
    at getSymbolAtLocation (/Users/billy/work/ts-bug/node_modules/typescript/lib/tsc.js:64910:32)

Playground Link:

Can't make a playground because 4.1.1-rc isn't available there yet but here's a minimal repo.

Related Issues:

Seems related to #41330 and prior PRs.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputDomain: JSX/TSXRelates to the JSX parser and emitterDomain: tsc: --incrementalThe issue relates to incremental compilationFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions