From 15e25291c66c4076ed9dcdb0b2f2632c3bcd2c85 Mon Sep 17 00:00:00 2001 From: ZHAO Jinxiang Date: Wed, 10 Nov 2021 17:48:54 +0800 Subject: [PATCH] fix: support for type alias, close #62 --- src/core/macros.ts | 3 -- test/__snapshots__/transform.test.ts.snap | 34 +++++++++++++++++++++-- test/fixtures/MacrosType4.vue | 7 +++++ 3 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 test/fixtures/MacrosType4.vue diff --git a/src/core/macros.ts b/src/core/macros.ts index 1feea44..951c32d 100644 --- a/src/core/macros.ts +++ b/src/core/macros.ts @@ -220,9 +220,6 @@ export function applyMacros(nodes: Statement[]) { return t.objectExpression( Object.entries(props).map(([key, value]) => { - if (value.type === 'null') - return t.objectProperty(t.identifier(key), t.nullLiteral()) - const prop = hasStaticDefaults ? (propsRuntimeDefaults as ObjectExpression).properties.find((node: any) => node.key.name === key) as ObjectProperty : undefined diff --git a/test/__snapshots__/transform.test.ts.snap b/test/__snapshots__/transform.test.ts.snap index d7abd93..fafc642 100644 --- a/test/__snapshots__/transform.test.ts.snap +++ b/test/__snapshots__/transform.test.ts.snap @@ -369,7 +369,11 @@ __sfc_main.props = { required: false, type: Array }, - any: null + any: { + key: \\"any\\", + required: true, + type: null + } }; __sfc_main.setup = (__props, __ctx) => { @@ -426,6 +430,28 @@ export default __sfc_main; " `; +exports[`transform fixtures test/fixtures/MacrosType4.vue 1`] = ` +" +" +`; + exports[`transform fixtures test/fixtures/MacrosTypeAny.vue 1`] = ` "