How can a component be created that accepts either json
with jsonParserRules
or jsonUrl
with jsonParserRulesUrl
, but not both? It would be ideal if the IDE could provide a warning when both props are specified.
Example of an Attempt that does not Work
<script setup lang="ts">
type Props = |
{
json: Object
jsonParserRules: Object
jsonUrl?: never
jsonParserRulesUrl?: never
}
|{
json?: never
jsonParserRules?: never
jsonUrl: string
jsonParserRulesUrl: string
}
defineProps<Props>()
</script>
<template>
<pre>some output</pre>
</template>
This approach resulted in an error:
[@vue/compiler-sfc] type argument passed to defineProps() must be a literal type, or a reference to an interface or literal type.