-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
TypeScript 2.4.1 - TS2345 - "Property 'push' is missing in type #16802
Comments
This is due to new weak type checking (#16047). |
@andy-ms, I think that will push me to Angular 1.6 type definitions, but we only run Angular 1.5 (Angular did not use semver back then, and we've encountered some issues with 1.6). Alternatively to upgrading type definitions, is it possible to explicitly turn of weak type checking? |
No, but you could use a similar fix to the one in DefinitelyTyped/DefinitelyTyped#17303; augment the interface with an index signature. interface Options {
a?: number;
b?: number;
}
// Won't compile without this
interface Options {
[x: string]: any;
}
class C {}
const options: Options = C; |
@andy-ms, Reading fully through #16047, it looks like there may not be an option to explicitly turn off the check and it's more of a "press forward and fix" approach. However, there appears to be an out with a cast. Turning
into
silences the error. I understand that that may be masking it, but it would also be somewhat inconsequential for me in this particular instance, I believe. |
@andy-ms, ah ok, so simply by introducing one (perhaps inconsequential), non-optional property or method in the interface to mark the type as non-weak, we get by the new weak type check in 2.4? Good to know. Would you say my approach is fair for the use-case I have? Looking for small, yet workable changes. And thanks again for all the info! |
Either is fine, although |
Totally valid point. I'll experiment with both approaches and see what ends up being preferable until we can do an angular/typings upgrade. As these are both valid workarounds, I will close this issue. Many thanks, @andy-ms! |
….6 upgrade occured (microsoft/TypeScript#16802) 2. add routes info to the test controller.
TypeScript Version: 2.4.1
I will preface this with me being unclear whether this is a bug or my misunderstanding of the error (more likely), but I hope I can get some traction on it here nevertheless, please. And, thank you!
Code
This code used to work with 2.3.4 but fails in 2.4.1
Stripping
private
in my constructor eliminates the error, but I do want the private property created.The text was updated successfully, but these errors were encountered: