You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A shim is a TS file that provides user-provided definitions for library types.
221
+
222
+
Required only if one needs to export certain basic ReScript data types to JS when one cannot modify the sources to add annotations (e.g. exporting ReScript lists), and if the types are not first-classed in genType.
223
+
- Example: `Array<string>` with format: `"RescriptModule=JavaScriptModule"`
224
+
225
+
Configure your shim files within `"gentypeconfig"` in your [`rescript.json`]:
226
+
227
+
```json
228
+
{
229
+
"gentypeconfig": {
230
+
"shims": {
231
+
"Js": "Js",
232
+
"ReactEvent": "ReactEvent",
233
+
"RescriptPervasives": "RescriptPervasives",
234
+
"ReasonReact": "ReactShim"
235
+
},
236
+
},
237
+
}
238
+
```
239
+
240
+
and add relevant `.shim.ts` files in a directory which is visible by ReScript e.g.
241
+
242
+
```
243
+
├── rescript.json
244
+
├── src
245
+
│ ├── shims
246
+
│ │ ├── Js.shim.ts
247
+
│ │ ├── ReactEvent.shim.ts
248
+
│ │ └── RescriptPervasives.shim.ts
249
+
```
250
+
251
+
Here are some examples:
252
+
253
+
```ts
254
+
// Excerpt from https://github.com/rescript-lang/rescript-compiler/blob/master/jscomp/gentype_tests/typescript-react-example/src/shims/Js.shim.ts
255
+
exporttypeJson_t=unknown;
256
+
exporttypet=unknown;
257
+
```
258
+
259
+
```ts
260
+
// Excerpt from https://github.com/rescript-lang/rescript-compiler/tree/master/jscomp/gentype_tests/typescript-react-example/src/shims
More complete example shims can be found [here](https://github.com/rescript-lang/rescript-compiler/blob/master/jscomp/gentype_tests/typescript-react-example/src/shims/).
265
+
217
266
## Deprecated features
218
267
219
268
Features related to generating runtimes were deprecated since v11 and should no longer be used.
0 commit comments