-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TypeScript] POJO with [<ParamObject>]
generates missing type hint.
#4003
Comments
Adding |
Hey! I know what the attributes do, the issue is more on the documentation and intent side. The fable documentation says to simulate nice POJOs using the construct shown above with type |
Ah I see. Yea in that case it seems to me to be a bug if it's still generating code that references the erased type for an effectively anonymous structurally typed pojo. |
We should try to generate an interface when the following rules applies
This is IHMO what reflect the best the intention when we are applying theses attributes to a type. A POJO is equivalent to an interface in TypeScript. For reference, when |
Description
I am working on Fable transpiled React components for usage from typescript. I wanted to create the best possible native feeling for typescript users. My component uses a type which i had defined as record type before:
To improve usability from ts I changed it according to the docs to a js pojo using
[<ParamObject>]
here.Which works as intented but produces a type hint without reference:
Repro code
Here is the code with an example:
repl
Expected and actual results
I would expect fable to do one of the following transpilations with decreasing favorability:
interface
(best solution){ data?: Option<any>, description?: string, href?: string, id?: string, isObsolete?: boolean, name?: string, source?: string }
)any
Instead it produces a type hint towards the non-generated class, which can lead to huge issues, as having types with similiar names can lead to shadowing at worst.
Related information
4.19.0
and repl version4.23.0
The text was updated successfully, but these errors were encountered: