Menu

1 / 2

declare global vs declare module: When to Use Which

DEV Community·Gabriel Anhaia·6 months ago
#k0p9gl2n
#case#declare#typescript#types#module
Reading 0:00
15s threshold

Book: TypeScript in Production — Tooling, Build, and Library Authoring Across Runtimes

Also by me: The TypeScript Library — the 5-book collection

My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools

Me: xgabriel.com | GitHub

You've seen this one. An engineer opens a PR adding an auth

field to Express.Request . The .d.ts file looks right, and the

handler that reads req.auth.userId compiles fine. Twenty minutes

after merge, a different service in the same monorepo starts

failing the type check with Property 'auth' does not exist on

type 'Request' . Same TypeScript version, same tsconfig shape,

same @types/express . Different result.

The reason is one missing line at the bottom of the .d.ts .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.