Issue
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();
})()
Solution
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'
Answered By - Suraj Rao
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.