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

Cerrado
#2,158 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
node.js, typescript

Línea de trabajo

Start by running the provided repro.ts example with scriptc 0.4.4 and compare it with Node’s type stripping; the report identifies string literal union narrowing to never as the failing case. Then trace how the compiler lowers that narrowed value and how it checks the argument passed to unreachable. Done when the example compiles and the reported number union and typeof narrowing cases still behave as described.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
6.4k
Forks
204
Merge medio
7 h 35 min
PR fusionados (30 d)
873

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de vercel-labs/scriptc

Todos los issues de vercel-labs/scriptc

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.