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

Fix/1031 #1035

Merged
merged 2 commits into from
Sep 7, 2021
Merged

Fix/1031 #1035

merged 2 commits into from
Sep 7, 2021

Conversation

GerkinDev
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: #1031

What is the new behavior?

Ensures ts-node register is called once, and if tried to be called multiple times, asserts that all uses same tsconfig.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

let lastTsConfig: string | null | undefined;
return (tsConfig?: string) => {
// Check if the function was previously called with the same tsconfig
if (typeof lastTsConfig !== 'undefined' && (tsConfig ?? null) !== lastTsConfig) {
Copy link
Owner

Choose a reason for hiding this comment

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

I think you can simplify it even more by initializing the lastTsConfig to null. Thus the only check you'll have to do is the equality check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't sure if you always call this function with a tsconfig parameter, since it is marked as optional in the calling function. So, to cover all cases, I did it this way. If the tsconfig parameter is always set, this simplification would still cover all cases, but the call signature should be changed.

Copy link
Owner

Choose a reason for hiding this comment

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

Fair point. Ok let's keep it this way.

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.

2 participants