]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compile-sfc): add symbol judge in prop type checks. (#4594)
authorygj6 <7699524+ygj6@users.noreply.github.com>
Thu, 16 Sep 2021 17:45:55 +0000 (01:45 +0800)
committerGitHub <noreply@github.com>
Thu, 16 Sep 2021 17:45:55 +0000 (13:45 -0400)
fix #4592

packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap
packages/compiler-sfc/__tests__/compileScript.spec.ts
packages/compiler-sfc/src/compileScript.ts

index 29bfc58cddb1c56c4cc0fd36ea28998e18e96ca5..e7ffb34450b7b9c0374fc4b3f0baeeca87f318ac 100644 (file)
@@ -971,6 +971,7 @@ export default /*#__PURE__*/_defineComponent({
     interface: { type: Object, required: true },
     alias: { type: Array, required: true },
     method: { type: Function, required: true },
+    symbol: { type: Symbol, required: true },
     union: { type: [String, Number], required: true },
     literalUnion: { type: String, required: true },
     literalUnionNumber: { type: Number, required: true },
index d3a1282f4c549557906acd0a84e10eb17e1c3778..bd654dfe9ee6e960d364eee326dae1da61d24464 100644 (file)
@@ -706,6 +706,7 @@ const emit = defineEmits(['a', 'b'])
         interface: Test
         alias: Alias
         method(): void
+        symbol: symbol
 
         union: string | number
         literalUnion: 'foo' | 'bar'
@@ -735,6 +736,7 @@ const emit = defineEmits(['a', 'b'])
       expect(content).toMatch(`interface: { type: Object, required: true }`)
       expect(content).toMatch(`alias: { type: Array, required: true }`)
       expect(content).toMatch(`method: { type: Function, required: true }`)
+      expect(content).toMatch(`symbol: { type: Symbol, required: true }`)
       expect(content).toMatch(
         `union: { type: [String, Number], required: true }`
       )
@@ -767,6 +769,7 @@ const emit = defineEmits(['a', 'b'])
         interface: BindingTypes.PROPS,
         alias: BindingTypes.PROPS,
         method: BindingTypes.PROPS,
+        symbol: BindingTypes.PROPS,
         union: BindingTypes.PROPS,
         literalUnion: BindingTypes.PROPS,
         literalUnionNumber: BindingTypes.PROPS,
index 609244232ef2ed65126017f9c7b1b8fb4e7c0001..3cc9705f730428da18867277edc5cde7c906bf24 100644 (file)
@@ -1541,6 +1541,9 @@ function inferRuntimeType(
     case 'TSIntersectionType':
       return ['Object']
 
+    case 'TSSymbolKeyword':
+      return ['Symbol']
+
     default:
       return [`null`] // no runtime check
   }