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

Commit885d5d2

Browse files
committed
improve typings
1 parent1f47510 commit885d5d2

File tree

69 files changed

+6424
-1727
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+6424
-1727
lines changed

‎.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
npm-debug.log
33
notes.md
4+
test/tests.md

‎lib/atom/editor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function open(filePath, options) {
4444
}
4545
exports.open=open;
4646
functionset(text){
47-
getEditor().then(function(editor){
47+
returngetEditor().then(function(editor){
4848
editor.setText(text);
4949
editor.insertNewline();
5050
editor.moveToBottom();
@@ -56,7 +56,7 @@ function insert(text, options) {
5656
options=Object.assign(options,{
5757
autoIndent:true
5858
});
59-
getEditor().then(function(editor){
59+
returngetEditor().then(function(editor){
6060
editor.moveToBottom();
6161
editor.insertText(text,options);
6262
editor.insertNewline();

‎lib/atom/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
'use strict';
22
varrender_1=require('../components/render');
3+
varpolyfills_1=require('../services/polyfills');
34
varsubscriptions_1=require('./subscriptions');
45
vareditor_1=require('./editor');
56
varMain=(function(){
67
functionMain(){
78
global.coderoad={};
9+
polyfills_1.default();
810
editor_1.setAtomGlobals();
911
this.root=render_1.initRoot();
1012
}

‎lib/reducers/alert/alert.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var defaultAlert = {
66
action:'',
77
duration:0
88
};
9-
varcurrent={};
9+
varcurrent=defaultAlert;
1010
functionalertReducer(alert,action){
1111
if(alert===void0){alert=defaultAlert;}
1212
varstatusBarAlert=document.getElementsByClassName('cr-alert-replay')[0];
@@ -52,7 +52,6 @@ function alertReducer(alert, action) {
5252
};
5353
returncurrent;
5454
}
55-
returndefaultAlert;
5655
default:
5756
returnalert;
5857
}

‎lib/reducers/reducer.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ var editor_actions_1 = require('./editor-actions/editor-actions');
1414
vartutorials_1=require('./tutorials/tutorials');
1515
varlog_1=require('./log/log');
1616
varhint_1=require('./hint/hint');
17-
varsolution_1=require('./solution/solution');
1817
Object.defineProperty(exports,"__esModule",{value:true});
1918
exports.default=redux_1.combineReducers({
2019
project:project_1.default,
@@ -30,6 +29,5 @@ exports.default = redux_1.combineReducers({
3029
editorActions:editor_actions_1.default,
3130
tutorials:tutorials_1.default,
3231
log:log_1.default,
33-
hint:hint_1.default,
34-
solution:solution_1.default
32+
hint:hint_1.default
3533
});

‎lib/reducers/run-tests/test-result.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"use strict";
22
var_base_1=require('../../_base');
33
varAction=require('../../actions/actions');
4-
;
54
functionhandleResult(result){
65
_base_1.store.dispatch(Action.testComplete());
76
if(!result.pass){

‎lib/reducers/solution/solution.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +0,0 @@
1-
"use strict";
2-
functionsolutionReducer(solution,action){
3-
if(solution===void0){solution=[];}
4-
switch(action.type){
5-
default:
6-
returnsolution;
7-
}
8-
}
9-
Object.defineProperty(exports,"__esModule",{value:true});
10-
exports.default=solutionReducer;

‎lib/reducers/task-tests/concat-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function concatTests(targetFile, files) {
66
}
77
files.forEach(function(tests){
88
if(typeoftests==='string'){
9-
readAppend(targetFile,test);
9+
readAppend(targetFile,tests);
1010
}
1111
elseif(Object.prototype.toString.call(tests)==='[object Array]'){
1212
tests.forEach(function(test){

‎lib/services/polyfills.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"use strict";
2+
functionloadPolyfills(){
3+
if(typeofObject.assign!='function'){
4+
(function(){
5+
Object.assign=function(target){
6+
'use strict';
7+
if(target===undefined||target===null){
8+
thrownewTypeError('Cannot convert undefined or null to object');
9+
}
10+
varoutput=Object(target);
11+
for(varindex=1;index<arguments.length;index++){
12+
varsource=arguments[index];
13+
if(source!==undefined&&source!==null){
14+
for(varnextKeyinsource){
15+
if(source.hasOwnProperty(nextKey)){
16+
output[nextKey]=source[nextKey];
17+
}
18+
}
19+
}
20+
}
21+
returnoutput;
22+
};
23+
})();
24+
}
25+
}
26+
Object.defineProperty(exports,"__esModule",{value:true});
27+
exports.default=loadPolyfills;
28+
;

‎lib/services/setGlobals.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ function loadRepo(config) {
5050
}
5151
global.coderoad.repo=repo;
5252
}
53-
global.coderoad.edit=config.config.edit&&!!repo||false;
53+
global.coderoad.edit=config.config.edit&&!!global.coderoad.repo||false;
5454
}

‎lib/store/initialState.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ function getInitialState() {
2323
editorActions:false,
2424
runTests:false,
2525
tutorials:[],
26-
alert:{},
27-
log:{open:false,message:''},
28-
hint:[]
26+
alert:{}
2927
};
3028
}
3129
exports.getInitialState=getInitialState;

‎package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@
4747
"classnames":"2.2.3"
4848
},
4949
"devDependencies": {
50+
"ava":"^0.12.0",
5051
"enzyme":"2.0.0",
5152
"jsdom":"8.0.4",
5253
"react-addons-test-utils":"0.14.7"
54+
},
55+
"scripts": {
56+
"test":"ava"
5357
}
5458
}

‎src/actions/actions.spec.ts

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

‎src/actions/actions.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,37 @@ import {store} from '../_base';
44
importPackagefrom'../services/package';
55

66
/* Project */
7-
exportfunctionsetProject():Action{
7+
exportfunctionsetProject():CR.Action{
88
return{type:Type.SET_PROJECT};
99
}
1010

11-
exportfunctionsetProgress():Action{
11+
exportfunctionsetProgress():CR.Action{
1212
return{type:Type.SET_PROGRESS};
1313
}
1414

1515
/* Navigation */
16-
exportfunctionsetRoute(route:string):Action{
16+
exportfunctionsetRoute(route:string):CR.Action{
1717
return{type:Type.SET_ROUTE,payload:{ route}};
1818
}
1919

2020
/* Position */
21-
exportfunctionsetPosition(position:cr.Position):Action{
21+
exportfunctionsetPosition(position:CR.Position):CR.Action{
2222
return{type:Type.SET_POSITION,payload:{ position}};
2323
}
2424

25-
exportfunctionloadTutorial(name){
25+
exportfunctionloadTutorial(name:string):void{
2626
Package.selectPackage(name);
2727
store.dispatch(setProject());
2828
store.dispatch(setPosition({chapter:0,page:0}));
2929
store.dispatch(setProgress());
3030
}
3131

32-
exportfunctiontoggleLog():Action{
32+
exportfunctiontoggleLog():CR.Action{
3333
letopen=!store.getState().log.open;
3434
return{type:Type.TOGGLE_LOG,payload:{ open}};
3535
}
3636

37-
exportfunctionlogMessage(message:string):Action{
37+
exportfunctionlogMessage(message:string):CR.Action{
3838
return{type:Type.LOG_MESSAGE,payload:{ message}};
3939
}
4040

‎src/actions/alert.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {store} from '../_base';
22
import*asTypefrom'./actionTypes';
33
const_=require('lodash');
44

5-
exportfunctiontoggleAlert(alert?:cr.Alert):Action{
5+
exportfunctiontoggleAlert(alert?:CR.Alert):CR.Action{
66
constisOpen=store.getState().alert.open;
77
if(!alert){
88
alert={message:'',action:'',open:false};
@@ -12,6 +12,6 @@ export function toggleAlert(alert?: cr.Alert): Action {
1212
return{type:Type.TOGGLE_ALERT,payload:{ alert}};
1313
}
1414

15-
exportfunctionreplayAlert():Action{
15+
exportfunctionreplayAlert():CR.Action{
1616
return{type:Type.REPLAY_ALERT};
1717
}

‎src/actions/page-actions.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import {store} from '../_base';
44
importPackagefrom'../services/package';
55
const_=require('lodash');
66

7-
exportfunctionsetPage(selectedPosition:cr.Position={chapter:0,page:0}):Action{
8-
constpage=Package.getPage(selectedPosition);
9-
consttasks=Package.getTasks(selectedPosition);
10-
consttaskTests:cr.TaskTest[]=_.flatten(tasks.map((task)=>task.tests||[]));
11-
letactions:string[]=tasks.map((task)=>task.actions||[]);
7+
exportfunctionsetPage(selectedPosition:CR.Position={chapter:0,page:0}):CR.Action{
8+
constpage:CR.Page=Package.getPage(selectedPosition);
9+
consttasks:CR.Task[]=Package.getTasks(selectedPosition);
10+
consttaskTests:CR.TaskTest[]=_.flatten(tasks.map((task)=>task.tests||[]));
11+
constactions:string[]=tasks.map((task)=>task.actions||[]);
1212
return{type:Type.SET_PAGE,payload:{ page, tasks,position:selectedPosition, taskTests, actions}};
1313
}
1414

15-
exportfunctionnextPage():Action{
16-
constposition=store.getState().position;
17-
constnextPosition=Package.getNextPosition(position);
15+
exportfunctionnextPage():CR.Action{
16+
constposition:CR.Position=store.getState().position;
17+
constnextPosition:CR.Position=Package.getNextPosition(position);
1818
returnsetPage(nextPosition);
1919
}

‎src/actions/progress-actions.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
import*asTypefrom'./actionTypes';
22
import{store}from'../_base';
33

4-
exportfunctionpageComplete(){
5-
constposition=store.getState().position;
6-
constpageLength=store.getState().progress.chapters[position.chapter].pages.length;
7-
constaction={type:Type.PAGE_COMPLETE,payload:{ position}};
4+
exportfunctionpageComplete():CR.Action{
5+
constposition:CR.Position=store.getState().position;
6+
constpageLength:number=store.getState().progress.chapters[position.chapter].pages.length;
7+
constaction:CR.Action={type:Type.PAGE_COMPLETE,payload:{ position}};
88
if(position.page>=pageLength-1){
99
store.dispatch(chapterComplete());
1010
returnaction;
1111
}
1212
returnaction;
1313
}
1414

15-
exportfunctionchapterComplete():Action{
16-
constchapter=store.getState().position.chapter;
17-
constchapterLength=store.getState().progress.chapters.length;
18-
constaction={type:Type.CHAPTER_COMPLETE,payload:{ chapter}};
15+
exportfunctionchapterComplete():CR.Action{
16+
constchapter:number=store.getState().position.chapter;
17+
constchapterLength:number=store.getState().progress.chapters.length;
18+
constaction:CR.Action={type:Type.CHAPTER_COMPLETE,payload:{ chapter}};
1919
if(chapter>=chapterLength-1){
2020
store.dispatch(projectComplete());
2121
returnaction;
2222
}
2323
returnaction;
2424
}
2525

26-
exportfunctionprojectComplete():Action{
26+
exportfunctionprojectComplete():CR.Action{
2727
return{type:Type.PROJECT_COMPLETE};
2828
}

‎src/actions/task-actions.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,35 @@ import * as Type from './actionTypes';
22
import*asActionfrom'./actions';
33
import{store}from'../_base';
44

5-
functioncheckPageComplete(taskPosition:number){
5+
functioncheckPageComplete(taskPosition:number):void{
66
consttaskLength:number=store.getState().taskTests.length;
77
if(taskPosition>taskLength){
88
store.dispatch(Action.pageComplete());
99
}
1010
}
1111

12-
exportfunctionsetTaskPosition(taskPosition:number):Action{
13-
constcurrentTaskPosition=store.getState().taskPosition;
12+
exportfunctionsetTaskPosition(taskPosition:number):CR.Action{
13+
constcurrentTaskPosition:number=store.getState().taskPosition;
1414
if(currentTaskPosition===taskPosition){
1515
return{type:Type.NULL};
1616
}
1717
checkPageComplete(taskPosition);
1818
return{type:Type.SET_TASK_POSITION,payload:{ taskPosition}};
1919
}
2020

21-
exportfunctionshowHint():Action{
21+
exportfunctionshowHint():CR.Action{
2222
return{type:Type.SHOW_HINT};
2323
}
2424

25-
exportfunctionrunTests():Action{
25+
exportfunctionrunTests():CR.Action{
2626
return{type:Type.RUN_TESTS};
2727
}
2828

29-
exportfunctiontestResult(result):Action{
29+
exportfunctiontestResult(result):CR.Action{
3030
letactions=store.getState().editorActions;
3131
return{type:Type.TEST_RESULT,payload:{ result, actions}};
3232
}
3333

34-
exportfunctiontestComplete():Action{
34+
exportfunctiontestComplete():CR.Action{
3535
return{type:Type.TEST_COMPLETE};
3636
}

‎src/actions/tutorials.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import * as fs from 'fs';
55
import*asTypefrom'./actionTypes';
66
import{fileExists}from'../services/exists';
77

8-
exportfunctionloadTutorials():Action{
8+
exportfunctionloadTutorials():CR.Action{
99
lettutorials=[];
1010
if(global.coderoad.dir){
11-
letpackageJson=loadRootPackageJson();
11+
letpackageJson:PackageJson|boolean=loadRootPackageJson();
1212
if(!packageJson){
1313
global.coderoad.package=null;
1414
letmessage='No package.json file available. Try running "npm init --y" in terminal';
@@ -24,7 +24,7 @@ export function loadTutorials(): Action {
2424
}
2525

2626

27-
functionloadRootPackageJson(){
27+
functionloadRootPackageJson():PackageJson|boolean{
2828
letpathToPackageJson=path.join(global.coderoad.dir,'package.json');
2929
if(fileExists(pathToPackageJson)){
3030
returnJSON.parse(fs.readFileSync(pathToPackageJson,'utf8'));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp