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

Implement logic to check previously generated methods to avoid repetition #95

Closed

Conversation

HeavenVolkoff
Copy link
Contributor

Hello,

This is my implementation of a fix for #92, It also includes some other changes:

  • Move functionHasConflict and related functions to utils.ts
  • Break conflict resolver outer loop as soon as unresolved conflicts are detected
  • Improve resolution between class methods and conflicting inherited ones. Only add as overloads inherited methods that are incompatible with the class implementation
  • Add ignore property to TsFunction, differ from hasUnresolvedConflict as no reference to this function will be included in the generated type definition
  • Introduce tracking of generated functions in type-definition-generator.ts's generateFunction to avoid producing redundant entries

I am opening this as a draft for now, because I think this still needs more tests, and I wanted @JumpLink's input about whether he agrees with this solution, as it has a (minor) performance impact.

Another thing I wanted to discuss is if the case of overlapping input/return types in overloads should be dealt by these changes, or if it should be a separated issue (IMO I think so). This seems to be somewhat common, especially with optional and nullable types and sometimes with overlapping union types
Example (notice the optional for the cancellable argument is the only difference between both init definitions):
image

@JumpLink
Copy link
Collaborator

JumpLink commented Oct 5, 2022

@HeavenVolkoff this all sounds very good so far, unfortunately I don't have time to look at it in detail right now, I hope I'll get to it next week

@HeavenVolkoff
Copy link
Contributor Author

No worries @JumpLink. I am in no hurry. Btw, thank you for the work you put into this project, and in keeping up with my stream of issues and PRs 👍🏼

…tion

 - Move functionHasConflict and related functions to utils.ts
 - Break conflict reolver outer loop as soon as unresolved conflicts are detected
 - Improve resolution between class methods and conflicting inherited ones. Only add as overloads inhereted methods that are incompatible with the class implementation
 - Add ignore property to TsFunction, differ from hasUnresolvedConflict as no reference to this function will be included in the generated type definition
 - Introduce tracking of generated functions in type-definition-generator.ts's generateFunction to avoid producing redundant entries
@JumpLink JumpLink deleted the branch gjsify:main July 24, 2023 14:27
@JumpLink JumpLink closed this Jul 24, 2023
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.

None yet

2 participants