Skip to content

Commit

Permalink
fix: new devtools typings
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Nov 17, 2021
1 parent 8789361 commit f288ca5
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages/vee-validate/src/devtools.ts
@@ -1,11 +1,11 @@
import { App, getCurrentInstance, nextTick, onUnmounted, unref } from 'vue';
import { ComponentInternalInstance, getCurrentInstance, nextTick, onUnmounted, unref } from 'vue';
import {
App,
setupDevtoolsPlugin,
DevtoolsPluginApi,
CustomInspectorNode,
CustomInspectorState,
InspectorNodeTag,
ComponentInstance,
} from '@vue/devtools-api';
import { PrivateFieldContext, PrivateFormContext } from './types';
import { keysOf, normalizeField, setInPath, throttle } from './utils';
Expand All @@ -27,8 +27,8 @@ function installDevtoolsPlugin(app: App) {
}
}

const DEVTOOLS_FORMS: Record<string, PrivateFormContext & { _vm?: ComponentInstance | null }> = {};
const DEVTOOLS_FIELDS: Record<string, PrivateFieldContext & { _vm?: ComponentInstance | null }> = {};
const DEVTOOLS_FORMS: Record<string, PrivateFormContext & { _vm?: ComponentInternalInstance | null }> = {};
const DEVTOOLS_FIELDS: Record<string, PrivateFieldContext & { _vm?: ComponentInternalInstance | null }> = {};

let API: DevtoolsPluginApi<Record<string, any>> | undefined;

Expand All @@ -48,7 +48,7 @@ export function registerFormWithDevTools(form: PrivateFormContext) {
return;
}

installDevtoolsPlugin(app);
installDevtoolsPlugin(app as unknown as App);
}

DEVTOOLS_FORMS[form.formId] = { ...form };
Expand All @@ -69,7 +69,7 @@ export function registerSingleFieldWithDevtools(field: PrivateFieldContext) {
return;
}

installDevtoolsPlugin(app);
installDevtoolsPlugin(app as unknown as App);
}

DEVTOOLS_FIELDS[field.id] = { ...field };
Expand All @@ -96,7 +96,8 @@ const COLORS = {
gray: 0xbbbfca,
};

let SELECTED_NODE: ((PrivateFormContext | PrivateFieldContext) & { _vm?: ComponentInstance | null }) | null = null;
let SELECTED_NODE: ((PrivateFormContext | PrivateFieldContext) & { _vm?: ComponentInternalInstance | null }) | null =
null;

function setupApiHooks(api: DevtoolsPluginApi<Record<string, any>>) {
API = api;
Expand Down Expand Up @@ -323,8 +324,8 @@ function encodeNodeId(form?: PrivateFormContext, field?: PrivateFieldContext, en
}

function decodeNodeId(nodeId: string): {
field?: PrivateFieldContext & { _vm?: ComponentInstance | null };
form?: PrivateFormContext & { _vm?: ComponentInstance | null };
field?: PrivateFieldContext & { _vm?: ComponentInternalInstance | null };
form?: PrivateFormContext & { _vm?: ComponentInternalInstance | null };
type?: 'form' | 'field';
} {
try {
Expand Down

0 comments on commit f288ca5

Please sign in to comment.