From: Evan You Date: Thu, 30 Mar 2023 12:06:11 +0000 (+0800) Subject: refactor(compiler-sfc): remove unnecessary emits type codegen X-Git-Tag: v3.3.0-alpha.7~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5971468e53683d8a54d9cd11f73d0b95c0e0fb7;p=thirdparty%2Fvuejs%2Fcore.git refactor(compiler-sfc): remove unnecessary emits type codegen This is no longer necessary as we no longer recommend type checking generated code --- diff --git a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap index da223439c5..082bfc884d 100644 --- a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap +++ b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap @@ -1388,7 +1388,7 @@ export interface Emits { (e: 'foo' | 'bar'): void } export default /*#__PURE__*/_defineComponent({ emits: [\\"foo\\", \\"bar\\"], - setup(__props, { expose: __expose, emit }: { emit: ({ (e: 'foo' | 'bar'): void }), expose: any, slots: any, attrs: any }) { + setup(__props, { expose: __expose, emit }) { __expose(); @@ -1405,7 +1405,7 @@ export type Emits = { (e: 'foo' | 'bar'): void } export default /*#__PURE__*/_defineComponent({ emits: [\\"foo\\", \\"bar\\"], - setup(__props, { expose: __expose, emit }: { emit: ({ (e: 'foo' | 'bar'): void }), expose: any, slots: any, attrs: any }) { + setup(__props, { expose: __expose, emit }) { __expose(); @@ -1439,7 +1439,7 @@ interface Emits { (e: 'foo' | 'bar'): void } export default /*#__PURE__*/_defineComponent({ emits: [\\"foo\\", \\"bar\\"], - setup(__props, { expose: __expose, emit }: { emit: ({ (e: 'foo' | 'bar'): void }), expose: any, slots: any, attrs: any }) { + setup(__props, { expose: __expose, emit }) { __expose(); @@ -1450,13 +1450,12 @@ return { emit } })" `; -exports[`SFC compile `) assertCode(content) - expect(content).toMatch(`emit: ((e: 'foo' | 'bar') => void),`) expect(content).toMatch(`emits: ["foo", "bar"]`) }) @@ -1437,7 +1436,6 @@ const emit = defineEmits(['a', 'b']) `) assertCode(content) - expect(content).toMatch(`emit: (${type}),`) expect(content).toMatch(`emits: ["foo", "bar", "baz"]`) }) @@ -1449,7 +1447,6 @@ const emit = defineEmits(['a', 'b']) `) assertCode(content) - expect(content).toMatch(`emit: ({ (e: 'foo' | 'bar'): void }),`) expect(content).toMatch(`emits: ["foo", "bar"]`) }) @@ -1461,7 +1458,6 @@ const emit = defineEmits(['a', 'b']) `) assertCode(content) - expect(content).toMatch(`emit: ({ (e: 'foo' | 'bar'): void }),`) expect(content).toMatch(`emits: ["foo", "bar"]`) }) @@ -1475,7 +1471,6 @@ const emit = defineEmits(['a', 'b']) `) assertCode(content) - expect(content).toMatch(`emit: ({ (e: 'foo' | 'bar'): void }),`) expect(content).toMatch(`emits: ["foo", "bar"]`) }) @@ -1487,7 +1482,6 @@ const emit = defineEmits(['a', 'b']) `) assertCode(content) - expect(content).toMatch(`emit: ({ (e: 'foo' | 'bar'): void }),`) expect(content).toMatch(`emits: ["foo", "bar"]`) }) @@ -1499,7 +1493,6 @@ const emit = defineEmits(['a', 'b']) `) assertCode(content) - expect(content).toMatch(`emit: ({ (e: 'foo' | 'bar'): void }),`) expect(content).toMatch(`emits: ["foo", "bar"]`) }) @@ -1511,7 +1504,6 @@ const emit = defineEmits(['a', 'b']) `) assertCode(content) - expect(content).toMatch(`emit: ((e: 'foo' | 'bar') => void),`) expect(content).toMatch(`emits: ["foo", "bar"]`) }) @@ -1523,7 +1515,6 @@ const emit = defineEmits(['a', 'b']) `) assertCode(content) - expect(content).toMatch(`emit: ((e: 'foo' | 'bar') => void),`) expect(content).toMatch(`emits: ["foo", "bar"]`) }) @@ -1536,11 +1527,10 @@ const emit = defineEmits(['a', 'b']) `) assertCode(content) - expect(content).toMatch(`setup(__props, { expose: __expose, emit }) {`) expect(content).toMatch(`emits: ['foo']`) }) - test('defineEmits w/ type (tuple syntax)', () => { + test('defineEmits w/ type (property syntax)', () => { const { content } = compile(`