gpt4 book ai didi

node.js - TypeScript 类型错误(错误 TS2687): All declarations of 'iterator' must have identical modifiers

转载 作者:搜寻专家 更新时间:2023-10-30 22:00:44 29 4
gpt4 key购买 nike

在我将路由器包添加到我的 Angular 应用程序(需要升级 Core、Common、Compiler 等)后,我无法正确输入。

谷歌搜索特定错误代码导致我遇到了很多问题,主要解决方案是删除 node_modulestypings 并重新创建它们。我这样做了,但遇到了同样的不当行为。

在 SO 上,有 another question但它很旧,与大多数软件包的不同版本有关,我几乎看不出它与我的问题有什么关系。

坦率地说,我有点迷茫,因为我根本不知道如何解决它。下面是我的 tsconfig.json 如果它有助于发现一些奇怪的东西。

编辑

const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");

const distribution = path.resolve(__dirname, "distribution");
const application = path.resolve(__dirname, "source/application");
const resources = path.resolve(__dirname, "source/resources");

module.exports = {
entry: "./source/application/main.ts",
output: {
path: distribution,
filename: "bundle.js"
},
module: {
loaders: [
{ test: /\.png$/, loader: "raw-loader", include: [resources] },
{ test: /\.s(a|c)ss$/, loaders: ["raw-loader", "sass-loader"] },
{ test: /\.html$/, loader: "raw-loader", include: [application] },
{ test: /\.ts$/, loader: "ts-loader", include: [application] },
]
},

resolve: {
modules: ["node_modules", application],
extensions: [".js", ".ts"]
},

performance: {},
devtool: "source-map",
context: __dirname,
target: "web",
externals: [],
stats: {},

devServer: {
contentBase: distribution,
port: 3002
},

plugins: [
new HtmlWebpackPlugin({ template: "./source/index.html" }),
new CopyWebpackPlugin([{ from: "./source/resources", to: "resources" }])
]
}

最佳答案

在 Webpack.common.js 中删除 debug=true 行,并更改以下代码

module.exports = {
entry: {
'polyfills': './src/polyfills.ts',
'vendor': './src/vendor.ts',
'app': './src/main.ts'
},

resolve: {
extensions: ['*', '.js', '.ts']
},

module: {
rules: [
]},
plugins: [
new webpack.ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
helpers.root('./src'), // location of your src
{} // a map of your routes
),

new webpack.optimize.CommonsChunkPlugin({
name: ['app', 'vendor', 'polyfills']
}),

关于node.js - TypeScript 类型错误(错误 TS2687): All declarations of 'iterator' must have identical modifiers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42925792/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com