From 1f93539d049691b9e1d355d3204c3fb4fe2011bb Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Sat, 5 Feb 2022 16:20:14 -0800 Subject: [PATCH] [feat] improve types for Style attributes and children --- src/compiler/interfaces.ts | 43 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/src/compiler/interfaces.ts b/src/compiler/interfaces.ts index 248175da59..10429b1735 100644 --- a/src/compiler/interfaces.ts +++ b/src/compiler/interfaces.ts @@ -118,10 +118,49 @@ export interface Script extends BaseNode { content: Program; } +export interface StyleAttribute extends BaseNode { + type: 'Attribute'; + name: string; + value: true | MustacheTag | any[]; +} + +export interface StyleSelector extends BaseNode { + type: 'Selector'; + children: any[]; +} + +export interface StyleDeclarationValue extends BaseNode { + type: 'Value'; + children: any[]; +} + +export interface StyleDeclaration extends BaseNode { + type: 'Declaration'; + important: boolean; + property: string; + value: StyleDeclarationValue; +} + +export interface StyleNode extends BaseNode { + type: 'Rule'; + prelude: { + type: 'SelectorList'; + children: StyleSelector[]; + start: number; + end: number; + }; + block: { + type: 'Block'; + children: StyleDeclaration[]; + start: number; + end: number; + } +} + export interface Style extends BaseNode { type: 'Style'; - attributes: any[]; // TODO - children: any[]; // TODO add CSS node types + attributes: StyleAttribute[]; + children: StyleNode[]; content: { start: number; end: number;