Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !5533

Simplified TypeScript steps

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/brunolemos/typescript-steps into master 6 years ago
  • Overview 6
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: brunolemos

We don't need to tell users to rename multiple files at this step, only one. And it's not needed to add {} to tsconfig anymore since #5532.

Compare
  • master (base)

and
  • latest version
    3e855fa1
    1 commit, 2 years ago

1 file
+ 2
- 3

    Preferences

    File browser
    Compare changes
docusaurus/docs/adding-typescript.md
+ 2
- 3
  • View file @ 3e855fa1

  • Edit in single-file editor

  • Open in Web IDE


@@ -10,9 +10,8 @@ Recent versions of [TypeScript](https://www.typescriptlang.org/) work with Creat
@@ -10,9 +10,8 @@ Recent versions of [TypeScript](https://www.typescriptlang.org/) work with Creat
To add TypeScript to a Create React App project, follow these steps:
To add TypeScript to a Create React App project, follow these steps:
1. Run `npm install --save typescript @types/react @types/react-dom @types/jest` (or `yarn add typescript @types/react @types/react-dom @types/jest`).
1. Run `npm install --save typescript @types/react @types/react-dom @types/jest` (or `yarn add typescript @types/react @types/react-dom @types/jest`).
2. Rename the `.js` files you want to convert: use `.tsx` if they use JSX or `.ts` if not (e.g. `git mv src/index.js src/index.tsx`).
2. Rename `src/index.js` to `src/index.tsx` or create an empty [`tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) at the root project directory.
3. Create a [`tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) at the root project directory with `{}` in it. Alternatively, rename `index.js` to `index.tsx`.
3. Restart your development server (if applicable). This will set sensible defaults and the required values in your [`tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html).
4. Restart your development server (if applicable). This will set sensible defaults and the required values in your [`tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html).
Type errors will show up in the same console as the build one.
Type errors will show up in the same console as the build one.
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
2
issue: typescript tag: documentation
2
issue: typescript tag: documentation
    Assign labels
  • Manage project labels

Milestone
2.1
2.1
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
1
1 participant
Administrator
Reference: facebook/create-react-app!5533
Source branch: github/fork/brunolemos/typescript-steps

Menu

Explore Projects Groups Snippets