TS2403: Subsequent variable declarations must have the same type TypeScript Origin: On your device OSI layer 7 · Application Last updated 5 Nov 2026

TypeScript: error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'number'.

A var was redeclared with a different type (or global declarations conflict).

Exact message you may see error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'number'.Subsequent variable declarations must have the same typeTS2403 Variable must be of type but here has type
Seen on: TypeScript

Meaning

Use let/const (block scoped, no redeclare), rename variables, or make the files modules. Conflicts also come from global scripts declaring the same variable (e.g. $) via different @types packages — remove duplicate type packages.

Common causes

  • var x declared twice with different types
  • Global script files sharing names
  • Conflicting @types packages (jquery/zepto)
  • Copy-paste
  • Global augmentations

⚡ Quick fix

  1. Use const/let and unique names
  2. Convert files to modules (export {})
  3. Remove duplicate @types

Detailed fix by platform

TypeScript

  1. export {}; // makes the file a module

How to diagnose

  1. var — Redeclared?
  2. Globals — Scripts?
  3. Types — Duplicate packages?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

Cannot find module './App.vue' or its corresponding type declarations — TypeScript: error TS2307: Cannot find module './App.vue' or its corresponding type declarations. (Vue)Cannot find module '.…TS1005: ';' expected / ',' expected (syntax error) — TypeScript: error TS1005: ';' expected. (TypeScript)TS1005: ';' expected …TS1128: Declaration or statement expected — TypeScript: error TS1128: Declaration or statement expected. (TypeScript)TS1128: Declaration o…TS1192: Module has no default export — TypeScript: error TS1192: Module '"./utils"' has no default export. (TypeScript)TS1192: Module has no…TS2300: Duplicate identifier — TypeScript: error TS2300: Duplicate identifier 'Foo'. (TypeScript)TS2300: Duplicate ide…TS2322 — TS2322: Type 'X' is not assignable to type 'Y' (TypeScript)TS2322TS2451: Cannot redeclare block-scoped variable — TypeScript: error TS2451: Cannot redeclare block-scoped variable 'name'. (TypeScript)TS2451: Cannot redecl…TS4023/TS2742: exported variable has or is using name from external module but cannot be named — TypeScript: error TS4023: Exported variable 'x' has or is using name 'Foo' from external module "..." but cannot be named. / TS2742: The inferred type cannot be named without a reference (TypeScript)TS4023/TS2742: export…TS2403: S…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.