Skip to content

Migrate scripts/ from JavaScript to TypeScript#30

Open
blackwood wants to merge 1 commit into
mainfrom
ts-migrate/PM-35418
Open

Migrate scripts/ from JavaScript to TypeScript#30
blackwood wants to merge 1 commit into
mainfrom
ts-migrate/PM-35418

Conversation

@blackwood

@blackwood blackwood commented Jun 23, 2026

Copy link
Copy Markdown

🎟️ Tracking

PM-35418

📔 Objective

Convert the build/validate/lint tooling under scripts/ from .mjs to .mts, type-checked with TypeScript via tsc --noEmit and run directly by Node's native type-stripping (no compile/emit step; Node >=22.18 strips types at runtime, already pinned via .nvmrc).

  • Add tsconfig.json (strict, noEmit, NodeNext, verbatimModuleSyntax) and a typecheck script wired into npm run check; add typescript + @types/node.
  • Add scripts/lib/types.mts with shared Location/Finding/LintResult/Form/ FormMapData shapes.
  • Type the selector linter against css-what's own token types, using explicit type-predicate filters and in guards for the discriminated union.
  • ajv/ajv-formats are CommonJS; alias their .default since NodeNext types the ESM default import as the module namespace.
  • Repoint package.json scripts and lint-staged, and the README link, to .mts.

No behavior change: the built dist/forms.v1.json is byte-identical to the pre-migration output, and all 189 tests pass.

Convert the build/validate/lint tooling under scripts/ from .mjs to .mts,
type-checked with TypeScript via `tsc --noEmit` and run directly by Node's
native type-stripping (no compile/emit step; Node >=22.18 strips types at
runtime, already pinned via .nvmrc).

- Add tsconfig.json (strict, noEmit, NodeNext, verbatimModuleSyntax) and a
  `typecheck` script wired into `npm run check`; add typescript + @types/node.
- Add scripts/lib/types.mts with shared Location/Finding/LintResult/Form/
  FormMapData shapes.
- Type the selector linter against css-what's own token types, using explicit
  type-predicate filters and `in` guards for the discriminated union.
- ajv/ajv-formats are CommonJS; alias their `.default` since NodeNext types the
  ESM default import as the module namespace.
- Repoint package.json scripts and lint-staged, and the README link, to .mts.

No behavior change: the built dist/forms.v1.json is byte-identical to the
pre-migration output, and all 189 tests pass.
@blackwood blackwood requested a review from a team as a code owner June 23, 2026 18:33
@blackwood blackwood requested a review from bensbits91 June 23, 2026 18:33
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

This PR migrates the scripts/ build, validate, and lint tooling from .mjs to .mts, adds a strict tsconfig.json with tsc --noEmit type checking wired into npm run check, and introduces shared types in scripts/lib/types.mts. The migration is consistent end-to-end: all package.json scripts, lint-staged entries, and the README link are repointed to .mts, and CI invokes the unchanged npm run check / npm run build targets. The two logic-touching edits — destructuring in isIdOnly and the type-narrowing filter in findNamespacedTokens — preserve the original behavior.

Code Review Details
  • ⚠️ : New dev dependency typescript (^6.0.3) added without an AppSec approval signal. Bitwarden's Dependency Review and Approval process requires AppSec review before introducing any new dependency, including dev/test. The PR references PM-35418 (a PM task), not a VULN task, and does not mention AppSec approval. The submitter should reach out to the AppSec team to initiate the dependency review process.
    • package.json:60

Dependency Changes

Package Change Ecosystem
typescript New (^6.0.3) npm
@types/node 22.19.17 → 22.20.0 npm

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.

2 participants