Repository: create-react-app
Issue: Changing compiler target in tsconfig.json does not seem to have any effect
Labels: needs triage,issue: bug report

### Describe the bug

When I update my Typescript compilation target to `es2017` in `tsconfig.json`, there does not seem to be any effect.

### Did you try recovering your dependencies?

<!--
  Your module tree might be corrupted, and that might be causing the issues.
  Let's try to recover it. First, delete these files and folders in your project:

    * node_modules
    * package-lock.json
    * yarn.lock

  Then you need to decide which package manager you prefer to use.
  We support both npm (https://npmjs.com) and yarn (http://yarnpkg.com/).
  However, **they can't be used together in one project** so you need to pick one.

  If you decided to use npm, run this in your project directory:

    npm install -g npm@latest
    npm install

  This should fix your project.

  If you decided to use yarn, update it first (https://yarnpkg.com/en/docs/install).
  Then run in your project directory:

    yarn

  This should fix your project.

  Importantly, **if you decided to use yarn, you should never run `npm install` in the project**.
  For example, yarn users should run `yarn add <library>` instead of `npm install <library>`.
  Otherwise your project will break again.

  Have you done all these steps and still see the issue?
  Please paste the output of `npm --version` and/or `yarn --version` to confirm.
-->
Yes, as per instructions.
```
» npm --version
6.14.8
```

### Environment

<!--
  To help identify if a problem is specific to a platform, browser, or module version, information about your environment is required.
  This enables the maintainers quickly reproduce the issue and give feedback.

  Run the following command in your React app's folder in terminal.
  Note: The result is copied to your clipboard directly.

  `npx create-react-app --info`

  Paste the output of the command in the section below.
-->

```
» npx create-react-app --info
npx: installed 92 in 6.354s

Environment Info:

  current version of create-react-app: 4.0.0
  running from /local/home/ctod/.npm/_npx/22463/lib/node_modules/create-react-app

  System:
    OS: Linux 5.4 Amazon Linux 2
    CPU: (8) x64 Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz
  Binaries:
    Node: 12.18.3 - ~/.nvm/versions/node/v12.18.3/bin/node
    Yarn: Not Found
    npm: 6.14.8 - ~/.nvm/versions/node/v12.18.3/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: support!
Mozilla Firefox 68.6.1esr
  npmPackages:
    react: ^16.13.1 => 16.14.0
    react-dom: ^16.13.1 => 16.14.0
    react-scripts: 4.0.0 => 4.0.0
  npmGlobalPackages:
    create-react-app: Not Found
```

I can't update to react-scripts 4.0.1 yet as it hasn't been pushed through to our private npm repo (it usually takes a couple of days).

### Steps to reproduce

<!--
  How would you describe your issue to someone who doesn’t know you or your project?
  Try to write a sequence of steps that anybody can repeat to see the issue.
-->

(Write your steps here:)

1. React/Typescript app was previously created with `create-react-app --typescript`, using `create-react-app` 3.4.x
2. In `src/index.tsx` - the entry point to my React app, I have a call to an asynchronous function at the top level:

`const thing = await returnsPromise();`

3. When running `npm run start`, I get the error "Cannot use await outside of an async function":

```
Module parse failed: Cannot use keyword 'await' outside an async function (16:22)
File was processed with these loaders:
 * ./node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|
| const config = new ThingConfig();
> const aConfigThing = await ThingConfig.thing();
```

4. await at the top level requires a typescript 'target' of 'es2017' or above and a 'module' of 'esnext'.
5. Update `tsconfig.json` to the following:

```javascript
{
  "compilerOptions": {
    "target": "es2017",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react"
  },
  "include": [
    "src"
  ]
}
```


### Expected behavior

<!--
  How did you expect the tool to behave?
  It’s fine if you’re not sure your understanding is correct.
  Just write down what you thought would happen.
-->

After changing the target in `tsconfig.json`, I expected the feature to work.

### Actual behavior

After changing the target in `tsconfig.json`, I get the same compilation failure.
<!--
  Did something go wrong?
  Is something broken, or not behaving as you expected?
  Please attach screenshots if possible! They are extremely helpful for diagnosing issues.
-->

(Write what happened. Please add screenshots!)



<!--
  What happens if you skip this step?

  We will try to help you, but in many cases it is impossible because crucial
  information is missing. In that case we'll tag an issue as having a low priority,
  and eventually close it if there is no clear direction.

  We still appreciate the report though, as eventually somebody else might
  create a reproducible example for it.

  Thanks for helping us help you!
-->