A subclass's method is missing natively when the instance is read back from a Set typed with its base class
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 58/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, typescript
Research direction
Start by tracing how scriptc compiles typed JavaScript Set values and preserves subclass methods; the report reproduces this in dm3.js with allowJs, checkJs and strict. Compare the native output with Node.js and the build without checkJs to narrow down where the method is lost. Done means the compiled reproduction calls Effect._schedule() and prints effect without a runtime error.
Written by the indexing model from the issue text.
Description
An override is lost natively when the instance is read back from a Set typed with its base class: calling the method throws TypeError: ... is not a function. The build reports no diagnostic.
Reproduction
dm3.js, built with a tsconfig that has allowJs, checkJs and strict:
class Reactive {
_schedule() { console.log("reactive"); }
}
class Effect extends Reactive {
_schedule() { console.log("effect"); }
}
class Dep {
constructor() {
/** @type {Set<Reactive>} */
this._subscribers = new Set();
}
/** @param {Reactive} w */
_add(w) { this._subscribers.add(w); }
_notify() {
for (const r of Array.from(this._subscribers)) r._schedule();
}
}
const d = new Dep();
d._add(new Effect());
d._notify();
| Output | Exit | |
|---|---|---|
| Node.js v25.3.0 | effect |
0 |
| scriptc 0.4.12, 0.4.16 and 0.5.0 | Uncaught TypeError: r._schedule is not a function |
1 |
Without checkJs (no JSDoc types reaching the compiler) it prints effect. Neither _schedule is called: the method is missing altogether, not dispatched to the base class.
Environment
Linux x86_64, glibc 2.39, scriptc's linux-x64-gnu packages from npm.
Found through light's probe packages/light/native/probes/p-d-signals.js (a signal library's subscribers kept in a Set of the base class), which fails the same way.
- Dominant language
- TypeScript
- Stars
- 6.7k
- Forks
- 229
- Avg merge
- 14h 29m
- Merged PRs (30d)
- 787
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vercel-labs/scriptc
-
Difficulty 4/5 3-5 days Newbie friendliness 58/100
vercel-labs/scriptc#4864 ·
Maintainers usually reply within 1 day
-
Windows ARM64 as a cross-compile targetPossibly taken @hum-n claimed this 1 day ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
vercel-labs/scriptc#4858 ·
Maintainers usually reply within 1 day
-
post-merge-bisect-unresolved
Difficulty 3/5 1-2 days Newbie friendliness 43/100
vercel-labs/scriptc#4791 ·
Maintainers usually reply within 1 day
-
post-merge-bisect-unconfirmed
Difficulty 5/5 Over a week Newbie friendliness 12/100
vercel-labs/scriptc#4755 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
vercel-labs/scriptc#4634 ·
Maintainers usually reply within 1 day
All issues in vercel-labs/scriptc
Similar issues
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/clickhouse-js#1293 ·
Maintainers usually reply within 1 day
-
area: middleware enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
agent/quality testing
Difficulty 1/5 Under an hour Newbie friendliness 95/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
juspay/agent-distro#203 ·
Maintainers usually reply within 1 day