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
This leads to the following in my ReactFirebaseHooks.gen.tsx...
import type {t as Error_t} from './Error.gen'; // does not exist
import type {t as Null_t} from './Null.gen'; // does not exist
If I change the code to reference Core__Error.gen this is probably closer to the desired result, but still doesn't work.
import type {t as Core__Error_t} from '@rescript/core/src/Core__Error.gen'; // does not exist
import type {t as Core__Null_t} from '@rescript/core/src/Core__Null.gen'; // does not exist
I tried taking out the -open RescriptCore but it still doesn't work. I tried adding node_modules/~rescript/core/src to bsconfig.json but this shouldn't be necessary and still doesn't work.
I have the same problem with a different package. Does the author of the package need to put @Gentype everywhere or is the compiler supposed to handle this?
I'll try again with a repo scenario but your example doesn't look like what I'm talking about - just reading on my phone. Array isn't a problem because it is built in. But Error.t and Null.t are not so typescript doesn't know where to find them. . Could you clarify if that gentyoe doc comment is still true that the library author must generate and publish the .gen files with their package?
There was an issue to explore that scenario: picking up annotations from dependencies. But there was no concrete work on that.
So it's about first finding out what's the current situation and take it from there.
@jmagaram I should look for the analogous discussion in the genType repo, where exactly these kinds of issues were discussed.
I think this might be a good time to look a bit more in depth into that. Because we might have the opportunity to, for example, make it work well for at least Core when used as a dependency. And for other projects after that.
Not sure if you're time/interest to help, but starting from figuring out current status and how one would expect this to work would be a first step.
Specifically, if a dependency has genType annotations then 2 things will happen:
.gen.tsx files should be checked in or anyhow produces so they are available.
one might need to access relevant type information from those files in the dependency. To see if this works one can try this: use some gentype'd value or type from another file in the same project. Then do it for another file in a dependency. Is the behaviour the same
Further ahead, there's the opportunity now after the latest changes for genType to conform to the way that TypeScript expects the .d.ts to be in a project. Particularly a dependency. So one can see if that is possible to do in future. So one would be able ideally to consume a dependency transparently from TS and from ReScript
I created another little package and tried to add it to bs-dependencies but it didn't work because the build system was looking inside node_modules. So I put it inside node_modules and was able to use it from my main project. Same issue. If you reference a type directly like Dependency__ShortString.t it works but if you go through the wrapping module it doesn't. When you access a type through the root wrapping module the typescript is looking for a file some dependency/src/Wrapped.gen and there isn't anything in it. Just doing module ShortString = Dependency__ShortString doesn't generate any .gen file. This little example I played with is not much different than the code I already have in my repro where I am trying to access Core.
I looked back at the code that is accessing Core. When I try to use a type through the root wrapping module the TypeScript is looking for ./Error.gen and ./Null.gen. Very weird. Why isn't it looking for RescriptCore.gen?
I don't want to spend more time on this. Please just take my repro repository and do whatever additional experiments you want on it. I'm very inefficient because I don't understand pinned dependencies and other things about the build system. I tried modifying Core inside node_modules to generate .gen files and it is very flaky. It was complaining about the annotations being ignored because there was a resi file, even though I used ignoreInterface in several places. I did a bunch of clean then rebuild etc. and finally it randomly started working. I have no idea why. Lots of wasted time. The existence of a RescriptCore.gen, Core__Error.gen etc. did NOT seem to change the fact that the generated TypeScript still looks for ./Error.gen and ./Null.gen.
That repro I mentioned in this thread has trouble using gentyoe with a local file. AND there is some code that tries to use Core as a dependency. So you can see what happens in both scenarios. If you don't want the dependency just take out Core - should not have any impact on your the no-dependency case.
Sorry if I misunderstood.
My understanding is that all your examples have a dependency (project in node modules).
My question was whether there was an example that does not use any dependencies.
The reason for the question is trying to understand if the issue has to do with dependencies.
An example of the issue without any dependencies would help clarify the scope of the issue.
It is common practice when trying to understand unexpected behaviour to cut down the possible causes. This helps coming up with solutions and debugging the issue more in detail.
Yes I understand the need to make examples that are as simple as they can be. I think my GitHub https://github.com/jmagaram/core-gentype is very simple. Yes it has a dependency but in 1 minute you can take it out of bsconfig.json and delete the res files that use it - UseRootModule, UseFullPath, and OpenCore. So you can see the case where (a) there is a dependency, and (b) there is no dependency. Couldn't be much simpler. Are we having a communication problem here? Just look at the code and it will be very obvious what is going on.
Thank you. If you are confident that your example using core will have the same problem when core is removed, I will assume that dependencies can be excluded as a possible contributing factor to the issue.
Activity
zth commentedon Apr 2, 2023
Hmm, IIRC this was recently fixed. What ReScript compiler version are you on?
jmagaram commentedon Apr 2, 2023
In my package.json I see
^10.1.3. My script isrescript build -w.zth commentedon Apr 2, 2023
Could you try
10.1.4explicitly?jmagaram commentedon Apr 2, 2023
Same problem
jmagaram commentedon Apr 2, 2023
Did a clean, verified with
npm list. The.gen.tsxfile...jmagaram commentedon Apr 2, 2023
I have the same problem with a different package. Does the author of the package need to put @Gentype everywhere or is the compiler supposed to handle this?
cristianoc commentedon Apr 3, 2023
Not sure what the issue is here.
#129
jmagaram commentedon Apr 3, 2023
I'll try again with a repo scenario but your example doesn't look like what I'm talking about - just reading on my phone. Array isn't a problem because it is built in. But Error.t and Null.t are not so typescript doesn't know where to find them. . Could you clarify if that gentyoe doc comment is still true that the library author must generate and publish the .gen files with their package?
jmagaram commentedon Apr 3, 2023
Just to be clear I'm trying to use Core in another project when it lives in the node_modules folder.
jmagaram commentedon Apr 3, 2023
Repo scenarios here https://github.com/jmagaram/core-gentype
Am I supposed to make shims for everything in Core?
cristianoc commentedon Apr 3, 2023
There was an issue to explore that scenario: picking up annotations from dependencies. But there was no concrete work on that.
So it's about first finding out what's the current situation and take it from there.
cristianoc commentedon Apr 4, 2023
@jmagaram I should look for the analogous discussion in the genType repo, where exactly these kinds of issues were discussed.
I think this might be a good time to look a bit more in depth into that. Because we might have the opportunity to, for example, make it work well for at least Core when used as a dependency. And for other projects after that.
Not sure if you're time/interest to help, but starting from figuring out current status and how one would expect this to work would be a first step.
Specifically, if a dependency has genType annotations then 2 things will happen:
10 remaining items
jmagaram commentedon Apr 5, 2023
Sorry I need to go to sleep. I'm not sure how to set it up. You could probably do it a lot faster than me. My repro code has the beginnings of it.
cristianoc commentedon Apr 5, 2023
There is no rush. The beauty of async communication.
jmagaram commentedon Apr 5, 2023
I created another little package and tried to add it to bs-dependencies but it didn't work because the build system was looking inside node_modules. So I put it inside node_modules and was able to use it from my main project. Same issue. If you reference a type directly like
Dependency__ShortString.tit works but if you go through the wrapping module it doesn't. When you access a type through the root wrapping module the typescript is looking for a filesome dependency/src/Wrapped.genand there isn't anything in it. Just doingmodule ShortString = Dependency__ShortStringdoesn't generate any .gen file. This little example I played with is not much different than the code I already have in my repro where I am trying to access Core.I looked back at the code that is accessing Core. When I try to use a type through the root wrapping module the TypeScript is looking for
./Error.genand./Null.gen. Very weird. Why isn't it looking forRescriptCore.gen?I don't want to spend more time on this. Please just take my repro repository and do whatever additional experiments you want on it. I'm very inefficient because I don't understand pinned dependencies and other things about the build system. I tried modifying
Coreinside node_modules to generate.genfiles and it is very flaky. It was complaining about the annotations being ignored because there was aresifile, even though I usedignoreInterfacein several places. I did a bunch of clean then rebuild etc. and finally it randomly started working. I have no idea why. Lots of wasted time. The existence of aRescriptCore.gen,Core__Error.genetc. did NOT seem to change the fact that the generated TypeScript still looks for./Error.genand./Null.gen.cristianoc commentedon Apr 5, 2023
As per my question: is there a repro without using any dependencies?
cristianoc commentedon Apr 5, 2023
If it exists, it's going to be a simple combination of aliasing just like for the repo.
jmagaram commentedon Apr 5, 2023
That repro I mentioned in this thread has trouble using gentyoe with a local file. AND there is some code that tries to use Core as a dependency. So you can see what happens in both scenarios. If you don't want the dependency just take out Core - should not have any impact on your the no-dependency case.
cristianoc commentedon Apr 5, 2023
Sorry if I misunderstood.
My understanding is that all your examples have a dependency (project in node modules).
My question was whether there was an example that does not use any dependencies.
The reason for the question is trying to understand if the issue has to do with dependencies.
An example of the issue without any dependencies would help clarify the scope of the issue.
It is common practice when trying to understand unexpected behaviour to cut down the possible causes. This helps coming up with solutions and debugging the issue more in detail.
jmagaram commentedon Apr 5, 2023
Yes I understand the need to make examples that are as simple as they can be. I think my GitHub https://github.com/jmagaram/core-gentype is very simple. Yes it has a dependency but in 1 minute you can take it out of
bsconfig.jsonand delete theresfiles that use it -UseRootModule,UseFullPath, andOpenCore. So you can see the case where (a) there is a dependency, and (b) there is no dependency. Couldn't be much simpler. Are we having a communication problem here? Just look at the code and it will be very obvious what is going on.cristianoc commentedon Apr 5, 2023
Thank you. If you are confident that your example using core will have the same problem when core is removed, I will assume that dependencies can be excluded as a possible contributing factor to the issue.
cristianoc commentedon Apr 5, 2023
Because of this, we can close this issue, as this is the core repository.
And this issue can move to the compiler repository.
jmagaram commentedon Apr 5, 2023
Ok please move the issue to the other repository and reference this one. The issue is definitely not specific to Core.
cristianoc commentedon Apr 6, 2023
I'll ask a "friend" to read this convo and provide a small example:
...more exchanges...
I apologize for the oversight. Here's the revised example incorporating the @Gentype annotations:
MyModule.res:
Wrapper.res:
You are correct. We need an additional file that uses MyModuleAlias to fully illustrate the issue. Let's create another file called Usage.res:
cristianoc commentedon Apr 6, 2023
I made a small alteration to the last file
Usage.res:
That provides the self-contained minimal repro that I will open up an issue about in the compiler repo.
cristianoc commentedon Apr 6, 2023
Done: rescript-lang/rescript#6112
Closing this