Movatterモバイル変換


[0]ホーム

URL:


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

Commit3078292

Browse files
committed
#000 okan switch awasome-typescript-loader to ts-loader and remove typings library
1 parentf4df075 commit3078292

File tree

12 files changed

+1810
-62
lines changed

12 files changed

+1810
-62
lines changed

‎.vscode/settings.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"typescript.tsdk":"./node_modules/typescript/lib"
3+
}

‎package.json‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"redux-ts",
3-
"version":"2.3.1",
3+
"version":"2.4.0",
44
"description":"Utils to define redux reducer/action in typescript",
55
"main":"lib/index.js",
66
"typings":"lib/src/index.d.ts",
@@ -23,9 +23,8 @@
2323
"build:test":"cross-env NODE_ENV=test webpack --output-filename lib/specs.js",
2424
"clean":"rimraf dist lib",
2525
"build":"npm run build:dev && npm run build:prod && npm run build:prod:min",
26-
"postinstall":"typings install",
2726
"prepublish":"npm run clean && npm run build && npm run test",
28-
"test":"npm run build:test && npm run test:run",
27+
"test":"npm runclean && npm runbuild:test && npm run test:run",
2928
"test:run":"mocha --require source-map-support/register ./lib/specs.js"
3029
},
3130
"tags": [
@@ -55,15 +54,16 @@
5554
"ts-helpers":"^1.1.1"
5655
},
5756
"devDependencies": {
58-
"awesome-typescript-loader":"2.1.1",
57+
"@types/chai":"^3.4.34",
58+
"@types/mocha":"^2.2.33",
5959
"chai":"^3.5.0",
6060
"cross-env":"^2.0.1",
6161
"glob":"^7.0.6",
6262
"mocha":"^2.0.1",
6363
"rimraf":"^2.5.4",
6464
"source-map-support":"^0.4.2",
65-
"typescript":"^1.8.10",
66-
"typings":"^1.3.3",
65+
"ts-loader":"^1.2.2",
66+
"typescript":"^2.0.10",
6767
"webpack":"^1.13.2",
6868
"webpack-node-externals":"^1.3.3"
6969
},

‎src/utils/actionHelpers.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import'ts-helpers'
22
import"./promiseHelpers"
3+
import{Dispatch,Action}from'redux'
34

5+
exporttypeNullableDispatch=Dispatch<any>|void;
46

5-
exporttypeNullableDispatch=Redux.Dispatch<any>|void;
6-
7-
exportabstractclassSyncActionimplementsRedux.Action{
7+
exportabstractclassSyncActionimplementsAction{
88
type:string;
99
}
1010

1111
exportabstractclassAsyncActionextendsSyncActionimplementsPromise<NullableDispatch>{
1212

13-
privatepromise:Promise<Redux.Dispatch<any>>
13+
privatepromise:Promise<Dispatch<any>>
1414

15-
then(onfulfilled?:(value:Redux.Dispatch<any>)=>NullableDispatch|PromiseLike<NullableDispatch>,onrejected?:(reason:any)=>void):Promise<NullableDispatch>{
15+
then(onfulfilled?:(value:Dispatch<any>)=>NullableDispatch|PromiseLike<NullableDispatch>,onrejected?:(reason:any)=>void):Promise<NullableDispatch>{
1616
returnthis.promise.then(onfulfilled,onrejected);
1717
}
1818

‎src/utils/asyncMiddleware.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import{Action,MiddlewareAPI,Dispatch}from'redux'
12
import{SyncAction,AsyncAction}from'./actionHelpers'
23

34

4-
constisSyncAction=(action:Redux.Action):action isany=>{
5+
constisSyncAction=(action:Action):action isany=>{
56
returnactioninstanceofSyncAction;
67
}
78

8-
constisAsyncAction=(action:Redux.Action):action isany=>{
9+
constisAsyncAction=(action:Action):action isany=>{
910
returnactioninstanceofAsyncAction;
1011
}
1112

@@ -19,12 +20,12 @@ const mergeObject = (action: any): any => {
1920
returnmerged;
2021
}
2122

22-
exportconstasyncMiddleware=<S>(store:Redux.MiddlewareAPI<S>)=>(next:Redux.Dispatch<S>):Redux.Dispatch<S>=>(action:Redux.Action)=>{
23+
exportconstasyncMiddleware=<S>(store:MiddlewareAPI<S>)=>(next:Dispatch<S>):Dispatch<S>=>(action:Action)=>{
2324
if(isSyncAction(action)){
24-
action.type=action.constructor.name;
25+
action.type=(<any>action).constructor.name;
2526

2627
if(isAsyncAction(action)){
27-
action.promise=newPromise<Redux.Dispatch<any>>((resolve,reject)=>{
28+
(<any>action).promise=newPromise<Dispatch<any>>((resolve,reject)=>{
2829
//After original dispatch lifecycle, resolve dispatch in order to handle async operations
2930
setTimeout(()=>{
3031
resolve(store.dispatch);

‎src/utils/reducerBuilder.spec.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import'mocha'
2-
import{expect}from'chai'
3-
import{StoreBuilder}from'./storeBuilder'
4-
import{ReducerBuilder}from'./reducerBuilder'
1+
import{Action,Store,Reducer}from'redux'
52
import{SyncAction,AsyncAction}from'./actionHelpers'
3+
import{ReducerBuilder}from'./reducerBuilder'
4+
import{StoreBuilder}from'./storeBuilder'
5+
import{expect}from'chai'
6+
import'mocha'
67

78

89
interfaceSampleState{
@@ -58,9 +59,9 @@ describe("Reducer", () => {
5859

5960
describe("with async action handler",()=>{
6061
vardispatchedEvents:any[]=[];
61-
varstore:Redux.Store<SampleStore>;
62+
varstore:Store<SampleStore>;
6263

63-
varhookReducer:Redux.Reducer<any>=(state:any={},action:Redux.Action)=>{
64+
varhookReducer:Reducer<any>=(state:any={},action:Action)=>{
6465
if(!action.type.startsWith("@@")){
6566
dispatchedEvents.push(action.type);
6667
}

‎src/utils/reducerBuilder.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import{Action}from'redux'
12
import{SyncAction,AsyncAction}from'../utils/actionHelpers'
23

34

4-
exportinterfaceIAction<TextendsRedux.Action>{
5+
exportinterfaceIAction<TextendsAction>{
56
prototype:T;
67
}
78

‎src/utils/storeBuilder.spec.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import'mocha'
2-
import{expect}from'chai'
1+
import{Action,StoreCreator}from'redux'
32
import{StoreBuilder}from'./storeBuilder'
3+
import{expect}from'chai'
4+
import'mocha'
45

56

67
describe("Store",()=>{
78

8-
varTestAction=<Redux.Action>{type:"test"};
9+
varTestAction=<Action>{type:"test"};
910
varreducer=(state:any={},action:any)=>{returnstate};
1011
varinitState={reducer:{test:true}};
1112

@@ -40,7 +41,7 @@ describe("Store", () => {
4041

4142
describe("with reducer",()=>{
4243
varisSet=false;
43-
vartestReducer=(state={},action:Redux.Action)=>{
44+
vartestReducer=(state={},action:Action)=>{
4445
if(action.type==TestAction.type){isSet=true;}
4546
returnstate;
4647
};
@@ -58,7 +59,7 @@ describe("Store", () => {
5859

5960
describe("with reducer map",()=>{
6061
varisSet=false;
61-
vartestReducer=(state={},action:Redux.Action)=>{
62+
vartestReducer=(state={},action:Action)=>{
6263
if(action.type==TestAction.type){isSet=true;}
6364
returnstate;
6465
}
@@ -76,7 +77,7 @@ describe("Store", () => {
7677

7778
describe("with enhancer",()=>{
7879
varisSet=false;
79-
varenhancer=(f:Redux.StoreCreator)=>{
80+
varenhancer=(f:StoreCreator)=>{
8081
isSet=true;
8182
returnf;
8283
};

‎src/utils/storeBuilder.ts‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import{combineReducers,createStore,applyMiddleware,compose}from'redux';
1+
import{combineReducers,createStore,applyMiddleware,compose,Middleware,ReducersMapObject,GenericStoreEnhancer,StoreCreator,Reducer,Store}from'redux';
22
import{asyncMiddleware}from'../utils/asyncMiddleware'
33

44

55
exportclassStoreBuilder<StoreType>{
66

7-
privatemiddlewares:Redux.Middleware[];
8-
privatereducers:Redux.ReducersMapObject;
7+
privatemiddlewares:Middleware[];
8+
privatereducers:ReducersMapObject;
99
privateinitialState:StoreType;
10-
privateenhancer:Redux.GenericStoreEnhancer;
10+
privateenhancer:GenericStoreEnhancer;
1111

1212
constructor(){
1313
this.middlewares=[asyncMiddleware];
1414
this.reducers={};
1515
this.initialState={}asStoreType;
16-
this.enhancer=(f:Redux.StoreCreator)=>f;
16+
this.enhancer=(f:StoreCreator)=>f;
1717
}
1818

19-
publicwithMiddleware(middleware:Redux.Middleware){
19+
publicwithMiddleware(middleware:Middleware){
2020
this.middlewares.push(middleware);
2121
returnthis;
2222
}
@@ -26,21 +26,21 @@ export class StoreBuilder<StoreType> {
2626
returnthis;
2727
}
2828

29-
publicwithReducer<S>(name:string,reducer:Redux.Reducer<S>){
29+
publicwithReducer<S>(name:string,reducer:Reducer<S>){
3030
this.reducers[name]=reducer;
3131
returnthis;
3232
}
3333

34-
publicwithReducersMap(reducers:Redux.ReducersMapObject){
34+
publicwithReducersMap(reducers:ReducersMapObject){
3535
for(letreducerinreducers){
3636
this.reducers[reducer]=reducers[reducer];
3737
}
3838
returnthis;
3939
}
4040

41-
publicwithEnhancer(enhancer:Redux.GenericStoreEnhancer){
41+
publicwithEnhancer(enhancer:GenericStoreEnhancer){
4242
letpreEnhancer=this.enhancer;
43-
this.enhancer=(f:Redux.StoreCreator)=>enhancer(preEnhancer(f));
43+
this.enhancer=(f:StoreCreator)=>enhancer(preEnhancer(f));
4444
returnthis;
4545
}
4646

@@ -51,6 +51,6 @@ export class StoreBuilder<StoreType> {
5151
letcomposer=compose(middlewares,this.enhancer)(createStore);
5252
letstore=composer(reducers,this.initialState);
5353

54-
returnstoreasRedux.Store<StoreType>;
54+
returnstoreasStore<StoreType>;
5555
}
5656
}

‎tsconfig.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"target":"es5",
55
"noImplicitAny":true,
66
"noEmitHelpers":true,
7-
"experimentalDecorators":true
7+
"experimentalDecorators":true,
8+
"lib": ["dom","es5","es2015.promise","es2015.core"]
89
},
910
"exclude": [
1011
"node_modules",

‎typings.json‎

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp