解决 store 的一些类型报错

This commit is contained in:
liaoxuezhi 2019-08-13 12:29:28 +08:00
parent 1217402b85
commit 49ed8bf570
6 changed files with 26 additions and 25 deletions

View File

@ -83,6 +83,7 @@
"@types/jest": "^24.0.11",
"@types/jquery": "^3.3.1",
"@types/lodash": "^4.14.76",
"@types/node": "^12.7.1",
"@types/pretty-bytes": "^4.0.0",
"@types/prop-types": "^15.5.2",
"@types/qs": "^6.5.1",
@ -106,6 +107,9 @@
"axios": "0.18.1",
"bce-sdk-js": "^0.2.9",
"bootstrap": "3.4.1",
"copy-to-clipboard": "3.0.8",
"css": "2.2.1",
"es6-symbol": "3.1.1",
"faker": "^4.1.0",
"fis-parser-node-sass": "^1.0.5",
"fis3": "^3.4.41",
@ -131,10 +135,7 @@
"react-testing-library": "6.0.4",
"strip-json-comments": "^2.0.1",
"ts-jest": "^24.0.0",
"typescript": "^3.3.4000",
"css": "2.2.1",
"es6-symbol": "3.1.1",
"copy-to-clipboard": "3.0.8"
"typescript": "^3.3.4000"
},
"jest": {
"testEnvironment": "jsdom",

View File

@ -1741,7 +1741,7 @@ export class HeadCellSearchDropDown extends React.Component<HeadCellSearchProps,
<Overlay
container={popOverContainer || (() => findDOMNode(this))}
placement="left-bottom-left-top right-bottom-right-top"
target={popOverContainer ? () => findDOMNode(this).parentNode : null}
target={popOverContainer ? () => findDOMNode(this)!.parentNode : null}
show
>
<PopOver

View File

@ -74,8 +74,8 @@ export const FormItemStore = types
filteredOptions: types.optional(types.frozen(), []),
})
.views(self => {
function getForm():IFormStore {
return getParent(self, 2) as IFormStore;
function getForm():any {
return getParent(self, 2);
}
function getValue():any {
@ -131,7 +131,7 @@ export const FormItemStore = types
return {
get form():IFormStore {
get form():any {
return getForm();
},

View File

@ -1,8 +1,7 @@
import {
types,
getEnv,
getRoot,
SnapshotIn
Instance,
} from "mobx-state-tree";
import {
extendObject,
@ -25,11 +24,12 @@ export const iRendererStore = types
dialogOpen: false,
dialogData: types.optional(types.frozen(), undefined),
drawerOpen: false,
drawerData: types.optional(types.frozen(), undefined),
drawerData: types.optional(types.frozen(), undefined)
})
.views((self) => {
return {
get parentStore():IIRendererStore | null {
// todo 不能自己引用自己
get parentStore(): any {
return self.parentId && getRoot(self) && (getRoot(self) as IRendererStore).storeType === 'RendererStore'
? (getRoot(self) as IRendererStore).stores.get(self.parentId)
: null;
@ -165,5 +165,5 @@ export const iRendererStore = types
export type IIRendererStore = typeof iRendererStore.Type;
export type SIRendererStore = SnapshotIn<typeof iRendererStore>;
// export type SIRendererStore = typeof iRendererStore.SnapshotType;
export type SIRendererStore = typeof iRendererStore.SnapshotType;
// export type SIRendererStore = typeof iRendererStore.SnapshotType;

View File

@ -23,7 +23,7 @@ export const Item = types
newIndex: types.number
})
.views((self) => ({
get checked() {
get checked():boolean {
return (getParent(self, 2) as IListStore).isSelected(self as IItem);
},
@ -39,19 +39,19 @@ export const Item = types
return self.index !== self.newIndex;
},
get locals() {
get locals():any {
return createObject(
createObject((getParent(self, 2) as IListStore).data, {
index: self.index
}), self.data);
},
get checkable() {
get checkable():boolean {
const table = (getParent(self, 2) as IListStore);
return table && table.itemCheckableOn ? evalExpression(table.itemCheckableOn, (self as IItem).locals) : true;
},
get draggable() {
get draggable():boolean {
const table = (getParent(self, 2) as IListStore);
return table && table.itemDraggableOn ? evalExpression(table.itemDraggableOn, (self as IItem).locals) : true;
}
@ -119,7 +119,7 @@ export const ListStore = iRendererStore
}
return {
get allChecked() {
get allChecked():boolean {
return !!(self.selectedItems.length === (self as IListStore).checkableItems.length && (self as IListStore).checkableItems.length);
},

View File

@ -69,7 +69,7 @@ export const Row = types
depth: types.number// 当前children位于第几层便于使用getParent获取最顶层TableStore
})
.views((self) => ({
get checked() {
get checked():boolean {
return (getParent(self, self.depth * 2) as ITableStore).isSelected(self as IRow);
},
@ -81,7 +81,7 @@ export const Row = types
return Object.keys(self.data).some(key => !isEqual(self.data[key], self.pristine[key]));
},
get expanded() {
get expanded():boolean {
return (getParent(self, self.depth * 2) as ITableStore).isExpanded(self as IRow);
},
@ -89,19 +89,19 @@ export const Row = types
return self.index !== self.newIndex;
},
get locals() {
get locals():any {
return createObject(
createObject((getParent(self, self.depth * 2) as ITableStore).data, {
index: self.index
}), self.data);
},
get checkable() {
get checkable():boolean {
const table = (getParent(self, self.depth * 2) as ITableStore);
return table && table.itemCheckableOn ? evalExpression(table.itemCheckableOn, (self as IRow).locals) : true;
},
get draggable() {
get draggable():boolean {
const table = (getParent(self, self.depth * 2) as ITableStore);
return table && table.itemDraggableOn ? evalExpression(table.itemDraggableOn, (self as IRow).locals) : true;
}
@ -334,7 +334,7 @@ export const TableStore = iRendererStore
return !!self.selectedRows.length;
},
get allChecked() {
get allChecked():boolean {
return !!(self.selectedRows.length === (self as ITableStore).checkableRows.length
&& (self as ITableStore).checkableRows.length);
},