lint tsc 跳过 node_modules

本文介绍了如何通过tsconfig.json配置文件排除node_modules,确保编译时忽略不必要文件。同时,为确保类型检查,配置include来指定需要校验的文件夹。当遇到库版本不匹配问题时,升级typescript和eslint至最新版本如v4和v7可有效解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

第一层

tsconfig.json 中配置 exclude,将想跳过的文件夹配置到 exclude 中

{
	"exclude": ["node_modules/**"]
}

第二层

tsconfig.json 中额外配置 include,将需要校验的文件夹配置到 include 中

{
	"include": ["src/**/*"],
	"exclude": ["node_modules/**"],
}

第三层

tsconfig.json 中在添加配置 “skipLibCheck”: true

{
	"compilerOptions": {
        "skipLibCheck": true
    },
	"include": ["src/**/*"],
	"exclude": ["node_modules/**"],
}

第四层

上述都配了的话,如果还有问题,可能使用的一些库依赖的是高版本的 ts 和 es, 需要升级 typescript 至 4 版本 eslint 7 版本,即可解决

{ "name": "pinia-plugin-persist", "version": "1.0.0", "repository": { "type": "git", "url": "https://github.com/Seb-L/pinia-plugin-persist.git" }, "scripts": { "dev": "vite", "build": "vite build && tsc", "lint": "eslint . --ext .ts", "unit:run": "vitest run --coverage", "unit:watch": "vitest watch", "docs:dev": "vitepress dev docs", "docs:build": "vitepress build docs" }, "files": [ "dist", "types" ], "main": "./dist/pinia-persist.umd.js", "module": "./dist/pinia-persist.es.js", "exports": { ".": { "import": "./dist/pinia-persist.es.js", "require": "./dist/pinia-persist.umd.js" } }, "types": "./dist", "devDependencies": { "@babel/types": "^7.17.0", "@types/node": "^17.0.21", "@typescript-eslint/eslint-plugin": "^5.14.0", "@typescript-eslint/parser": "^5.14.0", "c8": "^7.11.0", "eslint": "^8.10.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-simple-import-sort": "^7.0.0", "happy-dom": "^2.46.0", "pinia": "^2.0.0", "prettier": "^2.5.1", "typescript": "^4.5.4", "vite": "^2.8.0", "vitepress": "^0.22.3", "vitest": "^0.6.0", "vue": "^3.2.31" }, "dependencies": { "vue-demi": "^0.12.1" }, "peerDependencies": { "@vue/composition-api": "^1.0.0", "pinia": "^2.0.0", "vue": "^2.0.0 || >=3.0.0" }, "peerDependenciesMeta": { "@vue/composition-api": { "optional": true } } } Vue: Could not find a declaration file for module pinia-plugin-persist. d:/ poject/ sportstraininghall/ src/ main/ resources/ webpage/ node_modules/ pinia-plugin-persist/ dist/ pinia-persist. es. js implicitly has an any type. There are types at d:/ poject/ sportstraininghall/ src/ main/ resources/ webpage/ node_modules/ pinia-plugin-persist/ dist/ index. d. ts , but this result could not be resolved when respecting package. json exports. The pinia-plugin-persist library may need to update its package. json or typings. 根据以上错误提示纠正代码错误
最新发布
03-21
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值