core icon indicating copy to clipboard operation
core copied to clipboard

fix: prop value is symbol and invalid type throw error in dev

Open virgosoy opened this issue 2 years ago • 5 comments

Close #8487

Prod env can work but dev doesn't work.

Live Demo: https://sfc.vuejs.org/#__DEV__eNp9Uk1PwzAM/Ssml20SawXcqm4IceGChMSBSy7d6o2ifClOC2jqf8dJP4ZAWlVFec7Lc/zsk3hwLutaFIUoae8bF7bSNNpZH+D5+9FqBwdvNSyyfICRvJgpJ2joYUdoAvQzcQplgZiJX4lZ46FqFd+QBmDPQtYwhYohAGOyuO+v41pXoVquplOPofVmQgCajgUsnlApC2/Wq/pqkW7Fb0o/4D5JSsN/mc8VMgionaoCMgIo32+2p1OUhb4vc0YpOjpQdJVqcSPFLC225ejHQGyMawN0a21rVExkIebElHMacS0G09a6ctkHWcOep4JYNx2QFLMdUrDPEUvxHoKjIs/psI/mf1Bm/THnXeZbExqNGZJe77z9JPQsLMVoRdLIOdihX3s0NXr0lzT/UP/pTlZyKedhOE8OEHfJgarMkS2I5bADe2sogPPWEWziFDQGXyIqU6XJ2fsCKPjGHFl7u1xd6JQMZd10yXOAm9u7YcOdSzrcu9SNfOD8Ml+aaP95LvnR41wO75uneAOv33pn1XIl+h+DFQ92

virgosoy avatar Mar 01 '23 09:03 virgosoy

It's because you defined the prop to be of string type, which is incompatible with symbol, thus failing the prop validation.

const props = defineProps<{
  value?: string
}>()

It would work if you write value?: any instead.

haoqunjiang avatar Jun 05 '24 16:06 haoqunjiang

@sodatea I think this should be reopened, I believe you misunderstood the author's intent.

The type mismatch on the prop was intentional. The problem being fixed here is that the warning message isn't generated correctly.

skirtles-code avatar Jun 05 '24 16:06 skirtles-code

Oops. Sorry. Reopened.

haoqunjiang avatar Jun 05 '24 16:06 haoqunjiang

#8539 seems to be a similar idea.

skirtles-code avatar Jun 23 '24 02:06 skirtles-code

Duplicate of #8539

edison1105 avatar Aug 27 '24 02:08 edison1105