I recently upgraded TypeScript to version 5.2.2 and modified my tsconfig.json file a bit (set module/moduleResolution to "nodenext") and am now getting this error, which didn't previously occur:
我最近将TypeScrip升级到版本5.2.2,并稍微修改了我的tsconfig.json文件(将模块/模块分辨率设置为“nodenext”),现在我收到了这个错误,这是以前没有发生过的:
error TS2339: Property 'isIP' does not exist on type 'typeof import(".../node_modules/@types/validator/index")'.
Here's the file:
以下是文件:
// ./src/valid.ts
import validator from "validator";
console.log(validator.isIP("12312"));
validator
is npm intalled.
验证器已安装NPM。
My ts config:
我的TS配置:
// tsconfig.json
{
"extends": "../../tsconfig.json",
"exclude": [
"build",
"data",
"node_modules"
],
"include": [
"./src/**/*"
],
"compilerOptions": {
"rootDir": "./src",
"outDir": "./build"
}
}
// ../../tsconfig.json
{
"compilerOptions": {
"target": "es2022",
"lib": [
"es2022"
],
"types": [
"vitest/importMeta"
],
"module": "nodenext",
"moduleResolution": "nodenext",
"sourceMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"declaration": true,
"declarationMap": true,
"composite": true,
"noUncheckedIndexedAccess": true
}
}
Reproduced in this repository: https://github.com/olalonde/tsbug
在此存储库中转载:https://github.com/olalonde/tsbug
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!