chore: bump detypes (#548)

* chore: bump detypes

* test: update snapshot

* test: add test to check all type references

---------

Co-authored-by: zernonia <zernonia@gmail.com>
This commit is contained in:
Dunqing 2024-05-21 13:12:12 +08:00 committed by GitHub
parent 61dcd63ef2
commit 175762a959
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 1906 additions and 2134 deletions

View File

@ -42,6 +42,7 @@
"pub:next": "pnpm build && pnpm publish --no-git-checks --access public --tag next",
"pub:release": "pnpm build && pnpm publish --no-git-checks --access public",
"test": "vitest run",
"test:update": "vitest run -u",
"test:ui": "vitest --ui"
},
"peerDependencies": {
@ -55,7 +56,7 @@
"c12": "^1.10.0",
"commander": "^12.0.0",
"consola": "^3.2.3",
"detype": "npm:detypes@^0.7.9",
"detype": "npm:detypes@^0.8.0",
"diff": "^5.2.0",
"fs-extra": "^11.2.0",
"https-proxy-agent": "^7.0.4",

View File

@ -3,20 +3,44 @@
exports[`transform css vars 1`] = `
"<script setup lang="ts"></script>
<template>
<div class="bg-background hover:bg-muted text-primary-foreground sm:focus:text-accent-foreground">foo</div>
</template>""
<div
class="bg-background hover:bg-muted text-primary-foreground sm:focus:text-accent-foreground"
>
foo
</div>
</template>
"
"
`;
exports[`transform css vars 2`] = `
"<script setup lang="ts"></script>
<template>
<div class="bg-white hover:bg-stone-100 text-stone-50 sm:focus:text-stone-900 dark:bg-stone-950 dark:hover:bg-stone-800 dark:text-stone-900 dark:sm:focus:text-stone-50">foo</div>
</template>""
<div
class="bg-white hover:bg-stone-100 text-stone-50 sm:focus:text-stone-900 dark:bg-stone-950 dark:hover:bg-stone-800 dark:text-stone-900 dark:sm:focus:text-stone-50"
>
foo
</div>
</template>
"
"
`;
exports[`transform css vars 3`] = `
"<script setup lang="ts"></script>
<template>
<div :class="cn('bg-white hover:bg-stone-100 dark:bg-stone-950 dark:hover:bg-stone-800', true && 'text-stone-50 sm:focus:text-stone-900 dark:text-stone-900 dark:sm:focus:text-stone-50')">foo</div>
</template>""
<div
:class="
cn(
'bg-white hover:bg-stone-100 dark:bg-stone-950 dark:hover:bg-stone-800',
true &&
'text-stone-50 sm:focus:text-stone-900 dark:text-stone-900 dark:sm:focus:text-stone-50',
)
"
>
foo
</div>
</template>
"
"
`;

View File

@ -1,33 +1,22 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`transform import 1`] = `
"import { Foo } from "bar"
import { Button } from "@/components/ui/button"
import { Label} from "ui/label"
import { Box } from "@/components/box"
import { cn } from "@/lib/utils"
"
"import { Foo } from "bar" import { Button } from "@/components/ui/button" import
{ Label} from "ui/label" import { Box } from "@/components/box" import { cn }
from "@/lib/utils"
"
`;
exports[`transform import 2`] = `
"import { Foo } from "bar"
import { Button } from "~/src/components/ui/button"
import { Label} from "ui/label"
import { Box } from "~/src/components/box"
import { cn, foo, bar } from "~/lib"
import { bar } from "@/lib/utils/bar"
"
"import { Foo } from "bar" import { Button } from "~/src/components/ui/button"
import { Label} from "ui/label" import { Box } from "~/src/components/box"
import { cn, foo, bar } from "~/lib" import { bar } from "@/lib/utils/bar"
"
`;
exports[`transform import 3`] = `
"import { Foo } from "bar"
import { Button } from "~/src/components/ui/button"
import { Label} from "ui/label"
import { Box } from "~/src/components/box"
import { cn } from "~/src/utils"
import { bar } from "@/lib/utils/bar"
"
"import { Foo } from "bar" import { Button } from "~/src/components/ui/button"
import { Label} from "ui/label" import { Box } from "~/src/components/box"
import { cn } from "~/src/utils" import { bar } from "@/lib/utils/bar"
"
`;

View File

@ -36,7 +36,6 @@ const props = defineProps({
a: { type: String, required: true },
b: { type: Number, required: true },
});
export {};
</script>
"
`;
@ -49,7 +48,6 @@ const props = defineProps({
asChild: { type: Boolean, required: false },
as: { type: null, required: false },
});
export {};
</script>
"
`;
@ -62,3 +60,27 @@ const props = defineProps({
</script>
"
`;
exports[`transformSFC > remove all type reference 1`] = `
"<script setup>
const array = [1, 2, 3];
</script>
<template>
<div
v-bind="{ array }"
:prop="(a) => a"
:prop2="
(a) => {
let b = a;
return b;
}
"
>
{{ true ? 123 : 0 }}
</div>
</template>
<style scoped></style>
"
`;

View File

@ -24,6 +24,30 @@ describe('transformSFC', () => {
expect(result).toMatchSnapshot()
})
it('remove all type reference', async () => {
const result = await transform({
filename: 'app.vue',
raw: `<script lang="ts" setup>
const array: (number | string)[] = [1, 2, 3]
</script>
<template>
<div v-bind="{ array }" :prop="(a: number) => a" :prop2="(a: number) => {
let b: number = a
return b
}">
{{ true ? 123 as number : 0 }}
</div>
</template>
<style scoped>
</style>
`,
config: {},
})
expect(result).toMatchSnapshot()
})
it('defineProps', async () => {
const result = await transform({
filename: 'app.vue',

File diff suppressed because it is too large Load Diff