typescript错误:会覆盖输入文件 [英] typescript error: would overwrite input file

查看:5186
本文介绍了typescript错误:会覆盖输入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我更新了 最新的离子版 并删除 src / declarations.d.ts file.Now我的应用程序在我尝试运行应用程序时显示以下错误 ionic serve

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
模块'../../../node_modules/nprogress/nprogress.js'被解析为'/sophy/node_modules/nprogress/nprogress.js',但是
' - allowJs'不是设置。

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.


打字稿错误
Ca不写文件'/sophy/node_modules/nprogress/nprogress.js',因为
会覆盖输入文件。

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 :也是。请解决任何问题。

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();
    })()


推荐答案

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

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

npm install --save-dev @types/nProgress

可以看到声明文件这里
它将被添加到 node_modules / @ types 目录中。
Do

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

 import Nprogress from 'nprogress'

这篇关于typescript错误:会覆盖输入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆