Skip to content

Commit

Permalink
fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fwouts committed Jan 4, 2024
1 parent 9e912e3 commit 017c779
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions framework-plugins/vue3/src/vue-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
Reader,
} from "@previewjs/vfs";
import { ReaderListeners } from "@previewjs/vfs";
import type { ElementNode } from "@vue/compiler-core";
import type { ElementNode, RootNode } from "@vue/compiler-core";
import { parse } from "@vue/compiler-sfc";
import path from "path";
import ts from "typescript";
Expand Down Expand Up @@ -90,7 +90,7 @@ class VueTypeScriptReader implements Reader {
function convertToTypeScript(vueTemplateSource: string, name: string) {
const parsed = parse(vueTemplateSource);
let pjsSlotsType = "[]";
if (parsed.descriptor.template) {
if (parsed.descriptor.template?.ast) {
const slots = extractSlots(parsed.descriptor.template.ast);
pjsSlotsType = `[${slots
.map((slotName) => JSON.stringify(slotName))
Expand Down Expand Up @@ -191,8 +191,8 @@ function extractDefineComponentArgument(node: ts.Expression): ts.Expression {
return node;
}

function extractSlots(element: ElementNode): string[] {
namedSlot: if (element.tag === "slot") {
function extractSlots(element: RootNode | ElementNode): string[] {
namedSlot: if ("tag" in element && element.tag === "slot") {
let slotName = "default";
for (const prop of element.props) {
if (prop.name === "name" && prop.type === 6 && prop.value) {
Expand Down

0 comments on commit 017c779

Please sign in to comment.