Support structural constructor return types with static members
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, typescript
- Ambito
- compilers
Direzione di ricerca
Start by tracing how the compiler handles structural constructor types and static members during IR compilation, then follow the computed-expression extension path from Reproduction B. The issue gives two standalone repros and commands to build them with --emit=ir; run both to inspect the failures. Done means both compile and their native outputs match Node’s outputs, including the constructor intersection case.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Feature request for class values described by structural constructor types. The generic class factory example from #1241 now compiles, but exposing a constructor through an explicit structural return type still fails. These two examples belong to the same requested API surface; I have not established whether they need the same compiler fix.
Tested against scriptc main at a7e3a9d0aa (package version 0.3.6), macOS arm64, Node.js 24.22.0. The examples pass TypeScript 5.9.3 with strict mode, ESNext target, Bundler module resolution, and noEmit.
Reproduction A: constructor signature with a static member
type DescribedClass = { readonly schema: unknown; new (): unknown };
class Item {
static readonly schema = { name: true };
value = 42;
}
function classOf(): DescribedClass { return Item; }
console.log(JSON.stringify(classOf().schema));
Node prints {"name":true}. scriptc exits 1 during IR compilation:
SC2001: values of type 'DescribedClass' cannot be compiled yet (supported: number, string, boolean, arrays, Maps, Sets, RegExp, read-only Date values, functions, classes, records, unions of those, and 'unknown')
Reproduction B: extending a factory whose return type is a constructor intersection
type Struct<S> = (abstract new () => S) & { readonly decode: (value: unknown) => S };
function struct<S>(value: S): Struct<S> {
abstract class Base {
static decode(_input: unknown): S { return value; }
}
return Base as Struct<S>;
}
class Counter extends struct({ value: 42 }) {}
console.log(Counter.decode(null).value);
Node prints 42. scriptc exits 1 during IR compilation:
SC1090: extending computed expressions are not supported yet
SC2008: values of type 'Struct<{ value: number; }>' cannot be compiled: this intersection resolves to no runtime shape
Commands
Save each example separately as repro.ts. From a scriptc checkout with the compiler built:
node repro.ts
node --import tsx packages/cli/src/main.ts build repro.ts --emit=ir -o /tmp/repro.ir.json
Expected behavior and use case
Support passing and returning class values through a constructor signature that also describes their static members, including the factory-returned intersection above. Native execution should match the Node outputs.
Schema libraries use this pattern to expose static metadata or decoders together with a schema-derived instance type. This is a follow-up support request beyond the inferred factory return type in #1241, not a report that its original reproducer is still broken.
- Lingua principale
- TypeScript
- Stelle
- 6.2k
- Fork
- 183
- Merge medio
- 3h 22m
- PR unite (30g)
- 904
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di vercel-labs/scriptc
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 70/100
vercel-labs/scriptc#1625 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 1-2 giorni Idoneità per principianti 48/100
vercel-labs/scriptc#1624 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
vercel-labs/scriptc#1623 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
vercel-labs/scriptc#1622 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
vercel-labs/scriptc#1620 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di vercel-labs/scriptc
Issue simili
-
agent/scanner help wanted hive/claimed-by-scanner kind/bug stage/020-claimed
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
hivecommons/rationguard#315 ·
I maintainer di solito rispondono entro 1 giorno
-
agent-ready area: ui-sdk priority: p3 type: chore
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
schlessera/brain-kit#2534 ·
I maintainer di solito rispondono entro 1 giorno
-
bug lane:gh-5
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
LLM-4-People/bridlewise-testing#122 ·
I maintainer di solito rispondono entro 1 giorno
-
bug priority: P2
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement priority:low ready-for-dev
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno