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();
    })()
2
  • if it is the same nProgress , why not use types ? Commented Jun 9, 2017 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 Commented Jun 9, 2017 at 13:10

1 Answer 1

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'
Sign up to request clarification or add additional context in comments.

3 Comments

I did it.But it shows this error on import line [ts] File 'd:/sophy/node_modules/@types/nprogress/index.d.ts' is not a module..Why?
I have used like this import * as NProgress from 'nProgress'
Try import Nprogress from nprogress

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.