From 1617633c9997132cf71d891502b7636f0e344dd3 Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Mon, 14 Mar 2022 15:03:41 -0700 Subject: [PATCH 01/13] Add type check npm script --- package.json | 1 + tsconfig.build.json | 1 + tsconfig.json | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index a01da6a3276..6e9f3d5e1a2 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "lint:fix": "npm run lint -- --fix", "test": "jest", "test:update": "npm run test -- --updateSnapshot", + "test:type-check": "tsc --noEmit", "release": "npm run build && changeset publish", "size": "size-limit", "prepare": "husky install" diff --git a/tsconfig.build.json b/tsconfig.build.json index 561345472aa..953b62a979e 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,5 +1,6 @@ { "extends": "./tsconfig.json", + "emitDeclarationOnly": true, // NOTE: We exclude Storybook stories and test utilities which import // Storybook and its dependencies, because: // a) we don't want Storybook types in our build output, and diff --git a/tsconfig.json b/tsconfig.json index f5e13b8ceb5..7bb26edce02 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,6 @@ "jsx": "preserve", "declaration": true, "outDir": "./lib", - "emitDeclarationOnly": true, "strict": true, "moduleResolution": "node", "rootDirs": ["src"], From 5353d0cb4d5c9dad5bf362469c494fa2f74adb6a Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Mon, 14 Mar 2022 15:05:17 -0700 Subject: [PATCH 02/13] Add type checking to CI --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4c4f1d4cc64..ad5fc2c5e0f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,3 +29,6 @@ jobs: - name: Test run: npm run test + + - name: Type check + run: npm run test:type-check From 569c4327e616cdf3dfc782756ebfe2d09addbb1f Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Mon, 14 Mar 2022 17:27:49 -0700 Subject: [PATCH 03/13] Make value prop of Checkbox optional --- src/Checkbox.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Checkbox.tsx b/src/Checkbox.tsx index d7aeb16090a..bbad54491ca 100644 --- a/src/Checkbox.tsx +++ b/src/Checkbox.tsx @@ -30,7 +30,7 @@ export type CheckboxProps = { * A unique value that is never shown to the user. * Used during form submission and to identify which checkbox inputs are selected */ - value: string + value?: string } & Exclude, 'value'> & SxProp From ec94d9836bc915cf4fa8981f01e857bf82ed973b Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Mon, 14 Mar 2022 17:29:42 -0700 Subject: [PATCH 04/13] Export Select props type --- src/Select.tsx | 6 +++--- src/index.ts | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Select.tsx b/src/Select.tsx index ac9cfeeaf02..25708efa576 100644 --- a/src/Select.tsx +++ b/src/Select.tsx @@ -3,8 +3,8 @@ import styled from 'styled-components' import {get} from './constants' import TextInputWrapper, {StyledWrapperProps} from './_TextInputWrapper' -type SelectProps = Omit< - Omit, 'size'> & Omit, +export type SelectProps = Omit< + Omit, 'size'> & Omit, 'multiple' | 'hasLeadingVisual' | 'hasTrailingVisual' | 'as' > @@ -42,7 +42,7 @@ const ArrowIndicator = styled(ArrowIndicatorSVG)` ` const Select = React.forwardRef( - ({children, disabled, placeholder, size, required, validationStatus, ref: _propsRef, ...rest}: SelectProps, ref) => ( + ({children, disabled, placeholder, size, required, validationStatus, ...rest}: SelectProps, ref) => ( Date: Mon, 14 Mar 2022 17:30:01 -0700 Subject: [PATCH 05/13] Update LabelGroup test --- src/__tests__/LabelGroup.test.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/__tests__/LabelGroup.test.tsx b/src/__tests__/LabelGroup.test.tsx index df1636dfee1..3c666e86096 100644 --- a/src/__tests__/LabelGroup.test.tsx +++ b/src/__tests__/LabelGroup.test.tsx @@ -10,7 +10,6 @@ const comp = ( - ) From cd844e851b0d7186e435cdcf698af8cff57c3048 Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Mon, 14 Mar 2022 17:30:13 -0700 Subject: [PATCH 06/13] Update import in deprecated Label type test --- src/__tests__/deprecated/Label.types.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/__tests__/deprecated/Label.types.test.tsx b/src/__tests__/deprecated/Label.types.test.tsx index dcfa2638521..a88a34a76ef 100644 --- a/src/__tests__/deprecated/Label.types.test.tsx +++ b/src/__tests__/deprecated/Label.types.test.tsx @@ -1,5 +1,5 @@ import React from 'react' -import Label from '../deprecated/Label' +import Label from '../../deprecated/Label' export function shouldAcceptCallWithNoProps() { return