mirror of https://github.com/vuejs/core.git
fix(compiler-sfc): support global augments with named exports (#13789)
This commit is contained in:
parent
8f6b505051
commit
35da3c6dcb
|
@ -1342,6 +1342,33 @@ describe('resolveType', () => {
|
|||
expect(deps && [...deps]).toStrictEqual(Object.keys(files))
|
||||
})
|
||||
|
||||
test('global types with named exports', () => {
|
||||
const files = {
|
||||
'/global.d.ts': `
|
||||
declare global {
|
||||
export interface ExportedInterface { foo: number }
|
||||
export type ExportedType = { bar: boolean }
|
||||
}
|
||||
export {}
|
||||
`,
|
||||
}
|
||||
|
||||
const globalTypeFiles = { globalTypeFiles: Object.keys(files) }
|
||||
|
||||
expect(
|
||||
resolve(`defineProps<ExportedInterface>()`, files, globalTypeFiles)
|
||||
.props,
|
||||
).toStrictEqual({
|
||||
foo: ['Number'],
|
||||
})
|
||||
|
||||
expect(
|
||||
resolve(`defineProps<ExportedType>()`, files, globalTypeFiles).props,
|
||||
).toStrictEqual({
|
||||
bar: ['Boolean'],
|
||||
})
|
||||
})
|
||||
|
||||
test('global types with ambient references', () => {
|
||||
const files = {
|
||||
// with references
|
||||
|
|
|
@ -1296,9 +1296,14 @@ function recordTypes(
|
|||
}
|
||||
} else if (stmt.type === 'TSModuleDeclaration' && stmt.global) {
|
||||
for (const s of (stmt.body as TSModuleBlock).body) {
|
||||
if (s.type === 'ExportNamedDeclaration' && s.declaration) {
|
||||
// Handle export declarations inside declare global
|
||||
recordType(s.declaration, types, declares)
|
||||
} else {
|
||||
recordType(s, types, declares)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
recordType(stmt, types, declares)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue