diff --git a/packages/app-bridge-react/package.json b/packages/app-bridge-react/package.json index e4cbb2b..2ac03f4 100644 --- a/packages/app-bridge-react/package.json +++ b/packages/app-bridge-react/package.json @@ -24,7 +24,8 @@ "build": "vite build", "watch": "vite build --watch --mode=development", "test": "vitest run --passWithNoTests", - "type-check": "tsc -p tsconfig.json --noEmit", + "type-check": "tsc -p tsconfig.json --noEmit && pnpm run type-check:tests", + "type-check:tests": "tsc -p tests && tsc -p tests/tsconfig.react19.json", "coverage": "vitest run --passWithNoTests --coverage", "lint": "oxlint -c .eslintrc.json" }, @@ -71,6 +72,7 @@ "@shopify/typescript-configs": "catalog:", "@types/node": "catalog:", "@types/react": "catalog:", + "@types/react-19": "npm:@types/react@19.2.18", "@types/react-dom": "catalog:", "oxlint": "catalog:", "react": "catalog:", diff --git a/packages/app-bridge-react/tests/tsconfig.json b/packages/app-bridge-react/tests/tsconfig.json new file mode 100644 index 0000000..8c6a9a0 --- /dev/null +++ b/packages/app-bridge-react/tests/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "noEmit": true, + "skipLibCheck": false + }, + "include": ["types.test-d.tsx"] +} diff --git a/packages/app-bridge-react/tests/tsconfig.react19.json b/packages/app-bridge-react/tests/tsconfig.react19.json new file mode 100644 index 0000000..a5b363f --- /dev/null +++ b/packages/app-bridge-react/tests/tsconfig.react19.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "baseUrl": "..", + "paths": { + "react": ["node_modules/@types/react-19"], + "react/*": ["node_modules/@types/react-19/*"] + }, + "types": [] + } +} diff --git a/packages/app-bridge-react/tests/types.test-d.tsx b/packages/app-bridge-react/tests/types.test-d.tsx new file mode 100644 index 0000000..52bebde --- /dev/null +++ b/packages/app-bridge-react/tests/types.test-d.tsx @@ -0,0 +1,40 @@ +import {createRef} from 'react'; +import type {} from '@shopify/app-bridge-react'; + +export const elements = ( + <> + ()} + /> + ()} /> + ()} + /> + ()} /> + +); + +// @ts-expect-error Unknown attributes should not be accepted. +export const modalWithUnknownAttribute = ; +// @ts-expect-error Unknown attributes should not be accepted. +export const navMenuWithUnknownAttribute = ; +// @ts-expect-error Unknown attributes should not be accepted. +export const saveBarWithUnknownAttribute = ; +// @ts-expect-error Unknown attributes should not be accepted. +export const titleBarWithUnknownAttribute = ; + +const wrongRef = createRef<{notAnAppBridgeElement: true}>(); + +// @ts-expect-error The ref should point to a UIModalElement. +export const modalWithWrongRef = ; +// @ts-expect-error The ref should point to a UINavMenuElement. +export const navMenuWithWrongRef = ; +// @ts-expect-error The ref should point to a UISaveBarElement. +export const saveBarWithWrongRef = ; +// @ts-expect-error The ref should point to a UITitleBarElement. +export const titleBarWithWrongRef = ; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a61c4b6..703c1a3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -87,6 +87,9 @@ importers: '@types/react': specifier: 'catalog:' version: 18.3.28 + '@types/react-19': + specifier: npm:@types/react@19.2.18 + version: '@types/react@19.2.18' '@types/react-dom': specifier: 'catalog:' version: 18.3.7(@types/react@18.3.28) @@ -1456,6 +1459,9 @@ packages: '@types/react@18.3.28': resolution: {integrity: sha512-z9VXpC7MWrhfWipitjNdgCauoMLRdIILQsAEV+ZesIzBq/oUlxk0m3ApZuMFCXdnS4U7KrI+l3WRUEGQ8K1QKw==} + '@types/react@19.2.18': + resolution: {integrity: sha512-AnzbBERsrLKtk2XSfTbYRLjQPdy116Sty4q+T+Bp3IC4l6jNBvreVPAHmpq9qhXQM7CXZPjLVmGMw9sy+hxQ3w==} + '@typescript-eslint/eslint-plugin@8.56.0': resolution: {integrity: sha512-lRyPDLzNCuae71A3t9NEINBiTn7swyOhvUj3MyUOxb8x6g6vPEFoOU+ZRmGMusNC3X3YMhqMIX7i8ShqhT74Pw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -5009,6 +5015,10 @@ snapshots: '@types/prop-types': 15.7.15 csstype: 3.2.3 + '@types/react@19.2.18': + dependencies: + csstype: 3.2.3 + '@typescript-eslint/eslint-plugin@8.56.0(@typescript-eslint/parser@8.56.0(eslint@9.39.2)(typescript@5.9.3))(eslint@9.39.2)(typescript@5.9.3)': dependencies: '@eslint-community/regexpp': 4.12.2