Skip to content

docs: rewrite the TypeScript fundamentals page#3250

Open
bartlomieju wants to merge 1 commit into
mainfrom
docs/typescript-page-refresh
Open

docs: rewrite the TypeScript fundamentals page#3250
bartlomieju wants to merge 1 commit into
mainfrom
docs/typescript-page-refresh

Conversation

@bartlomieju

Copy link
Copy Markdown
Member

The TypeScript page never showed running a .ts file, buried the
execution-vs-checking mental model in a callout, and said nothing to its
most likely reader: a Node.js developer arriving with a tsc/tsx/ts-node
toolchain. It also taught a pattern that crashes on Deno 2 — the global
augmentation examples extend interface Window, which type-checks but
throws ReferenceError: window is not defined at runtime (verified),
since window was removed in Deno 2.

This rewrite leads with deno run main.ts, explains the strip-and-run
vs opt-in-checking split up front (including that Deno never emits,
pointing at deno transpile/deno pack), and adds a "Coming from
Node.js" section: a toolchain mapping table plus the three things Node
developers trip on — real file extensions in imports, full-language
support versus erasable-only type stripping, and emit options having
nothing to configure. The global augmentation examples now declare
globals with var and access them via globalThis; the JavaScript
section's "TSDoc" label is corrected to JSDoc with canonical syntax;
deno check's directory and --check-js forms are documented; and the
browser/worker lib material is condensed into a pointer at the
configuration reference instead of duplicating it. Every command and
claim was verified against Deno 2.8. Heading anchors linked from other
pages and all oldUrl redirect entries are unchanged.

Lead with running a .ts file, explain the execution/checking split as
the page's mental model, and add a Coming from Node.js section mapping
tsx/ts-node/tsc/@types/node to their built-in Deno equivalents,
covering the three things Node devs trip on: real file extensions in
imports, full-language support vs erasable-only type stripping, and
the absence of emit.

Fixes a Deno 2 bug in the global augmentation examples: they augmented
interface Window and accessed window.*, which type-checks but throws
ReferenceError at runtime since window was removed in Deno 2; the page
now declares globals with var and accesses them via globalThis. Also
corrects the TSDoc label (the feature is TypeScript's JSDoc support),
uses canonical JSDoc param order, documents deno check's directory and
--check-js forms, and condenses the browser/worker lib material into a
pointer at the configuration reference instead of duplicating it.

Headings linked from other pages (#providing-declaration-files,
#augmenting-global-types, #configuring-typescript-compiler-options,
#tsconfig) are preserved.
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