Skip to content

Commit 472bcf6

Browse files
committed
update typescript to 3.1, cycle/run to 5.1
1 parent 2b085ca commit 472bcf6

File tree

5 files changed

+47
-40
lines changed

5 files changed

+47
-40
lines changed

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@
1818
"typings": "lib/cjs/index.d.ts",
1919
"types": "lib/cjs/index.d.ts",
2020
"dependencies": {
21-
"@cycle/run": "4.x.x",
22-
"react": "16.4.x",
21+
"@cycle/run": "5.x.x",
22+
"react": "16.5.x",
2323
"xstream": "11.x.x"
2424
},
2525
"devDependencies": {
26-
"@cycle/run": "^4.4.0",
27-
"@cycle/isolate": "^3.3.0",
26+
"@cycle/run": "^5.1.0",
27+
"@cycle/isolate": "^4.1.0",
2828
"@types/mocha": "^2.2.40",
2929
"@types/node": "^10.5.2",
3030
"@types/react": "16.4.0",
3131
"mocha": "^5.2.0",
3232
"parcel": "^1.9.4",
3333
"parcel-bundler": "^1.9.6",
34-
"react": "16.4.1",
35-
"react-dom": "^16.4.1",
36-
"react-test-renderer": "16.4.1",
34+
"react": "16.5.2",
35+
"react-dom": "16.5.2",
36+
"react-test-renderer": "16.5.2",
3737
"symbol-observable": "^1.2.0",
3838
"ts-node": "^7.0.0",
39-
"typescript": "^2.9.2",
40-
"xstream": "^11.7.0"
39+
"typescript": "3.1.3",
40+
"xstream": "11.7.0"
4141
},
4242
"publishConfig": {
4343
"access": "public"

src/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import {createContext, Context} from 'react';
22
import {Scope} from './scope';
33

4-
export const ScopeContext = createContext<Scope>(new Scope());
4+
export const ScopeContext: Context<Scope> = createContext<Scope>(new Scope());

src/convert.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ import {
1010
} from 'react';
1111
import {Stream, Subscription} from 'xstream';
1212
import {ScopeContext} from './context';
13-
import {Sources, FantasySinks, Drivers, setup} from '@cycle/run';
13+
import {
14+
Sources,
15+
Drivers,
16+
MatchingDrivers,
17+
MatchingMain,
18+
setup,
19+
} from '@cycle/run';
1420
import {ReactSource} from './ReactSource';
1521
import {StreamRenderer} from './StreamRenderer';
1622

@@ -92,12 +98,12 @@ export function makeCycleReactComponent<P = any>(
9298
}
9399

94100
export function makeComponent<
95-
So extends Sources,
96-
Si extends FantasySinks<Si>,
101+
D extends MatchingDrivers<D, M>,
102+
M extends MatchingMain<D, M>,
97103
P = any
98104
>(
99-
main: (sources: So) => Si,
100-
drivers: Drivers<So, Si> = null as any,
105+
main: MatchingMain<D, M>,
106+
drivers: MatchingDrivers<D, M> = null as any,
101107
channel: string = 'react',
102108
): ComponentType<P> {
103109
if (drivers) {

src/h.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,62 @@
1-
import {createElement} from 'react';
1+
import {createElement, ReactElement, ReactType} from 'react';
22
import {incorporate} from './incorporate';
33

44
export type PropsExtensions = {
55
sel?: string | symbol;
66
};
77

8-
function createElementSpreading<P>(
9-
type: React.ReactType<P>,
8+
function createElementSpreading<P = any>(
9+
type: ReactType<P>,
1010
props: P | null,
11-
children: string | Array<React.ReactElement<any>>,
12-
): React.ReactElement<P> {
11+
children: string | Array<ReactElement<any>>,
12+
): ReactElement<P> {
1313
if (typeof children === 'string') {
1414
return createElement(type, props, children);
1515
} else {
1616
return createElement(type, props, ...children);
1717
}
1818
}
1919

20-
function hyperscriptProps<P>(
21-
type: React.ReactType<P>,
20+
function hyperscriptProps<P = any>(
21+
type: ReactType<P>,
2222
props: P & PropsExtensions,
23-
): React.ReactElement<P> {
23+
): ReactElement<P> {
2424
if (!props.sel) {
2525
return createElement(type, props);
2626
} else {
2727
return createElement(incorporate(type), props);
2828
}
2929
}
3030

31-
function hyperscriptChildren<P>(
32-
type: React.ReactType<P>,
33-
children: string | Array<React.ReactElement<any>>,
34-
): React.ReactElement<P> {
31+
function hyperscriptChildren<P = any>(
32+
type: ReactType<P>,
33+
children: string | Array<ReactElement<any>>,
34+
): ReactElement<P> {
3535
return createElementSpreading(type, null, children);
3636
}
3737

38-
function hyperscriptPropsChildren<P>(
39-
type: React.ReactType<P>,
38+
function hyperscriptPropsChildren<P = any>(
39+
type: ReactType<P>,
4040
props: P & PropsExtensions,
41-
children: string | Array<React.ReactElement<any>>,
42-
): React.ReactElement<P> {
41+
children: string | Array<ReactElement<any>>,
42+
): ReactElement<P> {
4343
if (!props.sel) {
4444
return createElementSpreading(type, props, children);
4545
} else {
4646
return createElementSpreading(incorporate(type), props, children);
4747
}
4848
}
4949

50-
export function h<P>(
51-
type: React.ReactType<P>,
52-
a?: (P & PropsExtensions) | string | Array<React.ReactElement<any>>,
50+
export function h<P = any>(
51+
type: ReactType<P>,
52+
a?: (P & PropsExtensions) | string | Array<ReactElement<any>>,
5353
b?: string | Array<React.ReactElement<any>>,
54-
): React.ReactElement<P> {
54+
): ReactElement<P> {
5555
if (a === undefined && b === undefined) {
5656
return createElement(type, null);
5757
}
5858
if (b === undefined && (typeof a === 'string' || Array.isArray(a))) {
59-
return hyperscriptChildren(type, a);
59+
return hyperscriptChildren(type, a as string | Array<ReactElement<any>>);
6060
}
6161
if (b === undefined && typeof a === 'object' && !Array.isArray(a)) {
6262
return hyperscriptProps(type, a);

test/isolation.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'mocha';
2-
import xs from 'xstream';
2+
import xs, {Stream} from 'xstream';
33
import {createElement, PureComponent} from 'react';
44
import isolate from '@cycle/isolate';
55
import * as renderer from 'react-test-renderer';
@@ -135,12 +135,13 @@ describe('Isolation', function() {
135135
}
136136

137137
function parent(sources: {react: ReactSource}) {
138-
const firstSinks = isolate(firstborn, 'first')(sources);
139-
const secondSinks = isolate(secondborn, 'second')(sources);
138+
type Sinks = {react: Stream<React.ReactElement<any>>};
139+
const firstSinks: Sinks = isolate(firstborn, 'first')(sources);
140+
const secondSinks: Sinks = isolate(secondborn, 'second')(sources);
140141

141142
const vdom$ = xs
142143
.combine(firstSinks.react, secondSinks.react)
143-
.map(([firstChild, secondChild]: [any, any]) =>
144+
.map(([firstChild, secondChild]) =>
144145
h('div', {sel: 'top-most'}, [firstChild, secondChild]),
145146
);
146147

0 commit comments

Comments
 (0)