volument / baretest

An extremely fast and simple JavaScript test runner.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support TypeScript

motss opened this issue · comments

Description

I really love the simplicity of baretest but it would be great if a typing file could be provided for TypeScript users like myself. Perhaps a TypeScript support has already been in your roadmap.

This is not on the roadmap currently, but would make sense to have. I'm not personally not familiar with TypeScript and what's the best way to integrate it to a project. Hopefully someone can help on this.

@motss what problem are you hoping to solve with a typing file?

If it's convenience in your IDE, then you can configure your IDE to also evaluate JavaScript: https://medium.com/@trukrs/type-safe-javascript-with-jsdoc-7a2a63209b76

@motss Have a look at the Deno test runner, it has TypeScript built in. Works great for straight JS and TS using ES6 Modules. https://github.com/denoland/deno/tree/master/std/testing

I found TypeScript’s documentation for adding types to a library: TypeScript Docs – Declaration Files

With the help of that documentation and some example files, I have written a TypeScript declarations file baretest.d.ts. But the next question is where to publish it. According to TypeScript’s Declaration Files – Publishing docs, since this package is not written in TypeScript, I shouldn’t add the TypeScript declarations file to this repo, but rather to the DefinitelyTyped repo that is the source of the @types/… packages.

I think I agree with that suggestion to put the types in DefinitelyTyped, because the DefinitelyTyped repo comes with dtslint tests already set up, allowing me to write tests for the types. There is one downside to not including the types in this repo: TypeScript users will need an extra step, npm install @types/baretest, to get types working. But unless you are willing to convert this repo to use TypeScript, it’s not practical to include the types in this repo. And I assume that with your emphasis on minimalism, you wouldn’t want to use TypeScript, as it would introduce a compile step to this code.

I’ll post another comment here once I have published the types in DefinitelyTyped and you can close the issue.

I created a PR to add types for the current version of the library to DefinitelyTyped: DefinitelyTyped/DefinitelyTyped#43752.

My DefinitelyTyped PR has been merged, and types for Baretest 2.0 are now in the @types/baretest package.

Run npm install --save @types/baretest or yarn add @types/baretest to install the new types in your project. See TypeScript’s declaration file consumption docs for more details.

Baretest 1.0 users who haven’t upgraded to Baretest 2.0 yet: DefinitelyTyped’s merge process caused my types for Baretest 1.0 to be ignored, but I don’t think it’s worth complaining to DefinitelyTyped about. If you need the types for Baretest 1.0, get them from commit roryokane/DefinitelyTyped@bcdacb3, which is from the branch of the merged PR.

@motss @tipiirai I guess this issue can be closed now?