1 回答
TA贡献1798条经验 获得超3个赞
undefined当可选值可能是打字稿或null打字稿时,您应该准确设置它们的类型。如果您处于strict模式下,针对这种情况有两种选择:
undefined1.设置s和nulls的类型
interface InputNumberProps {
className?: undefined | string | (string | undefined | null)[];
}
2. 将您的更改tsconfig为跳过检查null和undefined:
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"module": "commonjs",
"target": "es5",
"lib": ["es2015", "dom"],
"types": ["node", "jest"],
"jsx": "react",
"moduleResolution": "node",
"sourceMap": true,
"allowJs": false,
"strict": true,
"strictNullChecks": false, // this will skip that checking
"declaration": true,
"esModuleInterop": true
},
"exclude": ["src/**/__tests__/**"]
}
添加回答
举报