diff --git a/.changeset/eleven-vans-refuse.md b/.changeset/eleven-vans-refuse.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/eleven-vans-refuse.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/package.json b/package.json index 91d39ddfaa7..9c9dc53f688 100644 --- a/package.json +++ b/package.json @@ -140,7 +140,7 @@ "tailwindcss": "^3.3.5", "ts-jest": "^29.1.1", "turbo": "^1.10.16", - "typescript": "^4.9.5", + "typescript": "^5.3.2", "webpack": "^5.89.0" } } diff --git a/packages/components/package.json b/packages/components/package.json index 7f7be257194..8e259e31ebb 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -126,7 +126,7 @@ "serialize-query-params": "^2.0.2", "svgo": "^3.0.4", "ts-jest": "^29.1.1", - "ttypescript": "^1.5.15", + "ts-patch": "^3.0.2", "typescript-transform-paths": "^3.4.6" }, "peerDependencies": { diff --git a/packages/components/rollup.config.mjs b/packages/components/rollup.config.mjs index 0a19d2196dc..1259a966fc8 100644 --- a/packages/components/rollup.config.mjs +++ b/packages/components/rollup.config.mjs @@ -1,3 +1,4 @@ +import { createRequire } from "node:module"; import alias from "@rollup/plugin-alias" import { babel, getBabelOutputPlugin } from "@rollup/plugin-babel"; import commonjs from "@rollup/plugin-commonjs" @@ -9,9 +10,12 @@ import dts from "rollup-plugin-dts" import ignore from "rollup-plugin-ignore" import nodeExternals from "rollup-plugin-node-externals" import postcss from "rollup-plugin-postcss" -import ttypescript from "ttypescript" -const TYPES_TEMP_DIR = "dts" +// ts-patch needs to be in CJS, but rollup uses EMS +// https://github.com/nonara/ts-patch/issues/106 +const require = createRequire(import.meta.url); +const tspCompiler = require("ts-patch/compiler"); + const OUTPUT_DIR = "dist" const getCompiledConfigByModuleType = format => ({ @@ -44,16 +48,8 @@ const getCompiledConfigByModuleType = format => ({ extensions: [".scss", ".css"], }), typescript({ - declaration: true, - declarationDir: `${OUTPUT_DIR}/${format}/${TYPES_TEMP_DIR}`, - exclude: [ - "node_modules", - "**/*.spec.ts", - "**/*.spec.tsx", - "**/*.stories.tsx", - ], - // We use ttypescript instead of typescript to allow transformer to convert alias into actual paths/dependencies - typescript: ttypescript, + tsconfig: `./tsconfig.${format}.json`, + typescript: tspCompiler, }), commonjs(), image(), diff --git a/packages/components/src/Table/_docs/Table.stories.tsx b/packages/components/src/Table/_docs/Table.stories.tsx index 17046c78ee3..09b6f7c0a3a 100644 --- a/packages/components/src/Table/_docs/Table.stories.tsx +++ b/packages/components/src/Table/_docs/Table.stories.tsx @@ -22,7 +22,7 @@ export type TableStoryProps = { container?: TableContainerProps row?: TableRowProps rowCell?: TableRowCellProps - headerRowCell: Omit + headerRowCell: Partial card: TableCardProps } diff --git a/packages/components/tsconfig.cjs.json b/packages/components/tsconfig.cjs.json new file mode 100644 index 00000000000..c64609b87fa --- /dev/null +++ b/packages/components/tsconfig.cjs.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.dist.json", + "compilerOptions": { + "declarationDir": "dist/cjs/dts" + } +} diff --git a/packages/components/tsconfig.dist.json b/packages/components/tsconfig.dist.json new file mode 100644 index 00000000000..21302f44d5f --- /dev/null +++ b/packages/components/tsconfig.dist.json @@ -0,0 +1,21 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "esnext", + "moduleResolution": "node", + "declaration": true, + // Note: To transform paths for both the output .js and .d.ts files, you need both of the below entries + "plugins": [ + // Transform paths in output .js files + { "transform": "typescript-transform-paths" }, + // Transform paths in output .d.ts files (Include this line if you output declarations files) + { "transform": "typescript-transform-paths", "afterDeclarations": true } + ] + }, + "exclude": [ + "node_modules", + "**/*.spec.ts", + "**/*.spec.tsx", + "**/*.stories.tsx" + ] +} diff --git a/packages/components/tsconfig.esm.json b/packages/components/tsconfig.esm.json new file mode 100644 index 00000000000..63d80888df0 --- /dev/null +++ b/packages/components/tsconfig.esm.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.dist.json", + "compilerOptions": { + "declarationDir": "dist/esm/dts" + } +} diff --git a/packages/components/tsconfig.json b/packages/components/tsconfig.json index 93a13d807bb..d62f5d2bbfc 100644 --- a/packages/components/tsconfig.json +++ b/packages/components/tsconfig.json @@ -4,20 +4,12 @@ "baseUrl": ".", "module": "esnext", "moduleResolution": "node", - "declaration": true, "paths": { "~storybook/*": ["../../storybook/*"], "~types/*": ["./src/types/*"], "~utils/*": ["./src/utils/*"], "~components/*": ["./src/*"] - }, - // Note: To transform paths for both the output .js and .d.ts files, you need both of the below entries - "plugins": [ - // Transform paths in output .js files - { "transform": "typescript-transform-paths" }, - // Transform paths in output .d.ts files (Include this line if you output declarations files) - { "transform": "typescript-transform-paths", "afterDeclarations": true } - ] + } }, "files": ["types.d.ts"], "include": ["src/**/*"], diff --git a/renovate.json5 b/renovate.json5 index 4562ab26653..3d57d9ee29c 100644 --- a/renovate.json5 +++ b/renovate.json5 @@ -5,7 +5,6 @@ "ignoreDeps": [ // We can't always stick to latest due to infra and compatibility with other plugins "node", - "typescript", // 0.19.x breaks the import of rollup-plugin-esbuild "esbuild", // the 8.4.19 -> 8.4.21 patch causes typescript issues @@ -13,7 +12,7 @@ ], "packageRules": [ { - // Any peerDep or dep within the publishable packages triggers a + // Any peerDep or dep within the publishable packages triggers a // patch release as a _sensible default_. Merger should use their // discretion to determine whether a major change is more appropriate "matchPaths": ["packages/**", "draft-packages/**"], diff --git a/yarn.lock b/yarn.lock index a4fc91fb5ba..548dac62639 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16058,7 +16058,7 @@ resolve.exports@^2.0.0: resolved "https://registry.yarnpkg.com/resolve.exports/-/resolve.exports-2.0.2.tgz#f8c934b8e6a13f539e38b7098e2e36134f01e800" integrity sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg== -resolve@>=1.9.0, resolve@^1.1.7, resolve@^1.10.0, resolve@^1.14.2, resolve@^1.19.0, resolve@^1.20.0, resolve@^1.22.1, resolve@^1.22.2, resolve@^1.22.4: +resolve@^1.1.7, resolve@^1.10.0, resolve@^1.14.2, resolve@^1.19.0, resolve@^1.20.0, resolve@^1.22.1, resolve@^1.22.2, resolve@^1.22.4: version "1.22.8" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.8.tgz#b6c87a9f2aa06dfab52e3d70ac8cde321fa5a48d" integrity sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw== @@ -17778,6 +17778,18 @@ ts-node@^10.9.1: v8-compile-cache-lib "^3.0.1" yn "3.1.1" +ts-patch@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/ts-patch/-/ts-patch-3.0.2.tgz#cbdf88e4dfb596e4dab8f2c8269361d33270a0ba" + integrity sha512-iTg8euqiNsNM1VDfOsVIsP0bM4kAVXU38n7TGQSkky7YQX/syh6sDPIRkvSS0HjT8ZOr0pq1h+5Le6jdB3hiJQ== + dependencies: + chalk "^4.1.2" + global-prefix "^3.0.0" + minimist "^1.2.8" + resolve "^1.22.2" + semver "^7.3.8" + strip-ansi "^6.0.1" + tsconfig-paths@^3.14.2: version "3.14.2" resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz#6e32f1f79412decd261f92d633a9dc1cfa99f088" @@ -17818,13 +17830,6 @@ tty-table@^4.1.5: wcwidth "^1.0.1" yargs "^17.7.1" -ttypescript@^1.5.15: - version "1.5.15" - resolved "https://registry.yarnpkg.com/ttypescript/-/ttypescript-1.5.15.tgz#e45550ad69289d06d3bc3fd4a3c87e7c1ef3eba7" - integrity sha512-48ykDNHzFnPMnv4hYX1P8Q84TvCZyL1QlFxeuxsuZ48X2+ameBgPenvmCkHJtoOSxpoWTWi8NcgNrRnVDOmfSg== - dependencies: - resolve ">=1.9.0" - turbo-darwin-64@1.10.16: version "1.10.16" resolved "https://registry.yarnpkg.com/turbo-darwin-64/-/turbo-darwin-64-1.10.16.tgz#5a8717c1372f2a75e8cfe0b4b6455119ce410b19" @@ -17995,12 +18000,12 @@ typescript-transform-paths@^3.4.6: dependencies: minimatch "^3.0.4" -typescript@5: +typescript@5, typescript@^5.3.2: version "5.3.2" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.2.tgz#00d1c7c1c46928c5845c1ee8d0cc2791031d4c43" integrity sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ== -typescript@^4.3.5, typescript@^4.9.5: +typescript@^4.3.5: version "4.9.5" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==