diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f1487a13..9a66bfc1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,6 +45,8 @@ yarn typescript yarn lint ``` +The `yarn typescript` command runs both standard TypeScript type checking and React 19 JSX compatibility tests to ensure your changes work with React 19. You can also run `yarn types:react19` separately to check React 19 compatibility specifically. + To fix formatting and linting errors, run the following: ```sh @@ -93,7 +95,8 @@ yarn release The `package.json` file contains various scripts for common tasks: - `yarn bootstrap`: setup project by installing all dependencies and pods. -- `yarn typescript`: type-check files with TypeScript. +- `yarn typescript`: type-check files with TypeScript, including React 19 JSX compatibility. +- `yarn types:react19`: run React 19 JSX compatibility type checking specifically. - `yarn lint`: check files with Biome. - `yarn lint:fix`: fix formatting and linting issues with Biome. - `yarn test`: run unit tests with Jest. diff --git a/package.json b/package.json index de329e71..e2b9be22 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,8 @@ "test:watch": "jest --watch", "test:coverage": "jest --coverage", "test:ci": "jest --coverage --ci --runInBand --reporters=default --reporters=jest-junit", - "types": "tsc --noEmit", + "types": "tsc --noEmit && yarn types:react19", + "types:react19": "tsc --noEmit -p test/types/react19-jsx/tsconfig.json", "lint": "biome check .", "lint:fix": "biome check --write .", "format": "biome format .", diff --git a/src/components/Carousel.tsx b/src/components/Carousel.tsx index be766048..6a6bf017 100644 --- a/src/components/Carousel.tsx +++ b/src/components/Carousel.tsx @@ -19,10 +19,6 @@ const Carousel = React.forwardRef>((_prop ); }); -type CarouselComponent = ( - props: React.PropsWithChildren> & { - ref?: React.Ref; - } -) => React.ReactElement; +type CarouselComponent = (props: React.PropsWithChildren>) => React.ReactNode; export default Carousel as CarouselComponent; diff --git a/test/types/react19-jsx/CarouselReact19.tsx b/test/types/react19-jsx/CarouselReact19.tsx new file mode 100644 index 00000000..9cdc9066 --- /dev/null +++ b/test/types/react19-jsx/CarouselReact19.tsx @@ -0,0 +1,19 @@ +import * as React from "react"; +import Carousel from "../../../src"; + +const carouselElement = ( + <>} /> +); + +type IsExact = (() => T extends A ? 1 : 2) extends () => T extends B ? 1 : 2 + ? (() => T extends B ? 1 : 2) extends () => T extends A ? 1 : 2 + ? true + : false + : false; + +type Assert = T; +type CarouselReturn = ReturnType>; +const assertCarouselReturnType: Assert> = true; + +void carouselElement; +void assertCarouselReturnType; diff --git a/test/types/react19-jsx/tsconfig.json b/test/types/react19-jsx/tsconfig.json new file mode 100644 index 00000000..3d2722d1 --- /dev/null +++ b/test/types/react19-jsx/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "strict": true, + "jsx": "react-jsx", + "module": "esnext", + "moduleResolution": "node", + "target": "esnext", + "esModuleInterop": true, + "skipLibCheck": true, + "lib": ["esnext"] + }, + "include": ["./CarouselReact19.tsx"] +} diff --git a/tsconfig.json b/tsconfig.json index 39ccc57f..7400c02d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,5 +21,5 @@ "target": "esnext", "types": ["jest"] }, - "exclude": ["example", "node_modules", "**/*.test.ts", "**/*.test.tsx"] + "exclude": ["example", "node_modules", "test/types", "**/*.test.ts", "**/*.test.tsx"] }