Skip to content
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

vue-docgen-api: PropType<T> crashes if not used in prop.type field #1254

Closed
Disorrder opened this issue Jan 11, 2022 · 0 comments
Closed

vue-docgen-api: PropType<T> crashes if not used in prop.type field #1254

Disorrder opened this issue Jan 11, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@Disorrder
Copy link

Discovered this bug when used vue-intellisense which uses vue-docgen-api

Current behavior

It crashes with error

TypeError: Cannot read properties of undefined (reading 'length')
    at NodePath.each (/Users/disorder/Projects/PP/uikit/node_modules/recast/node_modules/ast-types/lib/path.js:72:30)
    at NodePath.filter (/Users/disorder/Projects/PP/uikit/node_modules/recast/node_modules/ast-types/lib/path.js:100:14)
    at /Users/disorder/Projects/PP/uikit/node_modules/vue-docgen-api/dist/script-handlers/propHandler.js:161:50
    at step (/Users/disorder/Projects/PP/uikit/node_modules/vue-docgen-api/dist/script-handlers/propHandler.js:52:23)
    at Object.next (/Users/disorder/Projects/PP/uikit/node_modules/vue-docgen-api/dist/script-handlers/propHandler.js:33:53)
    at /Users/disorder/Projects/PP/uikit/node_modules/vue-docgen-api/dist/script-handlers/propHandler.js:27:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/disorder/Projects/PP/uikit/node_modules/vue-docgen-api/dist/script-handlers/propHandler.js:23:12)
    at /Users/disorder/Projects/PP/uikit/node_modules/vue-docgen-api/dist/script-handlers/propHandler.js:107:99
    at Array.map (<anonymous>)

To reproduce

import { defineComponent, PropType } from 'vue';

type PPIconType = 'name1' | 'name2';

export default defineComponent({
  name: 'test',

  props: {
    icon: String as PropType<PPIconType>, // <--- This is valid Vue syntax, but docgen is not working
    // icon: {
    //   type: String as PropType<PPIconType>, // <--- This is OK
    // },
  }
})

Expected behavior

It should not crash obviously and work like you wrapped type in object

@Disorrder Disorrder changed the title PropType<T> crashes if not used in prop.type field vue-docgen-api: PropType<T> crashes if not used in prop.type field Jan 11, 2022
@elevatebart elevatebart added the bug Something isn't working label Jan 11, 2022
@elevatebart elevatebart added this to todo in vue-docgen-api via automation Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

2 participants