Skip to content

Commit b7c3671

Browse files
committed
Simplify import
1 parent 108ee47 commit b7c3671

File tree

1 file changed

+12
-19
lines changed
  • packages/@tailwindcss-postcss/src

1 file changed

+12
-19
lines changed

packages/@tailwindcss-postcss/src/ast.ts

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
type Postcss,
3-
type ChildNode as PostCssChildNode,
4-
type Container as PostCssContainerNode,
5-
type Input as PostCssInput,
6-
type Root as PostCssRoot,
7-
type Source as PostcssSource,
8-
} from 'postcss'
1+
import type * as postcss from 'postcss'
92
import { atRule, comment, decl, rule, type AstNode } from '../../tailwindcss/src/ast'
103
import { createLineTable, type LineTable } from '../../tailwindcss/src/source-maps/line-table'
114
import type { Source, SourceLocation } from '../../tailwindcss/src/source-maps/source'
@@ -15,10 +8,10 @@ const EXCLAMATION_MARK = 0x21
158

169
export function cssAstToPostCssAst(
1710
ast: AstNode[],
18-
source: PostcssSource | undefined,
19-
postcss: Postcss,
20-
): PostCssRoot {
21-
let inputMap = new DefaultMap<Source, PostCssInput>((src) => {
11+
source: postcss.Source | undefined,
12+
postcss: postcss.Postcss,
13+
): postcss.Root {
14+
let inputMap = new DefaultMap<Source, postcss.Input>((src) => {
2215
return new postcss.Input(src.code, {
2316
map: source?.input.map,
2417
from: src.file ?? undefined,
@@ -30,7 +23,7 @@ export function cssAstToPostCssAst(
3023
let root = postcss.root()
3124
root.source = source
3225

33-
function toSource(loc: SourceLocation | undefined): PostcssSource | undefined {
26+
function toSource(loc: SourceLocation | undefined): postcss.Source | undefined {
3427
// Use the fallback if this node has no location info in the AST
3528
if (!loc) return
3629
if (!loc[0]) return
@@ -54,7 +47,7 @@ export function cssAstToPostCssAst(
5447
}
5548
}
5649

57-
function updateSource(astNode: PostCssChildNode, loc: SourceLocation | undefined) {
50+
function updateSource(astNode: postcss.ChildNode, loc: SourceLocation | undefined) {
5851
let source = toSource(loc)
5952

6053
// The `source` property on PostCSS nodes must be defined if present because
@@ -68,7 +61,7 @@ export function cssAstToPostCssAst(
6861
}
6962
}
7063

71-
function transform(node: AstNode, parent: PostCssContainerNode) {
64+
function transform(node: AstNode, parent: postcss.Container) {
7265
// Declaration
7366
if (node.kind === 'declaration') {
7467
let astNode = postcss.decl({
@@ -130,13 +123,13 @@ export function cssAstToPostCssAst(
130123
return root
131124
}
132125

133-
export function postCssAstToCssAst(root: PostCssRoot): AstNode[] {
134-
let inputMap = new DefaultMap<PostCssInput, Source>((input) => ({
126+
export function postCssAstToCssAst(root: postcss.Root): AstNode[] {
127+
let inputMap = new DefaultMap<postcss.Input, Source>((input) => ({
135128
file: input.file ?? input.id ?? null,
136129
code: input.css,
137130
}))
138131

139-
function toSource(node: PostCssChildNode): SourceLocation | undefined {
132+
function toSource(node: postcss.ChildNode): SourceLocation | undefined {
140133
let source = node.source
141134
if (!source) return
142135

@@ -149,7 +142,7 @@ export function postCssAstToCssAst(root: PostCssRoot): AstNode[] {
149142
}
150143

151144
function transform(
152-
node: PostCssChildNode,
145+
node: postcss.ChildNode,
153146
parent: Extract<AstNode, { nodes: AstNode[] }>['nodes'],
154147
) {
155148
// Declaration

0 commit comments

Comments
 (0)