Abstract methods block coverage and direct calls when no subclass exists

Abierto
#3,077 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@alantriesagain ya está trabajando en esto.

Desde el 6/11/2026.

  • #3082 de @alantriesagain — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
typescript
Área
compilers

Línea de trabajo

Start by reading the compiler paths that handle abstract method declarations, untyped property lookup, and direct calls; the issue gives reproductions but names no source files or tests. Compare the two examples with Node and inspect the existing SC1090 handling. Done means coverage treats abstract declarations as having no runtime value and direct calls match Node’s receiver, argument, and TypeError behavior. A linked pull request is already open.

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

Descripción

Abstract methods block coverage and direct calls when no subclass exists

The compiler refuses or defers abstract methods in two shapes that JavaScript handles.

Untyped lookup

A value held as any whose instances reach o[k] gets a branch per class and member. For an abstract method, the branch asks for the method's value, which an abstract declaration does not have. Every such branch is deferred with SC1090 values of abstract method declarations. The program runs and matches Node, but coverage never reports it as fully static.

abstract class Holder {
  abstract current(): string;
}

class Impl extends Holder {
  current(): string {
    return "ok";
  }
}

const read = (o: any, k: string) => o[k];
const impl: Holder = new Impl();
console.log(read(impl, "current"), impl.current());

On 0.4.8, scriptc coverage of the larger form in our corpus (abstract-methods-untyped-lookup.ts) reports 6 deferred sites. The same failure reproduces on main (979a65246).

Direct call

A concrete method that calls an abstract method with no concrete implementation below the receiver's static class is refused at build time, even when the program never subclasses the class. tsc makes every instantiable subclass implement the method, so no instance can reach the call.

abstract class Source {
  abstract count(): number;

  liveFrom(): number {
    return this.count();
  }
}

class Shelf {
  source: Source | null = null;
}

const shelf = new Shelf();
console.log(shelf.source === null ? "none" : shelf.source.liveFrom());

Node prints none. On 0.4.8, the build fails with SC1090 calls of the abstract method 'count' with no concrete implementation below the receiver's static class.

An abstract declaration has no value at run time. An untyped lookup should select the implementation of the constructible subclass the instance belongs to, nearest first, and read undefined when no class below the receiver implements it. A direct call should evaluate its receiver and arguments, then throw Node's TypeError, <callee> is not a function.

I opened #TBD with a patch that implements both behaviors.

Lenguaje dominante
TypeScript
Estrellas
6.5k
Forks
212
Merge medio
13 h 2 min
PR fusionados (30 d)
798

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.