-
Notifications
You must be signed in to change notification settings - Fork 585
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
Add script to generate JS template apps from TS #4374
Conversation
# Strip types from every .ts* file (except those in node_modules) and write the output | ||
# to the corresponding file in react-native-template-realm-js, with the extension changed | ||
# to ".js" (regardless of whether the original was ".tsx" or ".ts") | ||
for i in `find . -path ./node_modules -prune -o -name "*.ts*" -print`; do npx detype $i $2/${i/\.ts*/\.js} ; done |
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.
@takameyer I'm wondering if maybe this should only convert files in app/
, and delete all the *.ts*
files in there first in case we delete/rename a file... WDYT?
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.
That makes sense. We should probably move the App.tsx
into app/
as well?
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.
See a4917cb
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 is amazing! We will have to ensure to get this into our CI at some point
What, How & Why?
Currently we have to manually sync our JS template apps with our TS template apps, which has led to them slipping out of sync.
This PR adds a script which strips the types out of the TS apps and writes the output into the JS template apps, using the detype npm package (tsc does not preserve comments and whitespace).
It also updates the JS apps with the output of the script.
A future enhancement might be to have the
react-native-template-realm-ts
as the "master" app, then we copy theapp
directory from there into the Expo template as part of this script, and generate the JS apps. This would mean we only have to maintain one set of app code, but each template could have its own supporting code.☑️ ToDos
Compatibility
label is updated or copied from previous entryBreaking
label has been applied or is not necessaryIf this PR adds or changes public API's: