Add type annotations to the tailwind.config.js file (#8493)

* add type annotation to the config by default

* use `@type {import('tailwindcss').Config}` instead
This commit is contained in:
Robin Malfait 2022-06-02 16:44:12 +02:00 • committed by GitHub
parent 64b4e6df7b
commit 4a745439f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 4 additions and 60 deletions

View file

@ -441,46 +441,6 @@ describe('Init command', () => {
// multiple keys in `theme` exists. However it loads `tailwindcss/colors`
// which doesn't exists in this context.
expect((await readOutputFile('../full.config.js')).split('\n').length).toBeGreaterThan(50)
expect(await readOutputFile('../full.config.js')).not.toContain(
`/** @type {import('tailwindcss/types').Config} */`
)
})
test('--types', async () => {
cleanupFile('simple.config.js')
let { combined } = await $(`${EXECUTABLE} init simple.config.js --types`)
expect(combined).toMatchInlineSnapshot(`
"
Created Tailwind CSS config file: simple.config.js
"
`)
expect(await readOutputFile('../simple.config.js')).toContain(
`/** @type {import('tailwindcss/types').Config} */`
)
})
test('--full --types', async () => {
cleanupFile('full.config.js')
let { combined } = await $(`${EXECUTABLE} init full.config.js --full --types`)
expect(combined).toMatchInlineSnapshot(`
"
Created Tailwind CSS config file: full.config.js
"
`)
// Not a clean way to test this. We could require the file and verify that
// multiple keys in `theme` exists. However it loads `tailwindcss/colors`
// which doesn't exists in this context.
expect((await readOutputFile('../full.config.js')).split('\n').length).toBeGreaterThan(50)
expect(await readOutputFile('../full.config.js')).toContain(
`/** @type {import('tailwindcss/types').Config} */`
)
})
test('--postcss', async () => {
@ -513,7 +473,6 @@ describe('Init command', () => {
Options:
-f, --full Initialize a full \`tailwind.config.js\` file
-p, --postcss Initialize a \`postcss.config.js\` file
--types Add TypeScript types for the \`tailwind.config.js\` file
-h, --help Display usage information
`)
)
@ -542,7 +501,6 @@ describe('Init command', () => {
Options:
-f, --full Initialize a full \`tailwind.config.cjs\` file
-p, --postcss Initialize a \`postcss.config.cjs\` file
--types Add TypeScript types for the \`tailwind.config.cjs\` file
-h, --help Display usage information
`)
)
@ -576,10 +534,6 @@ describe('Init command', () => {
// Not a clean way to test this.
expect(await readOutputFile('../tailwind.config.cjs')).toContain('module.exports =')
expect(await readOutputFile('../tailwind.config.cjs')).not.toContain(
`/** @type {import('tailwindcss/types').Config} */`
)
await writeInputFile('../package.json', pkg)
})
})