From fd7ae733f1acfb51a0119250b0a4bd3fc1a7672a Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 23 Jul 2024 18:33:56 -0700 Subject: [PATCH] Declare Node subclass attributes as getters This makes it easier to extend these classes and override these fields with information that's derived from other, internal fields. This helps enable https://github.com/sass/dart-sass/issues/88 --- lib/at-rule.d.ts | 7 +++++-- lib/comment.d.ts | 3 ++- lib/declaration.d.ts | 12 ++++++++---- lib/rule.d.ts | 6 ++++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/at-rule.d.ts b/lib/at-rule.d.ts index 5bdee38be..9fc375f13 100644 --- a/lib/at-rule.d.ts +++ b/lib/at-rule.d.ts @@ -88,7 +88,9 @@ declare class AtRule_ extends Container { * media.name //=> 'media' * ``` */ - name: string + get name(): string + set name(value: string) + /** * An array containing the layer’s children. * @@ -118,7 +120,8 @@ declare class AtRule_ extends Container { * media.params //=> 'print, screen' * ``` */ - params: string + get params(): string + set params(value: string) parent: ContainerWithChildren | undefined raws: AtRule.AtRuleRaws diff --git a/lib/comment.d.ts b/lib/comment.d.ts index d2445088e..8b0a7a289 100644 --- a/lib/comment.d.ts +++ b/lib/comment.d.ts @@ -51,7 +51,8 @@ declare class Comment_ extends Node { /** * The comment's text. */ - text: string + get text(): string + set text(value: string) type: 'comment' diff --git a/lib/declaration.d.ts b/lib/declaration.d.ts index a5db984a4..1c6821f4a 100644 --- a/lib/declaration.d.ts +++ b/lib/declaration.d.ts @@ -77,7 +77,8 @@ declare class Declaration_ extends Node { * root.first.last.important //=> undefined * ``` */ - important: boolean + get important(): boolean + set important(value: boolean) parent: ContainerWithChildren | undefined @@ -91,7 +92,8 @@ declare class Declaration_ extends Node { * decl.prop //=> 'color' * ``` */ - prop: string + get prop(): string + set prop(value: string) raws: Declaration.DeclarationRaws @@ -114,7 +116,8 @@ declare class Declaration_ extends Node { * decl.value //=> 'black' * ``` */ - value: string + get value(): string + set value(value: string) /** * It represents a getter that returns `true` if a declaration starts with @@ -134,7 +137,8 @@ declare class Declaration_ extends Node { * one.variable //=> true * ``` */ - variable: boolean + get variable(): boolean + set varaible(value: string) constructor(defaults?: Declaration.DeclarationProps) assign(overrides: Declaration.DeclarationProps | object): this diff --git a/lib/rule.d.ts b/lib/rule.d.ts index fc5dd721a..568dcc138 100644 --- a/lib/rule.d.ts +++ b/lib/rule.d.ts @@ -84,7 +84,8 @@ declare class Rule_ extends Container { * rule.selector //=> 'a, b' * ``` */ - selector: string + get selector(): string + set selector(value: string); /** * An array containing the rule’s individual selectors. @@ -101,7 +102,8 @@ declare class Rule_ extends Container { * rule.selector //=> 'a, strong' * ``` */ - selectors: string[] + get selectors(): string[] + set selectors(values: string[]); type: 'rule'