From d5ca096619bcdcd96f40210cb1c645cd476c66ef Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=A4=9C?= <951540966@qq.com> Date: Wed, 17 Jul 2024 11:02:05 +0800 Subject: [PATCH] fix: shape.css({}) --- svg.js.d.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/svg.js.d.ts b/svg.js.d.ts index 5fd0513..c731b25 100644 --- a/svg.js.d.ts +++ b/svg.js.d.ts @@ -10,8 +10,20 @@ declare type CSSStyleName = Exclude< 'parentRule' | 'length' > +// camelCase to kebab-case +type CamelToKebab = S extends `${infer T}${infer U}` + ? U extends Uncapitalize + ? `${Lowercase}${CamelToKebab}` + : `${Lowercase}-${CamelToKebab}` + : S; + +type ConvertKeysToKebab = { + [K in keyof T as CamelToKebab]: T[K]; +}; + + // create our own style declaration that includes css vars -interface CSSStyleDeclarationWithVars extends CSSStyleDeclaration { +interface CSSStyleDeclarationWithVars extends ConvertKeysToKebab { [key: `--${string}`]: string } -- 2.39.5