Add props type for styled-system__should-forward-prop (#43439)

This commit is contained in:
Jason Maurer 2020-04-02 11:30:55 -06:00 committed by GitHub
parent c9a874d204
commit 02a61894ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -1,10 +1,12 @@
// Type definitions for @styled-system/should-forward-prop 5.1
// Project: https://github.com/styled-system/styled-system/tree/master/packages/should-forward-prop
// Definitions by: Tom Picton <https://github.com/tpict>
// Definitions by: Tom Picton <https://github.com/tpict>, Jason Maurer <https://github.com/jsonmaur>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
type genericShouldForwardProp = (prop: string) => boolean;
export const props: string[];
export function createShouldForwardProp(props: string[]): genericShouldForwardProp;
declare const shouldForwardProp: genericShouldForwardProp;
export default shouldForwardProp;

View File

@ -1,10 +1,13 @@
import shouldForwardProp, {
props,
createShouldForwardProp
} from "@styled-system/should-forward-prop";
shouldForwardProp("onClick"); // True
shouldForwardProp("variant"); // False
const customShouldForwardProp = createShouldForwardProp(["magic"]);
const customShouldForwardProp = createShouldForwardProp([...props, "magic"]);
customShouldForwardProp("onClick"); // True
customShouldForwardProp("variant"); // False
customShouldForwardProp("magic"); // True
customShouldForwardProp("you know"); // False