Skip to content

Component cannot be inspected when prop has null in type array #1559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
senritsu opened this issue Sep 20, 2021 · 3 comments
Closed

Component cannot be inspected when prop has null in type array #1559

senritsu opened this issue Sep 20, 2021 · 3 comments
Labels

Comments

@senritsu
Copy link

Version

6.0.0-beta.17

Browser and OS info

Chrome 93 / Windows 10

Steps to reproduce

  • Create new vue3 app with typescript
  • Create SFC using the script setup syntactic sugar
  • Declare props using const props = defineProps<{ modelValue: Foo[] | null }>()
  • Open devtools
  • Try to inspect component

What is expected?

Component can be inspected

What is actually happening?

Infinite errors in console

An error occurred in hook inspectComponent

TypeError: Cannot read properties of null (reading 'toString')
    at getPropType (backend.js:4420)
    at backend.js:4418
    at Array.map (<anonymous>)
    at getPropType (backend.js:4418)
    at loop (backend.js:4395)
    at processProps (backend.js:4409)
    at getInstanceState (backend.js:4374)
    at Object.getInstanceDetails (backend.js:4368)
    at backend.js:5231
    at DevtoolsHookable.callHandlers (backend.js:727)

Component inspector panel stays empty.


Using the "old" syntax to defineProps

import type { PropType } from 'vue'

defineProps({
  modelValue: {
    type: Array as PropType<Foo[] | null>,
    required: true
  }
})
// instead of
defineProps<{ modelValue: Foo[] | null }>()

works like expected, but is considerably more verbose.

@Akryum
Copy link
Member

Akryum commented Sep 20, 2021

Please provide an actual runnable reproduction.

On main branch following your reproduction steps:
image

@Akryum Akryum added cannot reproduce We cannot reproduce the problem with the given information. More env information needed. need repro labels Sep 20, 2021
@senritsu
Copy link
Author

I managed to reproduce the issue using a fresh vue-cli typescript project, with minimal setup on top.

https://github.com/senritsu/vue-devtools-issue-reproduction-1559

Same behavior as in the original issue report, same OS/Browser/etc.

image

@Akryum Akryum added bug need team repro We acknowledged your report and will soon try to reproduce it and removed need repro cannot reproduce We cannot reproduce the problem with the given information. More env information needed. labels Sep 22, 2021
@Akryum
Copy link
Member

Akryum commented Sep 22, 2021

This has nothing to to with Typescript, the real issue is inspecting a component with a prop having null in type array:

export default {
  props: {
    foo: {
      type: [Number, null]
    }
  }
}

@Akryum Akryum removed the need team repro We acknowledged your report and will soon try to reproduce it label Sep 22, 2021
@Akryum Akryum changed the title Component cannot be inspected when using defineProps with typescript generic signature Component cannot be inspected when prop has null in type array Sep 22, 2021
@Akryum Akryum closed this as completed in 6ab078a Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants