Skip to content

Commit

Permalink
Adds typescript typings support (#8)
Browse files Browse the repository at this point in the history
* Adds typings for utils

* Adds a few core module and task typings

* Fucking hell typescript added to the project

* Adds type declaration generation

* Normalized codebase config and typings cleanup

* Fixes ts errors on utils

* AE Task converted to typescript

* Makes task monad types stricter + Adds some typing to core module

* Fixes broken test for task

* Fixes some more typing (operation)

* CORE typed. Temporary typing patches in someplaces

* Fully typescript now (with effects)

* Ts warning fixes

* TODO update

* Dependencies updated
  • Loading branch information
phenax authored Feb 23, 2020
1 parent 84a4955 commit 7314792
Show file tree
Hide file tree
Showing 65 changed files with 2,195 additions and 783 deletions.
7 changes: 5 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
- [x] Clone/Extend effect interface with new name.
- [x] "global" handlers to generic effects
- [x] Support try-catch inside program
- [x] Typescript types
- [ ] Stateful/parameterized states (to avoid the second parameter to .of method of State)
- [ ] Typescript types
- [ ] ?Redux middleware

**Multiple continuations**
Expand All @@ -32,6 +32,9 @@
- [x] Cancellation handler
- [x] Allow cancellation from within

**Observable**
- [ ] Implement observable monad to be used instead of Task monad

**Add more effects ...**
- [x] Exception
- [x] State
Expand Down Expand Up @@ -76,5 +79,5 @@
### Scripts and doc builder
- [x] Version upgrade in publish script should upgrade matching dependencies as well
- [x] Build and publish ae-docs as html github pages. (Maybe mdx?)
- [ ] ?Mobile issues (not confirmed yet)
- [ ] ?Mobile issues (not confirmed yet)
- [ ] Docs issue with scrolling to link hook. (Should attempt scrolling after page load)
6 changes: 4 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module.exports = {
'presets': [
// '@babel/preset-typescript',
'@babel/preset-env',
],
'plugins': [
'@babel/plugin-proposal-class-properties'
'@babel/plugin-proposal-class-properties',
'@babel/plugin-transform-typescript',
]
};
};
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
"docs": "node ./scripts/docs.js"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.2.3",
"@babel/preset-env": "^7.2.3",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.4",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/preset-env": "^7.8.4",
"@babel/preset-typescript": "^7.8.3",
"@mdx-js/loader": "^0.16.8",
"@mdx-js/runtime": "^0.16.8",
"@types/node": "^10.12.21",
Expand All @@ -35,7 +36,7 @@
"babel-polyfill": "^6.26.0",
"babel-preset-react-app": "^7.0.0",
"chalk": "^2.4.2",
"codecov": "^3.1.0",
"codecov": "^3.6.5",
"eslint": "^5.12.0",
"eslint-plugin-react": "^7.12.4",
"fs-extra": "^7.0.1",
Expand All @@ -51,8 +52,8 @@
"remark-slug": "^5.1.1",
"styled-components": "^4.1.3",
"terser-webpack-plugin": "^1.2.1",
"ts-loader": "^5.3.3",
"typescript": "^3.3.1",
"ts-loader": "^6.2.1",
"typescript": "^3.8.2",
"webpack": "^4.29.0"
}
}
}
26 changes: 13 additions & 13 deletions packages/ae-core/build/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.createGenericEffect = exports.background = exports.parallel = exports.race = exports.callMulti = exports.call = exports.runTask = exports.awaitPromise = exports.cancel = exports.resolve = exports.sleep = void 0;
exports["default"] = exports.createGenericEffect = exports.background = exports.parallel = exports.race = exports.callMulti = exports.call = exports.runTask = exports.awaitPromise = exports.cancel = exports.resolve = exports.sleep = void 0;

var _fns = require("@algebraic-effects/task/fns");

Expand Down Expand Up @@ -66,40 +66,40 @@ var genericOpHandlers = {
};
}
};
var sleep = (0, _utils2.Operation)('sleep', (0, _utils2.func)(['duration']));
var sleep = (0, _utils2.createOperation)('sleep', (0, _utils2.func)(['duration']));
exports.sleep = sleep;
var resolve = (0, _utils2.Operation)('resolve', (0, _utils2.func)(['*']));
var resolve = (0, _utils2.createOperation)('resolve', (0, _utils2.func)(['*']));
exports.resolve = resolve;
var cancel = (0, _utils2.Operation)('cancel', (0, _utils2.func)(['*']));
var cancel = (0, _utils2.createOperation)('cancel', (0, _utils2.func)(['*']));
exports.cancel = cancel;
var awaitPromise = (0, _utils2.Operation)('awaitPromise', (0, _utils2.func)(['promise e a'], 'a'));
var awaitPromise = (0, _utils2.createOperation)('awaitPromise', (0, _utils2.func)(['promise e a'], 'a'));
exports.awaitPromise = awaitPromise;
var runTask = (0, _utils2.Operation)('runTask', (0, _utils2.func)(['task e a'], 'a'));
var runTask = (0, _utils2.createOperation)('runTask', (0, _utils2.func)(['task e a'], 'a'));
exports.runTask = runTask;
var call = (0, _utils2.Operation)('call', (0, _utils2.func)(['generator ...a b', '...a'], 'b'));
var call = (0, _utils2.createOperation)('call', (0, _utils2.func)(['generator ...a b', '...a'], 'b'));
exports.call = call;
var callMulti = (0, _utils2.Operation)('callMulti', (0, _utils2.func)(['generator ...a b', '...a'], 'b', {
var callMulti = (0, _utils2.createOperation)('callMulti', (0, _utils2.func)(['generator ...a b', '...a'], 'b', {
isMulti: true
}));
exports.callMulti = callMulti;
var race = (0, _utils2.Operation)('race', (0, _utils2.func)(['...(generator ...a b)'], 'b', {
var race = (0, _utils2.createOperation)('race', (0, _utils2.func)(['...(generator ...a b)'], 'b', {
isMulti: true
}));
exports.race = race;
var parallel = (0, _utils2.Operation)('parallel', (0, _utils2.func)(['...(generator ...a b)'], '[b]', {
var parallel = (0, _utils2.createOperation)('parallel', (0, _utils2.func)(['...(generator ...a b)'], '[b]', {
isMulti: true
}));
exports.parallel = parallel;
var background = (0, _utils2.Operation)('background', (0, _utils2.func)(['...(generator ...a b)'], '[b]', {
var background = (0, _utils2.createOperation)('background', (0, _utils2.func)(['...(generator ...a b)'], '[b]', {
isMulti: true
}));
exports.background = background;

var createGenericEffect = function createGenericEffect(name, signature, handler) {
genericOpHandlers[name] = handler;
return (0, _utils2.Operation)(name, signature);
return (0, _utils2.createOperation)(name, signature);
};

exports.createGenericEffect = createGenericEffect;
var _default = genericOpHandlers;
exports.default = _default;
exports["default"] = _default;
Loading

0 comments on commit 7314792

Please sign in to comment.