EN
TypeScript - error TS2318: Cannot find global type 'Array'
1
answers
4
points
When I run my TypeScript project, compiler prints following errors:
error TS2318: Cannot find global type 'Array'.
error TS2318: Cannot find global type 'Boolean'.
error TS2318: Cannot find global type 'CallableFunction'.
error TS2318: Cannot find global type 'Function'.
error TS2318: Cannot find global type 'IArguments'.
error TS2318: Cannot find global type 'NewableFunction'.
error TS2318: Cannot find global type 'Number'.
error TS2318: Cannot find global type 'Object'.
error TS2318: Cannot find global type 'RegExp'.
error TS2318: Cannot find global type 'String'.
tsconfig.json
contains:
{
"version" : "4.0.3",
"compilerOptions": {
"strict": true,
"target": "es5",
"module": "amd",
"lib": ["es2015.promise"],
"jsx": "react",
"jsxFactory": "renderElement",
"jsxFragmentFactory": "renderFragment",
"allowJs": true,
"removeComments": true,
"noImplicitAny": true,
"preserveConstEnums": true,
"sourceMap": true,
"outFile": "src/main/webapp/resources/index.js"
},
"files": [
"src/main/webapp/resources/index.tsx"
],
"exclude": [
"../**/*.d.tsx"
]
}
1 answer
4
points
You need to add type declarations, so add "es5"
into your libs.
"lib": ["es2015.promise", "es5"],
your new configuration should look like:
{
"version" : "4.0.3",
"compilerOptions": {
"strict": true,
"target": "es5",
"module": "amd",
"lib": ["es2015.promise", "es5"],
"jsx": "react",
"jsxFactory": "renderElement",
"jsxFragmentFactory": "renderFragment",
"allowJs": true,
"removeComments": true,
"noImplicitAny": true,
"preserveConstEnums": true,
"sourceMap": true,
"outFile": "src/main/webapp/resources/index.js"
},
"files": [
"src/main/webapp/resources/index.tsx"
],
"exclude": [
"../**/*.d.tsx"
]
}
0 comments
Add comment