简体   繁体   中英

How to export Ramda curried function in TypeScript?

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?

charOrdAFactoryBase is being redeclared.

What you want to export here is a name referencing an already defined function.

export { charOrdAFactoryBase }

Reference:

https://developer.mozilla.org/en/docs/web/javascript/reference/statements/export

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM