-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: overwrite other fields in tsconfig.json (#440)
As we have full control over the config file content, we can easily overwrite other fields like `include` or `exclude`. It can be useful, for example, if you don't want to type-check storybook files in your webpack compilation. Now you don't have to create a separate tsconfig.json file to accomplish that. BREAKING CHANGE: 🧨 `typescript.compilerOptions` option changed to the `typescript.configOverwrite.compilerOptions` option
- Loading branch information
1 parent
2b72fd0
commit e812f18
Showing
14 changed files
with
178 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/typescript-reporter/TypeScriptConfigurationOverwrite.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
interface TypeScriptConfigurationOverwrite { | ||
extends?: string; | ||
compilerOptions?: object; | ||
include?: string[]; | ||
exclude?: string[]; | ||
files?: string[]; | ||
references?: { path: string; prepend?: boolean }[]; | ||
} | ||
|
||
export { TypeScriptConfigurationOverwrite }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 16 additions & 14 deletions
30
src/typescript-reporter/reporter/TypeScriptConfigurationParser.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { createSandbox, FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION, Sandbox } from './sandbox/Sandbox'; | ||
import { readFixture } from './sandbox/Fixture'; | ||
import { join } from 'path'; | ||
import { | ||
createWebpackDevServerDriver, | ||
WEBPACK_CLI_VERSION, | ||
WEBPACK_DEV_SERVER_VERSION, | ||
WebpackDevServerDriver, | ||
} from './sandbox/WebpackDevServerDriver'; | ||
|
||
describe('TypeScript Compiler Options parsing', () => { | ||
let sandbox: Sandbox; | ||
|
||
beforeAll(async () => { | ||
sandbox = await createSandbox(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await sandbox.reset(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await sandbox.cleanup(); | ||
}); | ||
|
||
it.each([ | ||
{ typescript: '2.7.1' }, | ||
{ typescript: '~3.0.0' }, | ||
{ typescript: '~3.6.0' }, | ||
{ typescript: '^3.8.0' }, | ||
])('reports errors because of the misconfiguration', async ({ typescript }) => { | ||
await sandbox.load([ | ||
await readFixture(join(__dirname, 'fixtures/environment/typescript-basic.fixture'), { | ||
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION: JSON.stringify( | ||
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION | ||
), | ||
TS_LOADER_VERSION: JSON.stringify('^5.0.0'), | ||
TYPESCRIPT_VERSION: JSON.stringify(typescript), | ||
WEBPACK_VERSION: JSON.stringify('^4.0.0'), | ||
WEBPACK_CLI_VERSION: JSON.stringify(WEBPACK_CLI_VERSION), | ||
WEBPACK_DEV_SERVER_VERSION: JSON.stringify(WEBPACK_DEV_SERVER_VERSION), | ||
ASYNC: JSON.stringify(false), | ||
}), | ||
await readFixture(join(__dirname, 'fixtures/implementation/typescript-basic.fixture')), | ||
]); | ||
|
||
let driver: WebpackDevServerDriver; | ||
let errors: string[]; | ||
|
||
await sandbox.write( | ||
'fork-ts-checker.config.js', | ||
'module.exports = { typescript: { configOverwrite: { compilerOptions: { target: "ES3", lib: ["ES3"] } } } };' | ||
); | ||
|
||
driver = createWebpackDevServerDriver(sandbox.spawn('npm run webpack-dev-server'), false); | ||
errors = await driver.waitForErrors(); | ||
expect(errors.length).toBeGreaterThan(0); | ||
await sandbox.kill(driver.process); | ||
|
||
await sandbox.write( | ||
'fork-ts-checker.config.js', | ||
'module.exports = { typescript: { configOverwrite: { include: [] } } };' | ||
); | ||
|
||
driver = createWebpackDevServerDriver(sandbox.spawn('npm run webpack-dev-server'), false); | ||
errors = await driver.waitForErrors(); | ||
expect(errors.length).toBeGreaterThan(0); | ||
await sandbox.kill(driver.process); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.