Skip to content

Commit f51504e

Browse files
DZakhcristianoc
authored andcommitted
Update object mangling mention
1 parent e89c13e commit f51504e

File tree

2 files changed

+6
-25
lines changed

2 files changed

+6
-25
lines changed

pages/docs/gentype/latest/supported-types.mdx

-21
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@ Since objects are immutable by default, their fields will be exported to readonl
5555

5656
It is possible to mix object and option types, so for example the ReScript type `{. "x":int, "y":option<string>}` exports to JS type `{x:number, ?y: string}`, requires no conversion, and allows option pattern matching on the ReScript side.
5757

58-
Object field names follow ReScript's mangling convention (so e.g. `_type` in ReScript represents `type` in JS):
59-
60-
```
61-
Remove trailing "__" if present.
62-
Otherwise remove leading "_" when followed by an uppercase letter, or keyword.
63-
```
64-
6558
## Tuples
6659

6760
ReScript tuple values of type e.g. `(int, string)` are exported as identical JS values of type `[number, string]`. This requires no conversion, unless one of types of the tuple items does.
@@ -123,20 +116,6 @@ Function components are exported and imported exactly like normal functions. For
123116
let make = (~name) => React.string(name);
124117
```
125118

126-
For renaming, named arguments follow ReScript's mangling convention:
127-
128-
```
129-
Remove trailing "__" if present.
130-
Otherwise remove leading "_" when followed by an uppercase letter, or keyword.
131-
```
132-
133-
For example:
134-
135-
```res
136-
@genType
137-
let exampleFunction = (~_type) => "type: " ++ _type
138-
```
139-
140119
## Imported Types
141120

142121
It's possible to import an existing TS/Flow type as an opaque type in ReScript. For example,

pages/docs/gentype/latest/usage.mdx

+6-4
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,14 @@ type persons = array<person>;
110110

111111
## Renaming, @genType.as, and object mangling convention.
112112

113-
By default, entities with a given name are exported/imported with the same name. However, you might wish to change the appearence of the name on the JS side.
114-
115113
**NOTE:** Starting from ReScript 7.0.0, `@genType.as` on record fields will be discouraged,
116-
as it incurs a runtime conversion cost. Instead `@bs.as` will be supported and incur zero cost.
114+
as it incurs a runtime conversion cost. Use a runtime free `@as` instead.
115+
116+
**NOTE:** Starting from ReScript 11.0.0, the object mangling is removed.
117+
118+
By default, entities with a given name are exported/imported with the same name. However, you might wish to change the appearence of the name on the JS side.
117119

118-
For example, in case of a record field whose name is a keyword, such as `type`:
120+
For example, to use a reserved keyword `type` as a record field:
119121

120122
```res
121123
@genType

0 commit comments

Comments
 (0)