typescript 错误: would overwrite input file

标签 typescript ionic-framework ionic3

我已更新latest Ionic version并删除了 src/declarations.d.ts 文件。现在,当我尝试运行应用程序 ionicserve 时,我的应用程序显示以下错误。

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:  (() => {

have found the solution对于它,现在上面的错误不存在。但现在它显示下面的错误。

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

你知道为什么吗?

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
  }
}

我认为这就是问题所在。那么我该如何解决呢?当我删除 declarations.d.ts 时,就会出现上述错误。如果我添加它,则没有问题(我也必须删除 "allowJs": true )。任何解决方案,请。

src\assets\load.ts

  import * as NProgress from '../../../node_modules/nprogress/nprogress.js'
    (() => {
      NProgress.start();
    })()

最佳答案

您可以尝试使用 js 库的类型声明。

npm install --save-dev @types/nProgress

声明文件可见here 。 它将被添加到 node_modules/@types 目录中。 做

 import Nprogress from 'nprogress'

关于 typescript 错误: would overwrite input file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44457138/

相关文章:

ionic-framework - 在 Windows 10 上安装 ionic 和 cordova

reactjs - 如何声明Set()类型的状态变量?

javascript - 在 Angular 6 中使用 json 模式验证 json

Angular 2 - 显示一个元素并隐藏其他元素,

ios - ionic 5 在 ios 上出现白屏失败

javascript - 在组件/页面之间传递对象

ionic-framework - Ionic 3如何更改 ionic 项目容器中选定单选按钮的背景颜色

javascript - 如何将 date-fns 与 Vue 类组件一起使用?

javascript - Ionic 侧面菜单 - 仅在一页上

ionic-framework - 安卓目标 : not installed (cordova requirements)