error TS2583: Cannot find name 'Map'. Do you need to change your target library? and its companion TS2585 ('Promise' only refers to a type, but is being used as a value here.) are reported when the libraries the checker loads predate ES2015. Without Map, Set, Promise and Symbol as values, everyday code fails.
The cause is nearly always a jsconfig.json without target. TypeScript 5.9 then assumes es5 and loads the ES5 library. The message suggests changing lib, but lib follows target by default, so setting target is the simpler fix.
At a glance
| Code | TS2583 |
|---|---|
| Message | Cannot find name '{0}'. Do you need to change your target library? Try changing the 'lib' compiler option to '{1}' or later. |
Also on this page: TS2585 | '{0}' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later. |
| TypeScript's category | error |
| Listed under | Unknown names and members |
| Depends on | target, lib |
| In .js files | Reported when the file is checked: checkJs in jsconfig.json, or // @ts-check at the top of the file |
The messages are TypeScript's own text from its diagnostic messages file (Apache-2.0); {0} and {1} are filled in by tsc for each error.
What it looks like
const prices = new Map();error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later.
const ready = Promise.resolve(prices);error TS2585: 'Promise' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later.
module.exports = { prices, ready };jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"types": []
},
"include": ["*.js"]
} What causes it
- No
targetin the config (the default ises5in TypeScript 5.9), and nomodulesuch asnodenextthat implies a newer one. - A
liblist that names an old ECMAScript year.
How to fix it
Set target to the JavaScript your runtimes support
Add "target": "es2022" (or the year your oldest runtime supports) to compilerOptions. The ES libraries up to that year load with it, and the same file passes. Setting module to nodenext also implies a recent target.
const prices = new Map();
const ready = Promise.resolve(prices);
module.exports = { prices, ready };jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"types": []
},
"include": ["*.js"]
} TypeScript 6.0
TypeScript 6.0 changes the default target to the newest ECMAScript year and deprecates es5, per its release notes; the target page has the details. Writing target explicitly keeps the config's meaning the same across versions.
Under TypeScript 6.0 and 7.0
Every example on this page also runs under TypeScript 6.0.3 and 7.0.2 when this site is built. One of them reports something different from 5.9.3, the version the page describes; the ✗ on its badge links to its entry below.
target defaults to the newest ECMAScript year
The pattern: Map or Promise in a project whose config sets neither target nor lib.
Why: Only the 6.0 default causes this. Without target, 5.9 assumed es5, whose library has no Map or Promise (TS2583, TS2585); 6.0 and 7.0 assume es2025. Source: TypeScript 6.0 release notes: Simple default changes.
No target in jsconfig.json, so the checker assumes ES5 cache.js
- TypeScript 5.9.3
cache.js(2,20): error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later. cache.js(5,15): error TS2585: 'Promise' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later.
- TypeScript 6.0.3differs from 5.9.3
No errors.
- TypeScript 7.0.2differs from 5.9.3
No errors.
What works in every version: Set target (and lib if you need one) explicitly.
The example The same file with a target on this page shows it, with the same result under every version.
Gotchas
- Installing
@types/nodecan hide this error, because the Node.js types load a newer library themselves. The code then passes for a reason unrelated to the config. - A newer
libthan the runtime supports makes the checker accept methods that fail when the code runs; match the year to your oldest browser or Node.js version. Methods that are missing for the same reason are TS2550.
Sources
- TSConfig Reference: target · TypeScript
- TSConfig Reference: lib · TypeScript
- diagnosticMessages.json (TypeScript 5.9.3) · TypeScript on GitHub
Last reviewed 20 October 2026.