summaryrefslogtreecommitdiffstats
path: root/svg.js.d.ts
diff options
context:
space:
mode:
authorGlandos <bugs-github@antipoul.fr>2020-05-27 16:48:26 +0200
committerGitHub <noreply@github.com>2020-05-27 16:48:26 +0200
commit8447a268737da54d44b99849bf3600a00c2f8983 (patch)
tree3e396990edb7dba48a8a93a3507971a45fbb4231 /svg.js.d.ts
parent18e4db2688f6b11eb5c57b6ab6ad0bb1ad6abb42 (diff)
downloadsvg.js-8447a268737da54d44b99849bf3600a00c2f8983.tar.gz
svg.js-8447a268737da54d44b99849bf3600a00c2f8983.zip
Better typing for css getter/setter
CSSStyleDeclaration contains readonly rule, so I excluded them, otherwise it doesn't make sense I didn't touch the Runner `css()` because I don't know the exact behavior of it.
Diffstat (limited to 'svg.js.d.ts')
-rw-r--r--svg.js.d.ts13
1 files changed, 8 insertions, 5 deletions
diff --git a/svg.js.d.ts b/svg.js.d.ts
index 0dddfdc..0aed23b 100644
--- a/svg.js.d.ts
+++ b/svg.js.d.ts
@@ -4,6 +4,9 @@
// 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" >
+
declare module "@svgdotjs/svg.js" {
function SVG(): Svg;
@@ -1008,11 +1011,11 @@ declare module "@svgdotjs/svg.js" {
toggleClass(name: string): this
// prototype method register in css.js
- css(): object;
- css(style: string): string
- css(style: string[]): object;
- css(style: string, val: any): this
- css(style: object): this
+ css(): Partial<CSSStyleDeclaration>
+ css<T extends CSSStyleName>(style: T): CSSStyleDeclaration[T]
+ css<T extends CSSStyleName[]>(style: T): Partial<CSSStyleDeclaration>
+ css<T extends CSSStyleName>(style: T, val: CSSStyleDeclaration[T]): this
+ css(style: Partial<CSSStyleDeclaration>): this
show(): this
hide(): this
visible(): boolean