d123546
d123546

Reputation: 247

Ionic project Typescript errors

I've just installed ionic, cordova, and created an empty project. Everytime I launch ionic serve it displays browser page with Typescript errors like this:

**Typescript Error**

All declarations of 'size' must have identical modifiers.
node_modules/typescript/lib/lib.es2015.collection.d.ts
get(key: K): V | undefined;
has(key: K): boolean;
set(key: K, value: V): this;
Typescript Error
All declarations of 'prototype' must have identical modifiers.
node_modules/typescript/lib/lib.es2015.collection.d.ts
new (): WeakMap<object, any>;
new <K extends object, V>(entries?: [K, V][]): WeakMap<K, V>;
readonly prototype: WeakMap<object, any>;

I have searched through the internet, and haven't found any solutions ( Ionic info log:

global packages:

@ionic/cli-utils : 1.4.0
Ionic CLI        : 3.4.0

local packages:

@ionic/app-scripts              : 1.3.12
@ionic/cli-plugin-ionic-angular : 1.3.1
Ionic Framework                 : ionic-angular 3.5.0

System:

Node       : v7.2.0
OS         : OS X El Capitan
Xcode      : Xcode 8.2.1 Build version 8C1002 
ios-deploy : not installed
ios-sim    : not installed
npm        : 4.1.1 

Upvotes: 0

Views: 452

Answers (1)

d123546
d123546

Reputation: 247

Not sure if this is a correct solution, what I did is in tsconfig.json I set the types to empty array:

"compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2015"
    ],
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es5",
    "types": []

Also this guys suggested to install typings lodash (npm install @types/lodash --save-dev --save-exact) https://stackoverflow.com/a/44032856/4984738

then I set "types": ["lodash"], which is also works. Please give any comments if there is a better solution. Because in my other project it doesnt resolve all the issues, not sure its a project issues or still due to the typescript

Upvotes: 1

Related Questions