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

Feat/strict class type #34

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Julusian
Copy link
Collaborator

Related: #20

This completely overhauls how we handle the class type. Instead of mangling the class to be 'Promisey', we instead require that the original class operates in promises. This is needed because the following class will need code changes as the callback will instead return a Promise<number> not a number

export class CallbackClass {
	async basicFcn (cb: () => number) {
		return cb() + 5
	}
}

Also by doing this, we can very clearly whitelist what datatypes are allowed to be used, and using anything else will result in type errors.

Additionally, support for property getters/setters has been removed, as they do not translate properly, and end up with the setters wanting to be given a promise, and you cant await the set so could become a floating promise.

This does make it a very breaking change, as any class not specifically designed for this will not work.

TODO

  • Remove the code which handled getters/setters
  • Review the code for other 'dead' bits (the changes so far only change the typings)
  • Fix/remove the remaining disabled tests
  • Finish implementing the EventEmitter2 in house.ts and move it to be a core type for library consumers to use

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.

1 participant