Skip to content

Commit f9357e7

Browse files
authored
TR-13266 Typings for frint (#171)
* typings for frint
1 parent 1defe4e commit f9357e7

File tree

12 files changed

+210
-6
lines changed

12 files changed

+210
-6
lines changed

packages/frint-model/index.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/** Declaration file generated by dts-gen */
2+
3+
import { Observable } from 'rxjs';
4+
5+
export class Model {
6+
constructor(attributes: { [key: string]: any });
7+
8+
get(key: string): any;
9+
10+
get$(key: string): Observable<any>;
11+
12+
set(key: string, value: any);
13+
14+
toJS(): Object;
15+
16+
}
17+
18+
export function createModel<T extends Model>(opts: {[name: string]: any}): Class<T>;

packages/frint-model/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@
3434
"bugs": {
3535
"url": "https://github.com/Travix-International/frint/issues"
3636
},
37-
"license": "MIT"
37+
"license": "MIT",
38+
"types": "index.d.ts"
3839
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { App } from 'frint';
2+
3+
export function renderToString(app: App): string;

packages/frint-react-server/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@
3737
"bugs": {
3838
"url": "https://github.com/Travix-International/frint/issues"
3939
},
40-
"license": "MIT"
40+
"license": "MIT",
41+
"types": "index.d.ts"
4142
}

packages/frint-react/index.d.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { App } from 'frint';
2+
import React, { PropTypes } from 'react';
3+
import { BehaviorSubject, Observable } from 'rxjs';
4+
5+
export class Streamer {
6+
constructor(...args: any[]);
7+
8+
set(value: any, ...args: any[]): Streamer;
9+
10+
setKey(key: string, value: any): Streamer;
11+
12+
setPlainObject(obj: any): Streamer;
13+
14+
setObservable(obj$: Observable<any>, mapper: Array<(item: any, index?: number) => void>): Streamer;
15+
16+
setDispatch(actions: {[name: string]: (...args:any[]) => void}): Streamer;
17+
18+
get$(): Observable<any>;
19+
}
20+
21+
export class RegionService {
22+
constructor();
23+
24+
emit() : void;
25+
26+
getProps$(): BehaviorSubject<any>;
27+
28+
getData$(): Observable<any>;
29+
}
30+
31+
export class Provider extends React.Component<any, any> {
32+
propTypes: PropTypes = {
33+
app: PropTypes.object.isRequired,
34+
children: PropTypes.element.isRequired,
35+
};
36+
37+
childContextTypes: PropTypes = {
38+
app: PropTypes.object.isRequired,
39+
};
40+
41+
getChildContext(): { app: App };
42+
43+
constructor(props: PropTypes, context: any);
44+
45+
render(): React.ReactElement<any>;
46+
}
47+
48+
export function streamProps(...args: any[]): Streamer;
49+
export function isObservable(obj: any): boolean;
50+
export function render(app: App, node: Element): void | Element | React.Component<any, React.ComponentState>;
51+
export function getMountableComponent(app: App): () => React.Component | Element;
52+
export function observe(fn: (app: App) => Observable<any>): () => React.Component | Element;

packages/frint-react/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@
4040
"bugs": {
4141
"url": "https://github.com/Travix-International/frint/issues"
4242
},
43-
"license": "MIT"
43+
"license": "MIT",
44+
"types": "index.d.ts"
4445
}

packages/frint-store/index.d.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { BehaviorSubject, Observable, Subscription } from 'rxjs';
2+
3+
export class StoreOptions {
4+
initialState: any;
5+
thunkArgument: any;
6+
appendAction: boolean;
7+
reducer: (state:any) => any;
8+
enableLogger: boolean;
9+
console: (...args: any[]) => any;
10+
}
11+
12+
export class Store {
13+
constructor(opts: StoreOptions);
14+
15+
options: StoreOptions;
16+
internalState$: BehaviorSubject<any>;
17+
exposedState$: BehaviorSubject<any>;
18+
cachedState: any;
19+
subscription: Subscription;
20+
21+
getState$(): BehaviorSubject<any>;
22+
23+
getState(): any;
24+
25+
disptach(action: string): () => Promise<any> | any;
26+
27+
destroy(): void;
28+
}
29+
30+
export function combineReducers(reducers: (previousState: any, action: string) => any, options:any): (state: any, action: string) => any;
31+
export function createStore(options: any): Class<Store>;

packages/frint-store/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@
3434
"bugs": {
3535
"url": "https://github.com/Travix-International/frint/issues"
3636
},
37-
"license": "MIT"
37+
"license": "MIT",
38+
"types": "index.d.ts"
3839
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export function resetDOM(): void;
2+
export function takeOverConsole(console: () => void): () => void;

packages/frint-test-utils/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@
3333
"bugs": {
3434
"url": "https://github.com/Travix-International/frint/issues"
3535
},
36-
"license": "MIT"
36+
"license": "MIT",
37+
"types": "index.d.ts"
3738
}

0 commit comments

Comments
 (0)