-
Notifications
You must be signed in to change notification settings - Fork 44
Generate opaque types corresponding to an existing Flow/TS type. #63
Comments
Here's an example: [@genType.import "./SomeFlowTypes"]
type anInterestingFlowType;
[@genType]
let identity = (x: anInterestingFlowType) => x; |
- Add support for nested modules: translation of nested types and values, as well as cross references. - [Remove deprecated way of wrapping JS components](9c38882). - [Use strict imports for wrapping JS values and components](81c6a7f). - [Generate opaque types corresponding to an existing Flow/TS type](#63).
Excuse my question, how to import type from Typescript when most of them start with uppercase letter? |
And it would be much helpful if i can rename the type from TS in Reason. // typescript file : A.ts
export class A {
prop: string;
getProp(): string{
return this.prop
}
}
// Reason
module A = {
[@genType.import "./A"]
[@genType.as "typeof A"] //this won't work
type t;
[@bs.send] external getProp_: (t)=>string="getProp";
let getProp = getProp_;
}
//then I use module A to make an utility function for ts
[@genType]
let operateA = (a: A.t) => {...} how can i make situation above work? |
This is interesting. Would you expand on the end goal here? Extend JS class A with one more method? |
First of all, kudos for your great work here. |
…ype. This gets around the issue that types cannot be capitalized in Reason. A first step towards #63.
@ybybzj the commit just above has a first step. The combination of The commit also shows one way to access a method of the class, which for now still does not check the type. |
And the example written more in the style you've used above: |
A possible future design of how to import classes, which is cleaner, is this, where one specifies only once what file the import is from, there's a convention (probably override-able) that type [@genType.import "./MyMath"]
module AbsoluteValue2 = {
type t;
[@bs.module "./WrapJsValue"]
external getProp: t => int = "";
[@bs.module "./WrapJsValue"]
external getAbs: t => int = "";
}; |
thanks for the updates. I'm really fond of reasonml after trying, and gonna persuade my colleagues to use reason too, your work will make my argument much convincing. |
I've tried the commit version. There is still a little inconvenience. Since
generated tsx:
What i can do is to put
only every time i want use |
Got it, thanks for the reply. |
@ybybzj see the commit above https://github.com/cristianoc/genType/commits/master. |
Have tried the commit, it's good enough for me, thanks for the diligent work. |
Great. Thanks a lot for the feedback. |
e.g.
would mean the type is opaque in Reason, and is seen as
someJsType
from JS.Or
@genType.alias
or something.The text was updated successfully, but these errors were encountered: