Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 163c6c5

Browse files
committed
upgrade packages and fix type errors
1 parent ba53480 commit 163c6c5

File tree

13 files changed

+1175
-895
lines changed

13 files changed

+1175
-895
lines changed

‎Makefile

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@ docsdir = ./docs/**/*
22
browserify = ./node_modules/.bin/browserify
33
watchify = ./node_modules/.bin/watchify
44
uglify = ./node_modules/.bin/uglifyjs
5+
mocha = ./node_modules/.bin/mocha
6+
tsc = ./node_modules/.bin/tsc
57

68
test: unit integrate
79

8-
build: lib/**/*.js
9-
10-
lib/**/*.js: src/**/*.ts
11-
tsc
12-
13-
lib/%.js: src/%.ts
14-
tsc
10+
build:
11+
${tsc}
1512

1613
all: test dist
1714

@@ -21,7 +18,7 @@ unit: build
2118
yarn test
2219

2320
integrate: build test/*.js docs/src/main/tut/examples/example.js
24-
mocha test/test.js
21+
${mocha} test/test.js
2522

2623
docs/src/main/tut/examples/example.js: docs/src/main/tut/examples/example.tsx
2724
$(browserify) -p [tsify -p tsconfig.examples.json] docs/src/main/tut/examples/example.tsx -o docs/src/main/tut/examples/example.js

‎package.json

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"most": "global:most"
2626
},
2727
"dependencies": {
28-
"prop-types": "^15.5.8",
29-
"reflect-metadata": "^0.1.10"
28+
"prop-types": "^15.6.0",
29+
"reflect-metadata": "^0.1.12"
3030
},
3131
"peerDependencies": {
3232
"@reactivex/rxjs": "^5.4.0",
@@ -35,31 +35,32 @@
3535
"react": "^15.5.4"
3636
},
3737
"devDependencies": {
38-
"@reactivex/rxjs": "^5.4.3",
39-
"@types/jest": "^21.1.0",
40-
"@types/node": "^8.0.0",
38+
"@reactivex/rxjs": "^5.5.6",
39+
"@types/jest": "^22.1.0",
40+
"@types/node": "^9.3.0",
4141
"@types/prop-types": "^15.5.2",
42-
"@types/react": "^16.0.13",
43-
"browserify": "^14.4.0",
42+
"@types/react": "^16.0.34",
43+
"browserify": "^15.2.0",
4444
"browserify-shim": "^3.8.14",
4545
"chai": "^4.1.2",
46-
"create-react-^15.6.0",
46+
"create-react-class": "^15.6.2",
4747
"envify": "^4.1.0",
48-
"enzyme": "^2.8.2",
49-
"jest": "^21.0.0",
48+
"enzyme": "^3.3.0",
49+
"enzyme-adapter-react-16": "^1.1.1",
50+
"jest": "^22.1.4",
5051
"lodash": "^4.0.0",
51-
"mocha": "^4.0.0",
52-
"most": "^1.2.2",
52+
"mocha": "^5.0.0",
53+
"most": "^1.7.2",
5354
"most-subject": "^5.3.0",
5455
"nightmare": "^2.10.0",
55-
"react": "^15.6.1",
56-
"react-dom": "^15.5.4",
57-
"react-test-renderer": "^15.5.4",
56+
"react": "^16.2.0",
57+
"react-dom": "^16.2.0",
58+
"react-test-renderer": "^16.2.0",
5859
"redux": "^3.0.4",
59-
"ts-jest": "^20.0.2",
60-
"tsify": "^3.0.3",
61-
"typescript": "^2.5.2",
62-
"uglify-js": "^3.1.1",
60+
"ts-jest": "^22.0.1",
61+
"tsify": "^3.0.4",
62+
"typescript": "^2.7.1",
63+
"uglify-js": "^3.3.8",
6364
"watchify": "^3.9.0"
6465
},
6566
"jest": {

‎src/__tests__/xtest.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import * as React from 'react';
2-
import { mount } from 'enzyme';
2+
import { mount,configure } from 'enzyme';
33
import '@reactivex/rxjs'
44
import { X, x } from '../index';
55
import * as createClass from 'create-react-class'
66
import * as rx from '../xs/rx'
77
const compose = (f, g) => x => f(g(x));
8-
import {Stream} from '../xs'
8+
import { Stream } from '../xs'
9+
import * as Adapter from 'enzyme-adapter-react-16';
10+
11+
configure({ adapter: new Adapter() });
912

1013
const CounterView: React.SFC<any> = props => (
1114
<div className="counter-view">
@@ -61,19 +64,19 @@ for (let name of Xs) {
6164
let engine, Xtest, mountx
6265
beforeEach(() => {
6366
engine = require(`../xs/${name}`)
64-
Xtest = require(`../xtests/${name}`).default
67+
Xtest = require(`../xtests/`)[name]
6568
mountx = compose(mount, y => React.createFactory(X)({}, y))
6669
})
6770
describe('actions', () => {
6871
let counterWrapper, counter, t, counterView, actions
6972
beforeEach(() => {
7073
counterWrapper = mountx(<Counter />)
71-
counter = counterWrapper.find(Counter).getNode()
74+
counter = counterWrapper.find(Counter).instance()
7275
counterView = counterWrapper.find(CounterView)
7376
actions = counterView.prop('actions')
7477
t = new Xtest(counterView.props());
7578
})
76-
it('add intent to intent$ and go through sink$', () => {
79+
it.only('add intent to intent$ and go through sink$', () => {
7780
return t
7881
.do([
7982
actions.inc,

‎src/fantasy/fantasyx.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ export class FantasyXCartesian implements Cartesian<"FantasyX"> {
237237
return new FantasyX(
238238
FlatMap.State.flatMap(s1$ => (
239239
Functor.State.map(s2$ => (
240-
streamOps.combine((a, b) => Cartesian.State.product(a, b), s1$, s2$)
240+
streamOps.combine((a: any, b: any) => Cartesian.State.product(a, b), s1$, s2$)
241241
), fb.plan)
242242
), fa.plan))
243243
}
@@ -259,7 +259,7 @@ export class FantasyXApply implements Apply<"FantasyX"> {
259259
return new FantasyX(
260260
FlatMap.State.flatMap(s1$ => (
261261
Functor.State.map(s2$ => (
262-
streamOps.combine((s1, s2) => Apply.State.ap(s1, s2), s1$, s2$)
262+
streamOps.combine((s1: any, s2: any) => Apply.State.ap(s1, s2), s1$, s2$)
263263
), fa.plan)
264264
), fab.plan))
265265
}

‎src/fantasy/state.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ declare module './typeclasses' {
1919

2020
@datatype(kind)
2121
export class State<S, A> {
22-
_S: S
23-
_A: A
2422
runState: (s: S) => pair<S, A>
2523
constructor(runState: (s: S) => pair<S, A>) {
2624
this.runState = runState
@@ -50,7 +48,7 @@ export class State<S, A> {
5048
return new State((s: S) => ({ a: undefined, s: Object.assign({}, s, f(s)) }))
5149
}
5250

53-
patch(f: (a: A, s?: S) => Partial<S>): State<S, Partial<S>> {
51+
patch(f: (a: A, s: S) => Partial<S>): State<S, Partial<S>> {
5452
return new State((state: S) => {
5553
let { a, s } = this.runState(state)
5654
let p = f(a, s)

‎src/fantasy/streamT.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { FunctorInstances, map } from './typeclasses/functor'
44

55

66
class StreamT<F extends FunctorInstances, A> {
7-
_F: F
8-
_A: A
97
value: $<F, $<Stream, A>>
108
constructor(v: $<F, $<Stream, A>>) {
119
this.value = v

‎src/fantasy/xstream.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ import { datatype, ,ドル HKT } from './typeclasses'
1313

1414
@datatype('Xstream')
1515
export class Xstream<S extends Stream, I, A> {
16-
_S: S
17-
_V: A
18-
_I: I
1916
streamS: State<$<S, I>, $<S, A>>
2017
constructor(streamS: State<$<S, I>, $<S, A>>) {
2118
this.streamS = streamS
@@ -26,14 +23,14 @@ export class Xstream<S extends Stream, I, A> {
2623
}
2724

2825
static fromIntent<F extends Stream, I>() {
29-
return new Xstream<F, I, I>(new State((intent$: Subject<F, I>) => ({
26+
return new Xstream<F, I, I>(new State((intent$: $<F, I>) => ({
3027
s: intent$,
3128
a: intent$
3229
})))
3330
}
3431

3532
static fromEvent<F extends Stream>(type: string, name: string, defaultValue?: string) {
36-
return new Xstream<F, Event, string>(new State((intent$: Subject<F, Event>) => ({
33+
return new Xstream<F, Event, string>(new State((intent$: $<F, Event>) => ({
3734
s: intent$,
3835
a: streamOps.merge(
3936
typeof defaultValue != 'undefined' ? streamOps.just(defaultValue) : streamOps.empty()
@@ -49,14 +46,14 @@ export class Xstream<S extends Stream, I, A> {
4946
}
5047

5148
static fromPromise<F extends Stream, I, A>(p: Promise<A>) {
52-
return new Xstream<F, I, A>(new State((intent$: Subject<F, I>) => ({
49+
return new Xstream<F, I, A>(new State((intent$: $<F, I>) => ({
5350
s: intent$,
5451
a: streamOps.fromPromise(p)
5552
})))
5653
}
5754

5855
static from<F extends Stream, I, A, G extends FunctorInstances>(p: $<G, A>) {
59-
return new Xstream<F, I, A>(new State((intent$: Subject<F, I>) => ({
56+
return new Xstream<F, I, A>(new State((intent$: $<F, I>) => ({
6057
s: intent$,
6158
a: streamOps.from(p) as $<F, A>
6259
})))
@@ -97,11 +94,11 @@ export class XstreamFunctor implements Functor<"Xstream">{
9794
Functor.Xstream = new XstreamFunctor
9895

9996
export class XstreamCartesian implements Cartesian<"Xstream">{
100-
product<A, B>(fa: Xstream<any,any, A>, fb: Xstream<any,any, B>): Xstream<any,typeoffa._I, [A, B]> {
97+
product<A, B,CextendsStream,D>(fa: Xstream<C,D, A>, fb: Xstream<C,D, B>): Xstream<C,D, [A, B]> {
10198
return new Xstream(
10299
FlatMap.State.flatMap(s1 => (
103100
Functor.State.map(s2 => (
104-
streamOps.combine((a, b) => [a, b], s1, s2)
101+
streamOps.combine<A,B,[A,B]>((a, b) => [a, b], s1, s2)
105102
), fb.streamS)
106103
), fa.streamS))
107104
}

‎src/interfaces.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface Actions<T> {
1010
}
1111

1212
export interface Plan<E extends Stream, I, S> {
13-
(intent: Subject<E, I>, props?: {}): Machine<E, I, S>
13+
(intent: Subject<E, I>, props?: Xprops<I>): Machine<E, I, S>
1414
}
1515

1616
export interface Update<S> {
@@ -43,7 +43,7 @@ export interface XcomponentClass<E extends Stream, I, S> {
4343
displayName: string
4444
contextTypes?: ContextType<E, I, S>
4545
defaultProps?: any
46-
new(props?: Xprops<I>, context?: ContextEngine<E, I, S>): Xcomponent<E, I, S>;
46+
new(props: Xprops<I>, context: ContextEngine<E, I, S>): Xcomponent<E, I, S>;
4747
}
4848

4949
export interface History<E extends Stream, S> {

‎src/x.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@ import { streamOps, Stream, Subject } from './xs'
66
import { Plan, Xcomponent, XcomponentClass, Engine, ContextEngine, XREACT_ENGINE } from './interfaces'
77
export { XREACT_ENGINE }
88

9-
export function isXcomponentClass<E extends Stream, I, S>(ComponentClass: XcomponentClass<E, I, S> | React.ComponentClass<any> | React.SFC<any>): ComponentClass is XcomponentClass<E, I, S> {
10-
return (<XcomponentClass<E, I, S>>ComponentClass).contextTypes == CONTEXT_TYPE;
9+
export function isXcomponentClass<E extends Stream, I, S>(
10+
ComponentClass: any): ComponentClass is XcomponentClass<E, I, S> {
11+
return (ComponentClass).contextTypes == CONTEXT_TYPE;
1112
}
1213
export type XOrReactComponent<E extends Stream, I, S> = XcomponentClass<E, I, S> | React.ComponentClass<S> | React.SFC<S>
1314

14-
export function x<E extends Stream, I, S>(main: Plan<E, I, S>, opts = {}): (WrappedComponent: XOrReactComponent<E, I, S>) => XcomponentClass<E, I, S> {
15-
return function(WrappedComponent: XOrReactComponent<E, I, S>) {
16-
if (isXcomponentClass(WrappedComponent)) {
17-
return extendXComponentClass(WrappedComponent, main)
15+
export function x<E extends Stream, I, S>(main: Plan<E, I, S>, opts = {}): (WrappedComponent: React.ComponentType<S>|XcomponentClass<E, I, S>) => XcomponentClass<E, I, S> {
16+
return function(WrappedComponent: React.ComponentType<S>|XcomponentClass<E, I, S>) {
17+
if (isXcomponentClass<E,I,S>(WrappedComponent)) {
18+
return extendXComponentClass<E,I,S>(WrappedComponent, main)
1819
} else {
19-
return genXComponentClass(WrappedComponent, main, opts)
20+
return genXComponentClass<E,I,S>(WrappedComponent, main, opts)
2021
}
2122
};
2223
}

‎src/xclass.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { createElement as h } from 'react'
33
import * as PropTypes from 'prop-types';
4-
import { Plan, Xcomponent, XcomponentClass, ContextEngine, XREACT_ENGINE, Update, Actions } from './interfaces'
4+
import { Plan, Xcomponent, XcomponentClass, ContextEngine, XREACT_ENGINE, Update, Actions,Xprops } from './interfaces'
55
import { streamOps, Stream, Subject } from './xs'
66

77
export const CONTEXT_TYPE = {
@@ -18,7 +18,7 @@ export function extendXComponentClass<E extends Stream, I, S>(WrappedComponent:
1818
return class XNode extends WrappedComponent {
1919
static contextTypes = CONTEXT_TYPE
2020
static displayName = `X(${getDisplayName(WrappedComponent)})`
21-
constructor(props: S, context: ContextEngine<E, I, S>) {
21+
constructor(props: Xprops<I>, context: ContextEngine<E, I, S>) {
2222
super(props, context);
2323
let engine = context[XREACT_ENGINE]
2424
let { actions, update$ } = main(engine.intent$, props)
@@ -28,12 +28,12 @@ export function extendXComponentClass<E extends Stream, I, S>(WrappedComponent:
2828
}
2929
}
3030
}
31-
export function genXComponentClass<E extends Stream, I, S>(WrappedComponent: React.SFC<S>|React.ComponentClass<S>, main: Plan<E, I, S>, opts?: any): XcomponentClass<E, I, S> {
31+
export function genXComponentClass<E extends Stream, I, S>(WrappedComponent: React.ComponentType<S>, main: Plan<E, I, S>, opts?: any): XcomponentClass<E, I, S> {
3232
return class XLeaf extends Xcomponent<E, I, S> {
3333
static contextTypes = CONTEXT_TYPE
3434
static displayName = `X(${getDisplayName(WrappedComponent)})`
3535
defaultKeys: (keyof S)[]
36-
constructor(props: any, context: ContextEngine<E, I, S>) {
36+
constructor(props: Xprops<I>, context: ContextEngine<E, I, S>) {
3737
super(props, context);
3838
let engine = context[XREACT_ENGINE]
3939
let { actions, update$ } = main(engine.intent$, props)
@@ -43,14 +43,14 @@ export function genXComponentClass<E extends Stream, I, S>(WrappedComponent: Rea
4343
this.machine.actions = bindActions(actions || {}, engine.intent$, this)
4444

4545
this.defaultKeys = WrappedComponent.defaultProps ? (<(keyof S)[]>Object.keys(WrappedComponent.defaultProps)) : [];
46-
this.state=Object.assign(
46+
this.setState(Object.assign(
4747
{},
4848
WrappedComponent.defaultProps,
49-
pick(this.defaultKeys, props)
50-
);
49+
<Pick<S,keyofS>>pick(this.defaultKeys, props)
50+
));
5151
}
5252
componentWillReceiveProps(nextProps: I) {
53-
this.setState(state => Object.assign({}, nextProps, pick(this.defaultKeys, state)));
53+
this.setState((state,props) => Object.assign({}, nextProps, pick(this.defaultKeys, state)));
5454
}
5555
componentDidMount() {
5656
this.subscription = streamOps.subscribe(
@@ -109,7 +109,7 @@ export function genXComponentClass<E extends Stream, I, S>(WrappedComponent: Rea
109109
}
110110
}
111111

112-
function getDisplayName<E extends Stream, I, S>(WrappedComponent: XcomponentClass<E,I,S>|React.SFC<S>|React.ComponentClass<S>) {
112+
function getDisplayName<E extends Stream, I, S>(WrappedComponent: React.ComponentType<S>) {
113113
return WrappedComponent.displayName || WrappedComponent.name || 'X';
114114
}
115115

@@ -137,7 +137,7 @@ function bindActions<E extends Stream, I, S>(actions: Actions<void>, intent$: Su
137137
return _actions;
138138
}
139139
function pick<A>(names: Array<keyof A>, obj: A) {
140-
let result = <Partial<A>>{};
140+
let result = <Pick<A,keyofA>>{};
141141
for (let name of names) {
142142
if (obj[name]) result[name] = obj[name];
143143
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /