feat: Replace this.$refs.refName as Vue with InstanceType<T> (no-changelog) (#6050)

* refactor: use InstanceType<T> for all this.$refs types

* refactor: update refs type in N8nSelect

* fix: remove inputRef non-null assertion

Co-authored-by: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com>

* fix: remove non-null assertion

---------

Co-authored-by: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com>
This commit is contained in:
Alex Grozav
2023-04-21 16:59:04 +03:00
committed by GitHub
parent 19f540ecf9
commit 54f99a7d0d
41 changed files with 427 additions and 318 deletions

View File

@@ -166,6 +166,8 @@ import { useRootStore } from '@/stores/n8nRootStore';
import { useNDVStore } from '@/stores/ndv';
import { useNodeTypesStore } from '@/stores/nodeTypes';
type ResourceLocatorDropdownRef = InstanceType<typeof ResourceLocatorDropdown>;
interface IResourceLocatorQuery {
results: INodeListSearchItems[];
nextPageToken: unknown;
@@ -407,9 +409,9 @@ export default mixins(debounceHelper, workflowHelpers, nodeHelpers).extend({
watch: {
currentQueryError(curr: boolean, prev: boolean) {
if (this.showResourceDropdown && curr && !prev) {
const input = this.$refs.input;
if (input) {
(input as HTMLElement).focus();
const inputRef = this.$refs.input as HTMLInputElement | undefined;
if (inputRef) {
inputRef.focus();
}
}
},
@@ -445,7 +447,7 @@ export default mixins(debounceHelper, workflowHelpers, nodeHelpers).extend({
},
methods: {
setWidth() {
const containerRef = this.$refs.container as HTMLElement;
const containerRef = this.$refs.container as HTMLElement | undefined;
if (containerRef) {
this.width = containerRef?.offsetWidth;
}
@@ -465,9 +467,9 @@ export default mixins(debounceHelper, workflowHelpers, nodeHelpers).extend({
this.trackEvent('User refreshed resource locator list');
},
onKeyDown(e: MouseEvent) {
const dropdown = this.$refs.dropdown;
if (dropdown && this.showResourceDropdown && !this.isSearchable) {
(dropdown as Vue).$emit('keyDown', e);
const dropdownRef = this.$refs.dropdown as ResourceLocatorDropdownRef | undefined;
if (dropdownRef && this.showResourceDropdown && !this.isSearchable) {
dropdownRef.$emit('keyDown', e);
}
},
openResource(url: string) {