Closed ernieturner closed 7 years ago
You will need a separate tsconfig.json that includes your test files along with the necessary compiler options and files to build the appropriate context. They are excluded in the above project, so TypeScript will effectively treat them as standalone files when opened.
It the problem only applies for jest, you can add this to your jest config:
"jest": {
"testPathIgnorePatterns": [
"<rootDir>/build/",
"<rootDir>/node_modules/"
]
}
For more info on working with multiple tsconfig.json files, see this StackOverflow answer. Basically you'd make use of the "extends"
field so as to not duplicate your compiler options overmuch.
You may need to change how you run tsc
just a tad:
tsc --project tsconfig.production.json # or whatever you call your other tsconfig
My tsconfig file currently looks like this
And my code is setup where my unit test files are located in a
tests
directory as a sibling of the source file, e.g.When I compile my code the current setup works find and ignores all unit test files during compilation. However, when I open the unit test files in Sublime with this configuration it can't find any of the global types that it should find from jasmine/karma/etc.
If I remove the unit test file from the
exclude
list in tsconfig, then it all starts working again.Is there a way to exclude files from TS compilation but still have the plugin process them correctly?