forked from facebook/create-react-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from facebook/master
Update from upstream repo facebook/create-react-app@master
- Loading branch information
Showing
15 changed files
with
258 additions
and
33 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
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,46 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const os = require('os'); | ||
const codeFrame = require('@babel/code-frame').codeFrameColumns; | ||
const chalk = require('chalk'); | ||
const fs = require('fs'); | ||
|
||
function formatter(message, useColors) { | ||
const colors = new chalk.constructor({ enabled: useColors }); | ||
const messageColor = message.isWarningSeverity() ? colors.yellow : colors.red; | ||
|
||
const source = | ||
message.getFile() && | ||
fs.existsSync(message.getFile()) && | ||
fs.readFileSync(message.getFile(), 'utf-8'); | ||
let frame = ''; | ||
|
||
if (source) { | ||
frame = codeFrame( | ||
source, | ||
{ start: { line: message.line, column: message.character } }, | ||
{ highlightCode: useColors } | ||
) | ||
.split('\n') | ||
.map(str => ' ' + str) | ||
.join(os.EOL); | ||
} | ||
|
||
return [ | ||
messageColor.bold(`Type ${message.getSeverity().toLowerCase()}: `) + | ||
message.getContent() + | ||
' ' + | ||
messageColor.underline(`TS${message.code}`), | ||
'', | ||
frame, | ||
].join(os.EOL); | ||
} | ||
|
||
module.exports = formatter; |
7 changes: 3 additions & 4 deletions
7
...s/react-scripts/template/src/loaders.d.ts → packages/react-scripts/config/react-app.d.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 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 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
Empty file.
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,16 @@ | ||
const testSetup = require('../__shared__/test-setup'); | ||
|
||
test('builds in development', async () => { | ||
const { fulfilled, ...rest } = await testSetup.scripts.start({ smoke: true }); | ||
expect(fulfilled).toBe(true); | ||
}); | ||
test('builds in production', async () => { | ||
const { fulfilled } = await testSetup.scripts.build(); | ||
expect(fulfilled).toBe(true); | ||
}); | ||
test('passes tests', async () => { | ||
const { fulfilled } = await testSetup.scripts.test({ | ||
jestEnvironment: 'node', | ||
}); | ||
expect(fulfilled).toBe(true); | ||
}); |
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,9 @@ | ||
{ | ||
"dependencies": { | ||
"@types/react": "*", | ||
"@types/react-dom": "*", | ||
"react": "*", | ||
"react-dom": "*", | ||
"typescript": "3.1.3" | ||
} | ||
} |
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,8 @@ | ||
import App from './App'; | ||
|
||
it('reads a typescript file with no syntax error', () => { | ||
const app = new App(); | ||
expect(App.foo.bar).toBe(true); | ||
expect(App.foo.baz!.n).toBe(123); | ||
expect(app.n).toBe(123); | ||
}); |
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,20 @@ | ||
import * as React from 'react'; | ||
|
||
interface MyType { | ||
foo: number; | ||
bar: boolean; | ||
baz?: { n: number }; | ||
} | ||
|
||
type MyObject = Pick<MyType, 'bar' | 'baz'>; | ||
|
||
class App extends React.Component { | ||
static foo: MyObject = { bar: true, baz: { n: 123 } }; | ||
n = App.foo.baz!.n; | ||
|
||
render() { | ||
return <div />; | ||
} | ||
} | ||
|
||
export default App; |
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,5 @@ | ||
import * as React from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
import App from './App'; | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')); |