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

Migration to Typescript #183

Merged
merged 8 commits into from
Nov 27, 2022
Merged

Migration to Typescript #183

merged 8 commits into from
Nov 27, 2022

Conversation

PowerKiKi
Copy link
Contributor

@PowerKiKi PowerKiKi commented Oct 14, 2022

This does not use the official prosemirror build chain, but instead keep our custom build chain based on Rollup.

While the commit is big I tried to minimize changes as much as possible. Specifically no logic should have been touched at all.

Typing is now generated by typescript and bundled by api-extractor, so that is always synced.

@PowerKiKi
Copy link
Contributor Author

@marijnh I hope you don't mind me pinging you here. I know you are not maintaining this project. However I am in the progress of migrating this package from JS to TS, like you did recently all other prosemirror packages. And I meant to re-use your build tools to keep everything consistent. But I might need guidance on how you use them, and whether there are a good fit for this package too ?

First I am a bit confused by the absence of tsconfig.json in any prosemirror packages. How/where do you manage your TypeScript config ? eg: are you using strictNullChecks in your config ?

Then ./node_modules/.bin/pm-buildhelper src/index.ts will correctly building something in dist/. But it will always build, even if I have blatant typing error in my source. Is this on purpose ? or am I missing your tools ?

And finally what is your development workflow ? I could not find any "watch" options in your tools. Are you using tsc --watch directly ? but then what about tsconfig.json ?

PS: @ocavue, the conversion should be almost done. The only things missing are a solid build system and enabling strictNullChecks (no small feat 😅 ).

@marijnh
Copy link
Member

marijnh commented Nov 3, 2022

See the readme in https://github.com/prosemirror/prosemirror for my multi-package setup. But since this is maintained separately, you'll probably want to use a different setup for it.

@PowerKiKi PowerKiKi force-pushed the typescript branch 2 times, most recently from e3521c4 to d262939 Compare November 14, 2022 13:35
This does not use the official prosemirror build chain, but instead keep our
custom build chain based on Rollup.

While the commit is big I tried to minimze changes as much as possible.
Specifically no logic should have been touched at all.

Typing is now generated by typescript and bundled by api-extractor, so that is
always synced.
@PowerKiKi PowerKiKi marked this pull request as ready for review November 14, 2022 14:10
@PowerKiKi
Copy link
Contributor Author

This PR is ready for review. @ocavue could please approve the CI, so that we can be sure that everything is fine ?

@PowerKiKi PowerKiKi changed the title WIP migration to Typescript Migration to Typescript Nov 14, 2022
index.d.ts Show resolved Hide resolved
src/util.ts Outdated Show resolved Hide resolved
index.d.ts Show resolved Hide resolved
src/commands.ts Show resolved Hide resolved
src/tablemap.ts Outdated Show resolved Hide resolved
src/tablemap.ts Outdated Show resolved Hide resolved
/**
* @public
*/
export function addColSpan(attrs: Attrs, pos: number, n = 1): Attrs {
Copy link
Collaborator

@ocavue ocavue Nov 27, 2022

Choose a reason for hiding this comment

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

The old addColSpan and removeColSpan has <T>. Maybe we should add <T> too to avoid breaking changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I always end up with a typescript error down the line when I try to add generic. I am not entirely convinced whether we need a generic or not here 🤔

Would you have a use-case to help convincing me ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

To be honest, I don't feel the generic here is much useful. I only reason I posted my previous comment is to avoid breaking change. To make the code clear, I'm ok to remove the generic here. We have such breaking changes during the migration from @types/prosemirror-* to official prosemirror-* packages too, so I guess it's not a big deal.

@ocavue
Copy link
Collaborator

ocavue commented Nov 27, 2022

@PowerKiKi Thank you so much for your contribution! I'm sorry that it takes me so long to find a time reviewing it. I posted some review comments above. Let me know what do you think about them.

PowerKiKi and others added 5 commits November 27, 2022 14:37
Use a `Record`, instead of a literal, to be compatible with `OrderedMap.append()`
Co-authored-by: ocavue <ocavue@users.noreply.github.com>
@PowerKiKi
Copy link
Contributor Author

I fixed everything, except the last point. Maybe you can have a look again...

Copy link
Collaborator

@ocavue ocavue left a comment

Choose a reason for hiding this comment

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

LGTM. I will merge it into the master branch and release a beta version. After a period of time (maybe a week?), if everything is fine, I will release a new minor version.

@ocavue ocavue merged commit c557431 into ProseMirror:master Nov 27, 2022
@PowerKiKi PowerKiKi deleted the typescript branch February 3, 2023 14:31
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