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

Perform compilation #3

Closed
novemberborn opened this issue Jan 26, 2020 · 5 comments · Fixed by #12
Closed

Perform compilation #3

novemberborn opened this issue Jan 26, 2020 · 5 comments · Fixed by #12
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@novemberborn
Copy link
Member

It should be possible to compile the TypeScript project before tests are run.

We should be able to control TypeScript programmatically. There is a feature to cache some of the compilation work, for faster subsequent compilation runs. We should use this.

As alluded to in #2 we should probably only support configuration files in the project directory itself (next to package.json files).

I'm not sure where to write the output files. Perhaps just follow the TypeScript configuration. With #2 done that makes it easiest to subsequently load the test files.

I'm not sure how to handle compilation errors. We could just write the files and run the tests. We could also explore an integration with AVA to surface errors better.

This should work automatically with AVA's watch mode, since AVA invokes compilation before every test run.

@novemberborn novemberborn added enhancement New feature or request help wanted Extra attention is needed labels Jan 26, 2020
@cinderblock
Copy link

How does this work with various rootDirs?

For instance, I usually use two tsconfig.conf files. The first is at the root (next to package.json) and that is for my src sources. It sets rootDir: 'src' since I want my output dist folder to not have the extra src directory in the path. This causes problems with test files in a different root dir. Therefore I use a second tsconfig.json to extend the first and give a rootDir (for testing) that includes both src and tests dir. This also enables using certain TypeScript features that I might only want in the testing environment.

@novemberborn
Copy link
Member Author

@szmarczak is working on an implementation in #12. Right now that assumes a single tsconfig.json file in the root.

I'm inclined to ship that, and then think about supporting your use case. Though in the meanwhile ideas are most welcome.

@novemberborn
Copy link
Member Author

Right now that assumes a single tsconfig.json file in the root.

Come to think of it, we can just invoke tsc and it should work fine.

@fregante
Copy link

Couldn't this be handled by @ava/babel with a TypeScript plugin?

@novemberborn
Copy link
Member Author

Couldn't this be handled by @ava/babel with a TypeScript plugin?

Sure, though if I understand correctly that strips types, and there are some constructs like const enum that don't work. But if it works for you then that's great.

@novemberborn novemberborn unpinned this issue Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants