Skip to content
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

Dm 5 tsconfig #17

Merged
merged 24 commits into from
Dec 9, 2021
Merged

Dm 5 tsconfig #17

merged 24 commits into from
Dec 9, 2021

Conversation

BCerki
Copy link
Collaborator

@BCerki BCerki commented Dec 1, 2021

This PR:

  • creates a new tsconfig in the root
  • extends the existing 7 tsconfigs from the root tsconfig, removing duplication
  • standardizes import paths, notably for front-end files (previously 'front-end' stood in for 'front-end/typescript')

A few things I'd love feedback on:

  • I ran npm run front-end:watch, npm run back-end:watch, npm run front-test, npm run back-end:test, npm run migrations:latest to confirm the changes hadn't caused compilation errors. I think the front-/back-end scripts would have covered my changes to the shared tsconfig, but I'm not sure about the scripts one
  • I thought about moving the front-end's tsconfig to the root of the front-end folder (all the other tsconfigs are the roots of their respective folders) but I left it where it is because it's closer to the ts files--not sure if that's best
  • @mikevespi and I ran into issues deleting the paths from the testing tsconfigs, so we left them in for now (late-breaking thought--I think the issue is related to using mocha (the paths are imported from the tsconfig into 'index.js), so once we've switched to jest, it won't be an issue)
  • @wenzowski, I'm failing sonarcloud because of duplication in front-end files. The only changes I made to those files were the import statements, so I don't think I've introduced any new duplication?

@kriscooke kriscooke linked an issue Dec 2, 2021 that may be closed by this pull request
@sonarcloud
Copy link

sonarcloud bot commented Dec 2, 2021

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
16.4% 16.4% Duplication

@wenzowski
Copy link

I completely agree and if that's the only reason this is failing the Quality Gate then it's a good thing that's not a required status check–we'll exercise our code review discretion and ignore the duplication as it's a pre-existing issue, this PR does not represent a regression, and this PR improves the overall quality of the target branch by removing tsconfig duplication.

@BCerki BCerki marked this pull request as ready for review December 2, 2021 18:48
@BCerki
Copy link
Collaborator Author

BCerki commented Dec 7, 2021

These changes standardize the front-import paths so "front-end" always stands in for "front-end/typescript." This means no 1,000 changes to front-end file import paths.

The two testing index.js files grab paths from the tsconfig, which is why I couldn't delete the paths there (this may also be why I was getting errors about having comments). I was able to get the front-end testing index.js to grab the paths from the root tsconfig. The back-end testing index.js still grabs the paths from the back-end testing tsconfig because when I tried to get them from the root one, I started getting path errors for the files the tests imported, not sure why.

@@ -1,5 +1,5 @@
const path = require('path');
const compilerOptions = require('./tsconfig.json').compilerOptions;
const compilerOptions = require('../../tsconfig.json').compilerOptions;

process.chdir(__dirname);

Copy link
Collaborator Author

@BCerki BCerki Dec 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if the block starting line 11 should also use the root tsconfig--struggled with the documentation: https://www.npmjs.com/package/ts-node#:~:text=ts-node%20and-,register%20the%20loader,-for%20future%20requires

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't worry too much about it yet since the existing mocha suite runs just one example test. I'd split the work of improving or replacing the mocha harness to a new PR, and since we're reading a property out of a json file and that property is from the parent this looks right to me.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be absolutely correct we'd want to read both properties out of both json files and then merge together the compilerOptions sub-keys the way typescript does...but this is working now (it's in a better state than in main) and we're only missing the override of target and noEmit keys from the overridden child compilerOptions.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a tech debt card about merging the compilerOptions keys from the two files?

Copy link
Collaborator Author

@BCerki BCerki Dec 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will combine compilerOptions as part of this PR. Came across some conversation on registering ts-node, so I'm more confident line 11 is right as is.

wenzowski
wenzowski previously approved these changes Dec 9, 2021
Copy link

@wenzowski wenzowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

Copy link

@BryanGK BryanGK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! Let's 🚢!!

@BCerki BCerki merged commit 203d7ed into main Dec 9, 2021
@BCerki BCerki deleted the dm-5-tsconfig branch December 9, 2021 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Harmonize .tsconfig files (and merge, if possible)
3 participants