Skip to content
This repository was archived by the owner on Mar 8, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/script-handlers/__tests__/propHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,39 @@ describe('propHandler', () => {
type: { name: 'boolean' },
})
})

it('should still return props with vue-types', () => {
const src = [
'export default {',
' props:{',
' test: VueTypes.shape({',
' line1: String,',
' line2: String,',
' })',
' }',
'}',
].join('\n')
tester(src, {
type: {
func: true,
},
})
})

it('should still return props with prop-types', () => {
const src = [
'export default {',
' props:{',
" test: PropTypes.oneOf(['News', 'Photos'])",
' }',
'}',
].join('\n')
tester(src, {
type: {
func: true,
},
})
})
})

describe('required', () => {
Expand Down
5 changes: 5 additions & 0 deletions src/script-handlers/propHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ export default function propHandler(documentation: Documentation, path: NodePath
} else if (bt.isIdentifier(propValuePath.node)) {
// contents of the prop is it's type
propDescriptor.type = getTypeFromTypePath(propValuePath)
} else {
propDescriptor.type = {
name: recast.print(prop.get('value')).code,
func: true,
}
}
})
} else if (bt.isArrayExpression(propsValuePath.node)) {
Expand Down