mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-24 05:05:53 +08:00
Add TSC_COMPILE_ON_ERROR setting (#6931)
This commit is contained in:
@@ -337,6 +337,7 @@ The `args` object accepts a number of properties:
|
||||
- **urls** `Object`: To provide the `urls` argument, use `prepareUrls()` described below.
|
||||
- **useYarn** `boolean`: If `true`, yarn instructions will be emitted in the terminal instead of npm.
|
||||
- **useTypeScript** `boolean`: If `true`, TypeScript type checking will be enabled. Be sure to provide the `devSocket` argument above if this is set to `true`.
|
||||
- **tscCompileOnError** `boolean`: If `true`, errors in TypeScript type checking will not prevent start script from running app, and will not cause build script to exit unsuccessfully. Also downgrades all TypeScript type checking error messages to warning messages.
|
||||
- **webpack** `function`: A reference to the webpack constructor.
|
||||
|
||||
##### `prepareProxy(proxySetting: string, appPublicFolder: string): Object`
|
||||
|
||||
@@ -108,6 +108,7 @@ function createCompiler({
|
||||
urls,
|
||||
useYarn,
|
||||
useTypeScript,
|
||||
tscCompileOnError,
|
||||
webpack,
|
||||
}) {
|
||||
// "Compiler" is a low-level interface to Webpack.
|
||||
@@ -190,16 +191,28 @@ function createCompiler({
|
||||
|
||||
const messages = await tsMessagesPromise;
|
||||
clearTimeout(delayedMsg);
|
||||
statsData.errors.push(...messages.errors);
|
||||
if (tscCompileOnError) {
|
||||
statsData.warnings.push(...messages.errors);
|
||||
} else {
|
||||
statsData.errors.push(...messages.errors);
|
||||
}
|
||||
statsData.warnings.push(...messages.warnings);
|
||||
|
||||
// Push errors and warnings into compilation result
|
||||
// to show them after page refresh triggered by user.
|
||||
stats.compilation.errors.push(...messages.errors);
|
||||
if (tscCompileOnError) {
|
||||
stats.compilation.warnings.push(...messages.errors);
|
||||
} else {
|
||||
stats.compilation.errors.push(...messages.errors);
|
||||
}
|
||||
stats.compilation.warnings.push(...messages.warnings);
|
||||
|
||||
if (messages.errors.length > 0) {
|
||||
devSocket.errors(messages.errors);
|
||||
if (tscCompileOnError) {
|
||||
devSocket.warnings(messages.errors);
|
||||
} else {
|
||||
devSocket.errors(messages.errors);
|
||||
}
|
||||
} else if (messages.warnings.length > 0) {
|
||||
devSocket.warnings(messages.warnings);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user