Skip to content

Add a new baseline lib#62540

Closed
3ru wants to merge 1 commit intomicrosoft:mainfrom
3ru:feat/baseline-lib
Closed

Add a new baseline lib#62540
3ru wants to merge 1 commit intomicrosoft:mainfrom
3ru:feat/baseline-lib

Conversation

@3ru
Copy link
Copy Markdown

@3ru 3ru commented Oct 4, 2025

Fixes #62536

Overview

  • This PoC adds a new lib value, baseline, to TypeScript.
  • When users set compilerOptions.lib: ["baseline"] in tsconfig.json, the compiler only exposes types for JavaScript built‑ins that have reached Baseline Widely Available ("high"). Any built‑ins that are not yet in Baseline (low/false) are left undeclared and thus surface as ordinary type errors when referenced.
  • Language syntax (operators/statements/grammar/classes) is out of scope for this PR.

Scope (In/Out)

  • In: ECMAScript (JS) built‑in APIs only.
  • Data source: Features under javascript.builtins.* in web‑features whose status.baseline == "high" (Widely Available).
  • Out: Language syntax (operators/statements/grammar/classes), DOM/Web API/Worker/ScriptHost (host environment APIs). (TODO)

Spec

  • baseline.
    • Concretely, we introduce src/lib/baseline.d.ts, and reference only those existing src/lib/es20xx.*.d.ts fragments that correspond to Baseline Widely features via /// <reference lib="...">.
    • Built‑ins that haven't reached Baseline remain undeclared, so referencing them produces normal type errors.
Data Source and Verification (jq)
  • Data: web-features data.json
    • Path: /Users/ru/Documents/eslint-plugin/eslint-plugin-baseline-js/node_modules/web-features/data.json
  • We extract feature IDs where status.baseline == "high" and any compat_features entry starts with javascript.builtins.. We verified both the count and the list.

Set a variable:

DATA_PATH="/Users/ru/Documents/eslint-plugin/eslint-plugin-baseline-js/node_modules/web-features/data.json"

Count (unique feature IDs):

jq -r '.features | to_entries[] \
  | select(.value.status?.baseline=="high") \
  | select(any(.value.compat_features[]?; startswith("javascript.builtins."))) \
  | .key' "$DATA_PATH" | sort -u | wc -l

List (unique feature IDs):

jq -r '.features | to_entries[] \
  | select(.value.status?.baseline=="high") \
  | select(any(.value.compat_features[]?; startswith("javascript.builtins."))) \
  | .key' "$DATA_PATH" | sort -u
  • At the time of writing, we extract 65 JS built‑in features as Baseline Widely.

TODO

  • Scope and variants

    • Should we offer a baseline.full variant similar to es2015.full that also includes host libs like dom? (Note: this would mean JS is Baseline‑gated, but DOM is not.)
  • Defining baseline.d.ts

    • Should we keep the allowlist references in the TS repo manually, or provide a mapper/tooling on the WebDX CG side? Either way, this repo needs the final mapping.
    • Known mismatch example between web‑features granularity and TS lib fragment granularity:
      • src/lib/es2023.array.d.ts currently contains both:
        • findLast/findLastIndex (web‑features: array-findlast, Baseline = high), and
        • toReversed/toSorted/toSpliced/with (web‑features: array-by-copy, Baseline = low)
      • We should decide whether to split this into separate fragments (e.g. es2023.array.findlast vs es2023.array.by-copy) so baseline can safely include only the Baseline‑high set.
  • Sustainable data maintenance

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Oct 4, 2025
@3ru

This comment was marked as resolved.

@typescript-bot
Copy link
Copy Markdown
Collaborator

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support lib: "baseline-widely-available"

3 participants