You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The type T[K] is a lookup type which gets the type of the property of T whose key is K. In (typeof list)[number], you're getting the types of the properties of (typeof list) whose keys are number. Arrays like typeof list have numeric index signatures, so their number key yields the union of all numerically-indexed properties.
export type AppToolbarActionType = (typeof actions)[number];
// We MUST keep setState() as a unified signature because it allows proper checking of the method return type.
// See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18365#issuecomment-351013257
// Also, the ` | S` allows intellisense to not be dumbisense
setState<K extends keyof S>(
state: ((prevState: Readonly<S>, props: Readonly<P>) => (Pick<S, K> | S | null)) | (Pick<S, K> | S | null),
callback?: () => void
): void;
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-1.html#keyof-and-lookup-types
https://stackoverflow.com/a/68399521/195893
The type T[K] is a lookup type which gets the type of the property of T whose key is K. In (typeof list)[number], you're getting the types of the properties of (typeof list) whose keys are number. Arrays like typeof list have numeric index signatures, so their number key yields the union of all numerically-indexed properties.
export type AppToolbarActionType = (typeof actions)[number];
// https://stackoverflow.com/questions/57773734/how-to-use-partially-the-computed-property-name-on-a-type-definition/57774343#57774343
// allow to index elements by string to simplify onChange
type EditLinkDialogState = LinkEditedProperties & Record<string, string | undefined>;
Document
color-mix
usageConfusion about tuple/array declaration syntax
Understand how to use https://react-hook-form.com/ts
Improve
InputHTMLAttributes
usagescomponents libraries
https://react.semantic-ui.com/
https://www.flowbite-react.com/
hooks
https://usehooks.com/
https://github.com/rehooks/awesome-react-hooks
migrate ref usage from component to functional component
Use https://react.dev/reference/react/useImperativeHandle, see InputText
Beta Was this translation helpful? Give feedback.
All reactions