From 39d9a02c8718a439085e40e6fe8eca1bf5274377 Mon Sep 17 00:00:00 2001 From: Michael Dougall <6801309+itsdouges@users.noreply.github.com> Date: Mon, 11 Mar 2024 10:32:21 +1100 Subject: [PATCH] Remove required pseudo from XCSS prop (#1643) * chore: remove required pseudos * chore: changeset * chore: fix test --- .changeset/orange-coins-whisper.md | 5 +++ .../__tests__/index.test.tsx | 16 +++------ packages/react/src/create-strict-api/index.ts | 3 +- .../xcss-prop/__tests__/xcss-prop.test.tsx | 35 ++----------------- packages/react/src/xcss-prop/index.ts | 9 ++--- 5 files changed, 14 insertions(+), 54 deletions(-) create mode 100644 .changeset/orange-coins-whisper.md diff --git a/.changeset/orange-coins-whisper.md b/.changeset/orange-coins-whisper.md new file mode 100644 index 000000000..b3d0dcfc1 --- /dev/null +++ b/.changeset/orange-coins-whisper.md @@ -0,0 +1,5 @@ +--- +'@compiled/react': minor +--- + +The `requiredPseudos` type property in XCSS prop has been removed. diff --git a/packages/react/src/create-strict-api/__tests__/index.test.tsx b/packages/react/src/create-strict-api/__tests__/index.test.tsx index cf2db2093..891220916 100644 --- a/packages/react/src/create-strict-api/__tests__/index.test.tsx +++ b/packages/react/src/create-strict-api/__tests__/index.test.tsx @@ -658,11 +658,7 @@ describe('createStrictAPI()', () => { }: { testId: string; xcss: ReturnType< - typeof XCSSProp< - 'background' | 'color', - never, - { requiredProperties: 'background'; requiredPseudos: never } - > + typeof XCSSProp<'background' | 'color', never, { requiredProperties: 'background' }> >; }) { return ; @@ -697,11 +693,7 @@ describe('createStrictAPI()', () => { }: { testId: string; xcss: ReturnType< - typeof XCSSProp< - 'color', - '&:hover' | '&:focus', - { requiredProperties: never; requiredPseudos: '&:hover' } - > + typeof XCSSProp<'color', '&:hover' | '&:focus', { requiredProperties: never }> >; }) { return ; @@ -711,7 +703,7 @@ describe('createStrictAPI()', () => { primary: { '&:hover': { color: 'var(--ds-text-hover)' } }, }); const stylesInvalid = cssMap({ - primary: { '&:focus': { color: 'var(--ds-text)' } }, + primary: { '&:focus': { background: 'var(--ds-surface)' } }, }); const { getByTestId } = render( @@ -728,7 +720,7 @@ describe('createStrictAPI()', () => { expect(getByTestId('button-valid')).toHaveCompiledCss('color', 'var(--ds-text-hover)', { target: ':hover', }); - expect(getByTestId('button-invalid')).toHaveCompiledCss('color', 'var(--ds-text)', { + expect(getByTestId('button-invalid')).toHaveCompiledCss('background', 'var(--ds-surface)', { target: ':focus', }); }); diff --git a/packages/react/src/create-strict-api/index.ts b/packages/react/src/create-strict-api/index.ts index 0d4c194d6..3e0a1f1e3 100644 --- a/packages/react/src/create-strict-api/index.ts +++ b/packages/react/src/create-strict-api/index.ts @@ -114,7 +114,7 @@ export interface CompiledAPI< * typeof XCSSProp< * XCSSAllProperties, * '&:hover', - * { requiredProperties: 'color', requiredPseudos: never } + * { requiredProperties: 'color' } * > * >; * } @@ -142,7 +142,6 @@ export interface CompiledAPI< TAllowedPseudos extends CSSPseudos, TRequiredProperties extends { requiredProperties: TAllowedProperties; - requiredPseudos: TAllowedPseudos; } = never >(): Internal$XCSSProp< TAllowedProperties, diff --git a/packages/react/src/xcss-prop/__tests__/xcss-prop.test.tsx b/packages/react/src/xcss-prop/__tests__/xcss-prop.test.tsx index 232a16cab..337348c79 100644 --- a/packages/react/src/xcss-prop/__tests__/xcss-prop.test.tsx +++ b/packages/react/src/xcss-prop/__tests__/xcss-prop.test.tsx @@ -228,11 +228,7 @@ describe('xcss prop', () => { function CSSPropComponent({ xcss, }: { - xcss: XCSSProp< - 'color' | 'backgroundColor', - '&:hover', - { requiredProperties: 'color'; requiredPseudos: never } - >; + xcss: XCSSProp<'color' | 'backgroundColor', '&:hover', { requiredProperties: 'color' }>; }) { return