Using Typescript with gem
See original GitHub issueI 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:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Will do, I’ll link the pull request here when I create it.
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:
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.