Skip to content

Commit 7229827

Browse files
committed
fix(component): fixes rest props typing for css function usage
1 parent e0ab2ed commit 7229827

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

config/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"preserveConstEnums": true,
1111
"removeComments": true,
1212
"sourceMap": true,
13+
"strictNullChecks": false,
1314
"types": ["jest", "react", "react-dom", "webpack-env"],
1415
"typeRoots": ["node_modules/@types"]
1516
},

src/matchers.tsx

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@
22

33
import { css } from "styled-components";
44

5-
export const is = (prop: string) => (...args: [any]) => (props: object) =>
6-
props[prop] ? css(...args) : "";
7-
8-
export const isnt = (prop: string) => (...args: [any]) => (props: object) =>
9-
!props[prop] ? css(...args) : "";
10-
11-
export const isAny = (prop: string, matches: any[]) => (...args: [any]) => (
5+
export const is = (prop: string) => (str: any, ...args: any[]) => (
126
props: object
13-
) => (matches.includes(props[prop]) ? css(...args) : "");
7+
) => (props[prop] ? css(str, ...args) : "");
148

15-
export const isntAny = (prop: string, matches: any[]) => (...args: [any]) => (
9+
export const isnt = (prop: string) => (str: any, ...args: any[]) => (
1610
props: object
17-
) => (!matches.includes(props[prop]) ? css(...args) : "");
11+
) => (!props[prop] ? css(str, ...args) : "");
12+
13+
export const isAny = (prop: string, matches: any[]) => (
14+
str: any,
15+
...args: any[]
16+
) => (props: object) =>
17+
matches.includes(props[prop]) ? css(str, ...args) : "";
18+
19+
export const isntAny = (prop: string, matches: any[]) => (
20+
str: any,
21+
...args: any[]
22+
) => (props: object) =>
23+
!matches.includes(props[prop]) ? css(str, ...args) : "";
1824

1925
export const value = (prop: string) => (props: object) => props[prop];
2026

@@ -24,10 +30,12 @@ export const swap = (prop: string, yup: any, nope: any) => (props: object) =>
2430
export const choose = (prop: string, map: object) => (props: object) =>
2531
map[props[prop]];
2632

27-
export const over = (prop: string, amount: number) => (...args: [any]) => (
28-
props: object
29-
) => (props[prop] > amount ? css(...args) : "");
33+
export const over = (prop: string, amount: number) => (
34+
str: any,
35+
...args: any[]
36+
) => (props: object) => (props[prop] > amount ? css(str, ...args) : "");
3037

31-
export const under = (prop: string, amount: number) => (...args: [any]) => (
32-
props: object
33-
) => (props[prop] < amount ? css(...args) : "");
38+
export const under = (prop: string, amount: number) => (
39+
str: any,
40+
...args: any[]
41+
) => (props: object) => (props[prop] < amount ? css(str, ...args) : "");

0 commit comments

Comments
 (0)