From 47b3652ecd4ed7b2361812e6b0dda2a1ea307b6f Mon Sep 17 00:00:00 2001 From: edison Date: Sat, 5 Dec 2020 05:28:26 +0800 Subject: [PATCH] chore(compiler-core): improve types (#2428) --- packages/compiler-core/src/parse.ts | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/packages/compiler-core/src/parse.ts b/packages/compiler-core/src/parse.ts index 63cb285f..bc1d55ea 100644 --- a/packages/compiler-core/src/parse.ts +++ b/packages/compiler-core/src/parse.ts @@ -29,6 +29,13 @@ import { type OptionalOptions = 'isNativeTag' | 'isBuiltInComponent' type MergedParserOptions = Omit, OptionalOptions> & Pick +type AttributeValue = + | { + content: string + isQuoted: boolean + loc: SourceLocation + } + | undefined // The default decoder only provides escapes for characters reserved as part of // the template syntax, and is only used if the custom renderer did not provide @@ -590,13 +597,7 @@ function parseAttribute( advanceBy(context, name.length) // Value - let value: - | { - content: string - isQuoted: boolean - loc: SourceLocation - } - | undefined = undefined + let value: AttributeValue = undefined if (/^[\t\r\n\f ]*=/.test(context.source)) { advanceSpaces(context) @@ -702,15 +703,7 @@ function parseAttribute( } } -function parseAttributeValue( - context: ParserContext -): - | { - content: string - isQuoted: boolean - loc: SourceLocation - } - | undefined { +function parseAttributeValue(context: ParserContext): AttributeValue { const start = getCursor(context) let content: string