From: edison Date: Wed, 1 Feb 2023 09:24:50 +0000 (+0800) Subject: fix(compiler-sfc): support resolving type declaration from normal script (#5831) X-Git-Tag: v3.2.46~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30399d46b15f890056e7a5d076cd588b3806cc15;p=thirdparty%2Fvuejs%2Fcore.git fix(compiler-sfc): support resolving type declaration from normal script (#5831) fix #5830 --- diff --git a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap index 47d401eeea..cbe511f1d0 100644 --- a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap +++ b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap @@ -1446,6 +1446,24 @@ export default /*#__PURE__*/_defineComponent({ +return { emit } +} + +})" +`; + +exports[`SFC compile + + `) + assertCode(content) + }) + // #7111 test('withDefaults (static) w/ production mode', () => { const { content } = compile( @@ -1261,6 +1277,21 @@ const emit = defineEmits(['a', 'b']) expect(content).toMatch(`emits: ["foo", "bar"]`) }) + + test('defineEmits w/ type from normal script', () => { + const { content } = compile(` + + + `) + assertCode(content) + expect(content).toMatch(`emit: ({ (e: 'foo' | 'bar'): void }),`) + expect(content).toMatch(`emits: ["foo", "bar"]`) + }) + test('defineEmits w/ type (type alias)', () => { const { content } = compile(`