diff options
author | 夜 <951540966@qq.com> | 2024-07-17 11:02:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-17 11:02:05 +0800 |
commit | d5ca096619bcdcd96f40210cb1c645cd476c66ef (patch) | |
tree | 678b20c29f115492769109616cde234ede343e8a | |
parent | ec9d2fc952a683aaa9f0c523fbba0786babdf629 (diff) | |
download | svg.js-d5ca096619bcdcd96f40210cb1c645cd476c66ef.tar.gz svg.js-d5ca096619bcdcd96f40210cb1c645cd476c66ef.zip |
fix: shape.css({})
-rw-r--r-- | svg.js.d.ts | 14 |
1 files changed, 13 insertions, 1 deletions
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 string> = S extends `${infer T}${infer U}` + ? U extends Uncapitalize<U> + ? `${Lowercase<T>}${CamelToKebab<U>}` + : `${Lowercase<T>}-${CamelToKebab<U>}` + : S; + +type ConvertKeysToKebab<T> = { + [K in keyof T as CamelToKebab<K & string>]: T[K]; +}; + + // create our own style declaration that includes css vars -interface CSSStyleDeclarationWithVars extends CSSStyleDeclaration { +interface CSSStyleDeclarationWithVars extends ConvertKeysToKebab<CSSStyleDeclaration> { [key: `--${string}`]: string } |