• Error
  • Reported by the type checker

TS1044

'{0}' modifier cannot appear on a module or namespace element.

A class-member modifier such as `public` or `static` is used on a declaration inside a namespace or module. Remove it, or use `export`.

What it means

Inside a namespace (or module) block, declarations are either exported or local. Class modifiers such as public, private, protected and static don't apply there.

Example

index.ts
export namespace App {
  public const version = 1;
}
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(2,3): error TS1044: 'public' modifier cannot appear on a module or namespace element.

Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.

How to fix

  • To make the declaration visible outside the namespace, use export const version = 1.
  • Otherwise delete the modifier.