Skip to content

Commit fcd5422

Browse files
authored
fix(compile-sfc): add symbol judge in prop type checks. (#4594)
fix #4592
1 parent 06c5bf5 commit fcd5422

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,7 @@ export default /*#__PURE__*/_defineComponent({
971971
interface: { type: Object, required: true },
972972
alias: { type: Array, required: true },
973973
method: { type: Function, required: true },
974+
symbol: { type: Symbol, required: true },
974975
union: { type: [String, Number], required: true },
975976
literalUnion: { type: String, required: true },
976977
literalUnionNumber: { type: Number, required: true },

packages/compiler-sfc/__tests__/compileScript.spec.ts

+3
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,7 @@ const emit = defineEmits(['a', 'b'])
706706
interface: Test
707707
alias: Alias
708708
method(): void
709+
symbol: symbol
709710
710711
union: string | number
711712
literalUnion: 'foo' | 'bar'
@@ -735,6 +736,7 @@ const emit = defineEmits(['a', 'b'])
735736
expect(content).toMatch(`interface: { type: Object, required: true }`)
736737
expect(content).toMatch(`alias: { type: Array, required: true }`)
737738
expect(content).toMatch(`method: { type: Function, required: true }`)
739+
expect(content).toMatch(`symbol: { type: Symbol, required: true }`)
738740
expect(content).toMatch(
739741
`union: { type: [String, Number], required: true }`
740742
)
@@ -767,6 +769,7 @@ const emit = defineEmits(['a', 'b'])
767769
interface: BindingTypes.PROPS,
768770
alias: BindingTypes.PROPS,
769771
method: BindingTypes.PROPS,
772+
symbol: BindingTypes.PROPS,
770773
union: BindingTypes.PROPS,
771774
literalUnion: BindingTypes.PROPS,
772775
literalUnionNumber: BindingTypes.PROPS,

packages/compiler-sfc/src/compileScript.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,9 @@ function inferRuntimeType(
15411541
case 'TSIntersectionType':
15421542
return ['Object']
15431543

1544+
case 'TSSymbolKeyword':
1545+
return ['Symbol']
1546+
15441547
default:
15451548
return [`null`] // no runtime check
15461549
}

0 commit comments

Comments
 (0)