我收到这个错误 Property 'find' does not exist on type 'string'.
我运行脚本的方式和详细错误:
$ npm run build-next
> [email protected] build-next /Users/.../admin-ui
> next build
Creating an optimized production build ...
Found experimental config:
Experimental features can change at anytime and aren't officially supported (use at your own risk).
> Using external babel configuration
> Location: "/Users/.../admin-ui/.babelrc"
Failed to compile.
/Users/.../admin-ui/pages/app/signup.tsx
ERROR in /Users/.../admin-ui/pages/app/signup.tsx
76:69 Property 'find' does not exist on type 'string'.
74 | ]);
75 |
> 76 | const forbiddenIndustryIds = industryOptions.filter(o => o.name.find('blah') !== -1).map(o => o.id.toString());
| ^
77 |
78 | const sortedIndustryOptions = industryOptions.map(item => {
79 | const result: SelectOption = {
> Build error occurred
Error: > Build failed because of webpack errors
at build (/Users/.../admin-ui/node_modules/next/dist/build/index.js:6:847)
我的tsconfig.json
文件:
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"jsx": "preserve",
"lib": [
"dom",
"esnext"
],
"module": "esnext",
"moduleResolution": "node",
"noEmit": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"preserveConstEnums": true,
"removeComments": false,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "esnext",
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"isolatedModules": true
},
"exclude": [
"node_modules"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
}
package.json
脚本部分:
"scripts": {
"dev": "node server.js",
"build-server": "tsc --esModuleInterop server.ts",
"build-next": "next build",
"start": "NODE_ENV=production node server.js"
}
编译器:+Infinity,我:0
find
字符串上确实不存在!indexOf
是我一直在寻找的。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句