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
  • !8983

Improve support for TypeScript file extensions

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Administrator requested to merge github/fork/jamescostian/improve_ts_extension_support into main 5 years ago
  • Overview 5
  • Commits 3
  • Pipelines 0
  • Changes 4

Created by: jamescostian

Fixes #6794 (closed), with mo's prior work as a fantastic starting point. Relevant docs were also updated.

When you use cra-template-typescript, this code will install @babel/register. Any projects that have @babel/register as a dependency (or devDependency) will cause @babel/register to be imported before importing src/setupProxy. Although I haven't tested it, this should also allow for other things like flow to work.


To verify my changes work, you may run the following:

git clone --single-branch --branch improve_ts_extension_support https://github.com/jamescostian/create-react-app.git
cd create-react-app
yarn
npm run create-react-app -- --use-npm --template typescript try-it-out
cd try-it-out
# Note that in the below line, it's a .ts file instead of a .js file
echo "module.exports = app => app.get('/proxied', (req, res) => res.send('IT WORKS!'))" > src/setupProxy.ts
# Make the changes immediately obvious
echo "location.pathname = '/proxied'" >> src/index.tsx
npm start

You will be brought to http://localhost:3000/proxied and see that it's proxying the request successfully to src/setupProxy.ts.

Activity

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
  1. 16 May, 2020 2 commits
    • James Costian's avatar
      Remove the attempt at supporting .d.tsx · 60e92494
      James Costian authored 5 years ago
      Turns out .d.tsx is not treated in the same special way as .d.ts.
      Source: https://github.com/microsoft/TypeScript/issues/4415
      Unverified
      60e92494
    • James Costian's avatar
      Merge remote-tracking branch 'upstream/master' into improve_ts_extension_support · 5a87c547
      James Costian authored 5 years ago
      Unverified
      5a87c547
  2. 10 May, 2020 1 commit
    • James Costian's avatar
      Improve support for TypeScript file extensions · 00b9d3a0
      James Costian authored 5 years ago
      Fixes #6794
      
      Also adds support for .d.tsx files, so that a project
      can consistently use .tsx instead of .ts files, everywhere.
      
      Uses @babel/register before loading src/setupProxy to provide TypeScript
      support, but only loads @babel/register for the TypeScript template or
      any project which has @babel/register as a dependency or devDependency
      Unverified
      00b9d3a0
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference: firstcontributions/first-contributions!54152
Source branch: github/fork/jamescostian/improve_ts_extension_support

Menu

Explore Projects Groups Snippets