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

Error in angular-token.model.d.ts #506

Open
3 of 17 tasks
nzacca opened this issue Jun 2, 2019 · 0 comments
Open
3 of 17 tasks

Error in angular-token.model.d.ts #506

nzacca opened this issue Jun 2, 2019 · 0 comments

Comments

@nzacca
Copy link
Contributor

nzacca commented Jun 2, 2019

I'm submitting a...

  • Regression (a behavior that used to work and stopped working in a new release)
  • Bug report
  • Performance issue
  • Feature request
  • Documentation issue or request
  • Other... Please describe:

Current behavior

When building with strictNullChecks=true, the following error is raised:

ERROR in node_modules/angular-token/lib/angular-token.model.d.ts(11,5): error TS2411: Property 'name' of type 'string | undefined' is not assignable to string index type 'string'.
node_modules/angular-token/lib/angular-token.model.d.ts(12,5): error TS2411: Property 'userType' of type 'string | undefined' is not assignable to string index type 'string'.

Expected behavior

No error.

What is the motivation / use case for changing the behavior?

I would like to be able to use this library with strictNullChecks set to true.

Environment

Angular-Token version: 7.0.1
Angular version: 7
Typescript version: 3.2.4 & 3.4.5

Bundler

  • Angular CLI (Webpack)
  • Webpack
  • SystemJS

Browser:

  • Chrome (desktop) version XX
  • Chrome (Android) version XX
  • Chrome (iOS) version XX
  • Firefox version XX
  • Safari (desktop) version XX
  • Safari (iOS) version XX
  • IE version XX
  • Edge version XX

Others:
N/A

Notes:
The issue is with the RegisterData definition here:

https://github.com/neroniaky/angular-token/blob/master/projects/angular-token/src/lib/angular-token.model.ts#L19

The following proposed change to the index signature should work since the RegisterData definition with the named properties allows an undefined string value for userType and name:

export interface RegisterData {
  [key: string]: string | undefined;
}

See the following for a demo of the issue and solution.

Edit: Updated environment version to indicate Typescript version.

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

No branches or pull requests

1 participant