fix(types): align Vue fallback declarations
The app and SDK ambient SFC declarations disagreed on indexed props. SDK-first declaration order reproduced all twelve Storybook default-argument errors. Use the same opaque fallback and compile existing stories under both declaration orders as a regression check.
This commit is contained in:
parent
b458e3c3ae
commit
11f9f1b57e
3
packages/vue/src/global.d.ts
vendored
3
packages/vue/src/global.d.ts
vendored
|
|
@ -13,6 +13,7 @@ declare module '*?raw' {
|
|||
declare module '*.vue' {
|
||||
import type { DefineComponent } from 'vue'
|
||||
|
||||
const component: DefineComponent<Record<string, unknown>, Record<string, unknown>, unknown>
|
||||
// Match the app's opaque fallback: an index signature breaks Storybook default-arg inference.
|
||||
const component: DefineComponent<object, object, unknown>
|
||||
export default component
|
||||
}
|
||||
|
|
|
|||
47
tools/lint/tests/vue-module.test.ts
Normal file
47
tools/lint/tests/vue-module.test.ts
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import { expect, test } from 'bun:test'
|
||||
import { execFile } from 'node:child_process'
|
||||
import { mkdtemp, rm, writeFile } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join, resolve } from 'node:path'
|
||||
import { promisify } from 'node:util'
|
||||
|
||||
const execute = promisify(execFile)
|
||||
const root = resolve(import.meta.dir, '../../..')
|
||||
|
||||
test.each(['app-first', 'sdk-first'])(
|
||||
'Vue module declarations preserve Storybook default args (%s)',
|
||||
async (order) => {
|
||||
const directory = await mkdtemp(join(tmpdir(), 'open-pencil-vue-module-'))
|
||||
try {
|
||||
const declarations = [join(root, 'src/env.d.ts'), join(root, 'packages/vue/src/global.d.ts')]
|
||||
if (order === 'sdk-first') declarations.reverse()
|
||||
const project = join(directory, 'tsconfig.json')
|
||||
await writeFile(
|
||||
project,
|
||||
JSON.stringify({
|
||||
extends: join(root, 'tsconfig.json'),
|
||||
include: [],
|
||||
files: [
|
||||
...declarations,
|
||||
join(root, 'src/components/ui/paint/FillSwatchTrigger.stories.ts')
|
||||
]
|
||||
})
|
||||
)
|
||||
const result = await execute(
|
||||
process.execPath,
|
||||
[
|
||||
join(root, 'node_modules/@typescript/native-preview/bin/tsgo'),
|
||||
'--noEmit',
|
||||
'--project',
|
||||
project
|
||||
],
|
||||
{ cwd: root, timeout: 20_000, maxBuffer: 2 * 1024 * 1024 }
|
||||
)
|
||||
expect(result.stdout).toBe('')
|
||||
expect(result.stderr).toBe('')
|
||||
} finally {
|
||||
await rm(directory, { recursive: true, force: true })
|
||||
}
|
||||
},
|
||||
30_000
|
||||
)
|
||||
Loading…
Reference in a new issue