Skip to content

Commit 22858ac

Browse files
authored
Make TypeScript a bit more happy (#19124)
While working on another PR, I noticed that some files had missing properties and made TypeScript unhappy. Let's make TypeScript happy again...
1 parent c7f6303 commit 22858ac

15 files changed

+80
-14
lines changed

packages/tailwindcss/src/at-import.test.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ async function run(
1515
candidates = [],
1616
optimize = true,
1717
}: {
18-
loadStylesheet?: (id: string, base: string) => Promise<{ content: string; base: string }>
18+
loadStylesheet?: (
19+
id: string,
20+
base: string,
21+
) => Promise<{ content: string; base: string; path: string }>
1922
loadModule?: (
2023
id: string,
2124
base: string,
2225
resourceHint: 'plugin' | 'config',
23-
) => Promise<{ module: Config | Plugin; base: string }>
26+
) => Promise<{ module: Config | Plugin; base: string; path: string }>
2427
candidates?: string[]
2528
optimize?: boolean
2629
},
@@ -41,6 +44,7 @@ test('can resolve relative @imports', async () => {
4144
}
4245
`,
4346
base: '/root/foo',
47+
path: '',
4448
}
4549
}
4650

@@ -67,6 +71,7 @@ test('can recursively resolve relative @imports', async () => {
6771
@import './bar/baz.css';
6872
`,
6973
base: '/root/foo',
74+
path: '',
7075
}
7176
} else if (base === '/root/foo' && id === './bar/baz.css') {
7277
return {
@@ -76,6 +81,7 @@ test('can recursively resolve relative @imports', async () => {
7681
}
7782
`,
7883
base: '/root/foo/bar',
84+
path: '',
7985
}
8086
}
8187

@@ -107,6 +113,7 @@ let loadStylesheet = async (id: string) => {
107113
return {
108114
content: exampleCSS,
109115
base: '/root',
116+
path: '',
110117
}
111118
}
112119

@@ -415,6 +422,7 @@ test('supports theme(reference) imports', async () => {
415422
}
416423
`,
417424
base: '',
425+
path: '',
418426
}),
419427
candidates: ['text-red-500'],
420428
},
@@ -435,8 +443,9 @@ test('updates the base when loading modules inside nested files', async () => {
435443
@plugin './nested-plugin.js';
436444
`,
437445
base: '/root/foo',
446+
path: '',
438447
})
439-
let loadModule = vi.fn().mockResolvedValue({ base: '', module: () => {} })
448+
let loadModule = vi.fn().mockResolvedValue({ base: '', path: '', module: () => {} })
440449

441450
expect(
442451
(
@@ -464,6 +473,7 @@ test('emits the right base for @source directives inside nested files', async ()
464473
@source './nested/**/*.css';
465474
`,
466475
base: '/root/foo',
476+
path: '',
467477
})
468478

469479
let compiler = await compile(
@@ -488,6 +498,7 @@ test('emits the right base for @source found inside JS configs and plugins from
488498
@plugin './nested-plugin.js';
489499
`,
490500
base: '/root/foo',
501+
path: '',
491502
})
492503
let loadModule = vi.fn().mockImplementation((id: string) => {
493504
let base = id.includes('nested') ? '/root/foo' : '/root'
@@ -502,12 +513,14 @@ test('emits the right base for @source found inside JS configs and plugins from
502513
plugins: [plugin(() => {}, { content: [pluginGlob] })],
503514
} satisfies Config,
504515
base: base + '-config',
516+
path: '',
505517
}
506518
} else {
507519
let glob = id.includes('nested') ? './nested-plugin/*.html' : './root-plugin/*.html'
508520
return {
509521
module: plugin(() => {}, { content: [glob] }),
510522
base: base + '-plugin',
523+
path: '',
511524
}
512525
}
513526
})
@@ -540,6 +553,7 @@ test('it crashes when inside a cycle', async () => {
540553
@import 'foo.css';
541554
`,
542555
base: '/root',
556+
path: '',
543557
})
544558

545559
await expect(
@@ -568,6 +582,7 @@ test('resolves @reference as `@import "…" reference`', async () => {
568582
}
569583
`,
570584
base: '/root/foo',
585+
path: '',
571586
}
572587
}
573588

@@ -600,6 +615,7 @@ test('resolves `@variant` used as `@custom-variant` inside `@reference`', async
600615
}
601616
`,
602617
base: '/root/foo',
618+
path: '',
603619
}
604620
}
605621

packages/tailwindcss/src/compat/apply-compat-hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ function upgradeToFullPluginSupport({
353353
// config would otherwise expand into namespaces like `background-color` which
354354
// core utilities already read from.
355355
applyConfigToTheme(designSystem, resolvedUserConfig, replacedThemeKeys)
356-
applyKeyframesToTheme(designSystem, resolvedUserConfig, replacedThemeKeys)
356+
applyKeyframesToTheme(designSystem, resolvedUserConfig)
357357

358358
registerThemeVariantOverrides(resolvedUserConfig, designSystem)
359359
registerScreensConfig(resolvedUserConfig, designSystem)

packages/tailwindcss/src/compat/apply-config-to-theme.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ test('config values can be merged into the theme', () => {
8383
},
8484
base: '/root',
8585
reference: false,
86+
src: undefined,
8687
},
8788
])
8889
applyConfigToTheme(design, resolvedConfig, replacedThemeKeys)
@@ -160,6 +161,8 @@ test('will reset default theme values with overwriting theme values', () => {
160161
},
161162
},
162163
base: '/root',
164+
reference: false,
165+
src: undefined,
163166
},
164167
])
165168
applyConfigToTheme(design, resolvedConfig, replacedThemeKeys)
@@ -189,6 +192,8 @@ test('invalid keys are not merged into the theme', () => {
189192
},
190193
},
191194
base: '/root',
195+
reference: false,
196+
src: undefined,
192197
},
193198
])
194199

@@ -227,6 +232,8 @@ test('converts opacity modifiers from decimal to percentage values', () => {
227232
},
228233
},
229234
base: '/root',
235+
reference: false,
236+
src: undefined,
230237
},
231238
])
232239
applyConfigToTheme(design, resolvedConfig, replacedThemeKeys)
@@ -261,6 +268,7 @@ test('handles setting theme keys to null', async () => {
261268
},
262269
base: '/root',
263270
reference: false,
271+
src: undefined,
264272
},
265273
])
266274
applyConfigToTheme(design, resolvedConfig, replacedThemeKeys)

packages/tailwindcss/src/compat/apply-keyframes-to-theme.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ test('keyframes can be merged into the theme', () => {
99
let theme = new Theme()
1010
let design = buildDesignSystem(theme)
1111

12-
let { resolvedConfig, replacedThemeKeys } = resolveConfig(design, [
12+
let { resolvedConfig } = resolveConfig(design, [
1313
{
1414
config: {
1515
theme: {
@@ -28,9 +28,11 @@ test('keyframes can be merged into the theme', () => {
2828
},
2929
},
3030
base: '/root',
31+
reference: false,
32+
src: undefined,
3133
},
3234
])
33-
applyKeyframesToTheme(design, resolvedConfig, replacedThemeKeys)
35+
applyKeyframesToTheme(design, resolvedConfig)
3436

3537
expect(toCss(design.theme.getKeyframes())).toMatchInlineSnapshot(`
3638
"@keyframes fade-in {
@@ -70,7 +72,7 @@ test('will append to the default keyframes with new keyframes', () => {
7072
]),
7173
)
7274

73-
let { resolvedConfig, replacedThemeKeys } = resolveConfig(design, [
75+
let { resolvedConfig } = resolveConfig(design, [
7476
{
7577
config: {
7678
theme: {
@@ -91,9 +93,11 @@ test('will append to the default keyframes with new keyframes', () => {
9193
},
9294
},
9395
base: '/root',
96+
reference: false,
97+
src: undefined,
9498
},
9599
])
96-
applyKeyframesToTheme(design, resolvedConfig, replacedThemeKeys)
100+
applyKeyframesToTheme(design, resolvedConfig)
97101

98102
expect(toCss(design.theme.getKeyframes())).toMatchInlineSnapshot(`
99103
"@keyframes slide-in {

packages/tailwindcss/src/compat/apply-keyframes-to-theme.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { objectToAst } from './plugin-api'
66
export function applyKeyframesToTheme(
77
designSystem: DesignSystem,
88
resolvedConfig: Pick<ResolvedConfig, 'theme'>,
9-
replacedThemeKeys: Set<string>,
109
) {
1110
for (let rule of keyframesToRules(resolvedConfig)) {
1211
designSystem.theme.addKeyframes(rule)

packages/tailwindcss/src/compat/config/resolve-config.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ test('top level theme keys are replaced', () => {
2020
},
2121
},
2222
base: '/root',
23+
reference: false,
24+
src: undefined,
2325
},
2426
{
2527
config: {
@@ -30,6 +32,8 @@ test('top level theme keys are replaced', () => {
3032
},
3133
},
3234
base: '/root',
35+
reference: false,
36+
src: undefined,
3337
},
3438
{
3539
config: {
@@ -40,6 +44,8 @@ test('top level theme keys are replaced', () => {
4044
},
4145
},
4246
base: '/root',
47+
reference: false,
48+
src: undefined,
4349
},
4450
])
4551

@@ -73,6 +79,8 @@ test('theme can be extended', () => {
7379
},
7480
},
7581
base: '/root',
82+
reference: false,
83+
src: undefined,
7684
},
7785
{
7886
config: {
@@ -85,6 +93,8 @@ test('theme can be extended', () => {
8593
},
8694
},
8795
base: '/root',
96+
reference: false,
97+
src: undefined,
8898
},
8999
])
90100

@@ -120,6 +130,8 @@ test('theme keys can reference other theme keys using the theme function regardl
120130
},
121131
},
122132
base: '/root',
133+
reference: false,
134+
src: undefined,
123135
},
124136
{
125137
config: {
@@ -133,6 +145,8 @@ test('theme keys can reference other theme keys using the theme function regardl
133145
},
134146
},
135147
base: '/root',
148+
reference: false,
149+
src: undefined,
136150
},
137151
{
138152
config: {
@@ -145,6 +159,8 @@ test('theme keys can reference other theme keys using the theme function regardl
145159
},
146160
},
147161
base: '/root',
162+
reference: false,
163+
src: undefined,
148164
},
149165
])
150166

@@ -212,6 +228,8 @@ test('theme keys can read from the CSS theme', () => {
212228
},
213229
},
214230
base: '/root',
231+
reference: false,
232+
src: undefined,
215233
},
216234
])
217235

@@ -274,6 +292,7 @@ test('handles null as theme values', () => {
274292
},
275293
base: '/root',
276294
reference: false,
295+
src: undefined,
277296
},
278297
{
279298
config: {
@@ -287,6 +306,7 @@ test('handles null as theme values', () => {
287306
},
288307
base: '/root',
289308
reference: false,
309+
src: undefined,
290310
},
291311
])
292312

packages/tailwindcss/src/compat/container-config.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ test('creates a custom utility to extend the built-in container', async () => {
2727
},
2828
},
2929
base: '/root',
30+
path: '',
3031
}),
3132
})
3233

@@ -85,6 +86,7 @@ test('allows padding to be defined at custom breakpoints', async () => {
8586
},
8687
},
8788
base: '/root',
89+
path: '',
8890
}),
8991
})
9092

@@ -146,6 +148,7 @@ test('allows breakpoints to be overwritten', async () => {
146148
},
147149
},
148150
base: '/root',
151+
path: '',
149152
}),
150153
})
151154

@@ -212,6 +215,7 @@ test('padding applies to custom `container` screens', async () => {
212215
},
213216
},
214217
base: '/root',
218+
path: '',
215219
}),
216220
})
217221

@@ -275,6 +279,7 @@ test("an empty `screen` config will undo all custom media screens and won't appl
275279
},
276280
},
277281
base: '/root',
282+
path: '',
278283
}),
279284
})
280285

@@ -340,6 +345,7 @@ test('legacy container component does not interfere with new --container variabl
340345
},
341346
},
342347
base: '/root',
348+
path: '',
343349
}),
344350
})
345351

@@ -386,6 +392,7 @@ test('combines custom padding and screen overwrites', async () => {
386392
},
387393
},
388394
base: '/root',
395+
path: '',
389396
}),
390397
})
391398

@@ -498,6 +505,7 @@ test('filters out complex breakpoints', async () => {
498505
},
499506
},
500507
base: '/root',
508+
path: '',
501509
}),
502510
})
503511

0 commit comments

Comments
 (0)