From 4ed326b52d6fe8da630cae29a487dc6ff609e89f Mon Sep 17 00:00:00 2001 From: jorenbroekema Date: Thu, 4 Jul 2024 12:34:49 +0200 Subject: [PATCH] feat: add originalType to studio extensions, fix type issues wrt optionals --- .changeset/small-mice-share.md | 5 +++++ package-lock.json | 14 +++++++------- package.json | 2 +- src/types/tokens/SingleGenericToken.ts | 11 ++++++++++- tsconfig.json | 4 ++-- 5 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 .changeset/small-mice-share.md diff --git a/.changeset/small-mice-share.md b/.changeset/small-mice-share.md new file mode 100644 index 0000000..132a105 --- /dev/null +++ b/.changeset/small-mice-share.md @@ -0,0 +1,5 @@ +--- +'@tokens-studio/types': minor +--- + +BREAKING: $extensions['studio.tokens'] is now optional, modify inner prop is optional, $extensions is extendable with other namespaces, add originalType meta prop to studio.tokens namespace. diff --git a/package-lock.json b/package-lock.json index 6d01078..12ba886 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@tokens-studio/types", - "version": "0.3.0", + "version": "0.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@tokens-studio/types", - "version": "0.3.0", + "version": "0.4.0", "license": "MIT", "devDependencies": { "@changesets/cli": "^2.26.0", @@ -26,7 +26,7 @@ "rimraf": "^5.0.0", "rollup": "^3.20.2", "typedoc": "^0.24.1", - "typescript": "^5.0.4" + "typescript": "^5.5.3" } }, "node_modules/@ampproject/remapping": { @@ -6847,16 +6847,16 @@ } }, "node_modules/typescript": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", - "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz", + "integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=12.20" + "node": ">=14.17" } }, "node_modules/unbox-primitive": { diff --git a/package.json b/package.json index 29692c2..856f649 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "rimraf": "^5.0.0", "rollup": "^3.20.2", "typedoc": "^0.24.1", - "typescript": "^5.0.4" + "typescript": "^5.5.3" }, "keywords": [ "design tokens", diff --git a/src/types/tokens/SingleGenericToken.ts b/src/types/tokens/SingleGenericToken.ts index 1e3732a..8c22254 100644 --- a/src/types/tokens/SingleGenericToken.ts +++ b/src/types/tokens/SingleGenericToken.ts @@ -13,7 +13,16 @@ type _SingleGenericToken = { oldValue?: V; internal__Parent?: string; inheritTypeLevel?: number; - $extensions?: { 'studio.tokens': { modify: ColorModifier } }; + $extensions?: { + 'studio.tokens'?: { + modify?: ColorModifier, + // this may be set by sd-transforms when aligning the Tokens Studio types to the DTCG types + // so that certain transforms can still match tokens e.g. letterSpacing -> dimension, but the letterspacing + // transform only wants to match for letterSpacing tokens, not all dimension tokens. + originalType?: T; + }, + [key: string]: object | undefined + }; } & (Named extends true ? { name: string; diff --git a/tsconfig.json b/tsconfig.json index cb56acc..81f59b2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,9 @@ { "compilerOptions": { "target": "esnext", - "module": "esnext", + "module": "NodeNext", "declaration": true, - "moduleResolution": "nodenext", + "moduleResolution": "NodeNext", "lib": ["ESNext", "dom"], "allowSyntheticDefaultImports": true, "strict": true,