I have the following error suddenly happens
Typescript Error
Duplicate identifier 'Map'.
/node_modules/#types/googlemaps/index.d.ts
Tried this way but it wasnt fixed
ionic 2 Duplicate identifier 'export='
my tsconfig file looks like below
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"declaration": false,
"sourceMap": true,
"noUnusedParameters": false,
"lib": [
"dom",
"es2015"
]
},
"types": [
"jasmine"
],
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
],
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
},
"awesomeTypescriptLoaderOptions": {
"forkChecker": true,
"useWebpackText": true
}
}
ionic -v 3.2.0
Check the section on #types, typeRoots and types
in tsconfig.json docs.
Because you have included
"types": [
"jasmine"
],
Typescript will only pick jasmine type declarations. You should add googlemaps to the array as well.
"types": [
"jasmine",
"googlemaps
],
Or remove the types array from tsconfig.json as typescript is configured to look at #types from node_modules by default.
Check this answer for further information.
Related
I am using eslint extension in vscode and it is always showing me the parser error which says that it cannot read tsconfig.json but when I run in the bash the command "eslint --ext .ts ." then it does not show there is any problem but only in the vscode eslint extension it's showing that problem.
Also, I noticed that it is not complaining about missing semicolons.
tsconfig.json
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"resolveJsonModule": true,
"outDir": "./build/",
"esModuleInterop": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"skipLibCheck": true
}
}
.eslintrc
{
"extends": [
"eslint:recommended",
"plugin:#typescript-eslint/recommended",
"plugin:#typescript-eslint/recommended-requiring-type-checking"
],
"plugins": [
"#typescript-eslint"
],
"env": {
"browser": true,
"es6": true,
"node": true
},
"rules": {
"#typescript-eslint/semi": [
"error"
],
"#typescript-eslint/explicit-function-return-type": "off",
"#typescript-eslint/explicit-module-boundary-types": "off",
"#typescript-eslint/restrict-template-expressions": "off",
"#typescript-eslint/restrict-plus-operands": "off",
"#typescript-eslint/no-unsafe-member-access": "off",
"#typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_"
}
],
"no-case-declarations": "off"
},
"parser": "#typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
}
}
I have a eslint config file .eslintrc.json (could be .eslintrc) like this:
{
"env": {
"browser": true,
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:#typescript-eslint/eslint-recommended",
"airbnb-typescript-prettier"
],
"plugins": [
"#typescript-eslint"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "#typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"overrides": [
{
"files": ["*.js", "*.jsx"],
"processor": "babel-eslint"
}
],
"rules": {
"react/prop-types": 0,
"semi": ["error", "never"]
}
}
and I got a persistent error
Error: ESLint configuration of processor in '.eslintrc.json#overrides[0]' is invalid: 'babel-eslint' was not found
Although official eslint site suggest this configuration, you need to use parser property in the overrides instead of processor such as the following:
...
"overrides": [
{
"files": ["*.js", "*.jsx"],
"parser": "babel-eslint"
}
],
...
With this change everything works pretty well.
I have a setup VS Code + TSLint extension on my work and it works perfectly.
No i work from home, did the same setup, but found that inline rules stop working at home setup, for example TS Lint says me that i should use self-closed tag for <script>, i want to ignore it and add // tslint:disable-next-line: jsx-self-close, but as you can see on screen shot the warning with underline still exists:
This also true for any other inline rules.
Since i have "source.fixAll.tslint": true in vs code settings.json it always fix it in unwanted way for me.
I try to googled about it but can't find similar issues
Also here is my tsconfig.json file:
{
"compilerOptions": {
"noEmit": false,
"sourceMap": true,
"noImplicitAny": false,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"strict": false,
"module": "commonjs",
"allowJs": true,
"target": "esnext",
"esModuleInterop": true,
"jsx": "react",
"typeRoots": [
"./src/typings",
"./node_modules/#types"
]
},
"include": [
"./src/**/*"
],
"exclude": [
"node_modules",
"./src/public"
]
}
The placement of comment was wrong, the correct placement is:
// tslint:disable: jsx-self-close
export const AmpAnalytics = React.memo(() => (
<amp-analytics type="googleanalytics">
<script
type="application/json"
dangerouslySetInnerHTML={{ __html: json }}
>
</script>
</amp-analytics>
));
My ts project in Visual Studio Code shows this path: ~/ and its suggestion to root of macos, as on screen shoot.
Whats goin on?
My tsconfig:
{
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"strict": true,
"jsx": "react",
"rootDir": "./",
"baseUrl": "./src",
"paths": {
"~*": ["./*"]
},
"incremental": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"lib": ["dom", "es2015", "webworker"]
}
}
Okay, found it.
In tsconfig should be:
"paths": {
"~/*": ["./*"]
},
instead of
"paths": {
"~*": ["./*"]
},
Getting exception and warning while uploading and package extension of Build Task.
I make a build task plugin i use below manifest file
{
"id": "sample-custom-build-task",
"type": "ms.vss-distributed-task.task",
"description": "Adds sample type Build Task",
"targets": [
"ms.vss-distributed-task.tasks"
],
"properties": {
"name": "buildtask"
}
}
Buildtask is a folder in home directory that contains node_modules,task.json,tsconfig,package.json and task image file.
tsConfig.json is look like this.
{
"compilerOptions":
{
"target": "es6",
"module": "commonjs",
"lib": ["es2015"],
"allowJs": true,
"checkJs": true,
"sourceMap": true,
"removeComments": true,
"strict": true,
"noImplicitAny": false,
"moduleResolution": "node",
"typeRoots": ["node_modules/typings"],
"types": ["node"]
},
"exclude": [
"**/node_modules/*",
"/NodeExecutor.ts"
],
"enableAutoDiscovery":true
}
Whenever i package my plugin there is some warning on console.
Refer image
and upload an extension show this error
Strange, for me, in past i make build task plugin but no error and warning whenever i add node_modules in my package it gave me error.
What i going to wrong, i add whole build task folder in my manifest file.
Thanks in advance.
Remove "addressable": true code for BuildTask:
"files": [
{
"path": "logo.png",
"addressable": true
},
{
"path": "BuildTask"
}
]
Also, the BuildTask folder should contains task.json file.