Skip to content

Commit

Permalink
Release 1/31 3.0.1 Hotfix (#1564)
Browse files Browse the repository at this point in the history
* Publish

 - @cmsgov/[email protected]
 - @cmsgov/[email protected]
 - @cmsgov/[email protected]
 - @cmsgov/[email protected]
 - @cmsgov/[email protected]

* [NO-TICKET] Remove a missed withTranslation instance (#1515)

* Remove a missed withTranslation instance

We don't use the HOC anymore

* Update tests and snapshots

* Actually, the previous snapshots were more informative

* [WNMGDS-1344][WNMGDS-1345] Fix Button types (#1532)

* Working on fixing the Button prop types

When coming across instances of `<Button>` in downstream apps, TypeScript wasn't able to determine which type of the intersection type `type ButtonProps = CommonButtonProps<ButtonComponent> | LinkButtonProps | ButtonButtonProps` was at play, so it would complain that props like `href` and `target` did not exist on `CommonButtonProps<ButtonComponent>` when it should have been using `LinkButtonProps`. The fix is to make the `Button` component itself a generic type, showing TypeScript which part of it is variable and it has to narrow down. This, I think, is also a little clearer and easier to follow than the big intersection type. It's either a regular html element or it's a `CustomButtonComponentType` (a React component), and the intrinsic HTML props are applied conditionally.

There are a couple more places where I have to update references to ButtonProps in our code

* Update the DrawerToggle module, but it still throws errors

* Converted Button to FC but will revert

I thought the generated type definition would drop the `: JSXElement` from the render function, but it didn't. The problem I'm now getting in downstream apps is that they can use any value they want for attributes like `size`, which we define on Button as having a specific set of allowable values

* Define the Link props for testing the type checking

* Remove default prop values to simplify discriminating types

* Fix button tests and update HelpDrawerToggle

* Try omitting href from intrinsic props - doesn't work

* Don't use auto Merge utility type - that worked?!

I suspect it could have to do with the 'ref' value actually...

* Fix errors in DrawerToggle tests

* Clean up and simplify

* Figured out how to narrow the `OtherTypeButtonProps`

The significance of this is that sometimes instances of Button even though they should be identified as having `LinkTypeButtonProps` (where `href` is strictly required)—like when explicitly passing `component='a'`—TypeScript seemed to be thinking it was the more generic `OtherTypeButtonProps<T>`. I _think_ this is working now.

Error that flags a missing `href` prop if the component has an explicit `component='a'` prop:
```
packages/design-system/src/components/Button/Button.test.tsx:36:8 - error TS2322: Type '{ component: "a"; target: "_blank"; type: string; children: string; }' is not assignable to type 'IntrinsicAttributes & ButtonProps<"a">'.
  Property 'href' is missing in type '{ component: "a"; target: "_blank"; type: string; children: string; }' but required in type 'LinkTypeButtonProps'.

36       <Button
          ~~~~~~

  packages/design-system/src/components/Button/Button.tsx:56:3
    56   href: string;
         ~~~~
    'href' is declared here.``
```

Note that it is correctly identifying this as a `LinkTypeButtonProps`.

Before this change, no error was thrown for a missing `href`, but in a similar situation where we explicitly pass a `component='a'` prop but give an _invalid_ value for `href`, we'd get the following error which illustrates TypeScript's incorrect inference about the type of the component props:
```
packages/design-system/src/components/Button/Button.test.tsx:36:8 - error TS2322: Type '{ component: "a"; href: { hello: string; }; target: "_blank"; type: string; children: string; }' is not assignable to type 'IntrinsicAttributes & ButtonProps<"a">'.
  Type '{ component: "a"; href: { hello: string; }; target: "_blank"; type: string; children: string; }' is not assignable to type 'OtherTypeButtonProps<"a">'.
    Types of property 'href' are incompatible.
      Type '{ hello: string; }' is not assignable to type 'null'.

36       <Button
          ~~~~~~
```
Note that it thinks our button has `OtherTypeButtonProps<"a">` props. We don't want that more generic type to be used when the more specific `LinkTypeButtonProps` should be used!!

* Fix other bug about "secondary" not being valid variant in hc.gov

* Match the button attribute behavior of before except without default "type"

Buttons don't need the default "button" type anyway

* Simplify Button types (#1538)

* Simplify types, trading accuracy for simplicity

These types are more permissive than before but contain no intersections or conditional types

* May need to keep CommonButtonProps generic in order to infer T

* Remove redundant type

* Add the `type` default back in

Need to do it the functional-component way, and also need to move the destructuring assignment into the function's call signature in order for the prop-table generator to pick up on that default value

* Update snapshots after adding the default `type` back in

* Fix problems Sarah identified

* [WNMGDS-1344][WNMGDS-1345] Revert button types (#1545)

* Revert back to the simplest types without support for custom component

* HTMLAttributes didn't actually contain all attributes of anchors like `target`

* [NO-TICKET] Deprecate Button's "component" prop (#1546)

* Add deprecation docs and warning for Button's `component` prop

* Update unit tests and story

* Publish

 - @cmsgov/[email protected]
 - @cmsgov/[email protected]
 - @cmsgov/[email protected]
 - @cmsgov/[email protected]
 - @cmsgov/[email protected]

* updating inputRef typing on Button component (#1553)

* Publish

 - @cmsgov/[email protected]
 - @cmsgov/[email protected]
 - @cmsgov/[email protected]
 - @cmsgov/[email protected]
 - @cmsgov/[email protected]

* merging deletion of svg icons commit 68a62c8

* Publish

 - @cmsgov/[email protected]
 - @cmsgov/[email protected]
 - @cmsgov/[email protected]
 - @cmsgov/[email protected]
 - @cmsgov/[email protected]

* Publish

 - @cmsgov/[email protected]
 - @cmsgov/[email protected]
 - @cmsgov/[email protected]
 - @cmsgov/[email protected]
 - @cmsgov/[email protected]

* Make the StepList props with default values optional

* Publish

 - @cmsgov/[email protected]
 - @cmsgov/[email protected]
 - @cmsgov/[email protected]
 - @cmsgov/[email protected]

Co-authored-by: Anna Kammeyer <[email protected]>
Co-authored-by: Patrick Wolfert <[email protected]>
Co-authored-by: Anna Scheuler Kammeyer <[email protected]>
  • Loading branch information
4 people authored Jan 31, 2022
1 parent 4ef0890 commit 8cafc13
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/design-system-docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cmsgov/design-system-docs",
"version": "3.0.0",
"version": "3.0.1",
"publishConfig": {
"access": "public",
"tag": "latest"
Expand All @@ -13,7 +13,7 @@
},
"license": "SEE LICENSE IN LICENSE.md",
"dependencies": {
"@cmsgov/design-system": "^3.0.0",
"@cmsgov/design-system": "^3.0.1",
"classnames": "^2.2.5",
"lodash": "^4.17.19",
"prismjs": "^1.11.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/design-system/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cmsgov/design-system",
"version": "3.0.0",
"version": "3.0.1",
"publishConfig": {
"access": "public",
"tag": "latest"
Expand Down
6 changes: 3 additions & 3 deletions packages/ds-healthcare-gov/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cmsgov/ds-healthcare-gov",
"version": "7.0.0",
"version": "7.0.1",
"publishConfig": {
"tag": "latest",
"access": "public"
Expand All @@ -20,7 +20,7 @@
"src"
],
"dependencies": {
"@cmsgov/design-system": "^3.0.0",
"@cmsgov/design-system": "^3.0.1",
"@types/js-cookie": "^2.2.7",
"@types/react": "^17.0.10",
"@types/react-dom": "^17.0.10",
Expand All @@ -34,7 +34,7 @@
"@babel/plugin-proposal-class-properties": "^7.10.1",
"@babel/plugin-transform-object-assign": "^7.10.4",
"@babel/preset-typescript": "^7.15.0",
"@cmsgov/design-system-docs": "^3.0.0",
"@cmsgov/design-system-docs": "^3.0.1",
"@cmsgov/design-system-scripts": "^3.0.0",
"@cmsgov/eslint-config-design-system": "2.0.0",
"@cmsgov/stylelint-config-design-system": "2.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/ds-medicare-gov/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cmsgov/ds-medicare-gov",
"version": "5.0.0",
"version": "5.0.1",
"publishConfig": {
"tag": "latest",
"access": "public"
Expand All @@ -25,15 +25,15 @@
"src"
],
"dependencies": {
"@cmsgov/design-system": "^3.0.0",
"@cmsgov/design-system": "^3.0.1",
"@types/react": "^17.0.10",
"@types/react-dom": "^17.0.10"
},
"devDependencies": {
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-proposal-object-rest-spread": "^7.9.0",
"@babel/preset-typescript": "^7.8.3",
"@cmsgov/design-system-docs": "^3.0.0",
"@cmsgov/design-system-docs": "^3.0.1",
"@cmsgov/design-system-scripts": "^3.0.0",
"@cmsgov/eslint-config-design-system": "2.0.0",
"@cmsgov/stylelint-config-design-system": "2.0.0",
Expand Down

0 comments on commit 8cafc13

Please sign in to comment.