TypeScript 中的“字符串”类型不存在属性“查找”

喜悦

我收到这个错误 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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Node.js TypeScript:“字符串|类型”中不存在属性“电子邮件” 目的'

TypeScript中的类型不存在属性

TypeScript 4-类型编号不存在属性查找[]

类声明-TypeScript中的类型不存在属性

TypeScript中的EventTarget类型不存在属性“值”

Typescript中的类型“ Date”上不存在属性“ getWeek”

ReactJS 中的 Typescript 错误 - 类型上不存在属性

TypeScript中的“ EventTarget”类型错误不存在属性“文件”

Typescript中的XXX类型不存在属性'forEach'

TypeScript类型不存在属性“ load”?

Typescript:组合类型不存在属性?

枚举类型不存在Typescript属性

如何告诉 TypeScript 我正在处理使用字符串访问对象上不存在的属性的情况?

TypeScript - 类型上不存在属性(但它存在)?

TypeScript:禁止联合类型的“类型上不存在属性”

在Typescript Reac + Redux中具有联合类型的类型错误时属性不存在

在声明对象后添加属性时,在 TypeScript 中获取“类型上不存在属性‘FOO’”

TypeScript + Express:类型“ IncomingMessage”上不存在属性“ rawBody”

与 TypeScript 反应 - 类型“EventTarget”上不存在属性“value”

类型'FileList'上不存在TypeScript属性'forEach'

类型'ChildNode [Typescript]上不存在属性'tagName'

TypeScript Joi:类型“ Root”上不存在属性“ validate”

Typescript 属性在类型元素上不存在

TypeScript错误:类型“ Navigator”上不存在属性“ app”

TypeScript:类型上不存在属性“范围”

Typescript属性“ length”在类型上不存在

属性“名称”在类型“ EventTarget”上不存在-React + TypeScript

Typescript 的“对象”错误类型上不存在属性

使用TypeScript时获取类型的属性不存在错误