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

Add type checking to source files #378

Closed
matthieu-foucault opened this issue Nov 30, 2018 · 9 comments
Closed

Add type checking to source files #378

matthieu-foucault opened this issue Nov 30, 2018 · 9 comments

Comments

@matthieu-foucault
Copy link
Collaborator

Expected Behavior / Situation

Not having bugs due to type errors

Actual Behavior / Situation

We have bugs such as #375 and #355 that wouldn't be there with static type checking

Modification Proposal

Build the source code with typescript

@alexander-akait
Copy link
Collaborator

@matthieu-foucault my recommendation doesn't rewrite code on typescript because it is hard maintenance for other developers, who not familiar with typescript and there are a lot of such contributors.

In webpack we use Typescript comments like this https://github.com/webpack/webpack/blob/master/lib/Compiler.js#L37. It is allow to static type checking and other developers easy work with code (you can merge PRs and late add types).

@matthieu-foucault
Copy link
Collaborator Author

Nice!, I didn't know that was possible, thanks for the tip!

For future reference, here's the documentation for that: https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html

@matthieu-foucault matthieu-foucault changed the title Migrate source code to Typescript Add type checking to source files Dec 13, 2018
@daKmoR
Copy link
Collaborator

daKmoR commented Dec 13, 2018

So the idea is to keep js as is (just add some typescript definition files + jsdocs) but still run a check via typescript?

that actually sounds really nice :)

@alexander-akait
Copy link
Collaborator

alexander-akait commented Dec 13, 2018

@daKmoR yep, you can look setup in webpack repo 👍

@daKmoR daKmoR mentioned this issue Dec 19, 2018
1 task
@daKmoR
Copy link
Collaborator

daKmoR commented Dec 19, 2018

@evilebottnawi at this wip you can see my intial attempt at starting type linting - can you pls check if it's the right direction?

also would we still need to generate type definition files or are the js doc hints good enough? If there would be a need to generate them any sugguestion on howto? I looked at the webpack setup but that seems rather complex 🙈

@matthieu-foucault
Copy link
Collaborator Author

matthieu-foucault commented Dec 19, 2018

Generating the typedefs is done simply by adding "declaration": true to the tsconfig compilerOptions,
and adding a "types": "./lib/main.d.ts" entry to the package.json.

The other option is to publish under @types/karma-webpack, which may be the preferred way (at least that seems to be what webpack is doing).

Either way, I don't think that publishing the type declarations would have much of an impact (unless someone writes something that extends karma-webpack 😨 )

@daKmoR
Copy link
Collaborator

daKmoR commented Dec 30, 2018

Generating the typedefs is done simply by adding "declaration": true to the tsconfig compilerOptions,
and adding a "types": "./lib/main.d.ts" entry to the package.json.

@matthieu-foucault hmm that does not seem to work? I would expect that a file ./lib/main.d.ts get's generated if I run ./node_modules/.bin/tsc --declaration

@matthieu-foucault
Copy link
Collaborator Author

Sorry, just noticed that comment now: might be because of the noEmit option?

@codymikol codymikol removed this from the 5.0.0 milestone Feb 3, 2021
@codymikol
Copy link
Owner

As karma is now deprecated and coming up on EOL, we are no longer planning on any significant enhancements to this project and are instead going to focus on security updates, stability, and a migration path forward as karma's lifecycle comes to an end.

Thank you for supporting and using this project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants