@@ -234,6 +234,15 @@ describe('transform typescript script setup', () => {
234
234
const msg = 1
235
235
</script>`
236
236
237
+ expect ( await legacyDeclaration ( src ) ) . toMatchInlineSnapshot ( `
238
+ "declare const _default: import("vue").DefineComponent<{
239
+ msg: string;
240
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
241
+ msg: string;
242
+ }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
243
+ export default _default;
244
+ "
245
+ ` )
237
246
expect ( await declaration ( src ) ) . toMatchInlineSnapshot ( `
238
247
"declare const _default: import("vue").DefineComponent<{
239
248
msg: string;
@@ -245,6 +254,11 @@ describe('transform typescript script setup', () => {
245
254
` )
246
255
247
256
expect ( await fixture ( `<template><div /></template>` ) ) . toMatchInlineSnapshot ( `"<template><div /></template>"` )
257
+ expect ( await legacyDeclaration ( `<template><div /></template>` ) ) . toMatchInlineSnapshot ( `
258
+ "declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
259
+ export default _default;
260
+ "
261
+ ` )
248
262
expect ( await declaration ( `<template><div /></template>` ) ) . toMatchInlineSnapshot ( `
249
263
"declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
250
264
export default _default;
@@ -424,11 +438,18 @@ describe('transform typescript script setup', () => {
424
438
return await readFile ( join ( tmpDir , 'dist/index.vue' ) , 'utf-8' )
425
439
}
426
440
427
- async function declaration ( src : string ) : Promise < string | undefined > {
441
+ async function legacyDeclaration ( src : string ) : Promise < string | undefined > {
428
442
await rm ( tmpDir , { force : true , recursive : true } )
429
443
await mkdir ( join ( tmpDir , 'src' ) , { recursive : true } )
430
444
await writeFile ( join ( tmpDir , 'src/index.vue' ) , src )
431
445
await mkdist ( { declaration : true , loaders : [ 'js' , vueLoader ] , rootDir : tmpDir } )
432
446
return await readFile ( join ( tmpDir , 'dist/index.vue.d.ts' ) , 'utf-8' ) . catch ( ( ) => undefined )
433
447
}
448
+ async function declaration ( src : string ) : Promise < string | undefined > {
449
+ await rm ( tmpDir , { force : true , recursive : true } )
450
+ await mkdir ( join ( tmpDir , 'src' ) , { recursive : true } )
451
+ await writeFile ( join ( tmpDir , 'src/index.vue' ) , src )
452
+ await mkdist ( { declaration : true , loaders : [ 'js' , vueLoader ] , rootDir : tmpDir } )
453
+ return await readFile ( join ( tmpDir , 'dist/index.d.vue.ts' ) , 'utf-8' ) . catch ( ( ) => undefined )
454
+ }
434
455
} )
0 commit comments