-
Notifications
You must be signed in to change notification settings - Fork 995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert component generator to TS #632
Convert component generator to TS #632
Conversation
type: 'boolean', | ||
default: false, | ||
describe: 'Generate TypeScript files', | ||
alias: 'ts', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 alias!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯this should be default setup across generators for sure!
retainLines: true, | ||
}).code | ||
|
||
return prettify(filename.replace(/\.ts$/, '.js'), result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we have .tsx, does all the extension magic still work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pass the final .js
output filename to transformTSToJS
here, so teeeechnically the PR doesn't use this replace
logic. I can remove it, and it can be re-added whenever we end up needing it. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd vote to remove. But defer to your decision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's in master now, so I'll amend it to cover the .tsx
case in case other generators end up needing it too.
Hey @kimadeline, thanks for this! I'm going to merge @jmreidy's PR soon and then I'll get to this next! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing! Thank you so much for this!
I would love to start a discussion around refactoring the generator code to make it easier to test and to extend, I'll open up an issue with some ideas at tag you! |
@kimadeline huge thanks for getting this rolling! Just to make sure, did you see that @jmreidy is going to be unavailable for awhile -- new baby!! 🎉 I'm working on #633 this morning. It's going to be a very simple @peterp Did you see this Q above?
^^ +1 to add to template on my end. I opened redwoodjs/create-redwood-app#61 -- just merge or close as needed. |
Whoa hadn't seen it, thanks for the heads-up @thedavidprice, and congrats to you and your family @jmreidy 🎉 I'll merge master and get my test app straightened out hopefully this evening (more realistically this weekend 😬). |
@kimadeline I opened a pull-request that does all that on your fork! :) |
…erator-to-ts Kimadeline convert component generator to ts
For #523
✅ What it does
component/templates/
files converted to TSyarn rw lint
component/__tests__
and fixtures converted to TS--typescript
and--javascript
args foryarn rw g component
(also supports--ts
and--js
to save myself some keystrokes, but I can remove/update that if needed)--force
is used--javascript=true
at the moment🔮 What needs to be verified
yarn rw test
, but that might be because I used a previous version of Redwood to create my test app, and the templates have changed since then:🚧 What it doesn't do (yet)
tsconfig.json
for example).Do you know where this code (probably a common helper) should go, or if anybody already got started on it?Add getLanguage() helper for project typescript | javascript default and settings #633--force
option;jsconfig.json
file intestapp/web
should have the"jsx": "preserve"
option, which should probably added when creating the app. Thoughts? set jsx preserve in web/jsconfig create-redwood-app#61packages/cli/src/lib/__tests__/fixtures/prettier.config.js
but the paths are set up as such as they are pointing to/path/to/project/prettier.config.js
, and, well, there's nothing there 😞transformTSToJS
incomponent.test.ts
, and testtransformTSToJS
's output separately inlib/index.test.ts
or something.👏 Credits
This PR is "inspired" by #515 (
transformTSToJS
is basically a copy-🍝 with added flair) and #557 (took yourindex.d.ts
and added dirty ambient module declarations).