@genType只生成了一个类型



在React Native typeScript代码库中添加ReasonML后,我发现@genType只生成了一个类型,尽管BuckleScript成功地转换了这两个函数。如何解决此问题?

reasonSum.re

[@genType]
let reasonSum = (a, b) => a + b;
let reasonSum2 = (a, b) => a + b;

reasonSum.gen.tsx

/* TypeScript file generated from reasonSum.re by genType. */
/* eslint-disable import/first */
// tslint:disable-next-line:no-var-requires
const Curry = require('bs-platform/lib/es6/curry.js');
// tslint:disable-next-line:no-var-requires
const reasonSumBS = require('./reasonSum.bs');
export const reasonSum: (a:number, b:number) => number = function (Arg1: any, Arg2: any) {
const result = Curry._2(reasonSumBS.reasonSum, Arg1, Arg2);
return result
};

bsconfig.json

{
"name": "reason-in-react-typescript",
"sources": [
{
"dir": "./reason",
"subdirs": true
}
],
"package-specs": [
{
"module": "es6-global",
"in-source": true
}
],
"bs-dependencies": [
"@glennsl/bs-json",
"bs-fetch"
],
"suffix": ".bs.js",
"namespace": true,
"refmt": 3,
"gentypeconfig": {
"language": "typescript",
"module": "es6",
"importPath": "relative",
"shims": {
"Js": "Js",
"React": "ReactShim",
"ReactEvent": "ReactEvent",
"ReasonPervasives": "ReasonPervasives",
"ReasonReact": "ReactShim"
},
"debug": {
"all": false
},
"exportInterfaces": false
}
}

通常,附加到单个项的属性都只适用于该项。可以通过不将属性与特定项相关联来使其独立,这可能被解释为与它所包含的模块相关联,但我认为genType不支持这一点。相反,你似乎必须为每个想要导出的项目添加一个属性:

[@genType]
let reasonSum = (a, b) => a + b;
[@genType]
let reasonSum2 = (a, b) => a + b;

相关内容

  • 没有找到相关文章

最新更新