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

WIP: feat: typings #385

Closed
wants to merge 10 commits into from
Closed

WIP: feat: typings #385

wants to merge 10 commits into from

Conversation

daKmoR
Copy link
Collaborator

@daKmoR daKmoR commented Dec 19, 2018

This is a WIP - do NOT merge.

This PR contains a:

  • code refactor

Motivation / Use-Case

To prevent errors as a result of type mismatching.
closes: #378

Additional Info

This is an initial proposal - to spark a discussions on howto do the type linting and possible next steps.

PS: not 100% if everything still works as there where some small refactors needed to allow for proper typing.
PPS: Typings are pretty loose so far and I am by no means an export on this so help is definitely wanted :)

to do the linting you need to run

npm run lint:types

currently, there are no typing errors... but it would be good to do this linting in the ci?

In order to support dynamic imports we add all their contents to
the main bundle as well.
@matthieu-foucault
Copy link
Collaborator

Great work! What you need to do now is import the type definitions from karma and webpack, to get rid of those remaining any.

For instance, towards the top of karma-webpack.js, you can add the following:

/** @typedef {import('karma').ConfigOptions} KarmaConfigOptions  */

And then, type registerExtraWebpackFiles as follows:

/**
 * @param {KarmaConfigOptions} config
 * @param {KarmaWebpackController} _controller
 */

You'll have an error below saying that config.files may be undefined, so we should check for that.

I agree that type linting should ultimately be done in the CI

@matthieu-foucault
Copy link
Collaborator

@daKmoR Let me know how I can help. I can type things (just did this on a massive project this year so I'm pretty efficient with this type of task 😄 )
We should synchronize on Gitter though if you want me to push to this branch

@daKmoR
Copy link
Collaborator Author

daKmoR commented Dec 19, 2018

@matthieu-foucault thx :)
working together sounds great 💪 - feel free to push more commits to the branch 👍

@ryanclark
Copy link
Collaborator

What’s everyone’s thoughts about rewriting it in TypeScript and changing the build process?

@daKmoR
Copy link
Collaborator Author

daKmoR commented Dec 30, 2018

As discussed in #378 a solution where we have type linting but do not need to require full typescript is probably a better situation for open source projects of this type.

  1. still gives you typings for IDE and errors
  2. easier for contributors

Also, within webpack it is handled the same way.
Some tweet about it: https://twitter.com/TheLarkInn/status/1078340062440509443

So my vote would be for this approach typings + type linting.

@ryanclark
Copy link
Collaborator

Fair enough, was just throwing the idea out there.

@daKmoR
Copy link
Collaborator Author

daKmoR commented Jan 2, 2019

fyi: just stumbled over this https://www.npmjs.com/package/@types/karma-webpack - so there are already types for karma-webpack

@matthieu-foucault
Copy link
Collaborator

Yes, this is the option I mentioned here. We can submit updates to this package later, but we don't need to use it ourselves (that's only if you want to type check your karma config).

@codymikol
Copy link
Owner

Hey @daKmoR is this something you are still interested in at this point?

@daKmoR
Copy link
Collaborator Author

daKmoR commented Feb 1, 2021

hey, I'm afraid that's a no... we have moved on from karma and webpack to @web/test-runner.

closing this PR

@daKmoR daKmoR closed this Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants