avajs / ava

Node.js test runner that lets you develop with confidence 🚀
MIT License
20.74k stars 1.41k forks source link

README clarification needed for typescript setup #2544

Closed aubreyyan closed 4 years ago

aubreyyan commented 4 years ago

While digging through some issue/commit history regarding typescript, I ran into this

https://github.com/avajs/ava/blob/0e1886582833986b896c31859aa61d8da404e996/readme.md#typescript-support

from this commit https://github.com/avajs/ava/commit/0e1886582833986b896c31859aa61d8da404e996

which essentially reads

image

It has since been removed from the main readme and possibly replaced with a link to recipes/typescript.md (that's what it looks like, at least), which doesn't say anything regarding the tsconfig setup and instead points to avajs/typescript readme for setup, which says nothing about tsconfig.

So now, I'm stuck in the predicament of not knowing whether I need to make certain adjustments to my tsconfig, and switch to commonjs + es2015, as opposed to es2020.

Given this discrepancy, I think it's worth it to at least give a nod to the fact that in the past modifications needed to be made to tsconfig and what the state of typescript setup looks like now.

Also

This might be another issue, but is there a reason commonjs needs to be the tsconfig module setting as opposed to es2020? Have we just not upgraded?

novemberborn commented 4 years ago

I'm not sure I follow… are you upgrading an existing installation? Remembering something you did before?

AVA 3 supports CJS modules, and for most use cases on supporting Node.js versions ESM. We've removed any automatic transpilation.

@ava/typescript, at its current stage, makes it easier to run TypeScript tests, provided you have already compiled them. Assuming you're working on a Node.js program and not something that gets packaged further using, say, webpack, you shouldn't have to make any adjustments. If Node.js can run your program, AVA can run your tests.

Hope that helps. I don't think our documentation needs to explain why something it said previously is no longer valid.

(I'm closing this issue for housekeeping purposes, but let's keep the conversation going.)

aubreyyan commented 4 years ago

What I'm saying actually, is that the bit about needing to set module to commonjs is actually still a required step for typescript to find ava's type definitions. With latest versions of everything, since it was a project I started recently. @novemberborn

novemberborn commented 4 years ago

What I'm saying actually, is that the bit about needing to set module to commonjs is actually still a required step for typescript to find ava's type definitions.

Huh. Not sure why that would be. @sindresorhus?

aubreyyan commented 4 years ago

@novemberborn

I'm sure this has happened a thousand times but I can't reproduce it. I distinctly recall typescript complaining about my ava import until I switched the module from es2020 to commonjs, but I have since commented out module entirely and when creating a new ava project typescript works without any tsconfig. So we should be good here

sindresorhus commented 4 years ago

I don't think that's correct. Any module type should be able to find any kind of type definition. How you import such type definition matter though.

aubreyyan commented 4 years ago

@sindresorhus I think I commented too late! It's not reproducible so there probably isn't any problem.