From a8f6da78eb5a833d7d2a7ac5f0ed44a32011641c Mon Sep 17 00:00:00 2001 From: Jan Hassel Date: Mon, 21 Oct 2024 14:32:37 +0200 Subject: [PATCH] feat(utilities): add typescript declarations to dist (#17797) --- packages/utilities-react/.gitignore | 1 + packages/utilities-react/package.json | 8 ++++++-- packages/utilities-react/tsconfig.json | 10 ++++++++++ packages/utilities/.gitignore | 1 + packages/utilities/package.json | 8 ++++++-- packages/utilities/src/dateTimeFormat/absolute.ts | 4 ++-- packages/utilities/tsconfig.json | 10 ++++++++++ yarn.lock | 4 ++++ 8 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 packages/utilities-react/.gitignore create mode 100644 packages/utilities-react/tsconfig.json create mode 100644 packages/utilities/.gitignore create mode 100644 packages/utilities/tsconfig.json diff --git a/packages/utilities-react/.gitignore b/packages/utilities-react/.gitignore new file mode 100644 index 000000000000..64dba6c41854 --- /dev/null +++ b/packages/utilities-react/.gitignore @@ -0,0 +1 @@ +types diff --git a/packages/utilities-react/package.json b/packages/utilities-react/package.json index 5be896003bfa..342bece80169 100644 --- a/packages/utilities-react/package.json +++ b/packages/utilities-react/package.json @@ -5,6 +5,7 @@ "license": "Apache-2.0", "main": "lib/index.js", "module": "es/index.js", + "types": "types/index.d.ts", "repository": { "type": "git", "url": "https://github.com/carbon-design-system/carbon.git", @@ -30,7 +31,8 @@ "scripts": { "build:es": "esbuild ./src/**/!(*-test).{js,ts,jsx,tsx} --minify --outdir=es --target=es2020 --format=esm", "build:cjs": "esbuild ./src/**/!(*-test).{js,ts,jsx,tsx} --minify --outdir=lib --target=es2020 --format=cjs", - "build": "yarn build:es & yarn build:cjs", + "build:types": "tsc", + "build": "yarn build:es & yarn build:cjs & yarn build:types", "watch": "yarn build:es --watch & yarn build:cjs --watch", "clean": "rimraf es lib", "test": "echo yay && exit 0", @@ -41,7 +43,9 @@ }, "devDependencies": { "esbuild": "^0.24.0", - "rimraf": "^6.0.0" + "rimraf": "^6.0.0", + "typescript": "^4.8.4", + "typescript-config-carbon": "^0.3.0" }, "dependencies": { "@carbon/utilities": "^0.1.0", diff --git a/packages/utilities-react/tsconfig.json b/packages/utilities-react/tsconfig.json new file mode 100644 index 000000000000..f6dc96d81f98 --- /dev/null +++ b/packages/utilities-react/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "typescript-config-carbon/tsconfig.base.json", + "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "declarationDir": "./types" + }, + "include": ["src/**/*"], + "exclude": ["src/**/*-test.js"] +} diff --git a/packages/utilities/.gitignore b/packages/utilities/.gitignore new file mode 100644 index 000000000000..64dba6c41854 --- /dev/null +++ b/packages/utilities/.gitignore @@ -0,0 +1 @@ +types diff --git a/packages/utilities/package.json b/packages/utilities/package.json index 9056b6dec6b8..32d3a2466927 100644 --- a/packages/utilities/package.json +++ b/packages/utilities/package.json @@ -5,6 +5,7 @@ "license": "Apache-2.0", "main": "lib/index.js", "module": "es/index.js", + "types": "types/index.d.ts", "repository": { "type": "git", "url": "https://github.com/carbon-design-system/carbon.git", @@ -29,7 +30,8 @@ "scripts": { "build:es": "esbuild ./src/**/!(*-test).{js,ts} --minify --outdir=es --target=es2020 --format=esm", "build:cjs": "esbuild ./src/**/!(*-test).{js,ts} --minify --outdir=lib --target=es2020 --format=cjs", - "build": "yarn build:es & yarn build:cjs", + "build:types": "tsc", + "build": "yarn build:es & yarn build:cjs & yarn build:types", "watch": "yarn build:es --watch & yarn build:cjs --watch", "clean": "rimraf es lib", "test": "echo yay && exit 0", @@ -37,7 +39,9 @@ }, "devDependencies": { "esbuild": "^0.24.0", - "rimraf": "^6.0.0" + "rimraf": "^6.0.0", + "typescript": "^4.8.4", + "typescript-config-carbon": "^0.3.0" }, "dependencies": { "@ibm/telemetry-js": "^1.6.1" diff --git a/packages/utilities/src/dateTimeFormat/absolute.ts b/packages/utilities/src/dateTimeFormat/absolute.ts index 280a0b0e0d27..1e14cce8d421 100644 --- a/packages/utilities/src/dateTimeFormat/absolute.ts +++ b/packages/utilities/src/dateTimeFormat/absolute.ts @@ -61,8 +61,8 @@ export function format( } export function formatRange( - startDate: Date | Number, - endDate: Date | Number, + startDate: Date | number, + endDate: Date | number, options?: Partial<{ locale: string; style: Intl.DateTimeFormatOptions['timeStyle']; diff --git a/packages/utilities/tsconfig.json b/packages/utilities/tsconfig.json new file mode 100644 index 000000000000..f6dc96d81f98 --- /dev/null +++ b/packages/utilities/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "typescript-config-carbon/tsconfig.base.json", + "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "declarationDir": "./types" + }, + "include": ["src/**/*"], + "exclude": ["src/**/*-test.js"] +} diff --git a/yarn.lock b/yarn.lock index d7245438d927..6e0b20a40ec3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2285,6 +2285,8 @@ __metadata: "@ibm/telemetry-js": "npm:^1.6.1" esbuild: "npm:^0.24.0" rimraf: "npm:^6.0.0" + typescript: "npm:^4.8.4" + typescript-config-carbon: "npm:^0.3.0" peerDependencies: react: ^16.8.6 || ^17.0.1 || ^18.2.0 languageName: unknown @@ -2297,6 +2299,8 @@ __metadata: "@ibm/telemetry-js": "npm:^1.6.1" esbuild: "npm:^0.24.0" rimraf: "npm:^6.0.0" + typescript: "npm:^4.8.4" + typescript-config-carbon: "npm:^0.3.0" languageName: unknown linkType: soft