Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

dynamic: `.ts` sources in embedded npm packages are not type-stripped — binary fails with SyntaxError at startup

Chiusa
#575 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
compilers

Direzione di ricerca

Start by reproducing the failure with build --dynamic and the minimal package.json, node_modules/tsdep/index.ts, and main.ts example. Trace how .ts files selected through npm exports enter the embedded npm graph and reach the engine. Done means erasable TypeScript syntax is stripped before execution, or the build emits a diagnostic instead of producing a failing binary.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

build --dynamic succeeds for a program that imports an npm package whose exports point at TypeScript sources (.ts), but the embedded engine receives the .ts source without type stripping. The binary then fails at startup with a SyntaxError on the first type annotation. There's no diagnostic at build time.

This affects real packages that ship .ts entry points. For example [email protected] has "exports": { ".": { "import": "./index.ts" } }, and the binary fails with Uncaught SyntaxError: Unexpected identifier 'AgentToolUpdateCallback' (from import { withFileMutationQueue, type AgentToolUpdateCallback, ... } from "@earendil-works/pi-coding-agent"). #470 fixed the checker side of .ts-shipping dependencies; this is the runtime side.

Reproduction
// package.json
{ "name": "r", "type": "module" }
// node_modules/tsdep/package.json
{ "name": "tsdep", "type": "module", "exports": { ".": { "types": "./index.ts", "import": "./index.ts", "default": "./index.ts" } } }
// node_modules/tsdep/index.ts
export function get(): number { return 42; }

// main.ts
import { get } from "tsdep";
console.log(`${get()}`);
$ scriptc build --dynamic -o ./r main.ts   # exit 0
$ ./r
Uncaught SyntaxError: Unexpected token ':'
$ echo $?
1

Variants that fail the same way:

  • import { value, type Shape } from "lib"; gives Unexpected identifier 'Shape'
  • import type { Shape } from "lib"; gives from clause expected

Expected: .ts modules in the embedded npm graph are type-stripped (erasable syntax, as with tsx / node --strip-types) before they reach the engine. If that isn't supported, the build should fail with a diagnostic instead of producing a binary that can't start.

Versions

Reproduced on scriptc 0.1.7 (npm) and on main at 0d9d946 (built from source), linux-x64-gnu, Node 26.10.0.

Lingua principale
TypeScript
Stelle
6.2k
Fork
183
Merge medio
2h 10m
PR unite (30g)
884

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vercel-labs/scriptc

Tutte le issue di vercel-labs/scriptc

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.