fix: 修复一些 ts 报错 (#6674)

* fix: 修复一些 ts 报错

* fix: 修复 ts 报错

* fix: 修复 ts 报错
This commit is contained in:
liaoxuezhi 2023-04-21 16:53:40 +08:00 committed by GitHub
parent 6bec8ebf13
commit 16becbfdec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 54 additions and 39 deletions

View File

@ -28,6 +28,9 @@ jobs:
- name: build gh-pages
run: |
npm i --legacy-peer-deps
cd packages/ooxml-viewer
npm i --legacy-peer-deps
cd ../../
npm run build --workspaces
sh deploy-gh-pages.sh
- name: Deploy 🚀

View File

@ -25,6 +25,9 @@ jobs:
- name: test
run: |
npm i --legacy-peer-deps
cd packages/ooxml-viewer
npm i --legacy-peer-deps
cd ../../
npm run build --workspaces
npm test --workspaces
sh deploy-gh-pages.sh

View File

@ -31,6 +31,7 @@ import * as utils from './utils/helper';
import {getEnv} from 'mobx-state-tree';
import {RegisterStore, RendererStore} from './store';
import type {IColumn, IColumn2, IRow, IRow2} from './store';
import {
setDefaultLocale,
getDefaultLocale,
@ -42,8 +43,8 @@ import {
} from './locale';
import type {LocaleProps, TranslateFn} from './locale';
import Scoped, {ScopedComponentType, ScopedContext} from './Scoped';
import type {IScopedContext} from './Scoped';
import Scoped, {ScopedContext} from './Scoped';
import type {ScopedComponentType, IScopedContext} from './Scoped';
import {
classnames,
@ -95,10 +96,12 @@ import LazyComponent from './components/LazyComponent';
import Overlay from './components/Overlay';
import PopOver from './components/PopOver';
import {FormRenderer} from './renderers/Form';
import type {FormHorizontal} from './renderers/Form';
import type {FormHorizontal, FormSchemaBase} from './renderers/Form';
import {enableDebug, promisify, replaceText, wrapFetcher} from './utils/index';
import type {OnEventProps} from './utils/index';
import {valueMap as styleMap} from './utils/style-helper';
import {RENDERER_TRANSMISSION_OMIT_PROPS} from './SchemaRenderer';
import type {IItem} from './store/list';
// @ts-ignore
export const version = '__buildVersion';
@ -179,7 +182,14 @@ export {
RendererConfig,
styleMap,
RENDERER_TRANSMISSION_OMIT_PROPS,
ScopedComponentType
ScopedComponentType,
IItem,
IColumn,
IRow,
IColumn2,
IRow2,
OnEventProps,
FormSchemaBase
};
export function render(

View File

@ -15,7 +15,7 @@ import IFrameBridge from './IFrameBridge';
import {isAlive} from 'mobx-state-tree';
import {findTree} from 'amis-core';
import BackTop from './base/BackTop';
import {RendererConfig} from 'amis-core/lib/factory';
import {RendererConfig} from 'amis-core';
export interface PreviewProps {
// isEditorEnabled?: (

View File

@ -18,8 +18,8 @@ import {createObject} from 'amis-core';
import {CommonConfigWrapper} from './CommonConfigWrapper';
import type {Schema} from 'amis';
import type {DataScope} from 'amis-core';
import type {RendererConfig} from 'amis-core/lib/factory';
import type {SchemaCollection} from 'amis/lib/Schema';
import type {RendererConfig} from 'amis-core';
import type {SchemaCollection} from 'amis';
import {omit} from 'lodash';
// 创建 Node Store 并构建成树

View File

@ -67,7 +67,7 @@ import {EditorDNDManager} from './dnd';
import {VariableManager} from './variable';
import {IScopedContext} from 'amis';
import type {SchemaObject, SchemaCollection} from 'amis/lib/Schema';
import type {RendererConfig} from 'amis-core/lib/factory';
import type {RendererConfig} from 'amis-core';
import isPlainObject from 'lodash/isPlainObject';
import {omit} from 'lodash';

View File

@ -10,9 +10,9 @@ import {EditorDNDManager} from './dnd';
import React from 'react';
import {DiffChange} from './util';
import find from 'lodash/find';
import type {RendererConfig} from 'amis-core/lib/factory';
import type {RendererConfig} from 'amis-core';
import type {MenuDivider, MenuItem} from 'amis-ui/lib/components/ContextMenu';
import type {BaseSchema, SchemaCollection} from 'amis/lib/Schema';
import type {BaseSchema, SchemaCollection} from 'amis';
import {DSFieldGroup} from './builder/DSBuilder';
/**

View File

@ -17,7 +17,7 @@ import {filterSchema} from 'amis';
import React from 'react';
import {EditorStoreType} from './editor';
import findIndex from 'lodash/findIndex';
import type {RendererConfig} from 'amis-core/lib/factory';
import type {RendererConfig} from 'amis-core';
export const EditorNode = types
.model('EditorNode', {

View File

@ -50,7 +50,7 @@ export interface TabsTransferProps
onTabChange: (key: number) => void;
activeKey: number;
onlyChildren?: boolean;
data?: any;
ctx?: Record<string, any>;
}
export interface TabsTransferState {
@ -258,7 +258,7 @@ export class TabsTransfer extends React.Component<
activeKey,
classnames: cx,
translate: __,
data
ctx
} = this.props;
const showOptions = options.filter(item => item.visible !== false);
@ -283,7 +283,7 @@ export class TabsTransfer extends React.Component<
key={index}
title={filter(
option.label || option.title,
createObject(data, option)
createObject(ctx, option)
)}
className="TabsTransfer-tab"
>

View File

@ -9,9 +9,7 @@ import './themes/ang';
import './themes/antd';
import './themes/dark';
import './themes/default';
import {
SchemaEditorItemPlaceholder,
schemaEditorItemPlaceholder
} from './components/schema-editor/Common';
import type {SchemaEditorItemPlaceholder} from './components/schema-editor/Common';
import {schemaEditorItemPlaceholder} from './components/schema-editor/Common';
export {schemaEditorItemPlaceholder, SchemaEditorItemPlaceholder};

View File

@ -127,7 +127,7 @@ import {
SchemaClassName,
SchemaExpression
} from 'amis-core';
import type {FormSchemaBase} from 'amis-core/lib/renderers/Form';
import type {FormSchemaBase} from 'amis-core';
import {MultilineTextSchema} from './renderers/MultilineText';
import {DateRangeSchema} from './renderers/DateRange';
import {PasswordSchema} from './renderers/Password';

View File

@ -2,8 +2,8 @@
* @file api
* @author fex
*/
import {SchemaNode, Schema} from 'amis-core/lib/types';
import {RendererProps, addSchemaFilter} from 'amis-core';
import {Schema} from 'amis-core';
import {addSchemaFilter} from 'amis-core';
import {CheckboxControlRenderer} from './renderers/Form/Checkbox';
import {FormRenderer} from 'amis-core';
import {FieldSetRenderer} from './renderers/Form/FieldSet';
@ -14,7 +14,6 @@ import {getLevelFromClassName} from 'amis-core';
import {FileControlRenderer} from './renderers/Form/InputFile';
import {ImageControlRenderer} from './renderers/Form/InputImage';
import {RichTextControlRenderer} from './renderers/Form/InputRichText';
import isPlainObject from 'lodash/isPlainObject';
import {GridRenderer} from './renderers/Grid';
import {HBoxRenderer} from './renderers/HBox';

View File

@ -154,5 +154,8 @@ import './renderers/OfficeViewer';
import './compat';
import './schemaExtend';
import type {BaseSchema, SchemaCollection} from './Schema';
export * from './renderers/Form/IconPickerIcons';
export * from './renderers/Form/IconSelectStore';
export {BaseSchema, SchemaCollection};

View File

@ -448,7 +448,6 @@ import {generateIcon} from 'amis-core';
import {withBadge} from 'amis-ui';
import {normalizeApi, str2AsyncFunction} from 'amis-core';
import {TooltipWrapper} from 'amis-ui';
import {ICmptAction} from 'amis-core/lib/actions/CmptAction';
// 构造一个假的 React 事件避免可能的报错,主要用于快捷键功能
// 来自 https://stackoverflow.com/questions/27062455/reactjs-can-i-create-my-own-syntheticevent

View File

@ -23,7 +23,7 @@ import {ActionSchema} from './Action';
import {Card} from 'amis-ui';
import {findDOMNode} from 'react-dom';
import {Icon} from 'amis-ui';
import type {IItem} from 'amis-core/lib/store/list';
import type {IItem} from 'amis-core';
export type CardBodyField = SchemaObject & {
/**

View File

@ -27,7 +27,7 @@ import {
} from '../Schema';
import {CardProps, CardSchema} from './Card';
import {Card2Props, Card2Schema} from './Card2';
import type {IItem} from 'amis-core/lib/store/list';
import type {IItem} from 'amis-core';
/**
* Cards

View File

@ -299,7 +299,8 @@ export class TabsTransferRenderer extends BaseTabsTransferRenderer<TabsTransferP
itemHeight,
virtualThreshold,
onlyChildren,
loadingConfig
loadingConfig,
data
} = this.props;
return (
@ -327,6 +328,7 @@ export class TabsTransferRenderer extends BaseTabsTransferRenderer<TabsTransferP
toNumber(itemHeight) > 0 ? toNumber(itemHeight) : undefined
}
virtualThreshold={virtualThreshold}
ctx={data}
/>
<Spinner

View File

@ -42,8 +42,8 @@ import {
} from '../Schema';
import {ActionSchema} from './Action';
import {SchemaRemark} from './Remark';
import type {IItem} from 'amis-core/lib/store/list';
import type {OnEventProps} from 'amis-core/lib/utils/renderer-event';
import type {IItem} from 'amis-core';
import type {OnEventProps} from 'amis-core';
/**
*

View File

@ -1,7 +1,5 @@
import React from 'react';
import {Renderer, RendererProps} from 'amis-core';
import {Api, SchemaNode, Schema, ActionObject} from 'amis-core';
import cx from 'classnames';
import {TooltipWrapper} from 'amis-ui';
import {filter, generateIcon} from 'amis-core';
import {ClassNamesFn, themeable} from 'amis-core';

View File

@ -17,8 +17,8 @@ import {getIcon} from 'amis-ui';
import {generateIcon} from 'amis-core';
import {RootClose} from 'amis-core';
import type {TooltipObject} from 'amis-ui/lib/components/TooltipWrapper';
import {IColumn} from 'amis-core/lib/store/table';
import type {IColumn2} from 'amis-core/lib/store/table2';
import {IColumn} from 'amis-core';
import type {IColumn2} from 'amis-core';
export interface ColumnTogglerProps extends RendererProps {
/**

View File

@ -9,7 +9,7 @@ import {trace, reaction} from 'mobx';
import {createObject, flattenTree} from 'amis-core';
import {LocaleProps} from 'amis-core';
import {ActionSchema} from '../Action';
import type {IColumn, IRow} from 'amis-core/lib/store/table';
import type {IColumn, IRow} from 'amis-core';
export interface TableBodyProps extends LocaleProps {
className?: string;

View File

@ -14,7 +14,7 @@ import ItemActionsWrapper from './ItemActionsWrapper';
import {SchemaTpl} from '../../Schema';
import {Icon} from 'amis-ui';
import type {IColumn, IRow} from 'amis-core/lib/store/table';
import type {IColumn, IRow} from 'amis-core';
export interface TableContentProps extends LocaleProps {
className?: string;

View File

@ -1,6 +1,6 @@
import {observer} from 'mobx-react';
import React from 'react';
import type {IColumn, IRow} from 'amis-core/lib/store/table';
import type {IColumn, IRow} from 'amis-core';
import {RendererProps} from 'amis-core';
import {Action} from '../Action';
import {isClickOnInput, createObject} from 'amis-core';

View File

@ -55,7 +55,7 @@ import ColumnToggler from './ColumnToggler';
import {offset} from 'amis-core';
import {getStyleNumber} from 'amis-core';
import {exportExcel} from './exportExcel';
import type {IColumn, IRow} from 'amis-core/lib/store/table';
import type {IColumn, IRow} from 'amis-core';
import intersection from 'lodash/intersection';
/**

View File

@ -672,7 +672,7 @@ export default class Word {
/**
*
*/
async print() {
async print(): Promise<any> {
const iframe = document.createElement('iframe') as HTMLIFrameElement;
iframe.style.position = 'absolute';
iframe.style.top = '-10000px';

View File

@ -1,7 +1,7 @@
function loadIframeImages(images: HTMLImageElement[]) {
const promises = images.map(image => {
const promises = images.map(async image => {
if (image.src && image.src !== window.location.href) {
return loadIframeImage(image);
await loadIframeImage(image);
}
});