Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Option for generating member function instead of lambda-getter-setter #429

Closed
davedawkins opened this issue Oct 30, 2021 · 1 comment
Closed

Comments

@davedawkins
Copy link
Contributor

davedawkins commented Oct 30, 2021

I have a PR for this ready

The API I'm working with (Appwrite) has many member functions which are currently being generated as property getter/setters. It works, but doesn't (usefully) capture the optional arguments.

For example

declare class Api {
    account: {
        users: (name : string, loggedIn? : boolean | undefined) => string[];
    };
}
export { Api };

Current output:

type [<AllowNullLiteral>] ApiAccount =
    abstract users: (string -> (bool) option -> string[]) with get, set

Preferred output:

type [<AllowNullLiteral>] ApiAccount =
    abstract users: name: string * ?loggedIn: bool -> string[]

With the second form, I'm able to call the API as users.name("Joe"). I don't get the correct behaviour if I use the first form as users.name "Joe" None

@davedawkins
Copy link
Contributor Author

davedawkins commented Oct 30, 2021

Incoming PR implements this:
convertpropfns

davedawkins added a commit to davedawkins/ts2fable that referenced this issue Oct 30, 2021
Booksbaum added a commit to Booksbaum/ts2fable that referenced this issue Nov 14, 2021
Booksbaum added a commit to Booksbaum/ts2fable that referenced this issue Nov 14, 2021
When `Config.ConvertPropertyFunctions` is enabled and a TypeLiteral
contains a Function-Property, it's converted into interface (instead of
Anon Record)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant