Skip to content

Commit

Permalink
fix(use-table): fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Jan 22, 2021
1 parent 55d4b77 commit c889fb1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 256 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"eslint": "^7.18.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^7.4.1",
"eslint-plugin-vue": "^7.5.0",
"esno": "^0.4.0",
"fs-extra": "^9.1.0",
"husky": "^4.3.8",
Expand All @@ -100,13 +100,13 @@
"stylelint-order": "^4.1.0",
"ts-node": "^9.1.1",
"typescript": "^4.1.3",
"vite": "2.0.0-beta.35",
"vite": "2.0.0-beta.36",
"vite-plugin-html": "^2.0.0-beta.5",
"vite-plugin-mock": "^2.0.0-beta.3",
"vite-plugin-purge-icons": "^0.5.2",
"vite-plugin-pwa": "^0.3.9",
"vite-plugin-style-import": "^0.4.6",
"vue-eslint-parser": "^7.3.0",
"vue-eslint-parser": "^7.4.1",
"yargs": "^16.2.0"
},
"repository": {
Expand Down
12 changes: 8 additions & 4 deletions src/components/Table/src/hooks/useTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ import type { FormActionType } from '/@/components/Form';

type Props = Partial<DynamicProps<BasicTableProps>>;

type UseTableMethod = TableActionType & {
getForm: () => FormActionType;
};

export function useTable(
tableProps?: Props
): [(instance: TableActionType, formInstance: FormActionType) => void, TableActionType] {
): [(instance: TableActionType, formInstance: UseTableMethod) => void, TableActionType] {
isInSetup();

const tableRef = ref<Nullable<TableActionType>>(null);
const loadedRef = ref<Nullable<boolean>>(false);
const formRef = ref<Nullable<FormActionType>>(null);
const formRef = ref<Nullable<UseTableMethod>>(null);

function register(instance: TableActionType, formInstance: FormActionType) {
function register(instance: TableActionType, formInstance: UseTableMethod) {
isProdMode() &&
onUnmounted(() => {
tableRef.value = null;
Expand Down Expand Up @@ -119,7 +123,7 @@ export function useTable(
return getTableInstance().getCacheColumns();
},
getForm: () => {
return unref(formRef) as FormActionType;
return (unref(formRef) as unknown) as FormActionType;
},
setShowPagination: async (show: boolean) => {
getTableInstance().setShowPagination(show);
Expand Down
Loading

0 comments on commit c889fb1

Please sign in to comment.