You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm running the following, simple example, but the generated declarations include declarations from the test directory and create the following tree.
$ tree dist/
dist/
├── foo.js
├── lib
│ └── foo.d.ts
└── test
└── foo-spec.d.ts
If I however rename the test file to remove the ts-extension (mv test/foo-spec.ts test/foo-spec.js), I get the the following tree, which is more aligned with my expectations.
$ tree dist/
dist/
├── foo.d.ts
└── foo.js
How is one supposed to test (while still using typescript), but not let it affect the build output?
Declarations are generated for all ts files that are captured in tsconfig.json, if you don't specify relevant files in tsconfig, the default is all files in the same folder and in all subdirectories I believe.
In your case try creating 2 tsconfigs -- one for source that will get published and one for test that uses built source and runs tests. See files and include/exclude options in tsconfig-json.
agilgur5
changed the title
Building includes declerations from sibling test directory
Building includes declarations from sibling test directory -- use 2 tsconfigs
May 21, 2022
What happens and why it is wrong
I'm running the following, simple example, but the generated declarations include declarations from the test directory and create the following tree.
If I however rename the test file to remove the ts-extension (
mv test/foo-spec.ts test/foo-spec.js
), I get the the following tree, which is more aligned with my expectations.How is one supposed to test (while still using typescript), but not let it affect the build output?
Environment
Versions
rollup.config.js
tsconfig.json
package.json
plugin output with verbosity 3
The text was updated successfully, but these errors were encountered: