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

Enable strict mode #123

Merged
merged 4 commits into from
Feb 25, 2021
Merged

Conversation

AlexElin
Copy link
Contributor

@AlexElin AlexElin commented Feb 22, 2021

Description

Enable strict TS options.
Set them to the same values that Angular sets during creating a new project via ng new.
I fixed new type errors + add generics for better type checking

References

https://blog.angular.io/angular-cli-strict-mode-c94ba5965f63
https://angular.io/guide/strict-mode

Checklist

  • I have added documentation for new/changed functionality in this PR or in auth0.com/docs
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not master

@AlexElin AlexElin requested a review from a team as a code owner February 22, 2021 09:31
@frederikprijck
Copy link
Member

frederikprijck commented Feb 23, 2021

Thanks for this PR, we always appreciate contributions like this.
However, in general, it is a good idea to open an issue to discuss the subject first, to avoid doing work that might end up not being merged.

As this includes a breaking change, we will need to consider how and if we want to include this.
If we merge this PR, the following two code snippets, that would work fine in applications that use strict mode, will fail now:

config: AuthConfig;
constructor(private config: Auth0ClientConfig) {
  this.config = config.get(); // Strict Error: Type 'AuthConfig | undefined' is not assignable to type 'AuthConfig'
}

or

constructor(private config: Auth0ClientConfig) {
  const config = config.get();
  console.log(config.domain); // Strict Error: Object is possibly undefined
}

I am a big fan of using TypeScript strict mode, but if it is the only reason for introducing a breaking change, I am not sure I am keen on doing so.

I will keep this PR open, as I want to discuss this with our team as well. But keep in mind this isn't a priority for us at the moment, especially given the breaking change it introduces.

@frederikprijck frederikprijck added the needs investigation An issue that has more questions to answer or otherwise needs work to fully understand the issue label Feb 23, 2021
@AlexElin
Copy link
Contributor Author

In AuthClientConfig I changed get(): AuthConfig -> get(): AuthConfig | undefined becasue config looked as optional field.
I could revert the signature change and impelment the method like

  get(): AuthConfig {
    return this.config as AuthConfig;
  }

This would not change method API. So, as I understand, it would not be a breaking change

@frederikprijck frederikprijck added CH: Changed PR is changing something review:medium Medium review and removed needs investigation An issue that has more questions to answer or otherwise needs work to fully understand the issue labels Feb 23, 2021
@frederikprijck frederikprijck added this to the vNext milestone Feb 23, 2021
add options in tsconfig
Fix type errors + add generics
frederikprijck
frederikprijck previously approved these changes Feb 25, 2021
@frederikprijck frederikprijck merged commit 99be8fc into auth0:master Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CH: Changed PR is changing something review:medium Medium review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants