Skip to content

Compile untyped bundled JavaScript: unchecked-JS opinions, promise-of-namespace loaders, and a scriptc export condition - #3566

Open
ctate wants to merge 3 commits into
mainfrom
ctate/compile-untyped-bundled-330cb8
Open

ctate wants to merge 3 commits into
mainfrom
ctate/compile-untyped-bundled-330cb8

Conversation

@ctate

@ctate ctate commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator
  • In unchecked JavaScript, an undeclared global read is a runtime ReferenceError (so typeof guards work), a subclass static whose signature differs from its base's compiles, and a truthiness test of a void-typed operand reads the value the call returned; a // @ts-check file keeps all three diagnostics.
  • A function whose result is a promise of a module namespace converts into an untyped slot through an interned adapter, so () => import("./chunk.mjs") loaders compile and the chunk loads at run time.
  • Package resolution selects a package's scriptc export condition before node, import, require and default, with a types branch still leading, in every world scriptc resolves (including the type-checked program), and the dependencies page documents it.

…-namespace loaders, and a `scriptc` export condition
@vercel

vercel Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
scriptc Ready Ready Preview, v0 Nov 12, 2026 9:42pm UTC

Comment on lines +2438 to +2446
// A `void`-typed operand (ADMITTED `if (fn())` / `!fn()` in an unchecked
// JavaScript source, tsc-codes.ts TS1345): the lowering produced no value,
// so Node's ToBoolean is of `undefined` — false — and the operand still
// runs once for its effects and any exception. Typed sources never reach
// this: the checker's TS1345 stops them at preflight.
if (e.type.kind === "void") {
return {
kind: "seqExpr",
stmts: [{ kind: "exprStmt", expr: e, loc: e.loc }],

@vercel vercel Bot Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A mutable callback alias retains its original function’s signature declaration, so replacing it with a truthy-returning callback still bypasses the guard and compiles its condition to false.

Fix on Vercel

This branch was successfully deployed

1 active deployment
Preview — 0e12ad26 Deployed Nov 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant