rescript-lang / rescript

ReScript is a robustly typed language that compiles to efficient and human-readable JavaScript.
https://rescript-lang.org
Other
6.75k stars 449 forks source link

Issue with genType Importing Modules in ReScript v11.1 with ReScript Core #6968

Open PritishBudhiraja opened 2 months ago

PritishBudhiraja commented 2 months ago

I'm using ReScript v11.1 and ReScript Core in my project, and I'm having trouble with genType. Specifically, I have a type that looks like this:

@genType
type hyperInstance = {
  ...,
  confirmOneClickPayment: (JSON.t, bool) => Promise.t<JSON.t>,
}

The compiler generates a file Types.gen.tsx for me, but I'm encountering the following issue:

import type {t as JSON_t} from './JSON.gen.tsx';

import type {t as Promise_t} from './Promise.gen.tsx';

I'm facing this issue in the rescript -

Cannot find module './JSON.gen.tsx' or its corresponding type declarations.ts(2307) Cannot find module './Promise.gen.tsx' or its corresponding type declarations.ts(2307)

I've followed the setup guide from the ReScript documentation here but can't seem to resolve this issue.

Steps I've Taken:

My Environment:

Is there something I'm missing, or is this potentially a bug? Any help or guidance would be greatly appreciated.

cometkim commented 2 months ago

@cknitt @fhammerschmidt We need to restore the genType shims documentation for v11 users.

fhammerschmidt commented 2 months ago

@cometkim Here you go: https://github.com/rescript-association/rescript-lang.org/pull/906 (Can't add you as a reviewer over there unfortunately)

fhammerschmidt commented 2 months ago

@PritishBudhiraja does this guide help? https://rescript-lang.org/docs/manual/latest/typescript-integration#shims

PritishBudhiraja commented 2 months ago

Hey @fhammerschmidt @cometkim ,

So we tried using shims. It worked for Js library and made it compiled too.

Screenshot 2024-09-03 at 3 38 34 PM

But still I have few issues.

We have updated our repo to v11 and using rescript-core everywhere. So we tried to make this work in the same way but it didn't. Can you please guide us where it's going wrong? or shim folder structure for the same. It's getting a bit confusing.

Screenshot 2024-09-03 at 3 34 18 PM Screenshot 2024-09-03 at 3 34 36 PM

The versions are mentioned in the above description.

Thanks!

PritishBudhiraja commented 2 months ago

Hey @cometkim @fhammerschmidt any update on the above issue. Like how can we resolve it?

cometkim commented 1 month ago

This is assigned to the v12 release. It is not a simple task as it requires a complete reimplementation of genType. I think I can start implementing it next month.

Until then, you should continue to use Shims. I'll provide a shimming example for Core and others soon.