From 03899c79bc647da2aea458ec754a33d25d39f934 Mon Sep 17 00:00:00 2001 From: Claas Date: Mon, 27 May 2024 15:13:15 +0200 Subject: [PATCH 1/4] Help typescript consumers with types they don't seem to automatically consume the JSDoc annotations --- default.config.js | 1 + jsconfig.json | 6 ------ package.json | 9 ++++++--- pnpm-lock.yaml | 10 ++++++++++ tsconfig.json | 18 ++++++++++++++++++ 5 files changed, 35 insertions(+), 9 deletions(-) delete mode 100644 jsconfig.json create mode 100644 tsconfig.json diff --git a/default.config.js b/default.config.js index 2cbb654..f6490e9 100644 --- a/default.config.js +++ b/default.config.js @@ -2,6 +2,7 @@ /** * @type {Partial }>} + * @private */ const defaultConfiguration = { borderRadius: { diff --git a/jsconfig.json b/jsconfig.json deleted file mode 100644 index 5ebfc59..0000000 --- a/jsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "compilerOptions": { - "checkJs": true, - "strict": true - } -} diff --git a/package.json b/package.json index d3af217..06f121e 100644 --- a/package.json +++ b/package.json @@ -13,14 +13,15 @@ "url": "https://github.com/SantaClaas/material-tailwind.git" }, "private": false, - "version": "0.1.1", + "version": "0.2.0", "type": "module", "exports": { ".": "./index.js" }, "scripts": { "build:bundle": "node ./build.js", - "test": "vitest" + "test": "vitest", + "create-definitions": "tsc" }, "dependencies": { "@material/material-color-utilities": "./@material/material-color-utilities", @@ -30,6 +31,8 @@ "@material/material-color-utilities" ], "devDependencies": { + "typescript": "^5.4.5", "vitest": "^1.5.0" - } + }, + "types": "./index.d.ts" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1da9760..f92f6e6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,6 +15,9 @@ importers: specifier: ^3.4.1 version: 3.4.3 devDependencies: + typescript: + specifier: ^5.4.5 + version: 5.4.5 vitest: specifier: ^1.5.0 version: 1.5.0(@types/node@20.12.7) @@ -833,6 +836,11 @@ packages: resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==} engines: {node: '>=4'} + typescript@5.4.5: + resolution: {integrity: sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==} + engines: {node: '>=14.17'} + hasBin: true + ufo@1.5.3: resolution: {integrity: sha512-Y7HYmWaFwPUmkoQCUIAYpKqkOf+SbVj/2fJJZ4RJMCfZp0rTGwRbzQD+HghfnhKOjL9E01okqz+ncJskGYfBNw==} @@ -1658,6 +1666,8 @@ snapshots: type-detect@4.0.8: {} + typescript@5.4.5: {} + ufo@1.5.3: {} undici-types@5.26.5: diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..e48fb2f --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,18 @@ +{ + "exclude": [ + "@material", + "example", + "node_modules", + "material-color-utilities" + ], + "include": ["index.js"], + "compilerOptions": { + "checkJs": true, + "allowJs": true, + "strict": true, + "declaration": true, + "emitDeclarationOnly": true, + "declarationMap": true, + "esModuleInterop": true + } +} From 2bfe582c9ef462f068b58748272f66bacd33df91 Mon Sep 17 00:00:00 2001 From: Claas Date: Mon, 27 May 2024 15:35:34 +0200 Subject: [PATCH 2/4] Generate definitions in publish --- .github/workflows/publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 302765c..5323afb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -42,6 +42,8 @@ jobs: run: pnpm run build:bundle - name: Test and ensure dependencies were built as expected run: pnpm test + - name: Create type definitions + run: pnpm create-definitions - name: Check if tag is release tag id: check-tag run: | From c9cd016fd47d93f1f28a2ea5c9b5bffa6ba4cf39 Mon Sep 17 00:00:00 2001 From: Claas Date: Mon, 27 May 2024 15:36:07 +0200 Subject: [PATCH 3/4] Remove typescript configuration from package bundle --- .npmignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.npmignore b/.npmignore index fc69ed0..aefebe8 100644 --- a/.npmignore +++ b/.npmignore @@ -1,6 +1,7 @@ pnpm-lock.yaml package-lock.json jsconfig.json +tsconfig.json example/ material-color-utilities/ # Don't include custom build of material-color-utilities as it will be bundled by "bundledDependencies" in package.json From 7bf2f435fd278babf741bec878ae8831ee04fe9e Mon Sep 17 00:00:00 2001 From: Claas Date: Mon, 27 May 2024 15:36:48 +0200 Subject: [PATCH 4/4] Ignore generated TypeScript files --- .gitignore | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d94cc5f..d3885cd 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,10 @@ dist-ssr *.sw? # Genrated custom build -@material/ \ No newline at end of file +@material/ + +# Generated TypeScript declarations +*.d.ts + +# Generated TypeScript declaration maps +*.d.ts.map \ No newline at end of file