Skip to content
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

Keep comments for ts interface generation ✨ #4020

Conversation

Freymaurer
Copy link
Contributor

I updated ts interface generation to keep xmlDoc comments from f# code. I tried to uphold existing patterns, but please check if everything is fine with you:

The changes transpile the following f# code:

/// This is a user, a very strange individium which will find each and every edge case existing.
[<AllowNullLiteral>]
[<Global>]
type User [<ParamObjectAttribute; Emit("$0")>] (id: int, ?name: string, ?age: int) =
    /// Id used for id stuff
    member val id = id with get, set
    /// name used for naming conventions
    member val name: string option = jsNative with get, set
    /// age because you never tell age
    member val age: int option = jsNative with get, set

to:

/**
 * This is a user, a very strange individium which will find each and every edge case existing.
 */
export interface User {
    /**
     * Id used for id stuff
     */
    id: int32,
    /**
     * name used for naming conventions
     */
    name?: string,
    /**
     * age because you never tell age
     */
    age?: int32
}

I kept the example in src/quicktest/QuickTest.fs.

src/quicktest/QuickTest.fs Outdated Show resolved Hide resolved
@ncave
Copy link
Collaborator

ncave commented Jan 22, 2025

@Freymaurer Can you also please update the changelog (both in Fable.Cli and Fable.Compiler) with this PR? Thanks!

@Freymaurer
Copy link
Contributor Author

Is there some contribution guide i can follow or just try to follow the existing patterns?

@MangelMaxime
Copy link
Member

Is there some contribution guide i can follow or just try to follow the existing patterns?

Just try to follow the existing convention for this PR it would be something like:

* [TS] Include XML Doc comment on interface properties (by @Freymaurer)

@Freymaurer
Copy link
Contributor Author

@ncave done!

@ncave ncave self-requested a review January 23, 2025 15:35
Copy link
Collaborator

@ncave ncave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

src/Fable.Transforms/Fable2Babel.fs Show resolved Hide resolved
@MangelMaxime MangelMaxime force-pushed the feature/emit_interface_paramObject branch from 9e62915 to 45a1ec5 Compare January 25, 2025 18:42
@MangelMaxime MangelMaxime force-pushed the feature/emit_interface_paramObject_withComments branch from 8966af1 to a06e807 Compare January 25, 2025 18:44
@MangelMaxime MangelMaxime merged commit cfc3426 into fable-compiler:feature/emit_interface_paramObject Jan 25, 2025
@MangelMaxime
Copy link
Member

Thank you

MangelMaxime added a commit that referenced this pull request Jan 26, 2025
…tern

* [TS] Emit `interface` declaration when encountering a `ParamObject` pattern

* Try fix condition

* Forward generics information

* Keep comments for ts interface generation ✨ (#4020)

* Keep comments for ts interface generation ✨

* Update QuickTest.fs, fix typo

* Update changelog and rmv print statements

* Generate the correct type name when assigning a `ParamObject` to a variable

* Add support for inheritance and multi shaped ParamObject

* Update changelog entry

* Revert `QuickTest.fs`

---------

Co-authored-by: Kevin Frey <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants