Convert component generator to TS#632
Convert component generator to TS#632peterp merged 12 commits intoredwoodjs:masterfrom kimadeline:convert-component-generator-to-ts
Conversation
| type: 'boolean', | ||
| default: false, | ||
| describe: 'Generate TypeScript files', | ||
| alias: 'ts', |
There was a problem hiding this comment.
💯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.
Now that we have .tsx, does all the extension magic still work?
There was a problem hiding this comment.
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.
I'd vote to remove. But defer to your decision.
There was a problem hiding this comment.
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! |
peterp
left a comment
There was a problem hiding this comment.
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 lintcomponent/__tests__and fixtures converted to TS--typescriptand--javascriptargs foryarn rw g component(also supports--tsand--jsto save myself some keystrokes, but I can remove/update that if needed)--forceis used--javascript=trueat 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.jsonfor 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--forceoption;jsconfig.jsonfile intestapp/webshould 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.jsbut the paths are set up as such as they are pointing to/path/to/project/prettier.config.js, and, well, there's nothing there 😞transformTSToJSincomponent.test.ts, and testtransformTSToJS's output separately inlib/index.test.tsor something.👏 Credits
This PR is "inspired" by #515 (
transformTSToJSis basically a copy-🍝 with added flair) and #557 (took yourindex.d.tsand added dirty ambient module declarations).