mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
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...
This commit is contained in:
parent
c7f6303070
commit
22858ac4ae
@ -15,12 +15,15 @@ async function run(
|
||||
candidates = [],
|
||||
optimize = true,
|
||||
}: {
|
||||
loadStylesheet?: (id: string, base: string) => Promise<{ content: string; base: string }>
|
||||
loadStylesheet?: (
|
||||
id: string,
|
||||
base: string,
|
||||
) => Promise<{ content: string; base: string; path: string }>
|
||||
loadModule?: (
|
||||
id: string,
|
||||
base: string,
|
||||
resourceHint: 'plugin' | 'config',
|
||||
) => Promise<{ module: Config | Plugin; base: string }>
|
||||
) => Promise<{ module: Config | Plugin; base: string; path: string }>
|
||||
candidates?: string[]
|
||||
optimize?: boolean
|
||||
},
|
||||
@ -41,6 +44,7 @@ test('can resolve relative @imports', async () => {
|
||||
}
|
||||
`,
|
||||
base: '/root/foo',
|
||||
path: '',
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,6 +71,7 @@ test('can recursively resolve relative @imports', async () => {
|
||||
@import './bar/baz.css';
|
||||
`,
|
||||
base: '/root/foo',
|
||||
path: '',
|
||||
}
|
||||
} else if (base === '/root/foo' && id === './bar/baz.css') {
|
||||
return {
|
||||
@ -76,6 +81,7 @@ test('can recursively resolve relative @imports', async () => {
|
||||
}
|
||||
`,
|
||||
base: '/root/foo/bar',
|
||||
path: '',
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,6 +113,7 @@ let loadStylesheet = async (id: string) => {
|
||||
return {
|
||||
content: exampleCSS,
|
||||
base: '/root',
|
||||
path: '',
|
||||
}
|
||||
}
|
||||
|
||||
@ -415,6 +422,7 @@ test('supports theme(reference) imports', async () => {
|
||||
}
|
||||
`,
|
||||
base: '',
|
||||
path: '',
|
||||
}),
|
||||
candidates: ['text-red-500'],
|
||||
},
|
||||
@ -435,8 +443,9 @@ test('updates the base when loading modules inside nested files', async () => {
|
||||
@plugin './nested-plugin.js';
|
||||
`,
|
||||
base: '/root/foo',
|
||||
path: '',
|
||||
})
|
||||
let loadModule = vi.fn().mockResolvedValue({ base: '', module: () => {} })
|
||||
let loadModule = vi.fn().mockResolvedValue({ base: '', path: '', module: () => {} })
|
||||
|
||||
expect(
|
||||
(
|
||||
@ -464,6 +473,7 @@ test('emits the right base for @source directives inside nested files', async ()
|
||||
@source './nested/**/*.css';
|
||||
`,
|
||||
base: '/root/foo',
|
||||
path: '',
|
||||
})
|
||||
|
||||
let compiler = await compile(
|
||||
@ -488,6 +498,7 @@ test('emits the right base for @source found inside JS configs and plugins from
|
||||
@plugin './nested-plugin.js';
|
||||
`,
|
||||
base: '/root/foo',
|
||||
path: '',
|
||||
})
|
||||
let loadModule = vi.fn().mockImplementation((id: string) => {
|
||||
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
|
||||
plugins: [plugin(() => {}, { content: [pluginGlob] })],
|
||||
} satisfies Config,
|
||||
base: base + '-config',
|
||||
path: '',
|
||||
}
|
||||
} else {
|
||||
let glob = id.includes('nested') ? './nested-plugin/*.html' : './root-plugin/*.html'
|
||||
return {
|
||||
module: plugin(() => {}, { content: [glob] }),
|
||||
base: base + '-plugin',
|
||||
path: '',
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -540,6 +553,7 @@ test('it crashes when inside a cycle', async () => {
|
||||
@import 'foo.css';
|
||||
`,
|
||||
base: '/root',
|
||||
path: '',
|
||||
})
|
||||
|
||||
await expect(
|
||||
@ -568,6 +582,7 @@ test('resolves @reference as `@import "…" reference`', async () => {
|
||||
}
|
||||
`,
|
||||
base: '/root/foo',
|
||||
path: '',
|
||||
}
|
||||
}
|
||||
|
||||
@ -600,6 +615,7 @@ test('resolves `@variant` used as `@custom-variant` inside `@reference`', async
|
||||
}
|
||||
`,
|
||||
base: '/root/foo',
|
||||
path: '',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -353,7 +353,7 @@ function upgradeToFullPluginSupport({
|
||||
// config would otherwise expand into namespaces like `background-color` which
|
||||
// core utilities already read from.
|
||||
applyConfigToTheme(designSystem, resolvedUserConfig, replacedThemeKeys)
|
||||
applyKeyframesToTheme(designSystem, resolvedUserConfig, replacedThemeKeys)
|
||||
applyKeyframesToTheme(designSystem, resolvedUserConfig)
|
||||
|
||||
registerThemeVariantOverrides(resolvedUserConfig, designSystem)
|
||||
registerScreensConfig(resolvedUserConfig, designSystem)
|
||||
|
||||
@ -83,6 +83,7 @@ test('config values can be merged into the theme', () => {
|
||||
},
|
||||
base: '/root',
|
||||
reference: false,
|
||||
src: undefined,
|
||||
},
|
||||
])
|
||||
applyConfigToTheme(design, resolvedConfig, replacedThemeKeys)
|
||||
@ -160,6 +161,8 @@ test('will reset default theme values with overwriting theme values', () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
reference: false,
|
||||
src: undefined,
|
||||
},
|
||||
])
|
||||
applyConfigToTheme(design, resolvedConfig, replacedThemeKeys)
|
||||
@ -189,6 +192,8 @@ test('invalid keys are not merged into the theme', () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
reference: false,
|
||||
src: undefined,
|
||||
},
|
||||
])
|
||||
|
||||
@ -227,6 +232,8 @@ test('converts opacity modifiers from decimal to percentage values', () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
reference: false,
|
||||
src: undefined,
|
||||
},
|
||||
])
|
||||
applyConfigToTheme(design, resolvedConfig, replacedThemeKeys)
|
||||
@ -261,6 +268,7 @@ test('handles setting theme keys to null', async () => {
|
||||
},
|
||||
base: '/root',
|
||||
reference: false,
|
||||
src: undefined,
|
||||
},
|
||||
])
|
||||
applyConfigToTheme(design, resolvedConfig, replacedThemeKeys)
|
||||
|
||||
@ -9,7 +9,7 @@ test('keyframes can be merged into the theme', () => {
|
||||
let theme = new Theme()
|
||||
let design = buildDesignSystem(theme)
|
||||
|
||||
let { resolvedConfig, replacedThemeKeys } = resolveConfig(design, [
|
||||
let { resolvedConfig } = resolveConfig(design, [
|
||||
{
|
||||
config: {
|
||||
theme: {
|
||||
@ -28,9 +28,11 @@ test('keyframes can be merged into the theme', () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
reference: false,
|
||||
src: undefined,
|
||||
},
|
||||
])
|
||||
applyKeyframesToTheme(design, resolvedConfig, replacedThemeKeys)
|
||||
applyKeyframesToTheme(design, resolvedConfig)
|
||||
|
||||
expect(toCss(design.theme.getKeyframes())).toMatchInlineSnapshot(`
|
||||
"@keyframes fade-in {
|
||||
@ -70,7 +72,7 @@ test('will append to the default keyframes with new keyframes', () => {
|
||||
]),
|
||||
)
|
||||
|
||||
let { resolvedConfig, replacedThemeKeys } = resolveConfig(design, [
|
||||
let { resolvedConfig } = resolveConfig(design, [
|
||||
{
|
||||
config: {
|
||||
theme: {
|
||||
@ -91,9 +93,11 @@ test('will append to the default keyframes with new keyframes', () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
reference: false,
|
||||
src: undefined,
|
||||
},
|
||||
])
|
||||
applyKeyframesToTheme(design, resolvedConfig, replacedThemeKeys)
|
||||
applyKeyframesToTheme(design, resolvedConfig)
|
||||
|
||||
expect(toCss(design.theme.getKeyframes())).toMatchInlineSnapshot(`
|
||||
"@keyframes slide-in {
|
||||
|
||||
@ -6,7 +6,6 @@ import { objectToAst } from './plugin-api'
|
||||
export function applyKeyframesToTheme(
|
||||
designSystem: DesignSystem,
|
||||
resolvedConfig: Pick<ResolvedConfig, 'theme'>,
|
||||
replacedThemeKeys: Set<string>,
|
||||
) {
|
||||
for (let rule of keyframesToRules(resolvedConfig)) {
|
||||
designSystem.theme.addKeyframes(rule)
|
||||
|
||||
@ -20,6 +20,8 @@ test('top level theme keys are replaced', () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
reference: false,
|
||||
src: undefined,
|
||||
},
|
||||
{
|
||||
config: {
|
||||
@ -30,6 +32,8 @@ test('top level theme keys are replaced', () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
reference: false,
|
||||
src: undefined,
|
||||
},
|
||||
{
|
||||
config: {
|
||||
@ -40,6 +44,8 @@ test('top level theme keys are replaced', () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
reference: false,
|
||||
src: undefined,
|
||||
},
|
||||
])
|
||||
|
||||
@ -73,6 +79,8 @@ test('theme can be extended', () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
reference: false,
|
||||
src: undefined,
|
||||
},
|
||||
{
|
||||
config: {
|
||||
@ -85,6 +93,8 @@ test('theme can be extended', () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
reference: false,
|
||||
src: undefined,
|
||||
},
|
||||
])
|
||||
|
||||
@ -120,6 +130,8 @@ test('theme keys can reference other theme keys using the theme function regardl
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
reference: false,
|
||||
src: undefined,
|
||||
},
|
||||
{
|
||||
config: {
|
||||
@ -133,6 +145,8 @@ test('theme keys can reference other theme keys using the theme function regardl
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
reference: false,
|
||||
src: undefined,
|
||||
},
|
||||
{
|
||||
config: {
|
||||
@ -145,6 +159,8 @@ test('theme keys can reference other theme keys using the theme function regardl
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
reference: false,
|
||||
src: undefined,
|
||||
},
|
||||
])
|
||||
|
||||
@ -212,6 +228,8 @@ test('theme keys can read from the CSS theme', () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
reference: false,
|
||||
src: undefined,
|
||||
},
|
||||
])
|
||||
|
||||
@ -274,6 +292,7 @@ test('handles null as theme values', () => {
|
||||
},
|
||||
base: '/root',
|
||||
reference: false,
|
||||
src: undefined,
|
||||
},
|
||||
{
|
||||
config: {
|
||||
@ -287,6 +306,7 @@ test('handles null as theme values', () => {
|
||||
},
|
||||
base: '/root',
|
||||
reference: false,
|
||||
src: undefined,
|
||||
},
|
||||
])
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ test('creates a custom utility to extend the built-in container', async () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
path: '',
|
||||
}),
|
||||
})
|
||||
|
||||
@ -85,6 +86,7 @@ test('allows padding to be defined at custom breakpoints', async () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
path: '',
|
||||
}),
|
||||
})
|
||||
|
||||
@ -146,6 +148,7 @@ test('allows breakpoints to be overwritten', async () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
path: '',
|
||||
}),
|
||||
})
|
||||
|
||||
@ -212,6 +215,7 @@ test('padding applies to custom `container` screens', async () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
path: '',
|
||||
}),
|
||||
})
|
||||
|
||||
@ -275,6 +279,7 @@ test("an empty `screen` config will undo all custom media screens and won't appl
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
path: '',
|
||||
}),
|
||||
})
|
||||
|
||||
@ -340,6 +345,7 @@ test('legacy container component does not interfere with new --container variabl
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
path: '',
|
||||
}),
|
||||
})
|
||||
|
||||
@ -386,6 +392,7 @@ test('combines custom padding and screen overwrites', async () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
path: '',
|
||||
}),
|
||||
})
|
||||
|
||||
@ -498,6 +505,7 @@ test('filters out complex breakpoints', async () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
path: '',
|
||||
}),
|
||||
})
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@ test('CSS `--breakpoint-*` merge with JS config `screens`', async () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
path: '',
|
||||
}),
|
||||
})
|
||||
|
||||
@ -115,6 +116,7 @@ test('JS config `screens` extend CSS `--breakpoint-*`', async () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
path: '',
|
||||
}),
|
||||
})
|
||||
|
||||
@ -207,6 +209,7 @@ test('JS config `screens` only setup, even if those match the default-theme expo
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
path: '',
|
||||
}),
|
||||
})
|
||||
|
||||
@ -288,6 +291,7 @@ test('JS config `screens` overwrite CSS `--breakpoint-*`', async () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
path: '',
|
||||
}),
|
||||
})
|
||||
|
||||
@ -389,6 +393,7 @@ test('JS config with `theme: { extends }` should not include the `default-config
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
path: '',
|
||||
}),
|
||||
})
|
||||
|
||||
@ -473,6 +478,7 @@ describe('complex screen configs', () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
path: '',
|
||||
}),
|
||||
})
|
||||
|
||||
@ -553,6 +559,7 @@ describe('complex screen configs', () => {
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
path: '',
|
||||
}),
|
||||
})
|
||||
|
||||
@ -628,6 +635,7 @@ test('JS config `screens` can overwrite default CSS `--breakpoint-*`', async ()
|
||||
},
|
||||
},
|
||||
base: '/root',
|
||||
path: '',
|
||||
}),
|
||||
})
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ import * as ValueParser from './value-parser'
|
||||
|
||||
// Assumption: We already assume that we receive somewhat valid `calc()`
|
||||
// expressions. So we will see `calc(1 + 1)` and not `calc(1+1)`
|
||||
export function constantFoldDeclaration(input: string, rem: number | null): string {
|
||||
export function constantFoldDeclaration(input: string, rem: number | null = null): string {
|
||||
let folded = false
|
||||
let valueAst = ValueParser.parse(input)
|
||||
|
||||
|
||||
@ -41,6 +41,7 @@ test('Utilities can be marked with important', async () => {
|
||||
loadStylesheet: async (id: string, base: string) => ({
|
||||
base,
|
||||
content: '@tailwind utilities;',
|
||||
path: '',
|
||||
}),
|
||||
})
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ const root = process.env.FOLDER || process.cwd()
|
||||
const css = String.raw
|
||||
|
||||
bench('compile', async () => {
|
||||
let scanner = new Scanner({ sources: [{ base: root, pattern: '**/*' }] })
|
||||
let scanner = new Scanner({ sources: [{ base: root, pattern: '**/*', negated: true }] })
|
||||
let candidates = scanner.scan()
|
||||
|
||||
let { build } = await compile(css`
|
||||
|
||||
@ -19,6 +19,7 @@ test('plugin', async () => {
|
||||
})
|
||||
}),
|
||||
base: '/root',
|
||||
path: '',
|
||||
}),
|
||||
})
|
||||
|
||||
@ -49,6 +50,7 @@ test('plugin.withOptions', async () => {
|
||||
}
|
||||
}),
|
||||
base: '/root',
|
||||
path: '',
|
||||
}),
|
||||
})
|
||||
|
||||
|
||||
@ -409,7 +409,7 @@ test('license comments preserve source locations', async ({ expect }) => {
|
||||
})
|
||||
|
||||
test('license comments with new lines preserve source locations', async ({ expect }) => {
|
||||
let { sources, annotations, css } = await run({
|
||||
let { sources, annotations } = await run({
|
||||
input: `/*! some \n comment */`,
|
||||
})
|
||||
|
||||
|
||||
@ -90,7 +90,7 @@ export function createSourceMap({ ast }: { ast: AstNode[] }) {
|
||||
}
|
||||
|
||||
// Get all the indexes from the mappings
|
||||
walk(ast, (node: AstNode) => {
|
||||
walk(ast, (node) => {
|
||||
if (!node.src || !node.dst) return
|
||||
|
||||
let originalSource = sourceTable.get(node.src[0])
|
||||
|
||||
@ -28,7 +28,7 @@ for (let path of paths) {
|
||||
await fs.rm(path.join(root, 'dist'), { recursive: true, force: true })
|
||||
|
||||
Promise.all(
|
||||
[...workspaces.entries()].map(async ([name, { version, dir }]) => {
|
||||
[...workspaces.entries()].map(async ([name, { dir }]) => {
|
||||
function pack() {
|
||||
return new Promise((resolve) => {
|
||||
exec(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user