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

Co-located test files have type declarations generated in dist folder #464

Closed
selbekk opened this issue Jan 28, 2020 · 4 comments · Fixed by #472
Closed

Co-located test files have type declarations generated in dist folder #464

selbekk opened this issue Jan 28, 2020 · 4 comments · Fixed by #472
Labels
kind: feature New feature or request kind: support Asking for support with something or a specific use case

Comments

@selbekk
Copy link
Contributor

selbekk commented Jan 28, 2020

Current Behavior

If you run

npx tsdx create test-project # choose react

, create a test file (say index.test.tsx) with some content, and run yarn build, you'll end up with a file called dist/index.test.d.ts.

Expected behavior

TSDX shouldn't create this.

Suggested solution(s)

Perhaps there's a filter you could apply? Idk 🤷‍♂ Haven't had time to research it yet.

Your environment

Software Version(s)
TSDX @latest
TypeScript not installed
Browser n/a
npm/Yarn yarn 1x
Node lts
Operating System osx
@agilgur5
Copy link
Collaborator

agilgur5 commented Jan 29, 2020

See ezolenko/rollup-plugin-typescript2#132 (comment) .

Is your test file in test/ or in src/?
If it's in test/ and this still occurs then the problem might be that the test/ directory is in the tsconfig "include": section in the templates of tsdx create.

I have tests in test/ and in my tsconfig.json have "include": ["src", "types"] and tests never have declaration files generated in dist/.

@selbekk
Copy link
Contributor Author

selbekk commented Jan 30, 2020

Seems to be the issue indeed.

My test files are co-located in the src folder, and that's where I want them to belong.

I guess I can exclude **/*.spec.tsx and **/*.test.tsx. I can add those to the default config in a pull request - is that something you'd like?

@agilgur5
Copy link
Collaborator

agilgur5 commented Jan 30, 2020

Just to confirm, did setting "exclude": ["**/*.spec.tsx", "**/*.test.tsx"] in your project's tsconfig.json resolve the issue?

I'm open to adding those as defaults as such project configurations are not uncommon, but don't feel strongly about it one way or the other. At the same time, TSDX doesn't have any built-in default includes either (just those in the templated tsconfigs). Can see what the other maintainers think in a PR ¯\_(ツ)_/¯
If you do decide to send a PR, keep in mind you'll need to add the defaults for exclude as well, e.g. node_modules etc. Also would add the equivalent .ts (not just .tsx)

@selbekk
Copy link
Contributor Author

selbekk commented Jan 30, 2020

Just to confirm, did setting "exclude": ["/*.spec.tsx", "/*.test.tsx"] in your project's tsconfig.json resolve the issue?

Yep!

For sure, I'll make sure to remember all of those. I guess I can make the PR, and do the rest of the discussion there

@agilgur5 agilgur5 changed the title Typings for test files end up in dist folder Co-located test files have type declarations generated in dist folder Mar 9, 2020
@agilgur5 agilgur5 added kind: feature New feature or request kind: support Asking for support with something or a specific use case labels Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: feature New feature or request kind: support Asking for support with something or a specific use case
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants