]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore(compiler-core): improve types (#2428)
authoredison <daiwei521@126.com>
Fri, 4 Dec 2020 21:28:26 +0000 (05:28 +0800)
committerGitHub <noreply@github.com>
Fri, 4 Dec 2020 21:28:26 +0000 (16:28 -0500)
packages/compiler-core/src/parse.ts

index 63cb285f2477105301303d28229beca2ed5e3a42..bc1d55eade7453924ae908b63bdd25c2dfa2b8db 100644 (file)
@@ -29,6 +29,13 @@ import {
 type OptionalOptions = 'isNativeTag' | 'isBuiltInComponent'
 type MergedParserOptions = Omit<Required<ParserOptions>, OptionalOptions> &
   Pick<ParserOptions, OptionalOptions>
+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