|
| 1 | +// Copyright 2024 Google Inc. Use of this source code is governed by an |
| 2 | +// MIT-style license that can be found in the LICENSE file or at |
| 3 | +// https://opensource.org/licenses/MIT. |
| 4 | + |
| 5 | +import * as postcss from 'postcss'; |
| 6 | + |
| 7 | +import {Rule} from './rule'; |
| 8 | +import {Root} from './root'; |
| 9 | +import {AtRule, ChildNode, Comment, Declaration, NewNode} from '.'; |
| 10 | + |
| 11 | +/** |
| 12 | + * A fake intermediate class to convince TypeScript to use Sass types for |
| 13 | + * various upstream methods. |
| 14 | + * |
| 15 | + * @hidden |
| 16 | + */ |
| 17 | +export class _Declaration<Props> extends postcss.Declaration { |
| 18 | + // Override the PostCSS container types to constrain them to Sass types only. |
| 19 | + // Unfortunately, there's no way to abstract this out, because anything |
| 20 | + // mixin-like returns an intersection type which doesn't actually override |
| 21 | + // parent methods. See microsoft/TypeScript#59394. |
| 22 | + |
| 23 | + after(newNode: NewNode): this; |
| 24 | + append(...nodes: NewNode[]): this; |
| 25 | + assign(overrides: Partial<Props>): this; |
| 26 | + before(newNode: NewNode): this; |
| 27 | + cloneAfter(overrides?: Partial<Props>): this; |
| 28 | + cloneBefore(overrides?: Partial<Props>): this; |
| 29 | + each( |
| 30 | + callback: (node: ChildNode, index: number) => false | void |
| 31 | + ): false | undefined; |
| 32 | + every( |
| 33 | + condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean |
| 34 | + ): boolean; |
| 35 | + insertAfter(oldNode: postcss.ChildNode | number, newNode: NewNode): this; |
| 36 | + insertBefore(oldNode: postcss.ChildNode | number, newNode: NewNode): this; |
| 37 | + next(): ChildNode | undefined; |
| 38 | + prepend(...nodes: NewNode[]): this; |
| 39 | + prev(): ChildNode | undefined; |
| 40 | + replaceWith(...nodes: NewNode[]): this; |
| 41 | + root(): Root; |
| 42 | + some( |
| 43 | + condition: (node: ChildNode, index: number, nodes: ChildNode[]) => boolean |
| 44 | + ): boolean; |
| 45 | + walk( |
| 46 | + callback: (node: ChildNode, index: number) => false | void |
| 47 | + ): false | undefined; |
| 48 | + walkAtRules( |
| 49 | + nameFilter: RegExp | string, |
| 50 | + callback: (atRule: AtRule, index: number) => false | void |
| 51 | + ): false | undefined; |
| 52 | + walkAtRules( |
| 53 | + callback: (atRule: AtRule, index: number) => false | void |
| 54 | + ): false | undefined; |
| 55 | + walkComments( |
| 56 | + callback: (comment: Comment, indexed: number) => false | void |
| 57 | + ): false | undefined; |
| 58 | + walkComments( |
| 59 | + callback: (comment: Comment, indexed: number) => false | void |
| 60 | + ): false | undefined; |
| 61 | + walkDecls( |
| 62 | + propFilter: RegExp | string, |
| 63 | + callback: (decl: Declaration, index: number) => false | void |
| 64 | + ): false | undefined; |
| 65 | + walkDecls( |
| 66 | + callback: (decl: Declaration, index: number) => false | void |
| 67 | + ): false | undefined; |
| 68 | + walkRules( |
| 69 | + selectorFilter: RegExp | string, |
| 70 | + callback: (rule: Rule, index: number) => false | void |
| 71 | + ): false | undefined; |
| 72 | + walkRules( |
| 73 | + callback: (rule: Rule, index: number) => false | void |
| 74 | + ): false | undefined; |
| 75 | + get first(): ChildNode | undefined; |
| 76 | + get last(): ChildNode | undefined; |
| 77 | +} |
0 commit comments