How to troubleshoot compile-time and run-time errors
13 Mar 20241 minute to read
Compile-time error
Cannot find name ‘Map’ in ej2.d.ts: Need to change your target library. Try changing the ‘lib’ compiler option to es2015 or later.
You may see the below error while running the application.
ERROR
Build:Cannot find name ‘Map’. Do you need to change your target library? Try changing the ‘lib’ compiler option to
es2015or later.
Cause:
This error is thrown due to not including the required target library for the TypeScript compiler option and it can be resolved by any one of the below solutions.
Solutions:
-
Using MS build
By adding the required target
dom,es2015library inTypeScriptLibMSBuild property in your.csprojfile as like below, following the TypeScriptToolsVersion tag.<TypeScriptToolsVersion>3.1</TypeScriptToolsVersion> <TypeScriptLib>dom,es2015</TypeScriptLib>NOTE
If
tsconfig.jsonexists in your project, the compiler will prioritize using the specified configuration options fromtsconfig.jsonfile. Otherwise, it’ll use the specified configuration options from the project file (.csproj).Refer KB Link for more details.
-
Using
tsconfig.jsonBy adding the required target library in
"compilerOptions"property as like below.{ "compilerOptions": { //... "target": "ES2015" }, //... }