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

Rewrite source in Typescript #25

Closed
wants to merge 9 commits into from
Closed

Conversation

asa-taka
Copy link
Contributor

@asa-taka asa-taka commented Nov 11, 2021

Currently index.d.ts exists (very helpful, thanks), but there are some diffs between implementation and that typing.
So I propose to rewrite src/*.js in TypeScript.

Internal Design Changes

Nested clausures are flatten, now mod is a module-scope global variable.

  • TypeScript couldn't generate definitions of private things (e.g. class Common inside of _setup function).
    • At first, I've tried to define module definitions by ReturnType, to keep original code shape, but got TS4025 error (ref).
  • To put out members, which originally placed inside setup function, I add a singleton variable mod, like a global variable inside mcl-wasm module.
    • Because many components inside setup function depend mod on the outside scope of them.
    • The new mod varialbe will be initialized after mcl.init() call, thus it doesn't leads braking changes for users.

Braking Changes (maybe nothing)

For JavaScript Users

Nothing. I've confirmed:

  • Exported member names are identical during this changes
  • All tests are passed
  • Browser domo works

For TypeScript Users

Types are refactored. I've confirmed no TypeScript errors in test/test-ts.ts.

TODO Before Merge

  • Remove tmp-for-ts-migration directory
    • This shows no API changes and no performance degrading

@asa-taka asa-taka changed the title Write source in Typescript Rewrite source in Typescript Nov 11, 2021
@asa-taka asa-taka marked this pull request as ready for review November 11, 2021 15:49
@asa-taka asa-taka changed the base branch from master to dev November 12, 2021 02:22
@asa-taka asa-taka changed the base branch from dev to master November 12, 2021 02:32
@asa-taka
Copy link
Contributor Author

Sorry for many rebasing. I've misunderstood this repo's manner.

src/value-types.ts Outdated Show resolved Hide resolved
@asa-taka
Copy link
Contributor Author

@herumi Thank you for merging 🎉

@asa-taka asa-taka closed this Dec 15, 2021
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

1 participant