aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author夜 <951540966@qq.com>2024-07-17 14:15:50 +0800
committerGitHub <noreply@github.com>2024-07-17 14:15:50 +0800
commit1f5f978accc559f54aed0868e1a7a575a14a6d74 (patch)
tree3bd133457efe2becc09ff04de7f721c94c8ece9a
parentd5ca096619bcdcd96f40210cb1c645cd476c66ef (diff)
downloadsvg.js-1f5f978accc559f54aed0868e1a7a575a14a6d74.tar.gz
svg.js-1f5f978accc559f54aed0868e1a7a575a14a6d74.zip
fix: CSSStyleName typescript
-rw-r--r--svg.js.d.ts31
1 files changed, 16 insertions, 15 deletions
diff --git a/svg.js.d.ts b/svg.js.d.ts
index c731b25..b3f17e9 100644
--- a/svg.js.d.ts
+++ b/svg.js.d.ts
@@ -4,26 +4,27 @@
// trick to keep reference to Array build-in type
declare class BuiltInArray<T> extends Array<T> {}
-// trick to have nice attribute list for CSS
-declare type CSSStyleName = Exclude<
- keyof CSSStyleDeclaration,
- '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];
+declare type CamelToKebab<S extends string> = S extends `${infer T}${infer U}`
+ ? U extends Uncapitalize<U>
+ ? `${Lowercase<T>}${CamelToKebab<U>}`
+ : `${Lowercase<T>}-${CamelToKebab<U>}`
+ : S;
+
+declare type ConvertKeysToKebab<T> = {
+ [K in keyof T as CamelToKebab<K & string>]: T[K];
};
+declare type KebabCSSStyleDeclaration = ConvertKeysToKebab<CSSStyleDeclaration>
+
+// trick to have nice attribute list for CSS
+declare type CSSStyleName = Exclude<
+ keyof KebabCSSStyleDeclaration,
+ 'parent-rule' | 'length'
+>
// create our own style declaration that includes css vars
-interface CSSStyleDeclarationWithVars extends ConvertKeysToKebab<CSSStyleDeclaration> {
+interface CSSStyleDeclarationWithVars extends KebabCSSStyleDeclaration {
[key: `--${string}`]: string
}