chore(api)!: migrate from TypeScript to JavaScript#347
Open
caugner wants to merge 8 commits into
Open
Conversation
Convert the `api/` package sources from TypeScript to JavaScript, keeping `tsc` for strict type checking via JSDoc annotations (`@import` for external types, `@typedef` for derived types). - `tsconfig.json` uses `allowJs`/`checkJs`/`emitDeclarationOnly` to type-check the `.js` sources and emit `dist/index.d.ts`. - Run the generator with `node cli.js` instead of `ts-node`. - Add a `files` allowlist so the published tarball still includes the generated `dist/index.d.ts`, which is no longer force-included once `main` points outside `dist/`. - Keep `typescript-eslint` for linting and add an `env` so `no-undef` resolves globals like `URL` in the `.js` sources. The package now ships ESM (`"type": "module"`) instead of CommonJS.
# Conflicts: # api/package-lock.json # api/package.json
Guarantee `dist/index.d.ts` is present in the published tarball regardless of build ordering, since `dist` is gitignored and `npm pack` silently omits missing `files` entries. Also makes local `npm pack` and `npm publish` ship the declarations.
`cli.js` is the internal generator entry, run via `npm run generate` from a checkout; it is not referenced by `main`, `bin`, or `exports`, so npm consumers never import it. It stays in the tsconfig `include` for type-checking.
`no-undef` needs only the `node` env to resolve runtime globals like `URL`; `es2024` adds no globals the sources use, and `@typescript-eslint/parser` already parses the modern syntax.
caugner
marked this pull request as ready for review
July 17, 2026 09:43
# Conflicts: # .lefthook.yml # package.json
caugner
marked this pull request as draft
July 17, 2026 14:00
`npm install` in a worktree derived the project name from the directory basename and rewrote it into the lockfile. The root `package.json` has no `name` field, so revert the leaked value.
`void` in a return union reads oddly for a function that returns a value or nothing; `undefined` is clearer and emits an identical declaration.
caugner
marked this pull request as ready for review
July 17, 2026 14:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Migrate the
api/package from TypeScript to JavaScript, keepingtscfor strict type checking via JSDoc annotations.index.ts/cli.tstoindex.js/cli.js(ESM), using@importfor external types and@typedeffor derived types.tsconfig.jsonusesallowJs/checkJs/emitDeclarationOnlyto type-check the sources and emitdist/index.d.ts.node cli.jsinstead oftsx, dropping thetsxdev dependency; add afilesallowlist (index.js,dist/index.d.ts) plus aprepackhook sotscalways builds the shipped declarations.typescript-eslintfor linting, adding anodeenvsono-undefresolves globals likeURLin.js; update the lefthook ESLint glob to*.js.Motivation
Make the sources plain JavaScript (matching the ESM
updates/workspace) while still getting strict, TypeScript-powered type checking through JSDoc, and removing thetsxruntime dependency.Additional details
The package now ships ESM (
"type": "module") instead of CommonJS — a breaking change for anyrequire("@mdn/bcd-utils-api")consumers. The generateddist/index.d.tsis structurally identical to the previous declarations, andnpm run generateproduces byte-compatible output.Related issues and pull requests