简体   繁体   English

如何在TypeScript 2.1.4中使TS2354错误消息静音?

[英]How can I silence the TS2354 error message in TypeScript 2.1.4?

I am getting error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found. 我收到错误TS2354:此语法需要导入的帮助程序,但找不到模块“ tslib”。 on my webpack 2 build using the new importHelpers option of TypeScript 2.1. 在我的webpack 2构建中,使用TypeScript 2.1的新importHelpers选项。 The bundle seems to build as expected but the error message is troubling. 该捆绑包似乎按照预期的方式构建,但错误消息令人担忧。 Can anyone point out what I'm doing wrong here? 谁能指出我在这里做错了什么? Or is it a problem with rxjs\\Subject.d.ts per the error (that mentioned line (Subject.d.ts:9,43) does use and innocent extends keyword)? 还是每个错误rxjs\\Subject.d.ts有问题(提到的那行(Subject.d.ts:9,43)确实使用并且无辜的extends关键字)?

ts-loader: Using typescript@2.1.4 and C:Repro\stuff\tsconfig.json
Hash: f24da06626836e4fc997
Version: webpack 2.1.0-beta.28
Time: 4256ms
Asset     Size  Chunks             Chunk Names
app.js  3.01 kB       0  [emitted]  app
  [1] ./src/main.ts 372 bytes {0} [built]
    + 1 hidden modules

ERROR in C:Repro\stuff\node_modules\rxjs\Subject.d.ts
(9,43): error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found.

main.ts 主要

import { Observable } from "rxjs";

Observable.timer(3000, 5000)
  .timeInterval()
  .subscribe((interval) => console.log(interval));

package.json 的package.json

{
  "name": "stuff",
  "version": "1.0.0",
  "scripts": {
    "build": "webpack"
  },
  "devDependencies": {
    "@types/core-js": "^0.9.35",
    "ts-loader": "^1.3.2",
    "typescript": "^2.1.4",
    "webpack": "^2.1.0-beta.25"
  },
  "dependencies": {
    "rxjs": "^5.0.1",
    "tslib": "^1.2.0"
  }
}

tsconfig.json tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "importHelpers": true,
    "target": "es5",
    "noEmitHelpers": true
  }
}

webpack.config.js webpack.config.js

module.exports = {
  name: 'server',
  target: 'node',
  entry: { 'app': './src/main.ts' },
  output: { path: './bin/', publicPath: 'bin/', filename: '[name].js' },
  externals: { rxjs: 'commonjs rxjs' },
  module: { rules: [{ test: /\.ts$/, loader: 'ts-loader' }], },
  resolve: { extensions: ['.ts'] }
};

看起来在此打字稿问题下已得到跟踪, 该问题应在TypeScript 2.1.5中修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeScript 错误“TS2354:此语法需要导入的帮助程序,但找不到模块‘tslib’” - TypeScript error "TS2354: This syntax requires an imported helper but module 'tslib' cannot be found" 如何解决打字稿中与错误相关的错误:TS2705 - How can I resolve the error related error:TS2705 in typescript 我可以为 typescript 上的错误 ts(7053) 提供帮助吗? - Can I have help for my error ts(7053) on typescript? 我该如何解决“错误:TypeScript 编译中缺少 \\src\\main.ts”。 - How can i solve "Error: \src\main.ts is missing from the TypeScript compilation." 如何在 ts 中使用“@devexpress/dx-react-scheduler”? 它会导致 Typescript 错误 - How can i use '@devexpress/dx-react-scheduler' in ts? It cause Typescript error Typescript 如何忽略 'types' 只能在 a.ts 文件中使用错误 - Typescript how to ignore 'types' can only be used in a .ts file error 如何在 typescript 中使用 package xpath-ts + xmldom? - How can I use package xpath-ts + xmldom in typescript? 如何解决打字稿/反应错误 TS7053? - How do I solve typescript/react error TS7053? 分配属性时,如何避免 Microsoft Bot Framework 的 StatePropertyAccessor 中的 Typescript 错误 TS2345 - How can I avoid a Typescript Error, TS2345, in the Microsoft Bot Framework's StatePropertyAccessor when I assign a property 如何使用TypeScript处理异常消息? - How can I handle an exception message with TypeScript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM