diff --git a/package.json b/package.json index cf39d6431..69c33a53b 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "oxlint-tsgolint": "^7.0.2003", "playwright-chromium": "^1.63.0", "simple-git-hooks": "^2.14.0", - "typescript": "^6.0.3", + "typescript": "^7.0.2", "vite": "^8.3.2", "vite-plugin-inspect": "^12.0.2", "vitest": "^5.0.3" diff --git a/packages/common/refresh-utils.ts b/packages/common/refresh-utils.ts index 2102d57a1..db0f76038 100644 --- a/packages/common/refresh-utils.ts +++ b/packages/common/refresh-utils.ts @@ -7,7 +7,7 @@ const reactCompRE = /extends\s+(?:React\.)?(?:Pure)?Component/ const refreshContentRE = /\$RefreshReg\$\(/ // NOTE: this is exposed publicly via plugin-react -export const preambleCode = `import { injectIntoGlobalHook } from "__BASE__${runtimePublicPath.slice( +export const preambleCode: string = `import { injectIntoGlobalHook } from "__BASE__${runtimePublicPath.slice( 1, )}"; injectIntoGlobalHook(window); diff --git a/packages/plugin-react-swc/package.json b/packages/plugin-react-swc/package.json index 5b217a959..492acb492 100644 --- a/packages/plugin-react-swc/package.json +++ b/packages/plugin-react-swc/package.json @@ -40,7 +40,7 @@ "fs-extra": "^11.4.1", "prettier": "^3.0.3", "tsdown": "^0.23.0", - "typescript": "^6.0.3" + "typescript": "^7.0.2" }, "peerDependencies": { "vite": "^4 || ^5 || ^6 || ^7 || ^8" diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index ef18d78ff..dea10d566 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -75,7 +75,7 @@ export interface Options { const defaultIncludeRE = /\.[tj]sx?$/ const defaultExcludeRE = /\/node_modules\// -export default function viteReact(opts: Options = {}): Plugin[] { +function viteReact(opts: Options = {}): Plugin[] { const include = opts.include ?? defaultIncludeRE const exclude = opts.exclude ?? defaultExcludeRE @@ -409,7 +409,10 @@ function createReactCompilerPlugin( } } -viteReact.preambleCode = preambleCode +const viteReactWithPreamble: typeof viteReact & { preambleCode: string } = + Object.assign(viteReact, { preambleCode }) + +export default viteReactWithPreamble export { reactCompilerPreset } export type { ReactCompilerPluginOptions as ReactCompilerOptions } diff --git a/packages/plugin-react/src/reactCompilerPreset.ts b/packages/plugin-react/src/reactCompilerPreset.ts index 7953b532a..9bc0b03dd 100644 --- a/packages/plugin-react/src/reactCompilerPreset.ts +++ b/packages/plugin-react/src/reactCompilerPreset.ts @@ -4,7 +4,8 @@ import type { RolldownBabelPreset, } from '#optionalTypes' -export const defaultCodeFilter = /forwardRef|memo|\b(?:[A-Z]|use[A-Z0-9])/ +export const defaultCodeFilter: RegExp = + /forwardRef|memo|\b(?:[A-Z]|use[A-Z0-9])/ export const reactCompilerPreset = ( options: ReactCompilerBabelPluginOptions = {}, diff --git a/packages/plugin-react/tsconfig.json b/packages/plugin-react/tsconfig.json index 86fa5239c..f29152012 100644 --- a/packages/plugin-react/tsconfig.json +++ b/packages/plugin-react/tsconfig.json @@ -6,6 +6,7 @@ "module": "preserve", "moduleResolution": "bundler", "declaration": true, + "isolatedDeclarations": true, "sourceMap": true, "noEmit": true, "noUnusedLocals": true, diff --git a/packages/plugin-rsc/package.json b/packages/plugin-rsc/package.json index cb0e78ee9..fcb7f7611 100644 --- a/packages/plugin-rsc/package.json +++ b/packages/plugin-rsc/package.json @@ -56,6 +56,7 @@ "@types/node": "^24.19.1", "@types/react": "^19.3.0", "@types/react-dom": "^19.3.0", + "@typescript/typescript6": "^6.0.2", "@vitejs/plugin-react": "workspace:*", "@vitejs/test-dep-cjs-and-esm": "./test-dep/cjs-and-esm", "@vitejs/test-dep-cjs-falsy-primitive": "./test-dep/cjs-falsy-primitive", diff --git a/packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts b/packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts index 2e2b01e0d..3569077e0 100644 --- a/packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts +++ b/packages/plugin-rsc/scripts/import-typescript-eslint-scope-fixtures.ts @@ -1,7 +1,7 @@ import fs from 'node:fs' import path from 'node:path' import { parseArgs as parseNodeArgs } from 'node:util' -import ts from 'typescript' +import ts from '@typescript/typescript6' const scriptDir = path.dirname(new URL(import.meta.url).pathname) const packageDir = path.resolve(scriptDir, '..') diff --git a/playground/compiler-react-18/package.json b/playground/compiler-react-18/package.json index 060722815..b5afc37aa 100644 --- a/playground/compiler-react-18/package.json +++ b/playground/compiler-react-18/package.json @@ -19,6 +19,6 @@ "@types/react-dom": "^18.3.7", "@vitejs/plugin-react": "workspace:*", "babel-plugin-react-compiler": "^1.0.0", - "typescript": "^6.0.3" + "typescript": "^7.0.2" } } diff --git a/playground/compiler/package.json b/playground/compiler/package.json index 5b288a39f..625cf36c4 100644 --- a/playground/compiler/package.json +++ b/playground/compiler/package.json @@ -18,6 +18,6 @@ "@types/react-dom": "^19.3.0", "@vitejs/plugin-react": "workspace:*", "babel-plugin-react-compiler": "19.1.0-rc.3", - "typescript": "^6.0.3" + "typescript": "^7.0.2" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a3a9067b1..ef57e0c97 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,7 +19,7 @@ importers: version: 1.10.0 eslint-plugin-n: specifier: ^18.4.1 - version: 18.4.1(typescript@6.0.3) + version: 18.4.1(typescript@7.0.2) eslint-plugin-regexp: specifier: ^3.3.1 version: 3.3.1 @@ -48,8 +48,8 @@ importers: specifier: ^2.14.0 version: 2.14.0 typescript: - specifier: ^6.0.3 - version: 6.0.3 + specifier: ^7.0.2 + version: 7.0.2 vite: specifier: ^8.3.2 version: 8.3.2(@types/node@24.19.1)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1) @@ -95,7 +95,7 @@ importers: version: 1.2.12 tsdown: specifier: ^0.23.0 - version: 0.23.0(publint@0.3.24)(typescript@6.0.3) + version: 0.23.0(publint@0.3.24)(typescript@7.0.2) vite: specifier: ^8.3.2 version: 8.3.2(@types/node@24.19.1)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1) @@ -129,10 +129,10 @@ importers: version: 3.6.2 tsdown: specifier: ^0.23.0 - version: 0.23.0(publint@0.3.24)(typescript@6.0.3) + version: 0.23.0(publint@0.3.24)(typescript@7.0.2) typescript: - specifier: ^6.0.3 - version: 6.0.3 + specifier: ^7.0.2 + version: 7.0.2 packages/plugin-react-swc/playground/base-path: dependencies: @@ -461,6 +461,9 @@ importers: '@types/react-dom': specifier: ^19.3.0 version: 19.3.0(@types/react@19.3.0) + '@typescript/typescript6': + specifier: ^6.0.2 + version: 6.0.2 '@vitejs/plugin-react': specifier: workspace:* version: link:../plugin-react @@ -487,7 +490,7 @@ importers: version: 1.3.1 tsdown: specifier: ^0.23.0 - version: 0.23.0(publint@0.3.24)(typescript@6.0.3) + version: 0.23.0(publint@0.3.24)(typescript@7.0.2) packages/plugin-rsc/examples/action-reachability: dependencies: @@ -1208,8 +1211,8 @@ importers: specifier: 19.1.0-rc.3 version: 19.1.0-rc.3 typescript: - specifier: ^6.0.3 - version: 6.0.3 + specifier: ^7.0.2 + version: 7.0.2 playground/compiler-react-18: dependencies: @@ -1242,8 +1245,8 @@ importers: specifier: ^1.0.0 version: 1.0.0 typescript: - specifier: ^6.0.3 - version: 6.0.3 + specifier: ^7.0.2 + version: 7.0.2 playground/hmr-false: dependencies: @@ -2960,6 +2963,130 @@ packages: '@types/unist@3.0.2': resolution: {integrity: sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==} + '@typescript/typescript-aix-ppc64@7.0.2': + resolution: {integrity: sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==} + engines: {node: '>=16.20.0'} + cpu: [ppc64] + os: [aix] + + '@typescript/typescript-darwin-arm64@7.0.2': + resolution: {integrity: sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [darwin] + + '@typescript/typescript-darwin-x64@7.0.2': + resolution: {integrity: sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [darwin] + + '@typescript/typescript-freebsd-arm64@7.0.2': + resolution: {integrity: sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [freebsd] + + '@typescript/typescript-freebsd-x64@7.0.2': + resolution: {integrity: sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [freebsd] + + '@typescript/typescript-linux-arm64@7.0.2': + resolution: {integrity: sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [linux] + + '@typescript/typescript-linux-arm@7.0.2': + resolution: {integrity: sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==} + engines: {node: '>=16.20.0'} + cpu: [arm] + os: [linux] + + '@typescript/typescript-linux-loong64@7.0.2': + resolution: {integrity: sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==} + engines: {node: '>=16.20.0'} + cpu: [loong64] + os: [linux] + + '@typescript/typescript-linux-mips64el@7.0.2': + resolution: {integrity: sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==} + engines: {node: '>=16.20.0'} + cpu: [mips64el] + os: [linux] + + '@typescript/typescript-linux-ppc64@7.0.2': + resolution: {integrity: sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==} + engines: {node: '>=16.20.0'} + cpu: [ppc64] + os: [linux] + + '@typescript/typescript-linux-riscv64@7.0.2': + resolution: {integrity: sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==} + engines: {node: '>=16.20.0'} + cpu: [riscv64] + os: [linux] + + '@typescript/typescript-linux-s390x@7.0.2': + resolution: {integrity: sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==} + engines: {node: '>=16.20.0'} + cpu: [s390x] + os: [linux] + + '@typescript/typescript-linux-x64@7.0.2': + resolution: {integrity: sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [linux] + + '@typescript/typescript-netbsd-arm64@7.0.2': + resolution: {integrity: sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [netbsd] + + '@typescript/typescript-netbsd-x64@7.0.2': + resolution: {integrity: sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [netbsd] + + '@typescript/typescript-openbsd-arm64@7.0.2': + resolution: {integrity: sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [openbsd] + + '@typescript/typescript-openbsd-x64@7.0.2': + resolution: {integrity: sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [openbsd] + + '@typescript/typescript-sunos-x64@7.0.2': + resolution: {integrity: sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [sunos] + + '@typescript/typescript-win32-arm64@7.0.2': + resolution: {integrity: sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [win32] + + '@typescript/typescript-win32-x64@7.0.2': + resolution: {integrity: sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [win32] + + '@typescript/typescript6@6.0.2': + resolution: {integrity: sha512-mbCddXd+jm7hfx7w2YU64/Av4/NqqeG3GoRZgxPcgoTxYjhrcfJRw9ULch71SS4G+Q3bOXFhRvPqjguN0Hyp5w==} + hasBin: true + '@ungap/structured-clone@1.2.0': resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} deprecated: Potential CWE-502 - Update to 1.3.1 or higher @@ -4627,6 +4754,11 @@ packages: engines: {node: '>=14.17'} hasBin: true + typescript@7.0.2: + resolution: {integrity: sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==} + engines: {node: '>=16.20.0'} + hasBin: true + ufo@1.6.4: resolution: {integrity: sha512-JFNbkD1Svwe0KvGi8GOeLcP4kAWQ609twvCdcHxq1oSL8svv39ZuSvajcD8B+5D0eL4+s1Is2D/O6KN3qcTeRA==} @@ -6053,6 +6185,70 @@ snapshots: '@types/unist@3.0.2': {} + '@typescript/typescript-aix-ppc64@7.0.2': + optional: true + + '@typescript/typescript-darwin-arm64@7.0.2': + optional: true + + '@typescript/typescript-darwin-x64@7.0.2': + optional: true + + '@typescript/typescript-freebsd-arm64@7.0.2': + optional: true + + '@typescript/typescript-freebsd-x64@7.0.2': + optional: true + + '@typescript/typescript-linux-arm64@7.0.2': + optional: true + + '@typescript/typescript-linux-arm@7.0.2': + optional: true + + '@typescript/typescript-linux-loong64@7.0.2': + optional: true + + '@typescript/typescript-linux-mips64el@7.0.2': + optional: true + + '@typescript/typescript-linux-ppc64@7.0.2': + optional: true + + '@typescript/typescript-linux-riscv64@7.0.2': + optional: true + + '@typescript/typescript-linux-s390x@7.0.2': + optional: true + + '@typescript/typescript-linux-x64@7.0.2': + optional: true + + '@typescript/typescript-netbsd-arm64@7.0.2': + optional: true + + '@typescript/typescript-netbsd-x64@7.0.2': + optional: true + + '@typescript/typescript-openbsd-arm64@7.0.2': + optional: true + + '@typescript/typescript-openbsd-x64@7.0.2': + optional: true + + '@typescript/typescript-sunos-x64@7.0.2': + optional: true + + '@typescript/typescript-win32-arm64@7.0.2': + optional: true + + '@typescript/typescript-win32-x64@7.0.2': + optional: true + + '@typescript/typescript6@6.0.2': + dependencies: + '@typescript/old': typescript@6.0.3 + '@ungap/structured-clone@1.2.0': {} '@vitejs/devtools-kit@0.4.12(cac@7.0.0)(srvx@1.0.5)(vite@8.3.2(@types/node@24.19.1)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))': @@ -6506,7 +6702,7 @@ snapshots: '@eslint-community/regexpp': 4.12.2 eslint-compat-utils: 0.5.1 - eslint-plugin-n@18.4.1(typescript@6.0.3): + eslint-plugin-n@18.4.1(typescript@7.0.2): dependencies: '@eslint-community/eslint-utils': 4.9.1 enhanced-resolve: 5.24.3 @@ -6518,7 +6714,7 @@ snapshots: js-yaml: 5.4.2 semver: 7.8.5 optionalDependencies: - typescript: 6.0.3 + typescript: 7.0.2 eslint-plugin-regexp@3.3.1: dependencies: @@ -7565,7 +7761,7 @@ snapshots: path-parse: 1.0.7 supports-preserve-symlinks-flag: 1.0.0 - rolldown-plugin-dts@0.28.5(rolldown@1.2.12)(typescript@6.0.3): + rolldown-plugin-dts@0.28.5(rolldown@1.2.12)(typescript@7.0.2): dependencies: dts-resolver: 3.0.0 get-tsconfig: 5.0.0-beta.6 @@ -7575,7 +7771,7 @@ snapshots: yuku-codegen: 0.9.5 yuku-parser: 0.9.5 optionalDependencies: - typescript: 6.0.3 + typescript: 7.0.2 transitivePeerDependencies: - oxc-resolver @@ -7751,7 +7947,7 @@ snapshots: trough@2.1.0: {} - tsdown@0.23.0(publint@0.3.24)(typescript@6.0.3): + tsdown@0.23.0(publint@0.3.24)(typescript@7.0.2): dependencies: cac: 7.0.0 defu: 6.1.7 @@ -7761,7 +7957,7 @@ snapshots: obug: 2.1.4 picomatch: 4.0.7 rolldown: 1.2.12 - rolldown-plugin-dts: 0.28.5(rolldown@1.2.12)(typescript@6.0.3) + rolldown-plugin-dts: 0.28.5(rolldown@1.2.12)(typescript@7.0.2) tinyexec: 1.3.1 tinyglobby: 0.2.17 tree-kill: 1.2.2 @@ -7769,7 +7965,7 @@ snapshots: verkit: 0.4.0 optionalDependencies: publint: 0.3.24 - typescript: 6.0.3 + typescript: 7.0.2 transitivePeerDependencies: - '@typescript/native-preview' - '@volar/typescript' @@ -7783,6 +7979,29 @@ snapshots: typescript@6.0.3: {} + typescript@7.0.2: + optionalDependencies: + '@typescript/typescript-aix-ppc64': 7.0.2 + '@typescript/typescript-darwin-arm64': 7.0.2 + '@typescript/typescript-darwin-x64': 7.0.2 + '@typescript/typescript-freebsd-arm64': 7.0.2 + '@typescript/typescript-freebsd-x64': 7.0.2 + '@typescript/typescript-linux-arm': 7.0.2 + '@typescript/typescript-linux-arm64': 7.0.2 + '@typescript/typescript-linux-loong64': 7.0.2 + '@typescript/typescript-linux-mips64el': 7.0.2 + '@typescript/typescript-linux-ppc64': 7.0.2 + '@typescript/typescript-linux-riscv64': 7.0.2 + '@typescript/typescript-linux-s390x': 7.0.2 + '@typescript/typescript-linux-x64': 7.0.2 + '@typescript/typescript-netbsd-arm64': 7.0.2 + '@typescript/typescript-netbsd-x64': 7.0.2 + '@typescript/typescript-openbsd-arm64': 7.0.2 + '@typescript/typescript-openbsd-x64': 7.0.2 + '@typescript/typescript-sunos-x64': 7.0.2 + '@typescript/typescript-win32-arm64': 7.0.2 + '@typescript/typescript-win32-x64': 7.0.2 + ufo@1.6.4: {} unconfig-core@7.5.0: