Reputation: 971
I'm new to TypeScript. I have some JavaScript code written with Ramda and I want to use it in TypeScript project.
This is a generic sort function in JavaScript:
var charOrdAFactoryBase = R.curry(function(sortDir, prepare){
return function(a, b) {
a = prepare(a);
b = prepare(b);
if(R.isNil(a) && R.isNil(b)) return 0;
if(R.isNil(a)) return 1;
if(R.isNil(b)) return -1;
if (a > b)
return sortDir === "asc" ? 1 : -1;
if (a < b)
return sortDir === "asc" ? -1 : 1;
return 0;
};
});
I tried to make:
export function charOrdAFactoryBase;
But TypeScript compiler says: Function implementation is missing or not immediately following the declaration.
Is it possible to export Ramda curried function?
Upvotes: 2
Views: 604
Reputation: 38982
charOrdAFactoryBase
is being redeclared.
What you want to export here is a name referencing an already defined function.
export { charOrdAFactoryBase }
https://developer.mozilla.org/en/docs/web/javascript/reference/statements/export
Upvotes: 5