Skip to content

Commit 3d340d0

Browse files
TS Strict SpectrumButton (#3143)
Co-authored-by: Daniel Lu <[email protected]>
1 parent 09ba8cb commit 3d340d0

File tree

5 files changed

+40
-9
lines changed

5 files changed

+40
-9
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"url": "https://github.com/adobe/react-spectrum"
99
},
1010
"scripts": {
11-
"check-types": "tsc",
11+
"check-types": "tsc && tsc-strict",
1212
"install-16": "yarn add -W react@^16.8.0 react-dom@^16.8.0 @testing-library/react@^12 @testing-library/react-hooks@^8",
1313
"install-17": "yarn add -W react@^17 react-dom@^17 @testing-library/react@^12 @testing-library/react-hooks@^8",
1414
"start": "cross-env NODE_ENV=storybook start-storybook -p 9003 --ci -c '.storybook'",
@@ -164,6 +164,7 @@
164164
"style-loader": "^0.23.1",
165165
"tempy": "^0.5.0",
166166
"typescript": "^4.6.0",
167+
"typescript-strict-plugin": "^2.0.0",
167168
"url-loader": "^1.1.2",
168169
"walk-object": "^4.0.0",
169170
"webpack": "^4.44.2",

packages/@react-spectrum/button/stories/Button.stories.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ function Example() {
139139
<Flex gap="size-200">
140140
<Button
141141
variant="cta"
142-
UNSAFE_style={show && {background: 'red', userSelect: 'text'}}
142+
UNSAFE_style={show ? undefined : {background: 'red', userSelect: 'text'}}
143143
onPressStart={() => setTimeout(() => setShow(true), 3000)}>
144144
Press and hold (overwrite)
145145
</Button>
146146
<Button
147147
variant="cta"
148-
UNSAFE_style={show2 && {background: 'red'}}
148+
UNSAFE_style={show2 ? undefined : {background: 'red'}}
149149
onPressStart={() => setTimeout(() => setShow2(true), 3000)}>
150150
Press and hold (no overwrite)
151151
</Button>
@@ -180,15 +180,13 @@ function renderStyles<T extends ElementType = 'button'>(props: SpectrumButtonPro
180180
onPress={action('press')}
181181
onPressStart={action('pressstart')}
182182
onPressEnd={action('pressend')}
183-
variant="primary"
184183
{...props}>
185184
Primary
186185
</Button>
187186
<Button
188187
onPress={action('press')}
189188
onPressStart={action('pressstart')}
190189
onPressEnd={action('pressend')}
191-
variant="primary"
192190
isDisabled
193191
{...props}>
194192
Disabled
@@ -237,7 +235,6 @@ function renderStyles<T extends ElementType = 'button'>(props: SpectrumButtonPro
237235
onPress={action('press')}
238236
onPressStart={action('pressstart')}
239237
onPressEnd={action('pressend')}
240-
variant="primary"
241238
isQuiet
242239
{...props}>
243240
Primary Quiet
@@ -246,7 +243,6 @@ function renderStyles<T extends ElementType = 'button'>(props: SpectrumButtonPro
246243
onPress={action('press')}
247244
onPressStart={action('pressstart')}
248245
onPressEnd={action('pressend')}
249-
variant="primary"
250246
isDisabled
251247
isQuiet
252248
{...props}>

packages/@react-spectrum/utils/src/classNames.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function keepSpectrumClassNames() {
2323
);
2424
}
2525

26-
export function classNames(cssModule: {[key: string]: string}, ...values: Array<string | Object>): string {
26+
export function classNames(cssModule: {[key: string]: string}, ...values: Array<string | Object | undefined>): string {
2727
let classes = [];
2828
for (let value of values) {
2929
if (typeof value === 'object' && value) {

tsconfig.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,16 @@
2727
"dom",
2828
"dom.iterable"
2929
],
30-
"skipLibCheck": false
30+
"skipLibCheck": false,
31+
"strict": false,
32+
"plugins": [
33+
{
34+
"name": "typescript-strict-plugin",
35+
"paths": [
36+
"./packages/@react-spectrum/button/s",
37+
]
38+
}
39+
]
3140
},
3241
"include": [
3342
"packages"

yarn.lock

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16868,6 +16868,21 @@ ora@^5.2.0:
1686816868
strip-ansi "^6.0.0"
1686916869
wcwidth "^1.0.1"
1687016870

16871+
ora@^5.4.1:
16872+
version "5.4.1"
16873+
resolved "https://registry.yarnpkg.com/ora/-/ora-5.4.1.tgz#1b2678426af4ac4a509008e5e4ac9e9959db9e18"
16874+
integrity sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==
16875+
dependencies:
16876+
bl "^4.1.0"
16877+
chalk "^4.1.0"
16878+
cli-cursor "^3.1.0"
16879+
cli-spinners "^2.5.0"
16880+
is-interactive "^1.0.0"
16881+
is-unicode-supported "^0.1.0"
16882+
log-symbols "^4.1.0"
16883+
strip-ansi "^6.0.0"
16884+
wcwidth "^1.0.1"
16885+
1687116886
orchestrator@^0.3.0:
1687216887
version "0.3.8"
1687316888
resolved "https://registry.yarnpkg.com/orchestrator/-/orchestrator-0.3.8.tgz#14e7e9e2764f7315fbac184e506c7aa6df94ad7e"
@@ -21773,6 +21788,16 @@ typedarray@^0.0.6:
2177321788
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
2177421789
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
2177521790

21791+
typescript-strict-plugin@^2.0.0:
21792+
version "2.0.0"
21793+
resolved "https://registry.yarnpkg.com/typescript-strict-plugin/-/typescript-strict-plugin-2.0.0.tgz#67a2e6cba57b51a9925f86429e988d61c9071682"
21794+
integrity sha512-fTolU+9yHTqft5kKjwX++p3TBLhER+bmV8X4/iLxlrVqEA9ZcGXchnTJClLxgEdLwecjvA/Y3YlMnnh51M8eXw==
21795+
dependencies:
21796+
chalk "^3.0.0"
21797+
execa "^4.0.0"
21798+
ora "^5.4.1"
21799+
yargs "^16.2.0"
21800+
2177621801
typescript@^4.6.0:
2177721802
version "4.6.3"
2177821803
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.3.tgz#eefeafa6afdd31d725584c67a0eaba80f6fc6c6c"

0 commit comments

Comments
 (0)