Skip to content

Commit

Permalink
fix: remove excluded props types from child components (#3657)
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ksem authored Aug 3, 2023
1 parent fdef6ac commit 66c8cbd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions packages/ui/src/components/va-rating/VaRating.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,19 @@ import { useComponentPresetProp } from '../../composables/useComponentPreset'
import VaRatingItem from './components/VaRatingItem/VaRatingItem.vue'
import VaRatingItemNumberButton from './components/VaRatingItemNumberButton.vue'
const VaRatingItemProps = extractComponentProps(VaRatingItem)
const VaRatingItemProps = extractComponentProps(VaRatingItem, ['modelValue', 'itemNumber'])
const VaRatingItemNumberButtonProps = extractComponentProps(VaRatingItemNumberButton, ['modelValue', 'itemNumber'])
export default defineComponent({
name: 'VaRating',
props: {
...VaRatingItemNumberButtonProps,
...useRatingProps,
...useVaRatingColorsProps,
...useFormFieldProps,
...VaRatingItemProps,
...VaRatingItemNumberButtonProps,
...useComponentPresetProp,
modelValue: { type: Number, default: 0 },
numbers: { type: Boolean, default: false },
halves: { type: Boolean, default: false },
max: { type: Number, default: 5 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { getComponentProps } from './resolve-component-props'
* }
* ```
*/
export function extractComponentProps<T extends DefineComponentOptions> (component: T, ignoreProps?: string[]): ExtractComponentProps<T> {
export function extractComponentProps<T extends DefineComponentOptions, IgnoreProps extends string = ''> (component: T, ignoreProps?: IgnoreProps[]): Omit<ExtractComponentProps<T>, IgnoreProps> {
const props: any = getComponentProps(component as any)

// TODO: Not sure if it is a good idea to handle ignore props here
Expand All @@ -25,7 +25,7 @@ export function extractComponentProps<T extends DefineComponentOptions> (compone
return Object
.keys(props)
.reduce<any>((acc, propName) => {
if (ignoreProps.includes(propName)) { return acc }
if (ignoreProps.includes(propName as unknown as IgnoreProps)) { return acc }

if (props[propName] === undefined) { return acc }

Expand Down
5 changes: 4 additions & 1 deletion packages/ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
"src/**/*.spec.disabled.ts",
"src/components/wip-*/**.*",
"src/services/api-docs",
"src/**/*.demo.vue"
"src/**/*.demo.vue",
"src/**/*.stories.ts",
"src/**/*.new.stories.ts",
".storybook",
]
}

0 comments on commit 66c8cbd

Please sign in to comment.