Updating expo-cli to support typescript by making sure that lib/insert.js inserts the relevant snippets into either app.js or app.ts, with app.ts taking priority. It previously only looked for and inserted into app.js
Design
The section of code that I modified in lib/insert.js first checks if app.ts exists. If it does, it checks whether the snippets are already there and inserts them if not. If app.ts does not exist, a try/catch block is implemented with the code to insert into app.js if it exists and does not already contain the snippets, and gives an error message that neither app.js nor app.ts could be found if not.
Testing
I added two tests: one to check that the snippets are correctly added to a fresh typescript project, and another to check that .ts is prioritised over .js (by checking that if both app.ts and app.js exist, snippets are only inserted into app.ts). I'm not entirely sure if the latter test is correctly checking that the snippets are not inserted into app.js.
I modified the test that checks if the correct error message is provided when app.js does not exist, to give an error message that neither app.js nor app.ts exist.
I ran the unit tests from my terminal and all looked good, but when I made this commit I got an email from Github saying all unit test jobs have failed, so not too sure why that is the case (update: I think I may have fixed this)
Goal
Updating expo-cli to support typescript by making sure that lib/insert.js inserts the relevant snippets into either app.js or app.ts, with app.ts taking priority. It previously only looked for and inserted into app.js
Design
The section of code that I modified in lib/insert.js first checks if app.ts exists. If it does, it checks whether the snippets are already there and inserts them if not. If app.ts does not exist, a try/catch block is implemented with the code to insert into app.js if it exists and does not already contain the snippets, and gives an error message that neither app.js nor app.ts could be found if not.
Testing
I added two tests: one to check that the snippets are correctly added to a fresh typescript project, and another to check that .ts is prioritised over .js (by checking that if both app.ts and app.js exist, snippets are only inserted into app.ts). I'm not entirely sure if the latter test is correctly checking that the snippets are not inserted into app.js.
I modified the test that checks if the correct error message is provided when app.js does not exist, to give an error message that neither app.js nor app.ts exist.
I ran the unit tests from my terminal and all looked good, but when I made this commit I got an email from Github saying all unit test jobs have failed, so not too sure why that is the case (update: I think I may have fixed this)
I don't know what other testing is needed