Files
scriptc/tests/library-mode/npm-static/lib.ts
T
Chris Tate 967f2ec85d Compile minified npm entries and untyped regex arguments
Refs #1777

npm packages are no longer refused up front for minified JavaScript. A
bundle whose interop helpers lost their names is still refused by the
bundle recognizers, and a package whose attempt fails is still refused on
its own.

A `var` read in a later declarator of the statement that stores it
(`var a = {...}, b = {...a}`) runs after the store. A read in a function
body is now located at the body's own statement instead of the body, so
JavaScript `var` bindings read after their store in a function keep their
type instead of gaining undefined.

`replace` and `replaceAll` with an untyped search value and a callback
call the regex callback replacement for a RegExp and the string-search
helper otherwise. That helper now accepts untyped callback parameters,
passes undefined to parameters after the subject, and converts number,
boolean and untyped results with ToString.

In JavaScript, `||` and `&&` over primitives of different types whose
result tsc types `any` evaluate in the checked domain.
2026-10-23 05:55:39 -05:00

20 lines
712 B
TypeScript

// Library-mode npm posture fixture (static-or-refuse): a bare specifier
// naming an ELIGIBLE package (own .d.ts, no
// build-transform markers) compiles statically as part of the library
// graph — no flag, no island — and the package's own top-level require
// ("mathdep") joins through the same bar. The node:path import alongside
// pins the builtin story: an async_free builtin keeps working under the
// npm posture, governed by SC4005 alone.
import { OFFSET, scale } from "mathkit";
import { basename } from "node:path";
export function scaled(x: number): number {
return scale(x, 3) + OFFSET;
}
export function tail(p: string): string {
return basename(p);
}
console.log("npm-static ready");