vuetify icon indicating copy to clipboard operation
vuetify copied to clipboard

Add generics for TreeviewItemFunction and SelectItemKey

Open sirlancelot opened this issue 2 years ago • 0 comments

Description

Add generics for the following types: TreeviewItemFunction and SelectItemKey

Motivation and Context

Current type is unusable due to item being of type object which cannot be cast easily.

How Has This Been Tested?

No tests necessary

Markup:

<template>
  <v-treeview :filter="filterFn" />
</template>

<script>
import { AppMenuItem } from "@/lib/app-menu-item"
import { TreeviewItemFunction } from "vuetify"

export default Vue.extend({
	data: () => ({
		search: "",
	}),
	computed: {
		filterFn(): TreeviewItemFunction<AppMenuItem> {
			const rFilter = new RegExp(this.search, "gi")

			return (item) => rFilter.test(item.displayName)
			//     /\ `item` is properly typed to `AppMenuItem`
		},
	},
})
</script>

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [x] Improvement/refactoring (non-breaking change that doesn't add any features but makes things better)

Checklist:

  • [x] The PR title is no longer than 64 characters.
  • [x] The PR is submitted to the correct branch (master for bug fixes and documentation updates, dev for new features and backwards compatible changes and next for non-backwards compatible changes).
  • [x] My code follows the code style of this project.
  • [x] I've added relevant changes to the documentation (applies to new features and breaking changes in core library)

sirlancelot avatar May 19 '22 00:05 sirlancelot