Skip to content

tsc crash with Error: start < 0 in a specific configΒ #58600

@yume-chan

Description

@yume-chan

πŸ”Ž Search Terms

crash createTextSpan

πŸ•— Version & Regression Information

  • This is a crash

⏯ Playground Link

No response

πŸ’» Code

https://github.com/yume-chan/ts-crash

This is a minimal repro with only 15 lines across 3 files.

πŸ™ Actual behavior

pnpm i
npx tsc

Output:

# npx tsc
/root/ts-crash/node_modules/.pnpm/typescript@5.5.0-dev.20240520/node_modules/typescript/lib/tsc.js:11034
    throw new Error("start < 0");
    ^

Error: start < 0
    at createTextSpan (/root/ts-crash/node_modules/.pnpm/typescript@5.5.0-dev.20240520/node_modules/typescript/lib/tsc.js:11034:11)
    at createTextSpanFromBounds (/root/ts-crash/node_modules/.pnpm/typescript@5.5.0-dev.20240520/node_modules/typescript/lib/tsc.js:11042:10)
    at getErrorSpanForNode (/root/ts-crash/node_modules/.pnpm/typescript@5.5.0-dev.20240520/node_modules/typescript/lib/tsc.js:13589:10)
    at createDiagnosticForNodeFromMessageChain (/root/ts-crash/node_modules/.pnpm/typescript@5.5.0-dev.20240520/node_modules/typescript/lib/tsc.js:13419:16)
    at resolveExternalModule (/root/ts-crash/node_modules/.pnpm/typescript@5.5.0-dev.20240520/node_modules/typescript/lib/tsc.js:48013:31)
    at resolveExternalModuleNameWorker (/root/ts-crash/node_modules/.pnpm/typescript@5.5.0-dev.20240520/node_modules/typescript/lib/tsc.js:47907:61)
    at resolveExternalModuleName (/root/ts-crash/node_modules/.pnpm/typescript@5.5.0-dev.20240520/node_modules/typescript/lib/tsc.js:47904:12)
    at getSymbolAtLocation (/root/ts-crash/node_modules/.pnpm/typescript@5.5.0-dev.20240520/node_modules/typescript/lib/tsc.js:84201:18)
    at Object.getSymbolAtLocation (/root/ts-crash/node_modules/.pnpm/typescript@5.5.0-dev.20240520/node_modules/typescript/lib/tsc.js:45191:21)
    at getReferencedFilesFromImportLiteral (/root/ts-crash/node_modules/.pnpm/typescript@5.5.0-dev.20240520/node_modules/typescript/lib/tsc.js:121837:28)

Node.js v21.6.2

πŸ™‚ Expected behavior

No crash.

Additional information about the issue

Reproducible in both 5.4.5 and 5.5.0-dev.20240520

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions