[英]Solve or get rid of pattern matching error in tsconfig.json
如何解決/消除 Visual Studio Code 中顯示的模式匹配錯誤?
在我的 TypeScript 應用程序中,我在tsconfig.json
文件中遇到錯誤,提到由於匹配特定模式**/*
而找不到 index.ts。 該應用程序仍然可以編譯和運行,沒有任何問題。 該錯誤僅顯示在 Visual Studio Code 中。 為了編譯我使用 Webpack 的應用程序,我在其中定義了index.tsx
文件作為入口點,而不是index.ts
文件。
webpack.config.js:
const path = require('path');
module.exports = {
entry: './src/main/ts/index.tsx',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
output: {
path: __dirname,
filename: './src/main/resources/static/built/bundle.js'
},
};
package.json 依賴項:
"dependencies": {
"@types/lodash": "^4.14.182",
"@types/react": "^18.0.14",
"@types/react-dom": "^18.0.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rest": "^1.3.1",
"sockjs-client": "^1.0.3",
"stompjs": "^2.3.3"
},
"devDependencies": {
"@babel/core": "^7.1.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.2",
"ts-loader": "^9.3.0",
"typescript": "^4.7.4",
"webpack": "^5.73.0",
"webpack-cli": "^4.10.0"
},
添加
"include": ["src/**/*"],
到你的tsconfig.json
它可能會有所幫助。 如果不是你必須重新打開 vscode 它會解決這個問題,但這有點煩人
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.