Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
b652ee3
docs: enhance documentation with TypeScript examples and improve erro…
bjohansebas Jul 4, 2026
d12b69a
docs: remove TypeScript code snippets from various guides to streamli…
bjohansebas Jul 4, 2026
1125584
Add TypeScript examples and enhance documentation for Express 5.x API
bjohansebas Jul 4, 2026
b5c0dc9
docs: add TypeScript parameter inference details to routing guide
bjohansebas Jul 4, 2026
a111af1
docs: update TypeScript request and response examples to remove param…
bjohansebas Jul 4, 2026
5795458
docs: enhance CodeTabs functionality to support JavaScript/TypeScript…
bjohansebas Jul 4, 2026
b10ea42
docs: add detailed guides for developing template engines and overrid…
bjohansebas Jul 4, 2026
a41e273
docs: add link to Node.js guide for running TypeScript natively in in…
bjohansebas Jul 4, 2026
b8a6479
docs: add TypeScript declaration merging example for request middleware
bjohansebas Jul 4, 2026
5a205e2
docs: add TypeScript extension examples for overriding Express API an…
bjohansebas Jul 4, 2026
197dd09
docs: add TypeScript type imports for error handling examples
bjohansebas Jul 4, 2026
ec2935b
docs: update TypeScript types for Express application and template en…
bjohansebas Jul 4, 2026
d351562
docs: improve TypeScript examples for template engines and installati…
bjohansebas Jul 4, 2026
111f77c
docs: add TypeScript parameter inference explanation for middleware e…
bjohansebas Jul 4, 2026
315d70f
docs: add TypeScript type definitions notes for various middleware pa…
bjohansebas Jul 4, 2026
fcff460
docs: enhance descriptions in routing and overriding API guides to in…
bjohansebas Jul 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/scripts/get-readmes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,34 @@ LIST_END
VERSION=$(echo "$NPM_DATA" | jq -r '.["dist-tags"].latest // empty')
DESC=$(echo "$NPM_DATA" | jq -r '.description // empty')

# Build a TypeScript types note for this package:
# - If the latest release declares its own types (a "types"/"typings" field),
# it ships types and no separate install is needed.
# - Otherwise, if a community-maintained @types/<pkg> package exists on npm,
# recommend installing it as a dev dependency.
# This relies on the declared types field; a package that ships a co-located
# index.d.ts without that field would not be detected (none currently do).
BUNDLED_TYPES=$(echo "$NPM_DATA" | jq -r --arg v "$VERSION" '(.versions[$v].types // .versions[$v].typings) // empty')
ATTYPES_VERSION=$(curl -s "https://registry.npmjs.org/@types/$NPM_PKG" | jq -r '.["dist-tags"].latest // empty')
DT_URL="https://github.com/DefinitelyTyped/DefinitelyTyped"
if [ -n "$BUNDLED_TYPES" ]; then
TYPES_ALERT="<Alert type=\"info\">

\`$NPM_PKG\` ships its own TypeScript type definitions, so you do not need to install a separate \`@types\` package.

</Alert>"
elif [ -n "$ATTYPES_VERSION" ]; then
TYPES_ALERT="<Alert type=\"info\">

\`$NPM_PKG\` does not include its own TypeScript type definitions. If you use TypeScript, also install the community-maintained types from [DefinitelyTyped](${DT_URL}) as a development dependency:

<PackageManagerCommand command=\"npm install --save-dev @types/$NPM_PKG\" />

</Alert>"
else
TYPES_ALERT=""
fi

# Preserve existing frontmatter if the file already exists
FRONTMATTER=""
if [ -f "$DEST" ]; then
Expand Down Expand Up @@ -118,6 +146,14 @@ LIST_END
}
}ge')

# Insert the TypeScript types note right after the install command (the first
# `npm install`/`npm i` PackageManagerCommand). Left untouched if none is found.
if [ -n "$TYPES_ALERT" ]; then
CONTENT=$(TYPES_ALERT="$TYPES_ALERT" perl -0777 -pe '
s{(<PackageManagerCommand command="npm (?:install|i)\b[^"]*"\s*/>)}{$1\n\n$ENV{TYPES_ALERT}};
' <<<"$CONTENT")
fi

# Convert relative links to absolute GitHub URLs
BASEURL="https://github.com/$org/$repo/blob/HEAD"
CONTENT=$(echo "$CONTENT" | sed -E "s|\]\(([^)#/][^):]*)\)|](${BASEURL}/\1)|g")
Expand Down
12 changes: 12 additions & 0 deletions src/content/api/4x/api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ app.get('/', function (req, res) {
app.listen(3000);
```

```ts title="index.ts"
import express, { type Express, type Request, type Response } from 'express';

const app: Express = express();

app.get('/', function (req: Request, res: Response) {
res.send('hello world');
});

app.listen(3000);
```

<Alert type="info">

Express 4.x requires **Node.js 0.10.0 or higher**.
Expand Down
Loading
Loading