2

I have updated latest Ionic version and removed src/declarations.d.ts file.Now my app shows below error when I try to run the app ionic serve.

typescript: /sophy/src/assets/dev-load/load.ts, line: 1 Module '../../../node_modules/nprogress/nprogress.js' was resolved to '/sophy/node_modules/nprogress/nprogress.js', but '--allowJs' is not set.

   L1:  import * as NProgress from '../../../node_modules/nprogress/nprogress.js'
   L2:  (() => {

I have found the solution for it and now above error is not there.But now it shows below error.

typescript error Cannot write file '/sophy/node_modules/nprogress/nprogress.js' because it would overwrite input file.

Do you know why?

tsconfig.json

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2015"
    ],
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es5",
    "allowJs": true
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

I think this is the issue here.So how can I solve it? When I remove the declarations.d.ts then above errors are coming.If I add it then no issues (I have to remove the "allowJs": true too).Any solution, please.

src\assets\load.ts

  import * as NProgress from '../../../node_modules/nprogress/nprogress.js'
    (() => {
      NProgress.start();
    })()
Sampath
  • 63,341
  • 64
  • 307
  • 441
  • if it is the same nProgress , why not use [types](https://www.npmjs.com/package/@types/nprogress) ? – Suraj Rao Jun 09 '17 at 13:03
  • Yes, same.Can you provide the answer how to do that? What changes should I do after installing the typings and etc? @suraj – Sampath Jun 09 '17 at 13:10

1 Answers1

2

You can try using the type declarations for the js library.

npm install --save-dev @types/nProgress

The declaration file can be seen here. It will be added to node_modules/@types directory. Do

 import Nprogress from 'nprogress'
Sampath
  • 63,341
  • 64
  • 307
  • 441
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103