@@ -234,6 +234,15 @@ describe('transform typescript script setup', () => {
234234 const msg = 1
235235 </script>`
236236
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+ ` )
237246 expect ( await declaration ( src ) ) . toMatchInlineSnapshot ( `
238247 "declare const _default: import("vue").DefineComponent<{
239248 msg: string;
@@ -245,6 +254,11 @@ describe('transform typescript script setup', () => {
245254 ` )
246255
247256 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+ ` )
248262 expect ( await declaration ( `<template><div /></template>` ) ) . toMatchInlineSnapshot ( `
249263 "declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
250264 export default _default;
@@ -424,11 +438,18 @@ describe('transform typescript script setup', () => {
424438 return await readFile ( join ( tmpDir , 'dist/index.vue' ) , 'utf-8' )
425439 }
426440
427- async function declaration ( src : string ) : Promise < string | undefined > {
441+ async function legacyDeclaration ( src : string ) : Promise < string | undefined > {
428442 await rm ( tmpDir , { force : true , recursive : true } )
429443 await mkdir ( join ( tmpDir , 'src' ) , { recursive : true } )
430444 await writeFile ( join ( tmpDir , 'src/index.vue' ) , src )
431445 await mkdist ( { declaration : true , loaders : [ 'js' , vueLoader ] , rootDir : tmpDir } )
432446 return await readFile ( join ( tmpDir , 'dist/index.vue.d.ts' ) , 'utf-8' ) . catch ( ( ) => undefined )
433447 }
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+ }
434455} )
0 commit comments