Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 26.9k
Speed up TypeScript projects#5903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
14ac5f58fb90474cc09f4b8bb7c6174a81a75400fd3c85b80775555f5dd25e47a41d2b29ca55068e2f50048822806d769f117f14291c76ad9a8fc4d321d960File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -106,7 +106,7 @@ function handleSuccess() { | ||
| tryApplyUpdates(function onHotUpdateSuccess() { | ||
| // Only dismiss it when we're sure it's a hot update. | ||
| // Otherwise it would flicker right before the reload. | ||
| ErrorOverlay.dismissBuildError(); | ||
| tryDismissErrorOverlay(); | ||
| }); | ||
| } | ||
| } | ||
| @@ -140,19 +140,15 @@ function handleWarnings(warnings) { | ||
| } | ||
| } | ||
| printWarnings(); | ||
| // Attempt to apply hot updates or reload. | ||
| if (isHotUpdate) { | ||
| tryApplyUpdates(function onSuccessfulHotUpdate() { | ||
| // Only print warnings if we aren't refreshing the page. | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only thing I'm on the fence about, what's the reason for this change? Can you please add the reasoning in the code?
| ||
| // Otherwise they'll disappear right away anyway. | ||
| printWarnings(); | ||
| // Only dismiss it when we're sure it's a hot update. | ||
| // Otherwise it would flicker right before the reload. | ||
| ErrorOverlay.dismissBuildError(); | ||
| tryDismissErrorOverlay(); | ||
| }); | ||
| } else { | ||
| // Print initial warnings immediately. | ||
| printWarnings(); | ||
| } | ||
| } | ||
| @@ -183,6 +179,12 @@ function handleErrors(errors) { | ||
| // We will reload on next success instead. | ||
| } | ||
| function tryDismissErrorOverlay() { | ||
| if (!hasCompileErrors) { | ||
| ErrorOverlay.dismissBuildError(); | ||
| } | ||
| } | ||
| // There is a newer version of the code available. | ||
| function handleAvailableHash(hash) { | ||
| // Update last known compilation hash. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -29,7 +29,7 @@ const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent') | ||
| const paths = require('./paths'); | ||
| const getClientEnvironment = require('./env'); | ||
| const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin'); | ||
| const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin-alt'); | ||
| const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); | ||
| const typescriptFormatter = require('react-dev-utils/typescriptFormatter'); | ||
| // @remove-on-eject-begin | ||
| const getCacheIdentifier = require('react-dev-utils/getCacheIdentifier'); | ||
| @@ -617,17 +617,10 @@ module.exports = function(webpackEnv) { | ||
| typescript: resolve.sync('typescript', { | ||
| basedir: paths.appNodeModules, | ||
| }), | ||
| async: false, | ||
| async: isEnvDevelopment, | ||
| useTypescriptIncrementalApi: true, | ||
| checkSyntacticErrors: true, | ||
| tsconfig: paths.appTsConfig, | ||
| compilerOptions: { | ||
| module: 'esnext', | ||
| moduleResolution: 'node', | ||
| resolveJsonModule: true, | ||
| isolatedModules: true, | ||
| noEmit: true, | ||
| jsx: 'preserve', | ||
| }, | ||
| reportFiles: [ | ||
| '**', | ||
| '!**/*.json', | ||
| @@ -638,7 +631,8 @@ module.exports = function(webpackEnv) { | ||
| ], | ||
| watch: paths.appSrc, | ||
| silent: true, | ||
| formatter: typescriptFormatter, | ||
| // The formatter is invoked directly in WebpackDevServerUtils during development | ||
| formatter: isEnvProduction ? typescriptFormatter : undefined, | ||
deftomat marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| }), | ||
| ].filter(Boolean), | ||
| // Some libraries import Node modules but don't use them in the browser. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| const testSetup = require('../__shared__/test-setup'); | ||
| const puppeteer = require('puppeteer'); | ||
| const expectedErrorMsg = `Argument of type '123' is not assignable to parameter of type 'string'`; | ||
| test('shows error overlay in browser', async () => { | ||
| const { port, done } = await testSetup.scripts.start(); | ||
| const browser = await puppeteer.launch({ headless: true }); | ||
| try { | ||
| const page = await browser.newPage(); | ||
| await page.goto(`http://localhost:${port}/`); | ||
| await page.waitForSelector('iframe', { timeout: 5000 }); | ||
| const overlayMsg = await page.evaluate(() => { | ||
| const overlay = document.querySelector('iframe').contentWindow; | ||
| return overlay.document.body.innerHTML; | ||
| }); | ||
| expect(overlayMsg).toContain(expectedErrorMsg); | ||
| } finally { | ||
| browser.close(); | ||
| done(); | ||
| } | ||
| }); | ||
| test('shows error in console (dev mode)', async () => { | ||
| const { stderr } = await testSetup.scripts.start({ smoke: true }); | ||
| expect(stderr).toContain(expectedErrorMsg); | ||
| }); | ||
| test('shows error in console (prod mode)', async () => { | ||
| const { stderr } = await testSetup.scripts.build(); | ||
| expect(stderr).toContain(expectedErrorMsg); | ||
| }); |
| 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" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import * as React from 'react'; | ||
| class App extends React.Component { | ||
| render() { | ||
| return <div>{format(123)}</div>; | ||
| } | ||
| } | ||
| function format(value: string) { | ||
| return value; | ||
| } | ||
| export default App; |
| 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')); |
Uh oh!
There was an error while loading. Please reload this page.