File tree 4 files changed +53
-0
lines changed
4 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 36
36
" openChrome.applescript" ,
37
37
" printBuildError.js" ,
38
38
" printHostingInstructions.js" ,
39
+ " typescriptFormatter.js" ,
39
40
" WatchMissingNodeModulesPlugin.js" ,
40
41
" WebpackDevServerUtils.js" ,
41
42
" webpackHotDevClient.js"
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ 'use strict' ;
9
+
10
+ const os = require ( 'os' ) ;
11
+ const codeFrame = require ( '@babel/code-frame' ) . codeFrameColumns ;
12
+ const chalk = require ( 'chalk' ) ;
13
+ const fs = require ( 'fs' ) ;
14
+
15
+ function formatter ( message , useColors ) {
16
+ const colors = new chalk . constructor ( { enabled : useColors } ) ;
17
+ const messageColor = message . isWarningSeverity ( ) ? colors . yellow : colors . red ;
18
+
19
+ const source =
20
+ message . getFile ( ) &&
21
+ fs . existsSync ( message . getFile ( ) ) &&
22
+ fs . readFileSync ( message . getFile ( ) , 'utf-8' ) ;
23
+ let frame = '' ;
24
+
25
+ if ( source ) {
26
+ frame = codeFrame (
27
+ source ,
28
+ { start : { line : message . line , column : message . character } } ,
29
+ { highlightCode : useColors }
30
+ )
31
+ . split ( '\n' )
32
+ . map ( str => ' ' + str )
33
+ . join ( os . EOL ) ;
34
+ }
35
+
36
+ return [
37
+ messageColor . bold ( `Type ${ message . getSeverity ( ) . toLowerCase ( ) } : ` ) +
38
+ message . getContent ( ) +
39
+ ' ' +
40
+ messageColor . underline ( `TS${ message . code } ` ) ,
41
+ '' ,
42
+ frame ,
43
+ ] . join ( os . EOL ) ;
44
+ }
45
+
46
+ module . exports = formatter ;
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ const paths = require('./paths');
24
24
const ManifestPlugin = require ( 'webpack-manifest-plugin' ) ;
25
25
const ModuleNotFoundPlugin = require ( 'react-dev-utils/ModuleNotFoundPlugin' ) ;
26
26
const ForkTsCheckerWebpackPlugin = require ( 'fork-ts-checker-webpack-plugin-alt' ) ;
27
+ const typescriptFormatter = require ( 'react-dev-utils/typescriptFormatter' ) ;
27
28
// @remove -on-eject-begin
28
29
const getCacheIdentifier = require ( 'react-dev-utils/getCacheIdentifier' ) ;
29
30
// @remove -on-eject-end
@@ -419,6 +420,8 @@ module.exports = {
419
420
checkSyntacticErrors : true ,
420
421
tsconfig : paths . appTsConfig ,
421
422
watch : paths . appSrc ,
423
+ silent : true ,
424
+ formatter : typescriptFormatter ,
422
425
} ) ,
423
426
] . filter ( Boolean ) ,
424
427
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ const paths = require('./paths');
28
28
const getClientEnvironment = require ( './env' ) ;
29
29
const ModuleNotFoundPlugin = require ( 'react-dev-utils/ModuleNotFoundPlugin' ) ;
30
30
const ForkTsCheckerWebpackPlugin = require ( 'fork-ts-checker-webpack-plugin-alt' ) ;
31
+ const typescriptFormatter = require ( 'react-dev-utils/typescriptFormatter' ) ;
31
32
// @remove -on-eject-begin
32
33
const getCacheIdentifier = require ( 'react-dev-utils/getCacheIdentifier' ) ;
33
34
// @remove -on-eject-end
@@ -539,6 +540,8 @@ module.exports = {
539
540
checkSyntacticErrors : true ,
540
541
tsconfig : paths . appTsConfig ,
541
542
watch : paths . appSrc ,
543
+ silent : true ,
544
+ formatter : typescriptFormatter ,
542
545
} ) ,
543
546
] . filter ( Boolean ) ,
544
547
// Some libraries import Node modules but don't use them in the browser.
You can’t perform that action at this time.
0 commit comments