Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 后续属性声明必须具有相同的类型_Typescript_Webpack_Vue.js - Fatal编程技术网

Typescript 后续属性声明必须具有相同的类型

Typescript 后续属性声明必须具有相同的类型,typescript,webpack,vue.js,Typescript,Webpack,Vue.js,我有两个webpackconfig文件 webpack1.config.js const ExtractTextPlugin = require('extract-text-webpack-plugin'); const path = require('path'); const config = { entry: [ './app/App1/App1.ts' ], output: { path: path.resolve('', 'w

我有两个
webpack
config文件

webpack1.config.js

const ExtractTextPlugin = require('extract-text-webpack-plugin');
const path = require('path');

const config = {
    entry: [
        './app/App1/App1.ts'
    ],

    output: {
        path: path.resolve('', 'web/assets/js'),
        filename: 'app1.js'
    },

    resolve: {
        extensions: [".ts", ".tsx", ".vue", ".js"],
        modules: [
            path.resolve('./app'),
            path.resolve('./node_modules')
        ],
        alias: {
            'vue$': 'vue/dist/vue.esm.js'
        },
    },

    module: {
        rules: [
            {
                test: /\.ts?$/,
                loader: 'ts-loader',
                exclude: /node_modules/,
                options: {
                    appendTsSuffixTo: [/\.vue$/]
                }
            },
            {
                test: /\.vue?$/,
                loader: 'vue-loader',
                exclude: /node_modules/,
                options: {
                    esModule: true
                }
            }
        ]
    },
};

module.exports = config;
const path = require('path');

const config = {
    entry: [
        './app/App2/App2.ts'
    ],

    output: {
        path: path.resolve('', 'web/assets/js'),
        filename: 'app2.js'
    },

    resolve: {
        extensions: [".ts", ".tsx", ".vue", ".js"],
        modules: [
            path.resolve('./app'),
            path.resolve('./node_modules')
        ],
        alias: {
            'vue$': 'vue/dist/vue.esm.js'
        },
    },

    module: {
        rules: [
            {
                test: /\.ts?$/,
                loader: 'ts-loader',
                exclude: /node_modules/,
                options: {
                    appendTsSuffixTo: [/\.vue$/]
                }
            },
            {
                test: /\.vue?$/,
                loader: 'vue-loader',
                exclude: /node_modules/,
                options: {
                    esModule: true
                }
            }
        ]
    },
};

module.exports = config;
webpack2.config.js

const ExtractTextPlugin = require('extract-text-webpack-plugin');
const path = require('path');

const config = {
    entry: [
        './app/App1/App1.ts'
    ],

    output: {
        path: path.resolve('', 'web/assets/js'),
        filename: 'app1.js'
    },

    resolve: {
        extensions: [".ts", ".tsx", ".vue", ".js"],
        modules: [
            path.resolve('./app'),
            path.resolve('./node_modules')
        ],
        alias: {
            'vue$': 'vue/dist/vue.esm.js'
        },
    },

    module: {
        rules: [
            {
                test: /\.ts?$/,
                loader: 'ts-loader',
                exclude: /node_modules/,
                options: {
                    appendTsSuffixTo: [/\.vue$/]
                }
            },
            {
                test: /\.vue?$/,
                loader: 'vue-loader',
                exclude: /node_modules/,
                options: {
                    esModule: true
                }
            }
        ]
    },
};

module.exports = config;
const path = require('path');

const config = {
    entry: [
        './app/App2/App2.ts'
    ],

    output: {
        path: path.resolve('', 'web/assets/js'),
        filename: 'app2.js'
    },

    resolve: {
        extensions: [".ts", ".tsx", ".vue", ".js"],
        modules: [
            path.resolve('./app'),
            path.resolve('./node_modules')
        ],
        alias: {
            'vue$': 'vue/dist/vue.esm.js'
        },
    },

    module: {
        rules: [
            {
                test: /\.ts?$/,
                loader: 'ts-loader',
                exclude: /node_modules/,
                options: {
                    appendTsSuffixTo: [/\.vue$/]
                }
            },
            {
                test: /\.vue?$/,
                loader: 'vue-loader',
                exclude: /node_modules/,
                options: {
                    esModule: true
                }
            }
        ]
    },
};

module.exports = config;
现在,当我使用
webpack1.config.js
编译
app1
时,它抛出一个错误后续属性声明必须具有相同的类型。属性“user”的类型必须为“IUser”,但此处的类型为“IUser”。

因为在App1.ts中,我有下面一行

   import IUser from 'IUser'; // /app/App1/IUser.ts
   ...
   user:IUser;
   ...
App2.ts

   import IUser from 'IUser'; // /app/App2/IUser.ts
   ...
   user:IUser;
   ...
问题是位置
app/App2
也包含
IUser
界面,但是如何在
webpack1.config.js
中告诉停止查看
app/App2
位置

我已经试过了

``

因此,我试图排除
app/App2
,但没有效果,我仍然看到了错误。
我有最新版本的TypeScript,很有趣,因为它一直运行良好,今天突然出现了这个错误(我没有更新任何内容,只是像往常一样尝试编译项目)。

也许排除应用程序应该是一个字符串?因此,
“/app/App2”
否则它是一个正则表达式,可能只匹配名为
app/App2
的即时文件夹,而不是实际路径谢谢您的评论。我也试过了,可惜没有用。嗯,那么可能
path.resolve(uu dirname,“/App2”)