Skip to content

Commit 72f8bc2

Browse files
committed
chore: rebase
1 parent d261c02 commit 72f8bc2

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ exports[`SFC compile <script setup> with TypeScript defineEmits w/ type from nor
14581458
export interface Emits { (e: 'foo' | 'bar'): void }
14591459

14601460
export default /*#__PURE__*/_defineComponent({
1461-
emits: [\\"foo\\", \\"bar\\"],
1461+
emits: ["foo", "bar"],
14621462
setup(__props, { expose, emit }: { emit: ({ (e: 'foo' | 'bar'): void }), expose: any, slots: any, attrs: any }) {
14631463
expose();
14641464

@@ -1791,12 +1791,12 @@ exports[`SFC compile <script setup> with TypeScript withDefaults (static) + norm
17911791

17921792
export default /*#__PURE__*/_defineComponent({
17931793
props: {
1794-
a: { type: String, required: false, default: \\"a\\" }
1794+
a: { type: String, required: false, default: "a" }
17951795
},
17961796
setup(__props: any, { expose }) {
17971797
expose();
17981798

1799-
const props = __props as { a: string }
1799+
const props = __props as { a: string };
18001800

18011801

18021802

packages/compiler-sfc/src/compileScript.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ export interface ImportBinding {
136136
isUsedInTemplate: boolean
137137
}
138138

139-
type FromNormalScript = { __fromNormalScript?: boolean }
140-
141-
type PropsDeclType = (TSTypeLiteral | TSInterfaceBody) & FromNormalScript
142-
143-
type EmitsDeclType = (TSFunctionType | TSTypeLiteral | TSInterfaceBody) & FromNormalScript
139+
type FromNormalScript<T> = T & { __fromNormalScript?: boolean | null }
140+
type PropsDeclType = FromNormalScript<TSTypeLiteral | TSInterfaceBody>
141+
type EmitsDeclType = FromNormalScript<
142+
TSFunctionType | TSTypeLiteral | TSInterfaceBody
143+
>
144144

145145
/**
146146
* Compile `<script setup>`
@@ -669,7 +669,7 @@ export function compileScript(
669669
function resolveQualifiedType(
670670
node: Node,
671671
qualifier: (node: Node) => boolean
672-
): (Node & FromNormalScript)| undefined {
672+
): Node | undefined {
673673
if (qualifier(node)) {
674674
return node
675675
}
@@ -693,7 +693,7 @@ export function compileScript(
693693
filterExtendsType(extendsTypes, bodies)
694694
qualified.body = bodies
695695
}
696-
;(qualified as Node & FromNormalScript).__fromNormalScript =
696+
;(qualified as FromNormalScript<Node>).__fromNormalScript =
697697
scriptAst && i >= scriptSetupAst.body.length
698698
return qualified
699699
}
@@ -1486,7 +1486,9 @@ export function compileScript(
14861486
if (destructureElements.length) {
14871487
args += `, { ${destructureElements.join(', ')} }`
14881488
if (emitsTypeDecl) {
1489-
const content = emitsTypeDecl.__fromNormalScript ? script!.content : scriptSetup.content
1489+
const content = emitsTypeDecl.__fromNormalScript
1490+
? script!.content
1491+
: scriptSetup.content
14901492
args += `: { emit: (${content.slice(
14911493
emitsTypeDecl.start!,
14921494
emitsTypeDecl.end!

0 commit comments

Comments
 (0)