question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using Typescript with gem

See original GitHub issue

I was wondering if it is possible to use typescript with this gem.

I do not have the config/wepback/loaders folder, but I do have config/weback/evironment.js to which I tried adding a typescript loader like so:

const { environment } = require('@rails/webpacker')

environment.loaders.set('typescript', {
  test: /.(ts|tsx)$/,
  loader: 'ts-loader'
});

module.exports = environment

Apart from adding this to my config/weback/evironment.js, I also ran yarn add ts-loader typescript @types/react @types/react-dom and added a tsconfig.json file.

This process did didn’t seem to work, so I was wondering if I am missing a step or if it’s even possible.

Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
iporollocommented, Feb 14, 2018

Will do, I’ll link the pull request here when I create it.

1reaction
iporollocommented, Feb 14, 2018

Hi @BookOfGreg,

Thank you for your quick response. The link you provided - https://github.com/rails/webpacker/blob/master/docs/typescript.md did the trick.

After following the initial set up of the react rails gem, you simply need to run:

bundle exec rails webpacker:install:typescript
yarn add @types/react @types/react-dom

This adds all of the necessary files and loaders for Typescript support. With that, it is now possible to declare react component files with the .tsx extension.

Thanks again for your time and help. If any more information is needed, let me know.

Read more comments on GitHub >

github_iconTop Results From Across the Web

typescript-node | RubyGems.org | your community gem host
RubyGems.org is the Ruby community's gem hosting service. Instantly publish your gems and then install them. Use the API to find out more...
Read more >
Just found this gem from my coworker in Typescript : r/typescript
Here is what I think your coworker will find interesting: 1)Install typescript-is : npm install --save-dev typescript-is.
Read more >
JavaScript and TypeScript Hidden Gems: Decorators
The main benefit of using decorators is that they allow you to enhance your code using a declarative syntax, which is quite easier...
Read more >
TypeScript Mapped Types as clauses // Hidden Gem - YouTube
In this tutorial, we look at a little-known feature of Advanced TypeScript called mapped type as clauses.
Read more >
@gemworks/gem-farm-ts - npm
@gemworks/gem-farm-ts. TypeScript icon, indicating that this package has built-in type declarations · Keywords.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found