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

add rule to enforce initialization of static properties #557

Open
ajafff opened this issue Feb 25, 2019 · 1 comment · May be fixed by #734
Open

add rule to enforce initialization of static properties #557

ajafff opened this issue Feb 25, 2019 · 1 comment · May be fixed by #734

Comments

@ajafff
Copy link
Member

ajafff commented Feb 25, 2019

strictPropertyInitialization only works with instance properties. The proposed rule would enforce every static property (except for ambient declarations) whose type doesn't allow undefined to have an initializer.

declare class C {
  static P: string; // ok, ambient declaration
}
class D {
  static P: string; // missing initializer
}

class E {
  static P = ''; // ok
}

class F {
  static P: string | undefined; // ok, allows 'undefined'
  static Q: any; // ok, allows 'undefined'
  static R: unknown; // ok, allows 'undefined'
}
@ajafff
Copy link
Member Author

ajafff commented Jun 21, 2019

Upstream issue: microsoft/TypeScript#27899

ajafff added a commit that referenced this issue Dec 6, 2020
@ajafff ajafff linked a pull request Dec 16, 2020 that will close this issue
3 tasks
@ajafff ajafff removed a link to a pull request Dec 16, 2020
3 tasks
@ajafff ajafff linked a pull request Jan 6, 2021 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant