// test-code.js
add :: (number, number) => number
function add (x, y) {
return x + y
}
babel --plugins=transform-dctypes-comments --no-babelrc test-code.js
// add :: (number, number) => number
function add(x, y) {
return x + y;
}
Babel as well as its parser Babylon had to be patched/extended in order to parse the double-colon type syntax. You can find the Babylon fork here. Clone the feature branch and run yarn && npm run build && npm link
.
The Babel fork can be found here. Clone the feature branch and run yarn && lerna bootstrap && npm run build
in the project root directory, then cd packages/babel-core && rm -rf node_modules/babylon && npm link babylon
. Finally cd ../babel-types && npm link
.
To set up the samples in dctypes-test/
in the babel root directory:
cd dctypes-test/
npm i
rm -rf node_modules/babylon node_modules/babel-types
npm link babylon
npm link babel-types
npm run
will show you the samples to run.
It is worth mentioning that the double colon operator has already been introduced by the Function bind operator proposal and works well along with this proposed features. They don't really interfere with eatch other, since the double colon function-bind syntax only really makes sense when used as part of expressions, whereas the double colon types can only be written as separate statements.
Getting the following error
Any idea what is causing this? What additional information should I provide to make debugging easier?