Types我目前收到关于or内的函数参数的 eslint 警告Interfaces。
执行以下操作:
type Test = {
fn: (param: string) => void
}
Run Code Online (Sandbox Code Playgroud)
结果出现以下警告:
'param' is defined but never used. Allowed unused args must match /^_/u.
Run Code Online (Sandbox Code Playgroud)
这是我的.eslintrc.json样子:
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json"
},
"env": {
"node": true
},
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"rules": {
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off"
}
}
Run Code Online (Sandbox Code Playgroud)
封装版本:
"eslint": "^7.23.0"
"@typescript-eslint/eslint-plugin": "^4.22.1"
"@typescript-eslint/parser": "^4.22.1"
Run Code Online (Sandbox Code Playgroud)
类似的问题已经在这里和这里被问过,但提供的答案似乎并不适合我。
对于可能发生的情况有什么建议吗?
随着graphql瑜伽,你可以简单地通过执行以下导入架构:typeDefs: './src/schema.graphql'。apollo-server-express 是否有类似的方法?
如果没有,如何从外部.graphql文件导入 typeDefs ?
我的自定义输入组件收到以下警告:
'TextInput' refers to a value, but is being used as a type here. Did you mean 'typeof TextInput'?
useRef当引用它时,像这样使用:
const lastNameRef = useRef<TextInput>(null)
看起来像这样TextInput:
import React, { forwardRef } from "react"
import {
TextInput as ReactTextInput,
TextInputProps as ReactTextInputProps,
} from "react-native"
import styled from "styled-components/native"
import {
compose,
space,
SpaceProps,
color,
ColorProps,
layout,
LayoutProps,
flexbox,
FlexboxProps,
border,
BorderProps,
position,
PositionProps,
background,
BackgroundProps,
typography,
TypographyProps,
} from "styled-system"
export type TextInputProps = ReactTextInputProps &
SpaceProps & …Run Code Online (Sandbox Code Playgroud) 我有一些对象数组,如下所示:
const data = [
{ date: "04-08-2021", name: "bojes" },
{ date: "03-08-2021", name: "yolla" },
{ date: "02-08-2021", name: "rafika" },
{ date: "01-08-2021", name: "adit" },
{ date: "26-07-2021", name: "qor" },
{ date: "10-05-2021", name: "pandu" },
]
Run Code Online (Sandbox Code Playgroud)
当前日期之前 7 天的数组如下所示:
const dataCurretToLastWeek = [
"29-07-2021",
"30-07-2021",
"01-08-2021",
"02-08-2021",
"03-08-2021",
"04-08-2021",
"05-08-2021",
]
Run Code Online (Sandbox Code Playgroud)
并想把它改造成这样的东西:
const newData = [
{ date: "04-08-2021", name: "bojes" },
{ date: "03-08-2021", name: "yolla" },
{ date: "02-08-2021", name: "rafika" }, …Run Code Online (Sandbox Code Playgroud) typescript ×2
apollo ×1
arrays ×1
eslint ×1
graphql ×1
javascript ×1
object ×1
react-native ×1
sorting ×1