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

Narrowed-to-never string-literal union passed to a `never` parameter: SC1090 "'string' values where 'number' is expected"

Aperta
#2,159 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
53/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
compilers

Direzione di ricerca

Start by tracing how the compiler lowers string-literal unions narrowed to never and compares the resulting argument type with a never parameter. Use the supplied repro with scriptc build repro.ts -o t as the failing case, then compare it with the number-literal union and typeof narrowing examples. Done means the string-literal exhaustiveness example compiles while those comparison cases continue to behave as described.

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

Descrizione

Disclosure: this report was produced with the help of an AI agent (Claude Code). The agent reduced the problem from a real codebase to the repro below, ran every command shown, and drafted this text; a human reviewed it and decided to file it. The commands and outputs are real runs.

Environment: scriptc 0.4.4 (@scriptc/cli-linux-x64-gnu), Linux x86_64, Node 22.22.0. Reference behaviour from node --experimental-strip-types.

function unreachable(_: never): never { throw new Error("unreachable"); }
type K = "a" | "b";
function f(k: K): number {
  if (k === "a") return 1;
  if (k === "b") return 2;
  return unreachable(k);
}
console.log(f(Date.now() > 0 ? "a" : "b"));
$ scriptc build repro.ts -o t
repro.ts:6:22 - error SC1090: 'string' values where 'number' is expected is not supported yet
$ node --experimental-strip-types repro.ts
1

Expected: compiles (the standard exhaustiveness-check idiom).

Observations (all run 2026-10-24)

  • unreachable(k as never) fails the same way.
  • The same program with a number-literal union (type K = 1 | 2) compiles and prints 1.
  • typeof-narrowing a string | number to never compiles and prints 1.
  • So the failure seems specific to a string-literal union narrowed to never, which appears to be lowered as number.

Context: vjuga FunctionUtils.unreachable(_: never): never, used for exhaustive switch/if chains over string-literal unions.

Lingua principale
TypeScript
Stelle
6.4k
Fork
201
Merge medio
4h 41m
PR unite (30g)
885

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.