Abstract methods block coverage and direct calls when no subclass exists

オープン
#3,077 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@alantriesagain がすでに取り組んでいます。

2026年11月6日 から。

  • #3082 @alantriesagain による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
typescript
領域
compilers

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
TypeScript
スター
6.5k
フォーク
212
平均マージ
13時間 2分
マージ済み PR(30日)
798

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

vercel-labs/scriptc のほかの issue

vercel-labs/scriptc の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。