-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
It's common to have different configurations for files in the same directory with different name patterns. The most common is file.ts and file.test.ts. We usually have different configurations for test files. For instance the global "jest" type is needed in test files but not in source files.
To separate configuration for test and source we can have two separate tsconfig.json files which "include" only test and source:
// tsconfig.json
{
"exclude": ["*.test.ts"]
} Exclude glob is pending #10202
// test.tsconfig.json
{
"include": ["*.test.ts"],
"compilerOptions": {
"types": ["jest"]
}
} But this is not optimal for IDEs and other tsc users.
Glob based tsconfig.json
I'm proposing a glob based tsconfig.json which has different config per glob pattern:
[
{
// Shared config
"compilerOptions": {}
},
{
"include": ["*.test.ts"],
"compilerOptions": {
"lib": ["jest"]
}
}
]Changes to tsconfig.json
- It can be an array of configurations
- Each item in the array can specify
includeorexcludefor fine grained compiler options
Resolving compiler option per file pattern
TODO
Conflicting exclude and include pattern between compiler options
TODO
this way one tsconfig.json can serve for all files with different configs per pattern
TypeScript Version: 2.7
Search Terms:
- TSConfig
- Glob
- Pattern
TasukuUno, alistair-hmh, yacinehmito, ozyman42, SpainTrain and 24 moreFilipeBeckscreendriver
Metadata
Metadata
Assignees
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript