Browse Source

Pull request #1689: KERNEL-6543 补充遗漏的类型描述

Merge in VISUAL/fineui from ~TELLER/fineui:bugfix to master

* commit 'f41b725aa538582eeba1bda685c3189292674cf5':
  refactor: 补充遗漏的类型描述
  refactor: 整理描述
es6
Teller 4 years ago
parent
commit
2d9783015d
  1. 18
      typescript/core/base.ts
  2. 15
      typescript/core/func/array.ts
  3. 50
      typescript/core/func/date.ts
  4. 17
      typescript/core/func/function.ts
  5. 12
      typescript/core/func/index.ts
  6. 16
      typescript/core/func/number.ts
  7. 25
      typescript/core/func/string.ts
  8. 132
      typescript/core/var.ts
  9. 3
      typescript/index.ts

18
typescript/core/base.ts

@ -261,6 +261,10 @@ export interface _base {
isWindow: (obj: any) => obj is Window; isWindow: (obj: any) => obj is Window;
deepClone: <T>(obj: T) => T;
deepExtend: merge['deepExtend'];
isDeepMatch: (object: any, attrs: any) => boolean; isDeepMatch: (object: any, attrs: any) => boolean;
contains: (obj: any[], target: any, fromIndex?: number) => boolean; contains: (obj: any[], target: any, fromIndex?: number) => boolean;
@ -373,3 +377,17 @@ export interface _base {
getTime: (...args: any[]) => number; getTime: (...args: any[]) => number;
} }
type merge = {
deepExtend<TObject, TSource>(object: TObject, source: TSource): TObject & TSource;
deepExtend<TObject, TSource1, TSource2>(object: TObject, source1: TSource1, source2: TSource2): TObject & TSource1 & TSource2;
deepExtend<TObject, TSource1, TSource2>(object: TObject, source1: TSource1, source2: TSource2): TObject & TSource1 & TSource2;
deepExtend<TObject, TSource1, TSource2, TSource3>(object: TObject, source1: TSource1, source2: TSource2, source3: TSource3): TObject & TSource1 & TSource2 & TSource3;
deepExtend<TObject, TSource1, TSource2, TSource3, TSource4>(object: TObject, source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4): TObject & TSource1 & TSource2 & TSource3 & TSource4;
deepExtend(object: any, ...otherArgs: any[]): any;
}

15
typescript/core/func/array.ts

@ -1,12 +1,5 @@
export type _pushArray = (sArray: any[], array: any[]) => void; export type _array = {
pushArray: (sArray: any[], array: any[]) => void;
export type _pushDistinct = (sArray: any[], obj: any) => void; pushDistinct: (sArray: any[], obj: any) => void;
pushDistinctArray: (sArray: any[], array: any[]) => void;
export type _pushDistinctArray = (sArray: any[], array: any[]) => void;
type _array = {
pushArray: _pushArray;
pushDistinct: _pushDistinct;
pushDistinctArray: _pushDistinctArray;
} }
export default _array;

50
typescript/core/func/date.ts

@ -13,95 +13,81 @@ export type _Date = {
_MD: number[]; _MD: number[];
_OFFSET: number[]; _OFFSET: number[];
} }
export type _date = {
/** /**
* *
*/ */
export type _getTimezone = (date: Date) => string; getTimezone: (date: Date) => string;
/** /**
* *
*/ */
export type _getMonthDays = (date: Date, month: number) => string; getMonthDays: (date: Date, month: number) => number;
/** /**
* *
*/ */
export type _getLastDateOfMonth = (data: Date) => Date; getLastDateOfMonth: (data: Date) => Date;
/** /**
* *
*/ */
export type _getDayOfYear = (data: Date) => number; getDayOfYear: (data: Date) => number;
/** /**
* *
*/ */
export type _getWeekNumber = (data: Date) => number; getWeekNumber: (data: Date) => number;
/** /**
* *
*/ */
export type _getQuarter = (date: Date) => number; getQuarter: (date: Date) => number;
/** /**
* *
*/ */
export type _getOffsetDate = (date: Date, offset: number) => Date; getOffsetDate: (date: Date, offset: number) => Date;
/** /**
* *
*/ */
export type _getOffsetQuarter = (date: Date, n: number) => Date; getOffsetQuarter: (date: Date, n: number) => Date;
/** /**
* *
*/ */
export type _getQuarterStartMonth = (date: Date) => number; getQuarterStartMonth: (date: Date) => number;
/** /**
* *
*/ */
export type _getQuarterStartDate = (date: Date) => number; getQuarterStartDate: (date: Date) => number;
/** /**
* *
*/ */
export type _getQuarterEndDate = (date: Date) => number; getQuarterEndDate: (date: Date) => number;
/** /**
* n个月之前或之后的日期 * n个月之前或之后的日期
*/ */
export type _getOffsetMonth = (date: Date, n: number) => Date; getOffsetMonth: (date: Date, n: number) => Date;
/** /**
* *
*/ */
export type _getWeekStartDate = (date: Date) => Date; getWeekStartDate: (date: Date) => Date;
/** /**
* *
*/ */
export type _getWeekEndDate = (date: Date) => Date; getWeekEndDate: (date: Date) => Date;
/** /**
* *
*/ */
export type _print = (date: Date, str: string) => string; print: (date: Date, str: string) => string;
export type _date = {
getTimezone: _getTimezone;
getMonthDays: _getMonthDays;
getLastDateOfMonth: _getLastDateOfMonth;
getDayOfYear: _getDayOfYear;
getWeekNumber: _getWeekNumber;
getQuarter: _getQuarter;
getOffsetDate: _getOffsetDate;
getOffsetQuarter: _getOffsetQuarter;
getQuarterStartMonth: _getQuarterStartMonth;
getQuarterStartDate: _getQuarterStartDate;
getQuarterEndDate: _getQuarterEndDate;
getOffsetMonth: _getOffsetMonth;
getWeekStartDate: _getWeekStartDate;
getWeekEndDate: _getWeekEndDate;
print: _print;
} }

17
typescript/core/func/function.ts

@ -1,10 +1,12 @@
export type _function = {
/** /**
* *
* @param array * @param array
* @param name * @param name
* @return * @return
*/ */
export type _createDistinctName = (array: any[], name: string) => string; createDistinctName: (array: any[], name: string) => string;
/** /**
* *
@ -12,26 +14,19 @@ export type _createDistinctName = (array: any[], name: string) => string;
* @param keyword * @param keyword
* @param param * @param param
*/ */
export type _getSearchResult = (items: any, keyword: any, param?: string) => { find: any[], match: any[] } getSearchResult: (items: any, keyword: any, param?: string) => { find: any[], match: any[] };
/** /**
* A执行之前执行方法B * A执行之前执行方法B
* @param sFunc A * @param sFunc A
* @param func B * @param func B
*/ */
export type _beforeFunc = (sFunc: Function, func: Function) => Function; beforeFunc: (sFunc: Function, func: Function) => Function;
/** /**
* A执行之后执行方法B * A执行之后执行方法B
* @param sFunc A * @param sFunc A
* @param func B * @param func B
*/ */
export type _afterFunc = (sFunc: Function, func: Function) => Function; afterFunc: (sFunc: Function, func: Function) => Function;
type _function = {
createDistinctName: _createDistinctName;
getSearchResult: _getSearchResult;
beforeFunc: _beforeFunc;
afterFunc: _afterFunc;
} }
export default _function;

12
typescript/core/func/index.ts

@ -1,9 +1,9 @@
import _array from "./array"; import { _array } from "./array";
import _string from "./string"; import { _string } from "./string";
import _number from "./number"; import { _number } from "./number";
import _function from "./function"; import { _function } from "./function";
import { _Date } from "./date"; import { _Date, _date } from "./date";
export interface _func extends _array, _string, _number, _function { export interface _func extends _array, _string, _number, _function, _date {
Date: _Date; Date: _Date;
} }

16
typescript/core/func/number.ts

@ -1,3 +1,4 @@
export type _number = {
/** /**
* *
@ -5,7 +6,7 @@
* @param {Number} arg * @param {Number} arg
* @return {Number} * @return {Number}
*/ */
export type _add = (num: number, arg: number) => number; add: (num: number, arg: number) => number;
/** /**
* *
@ -13,7 +14,7 @@ export type _add = (num: number, arg: number) => number;
* @param {Number} arg * @param {Number} arg
* @return {Number} * @return {Number}
*/ */
export type _sub = (num: number, arg: number) => number; sub: (num: number, arg: number) => number;
/** /**
* *
@ -21,7 +22,7 @@ export type _sub = (num: number, arg: number) => number;
* @param {Number} arg * @param {Number} arg
* @return {Number} * @return {Number}
*/ */
export type _mul = (num: number, arg: number) => number; mul: (num: number, arg: number) => number;
/** /**
* *
@ -29,12 +30,5 @@ export type _mul = (num: number, arg: number) => number;
* @param {Number} arg * @param {Number} arg
* @return {Number} * @return {Number}
*/ */
export type _div = (num: number, arg: number) => number; div: (num: number, arg: number) => number;
type _number = {
add: _add;
sub: _sub;
mul: _mul;
div: _div;
} }
export default _number

25
typescript/core/func/string.ts

@ -1,10 +1,12 @@
export type _string = {
/** /**
* *
* @param str source字符串 * @param str source字符串
* @param {String} startTag * @param {String} startTag
* @return {Boolean} truefalse * @return {Boolean} truefalse
*/ */
export type _startWith = (str: string, startTag: string) => boolean; startWith: (str: string, startTag: string) => boolean;
/** /**
* *
@ -12,7 +14,7 @@ export type _startWith = (str: string, startTag: string) => boolean;
* @param {String} endTag * @param {String} endTag
* @return {Boolean} truefalse * @return {Boolean} truefalse
*/ */
export type _endWith = (str: string, endTag: string) => boolean; endWith: (str: string, endTag: string) => boolean;
/** /**
* url中指定名字的参数 * url中指定名字的参数
@ -20,7 +22,7 @@ export type _endWith = (str: string, endTag: string) => boolean;
* @param {String} name * @param {String} name
* @return {String} * @return {String}
*/ */
export type _getQuery = (str: string, name: string) => string|null; getQuery: (str: string, name: string) => string|null;
/** /**
* url加上给定的参数 * url加上给定的参数
@ -28,7 +30,7 @@ export type _getQuery = (str: string, name: string) => string|null;
* @param {Object} paras * @param {Object} paras
* @return {String} url * @return {String} url
*/ */
export type _appendQuery = (str: string, paras: {[key: string]: string|number}) => string; appendQuery: (str: string, paras: {[key: string]: string|number}) => string;
/** /**
* *
@ -37,7 +39,7 @@ export type _appendQuery = (str: string, paras: {[key: string]: string|number})
* @param {String} s2 * @param {String} s2
* @returns {String} * @returns {String}
*/ */
export type _replaceAll = (str: string, s1: string, s2: string) => string; replaceAll: (str: string, s1: string, s2: string) => string;
/** /**
* *
@ -45,7 +47,7 @@ export type _replaceAll = (str: string, s1: string, s2: string) => string;
* @param {String} start * @param {String} start
* @returns {String} * @returns {String}
*/ */
export type _perfectStart = (str: string, start: string) => string; perfectStart: (str: string, start: string) => string;
/** /**
* *
@ -53,14 +55,5 @@ export type _perfectStart = (str: string, start: string) => string;
* @param {String} sub * @param {String} sub
* @return {Number[]} * @return {Number[]}
*/ */
export type _allIndexOf = (str: string, sub: string) => number[]; allIndexOf: (str: string, sub: string) => number[];
type _string = {
startWith: _startWith;
endWith: _endWith;
getQuery: _getQuery;
appendQuery: _appendQuery;
replaceAll: _replaceAll;
perfectStart: _perfectStart;
allIndexOf: _allIndexOf;
} }
export default _string

132
typescript/core/var.ts

@ -0,0 +1,132 @@
export interface _var {
MAX: number;
MIN: number;
EVENT_RESPONSE_TIME: number;
zIndex_layer: number;
zIndex_popover: number;
zIndex_popup: number;
zIndex_masker: number;
zIndex_tip: number;
emptyStr: string;
emptyFn: Function;
empty: null,
Key: {
48: string;
49: string;
50: string;
51: string;
52: string;
53: string;
54: string;
55: string;
56: string;
57: string;
65: string;
66: string;
67: string;
68: string;
69: string;
70: string;
71: string;
72: string;
73: string;
74: string;
75: string;
76: string;
77: string;
78: string;
79: string;
80: string;
81: string;
82: string;
83: string;
84: string;
85: string;
86: string;
87: string;
88: string;
89: string;
90: string;
96: string;
97: string;
98: string;
99: string;
100: string;
101: string;
102: string;
103: string;
104: string;
105: string;
106: string;
107: string;
109: string;
110: string;
111: string;
},
KeyCode: {
BACKSPACE: number;
COMMA: number;
DELETE: number;
DOWN: number;
END: number;
ENTER: number;
ESCAPE: number;
HOME: number;
LEFT: number;
NUMPAD_ADD: number;
NUMPAD_DECIMAL: number;
NUMPAD_DIVIDE: number;
NUMPAD_ENTER: number;
NUMPAD_MULTIPLY: number;
NUMPAD_SUBTRACT: number;
PAGE_DOWN: number;
PAGE_UP: number;
PERIOD: number;
RIGHT: number;
SPACE: number;
TAB: number;
UP: number;
},
Status: {
SUCCESS: number;
WRONG: number;
START: number;
END: number;
WAITING: number;
READY: number;
RUNNING: number;
OUTOFBOUNDS: number;
NULL: number;
},
Direction: {
Top: string;
Bottom: string;
Left: string;
Right: string;
Custom: string;
},
Axis: {
Vertical: string;
Horizontal: string;
},
Selection: {
Default: number;
None: number;
Single: number;
Multi: number;
All: number;
},
HorizontalAlign: {
Left: string;
Right: string;
Center: string;
Stretch: string;
},
VerticalAlign: {
Middle: string;
Top: string;
Bottom: string;
Stretch: string;
},
StartOfWeek: number;
}

3
typescript/index.ts

@ -36,6 +36,7 @@ import * as decorator from "./core/decorator/decorator";
import { _func } from "./core/func"; import { _func } from "./core/func";
import { _i18n } from "./core/i18n"; import { _i18n } from "./core/i18n";
import { _Plugin } from "./core/plugin"; import { _Plugin } from "./core/plugin";
import { _var } from "./core/var";
import { OB, _OB } from "./core/ob"; import { OB, _OB } from "./core/ob";
import { _Widget, _WidgetStatic, Widget } from "./core/widget"; import { _Widget, _WidgetStatic, Widget } from "./core/widget";
import { _inject } from "./core/inject"; import { _inject } from "./core/inject";
@ -146,7 +147,7 @@ type ClassConstructor<T extends {}> = T & {
readonly xtype: string; readonly xtype: string;
} }
export interface BI extends _func, _i18n, _base, _inject { export interface BI extends _func, _i18n, _base, _inject, _var {
OB: ClassConstructor<_OB>; OB: ClassConstructor<_OB>;
Plugin: _Plugin; Plugin: _Plugin;
Widget: ClassConstructor<_Widget> & _WidgetStatic; Widget: ClassConstructor<_Widget> & _WidgetStatic;

Loading…
Cancel
Save