Skip to content

Commit 9cfc436

Browse files
committed
Fixed type inference on the ESLintCompatiblePostCSSNode type
1 parent 1db5f7d commit 9cfc436

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

src/ast/style.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,14 @@ import type { BaseNode } from "./base";
33

44
export type ESLintCompatiblePostCSSNode<PostCSSNode extends Node = Node> =
55
BaseNode &
6+
Omit<PostCSSNode, "walk"> &
67
(PostCSSNode extends Container<infer Child>
7-
? Omit<PostCSSNode, "parent" | "type"> &
8-
Omit<
9-
Container<ESLintCompatiblePostCSSNode<Child>>,
10-
"parent" | "walk"
11-
> & {
12-
parent: BaseNode;
13-
walk(
14-
callback: (
15-
node: ESLintCompatiblePostCSSNode<Child>,
16-
index: number
17-
) => false | void
18-
): false | undefined;
19-
}
20-
: PostCSSNode);
8+
? {
9+
walk(
10+
callback: (
11+
node: ESLintCompatiblePostCSSNode<Child>,
12+
index: number
13+
) => false | void
14+
): false | undefined;
15+
}
16+
: unknown);

src/parser/converts/root.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type { Context } from "../../context";
1111
import { convertChildren, extractElementTags } from "./element";
1212
import { convertAttributeTokens } from "./attr";
1313
import type { Scope } from "eslint-scope";
14-
import type { ChildNode, Node, Parser, Root } from "postcss";
14+
import type { Document, Node, Parser, Root } from "postcss";
1515
import postcss from "postcss";
1616
import { parse as SCSSparse } from "postcss-scss";
1717
import type { ESLintCompatiblePostCSSNode } from "../../ast/style";
@@ -154,10 +154,10 @@ export function convertSvelteRoot(
154154
style.body.loc.start.column += style.startTag.loc.end.column;
155155
style.body.loc.end.column -=
156156
style.endTag.loc.end.column - style.endTag.loc.start.column;
157-
style.body?.walk((node: ESLintCompatiblePostCSSNode<ChildNode>) =>
157+
style.body?.walk((node) =>
158158
convertPostCSSNodeToESLintNode(node, style.loc, contentRange)
159159
);
160-
style.body.parent = style;
160+
style.body.parent = style as unknown as Document;
161161
delete style.body.source?.input.file;
162162
}
163163
ctx.addToken("HTMLText", contentRange);

0 commit comments

Comments
 (0)