Skip to content

Commit

Permalink
Declare Node subclass attributes as getters
Browse files Browse the repository at this point in the history
This makes it easier to extend these classes and override these fields
with information that's derived from other, internal fields.

This helps enable sass/dart-sass#88
  • Loading branch information
nex3 committed Jul 24, 2024
1 parent 79a6396 commit fd7ae73
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
7 changes: 5 additions & 2 deletions lib/at-rule.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/comment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ declare class Comment_ extends Node {
/**
* The comment's text.
*/
text: string
get text(): string
set text(value: string)

type: 'comment'

Expand Down
12 changes: 8 additions & 4 deletions lib/declaration.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -91,7 +92,8 @@ declare class Declaration_ extends Node {
* decl.prop //=> 'color'
* ```
*/
prop: string
get prop(): string
set prop(value: string)

raws: Declaration.DeclarationRaws

Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions lib/rule.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -101,7 +102,8 @@ declare class Rule_ extends Container {
* rule.selector //=> 'a, strong'
* ```
*/
selectors: string[]
get selectors(): string[]
set selectors(values: string[]);

type: 'rule'

Expand Down

0 comments on commit fd7ae73

Please sign in to comment.