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.7 support #21571
Comments
Until now, when Angular supported a new version of TypeScript, it supported it in But in TS 2.7, What's the plans about that ? |
Thanks Cyrille, we'll discuss this issue.
…On Tue, Jan 23, 2018 at 12:40 AM Cyrille Tuzi ***@***.***> wrote:
Until now, when Angular supported a new version of TypeScript, it
supported it in strict mode.
But in TS 2.7, --strictPropertyInitialization causes a lot of mess in
Angular code, as reported in microsoft/TypeScript#20740
<microsoft/TypeScript#20740>. Solutions have
been discussed, but nothing seems to be included in the 2.7 release.
What's the plans about that ?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#21571 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AANM6N8mOkEOMaQUh_AFE0dT4R9CGc0Tks5tNZsSgaJpZM4RgeFi>
.
|
I discussed the Our recommendation is to either don't use the flag, or the better option is to initialize the inputs to a default value or |
Why can not inputs be defined in the constructor? Like this for example : @Component({ selector: 'my-component' })
class MyComponent {
constructor(@Input() private myInput: string) {}
} This would enable a proper use of |
Inputs by definition can change over time. Constructor can only receive one value. But you can use |
Setting a default value is not possible for objects, which is a very common case. Setting to The very classic architecture of Angular is : a controller component get data via a service and pass the data to a presentation component with So for me, it's sure it will be the option of not being |
@mhevery Actually, I would have hoped that this ( @Component({ selector: 'my-component' })
class MyComponent {
constructor(@Input('myInput') public myInput: string) {}
} would be the equivalent to this in some way : @Component({ selector: 'my-component' })
class MyComponent {
@Input('myInput')
public myInput: string;
constructor(@Attribute('myInput') myInput: string) {
this.myInput = myInput;
}
} |
@cyrilletuzi - I don't think that any check forces you to set the input parameters, so technically marking them as potentially undefined does make sense. I'd rather want to have a possibility within angular to say - these properties need to be set, to have the type check there. The example above, by @nicolashenry would be perfect, if it works like that. By the way - in case I don't care for implementing a setter for
|
@cyrilletuzi Nothing forces What would be nice is to have |
Could |
What would be really nice is that But with the actual behavior, yes, there should be a check, and there is one : the |
Have you considered making @input, @ViewChild/@ViewChildren/@ContentChild/@ContentChilren etc injectable as Observables? Personally I've been wanting that anyway for easier rxjs compositions, and it seems like it would solve a large percentage of the strictPropertyInitialization problem. You would still have properties that are initialized in onInit, but that would be small enough I'd probably be happy dealing with them on a case by case either adding '| null', '!', or a default as needed. |
Yes adding Observables is on the roadmap...
…On Tue, Feb 6, 2018 at 10:28 AM, james-schwartzkopf < ***@***.***> wrote:
Have you considered making @input <https://github.com/input>,
@***@***.******@***.******@***.*** etc injectable as
Observables?
Personally I've been wanting that anyway for easier rxjs compositions, and
it seems like it would solve a large percentage of the
strictPropertyInitialization problem. You would still have properties that
are initialized in onInit, but that would be small enough I'd probably be
happy dealing with them on a case by case either adding '| null', '!', or a
default as needed.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#21571 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAG1T0FhwzhkAglg_HL6THg_tR54_QJIks5tSJnDgaJpZM4RgeFi>
.
|
Any progress on this? |
@sebastian-zarzycki-es As you can see, a pull request dealing with this issue has been opened 13 days ago. It currently has merge conflicts with |
Yeah, I can see that. "any" was probably a bit too vague. The question really was "when, roughly, can I expect it?" :) |
@sebastian-zarzycki-es The |
A comment from above - "Until now, when Angular supported a new version of TypeScript, it supported it in strict mode." |
@sebastian-zarzycki-es Please refer to angular/devkit#218 and angular/devkit#397, this tracker is for Angular itself, not for CLI project. |
I didn't bring CLI into this, you did. I've merely referred to the first cyrilletuzi's comment here. But that's really a sidequestion, I was interested in release date/estimate, mostly. |
@sebastian-zarzycki-es Since it's under the 6.0 milestone, should happen before the 6.0 stable release. |
You're asking if it was "turned off". The only place this is likely to be turned on for you by Google is the CLI. So I think the assumption is that you're asking if it was turned off there... in which case the answer is that it was never turned on in the first place. Otherwise, if you're not using CLI, you can simply not enable strict checking in your own config and this won't be an issue for you. |
Also please note that these two questions are different:
The latter one is not something Angular can directly helped. |
All clear now, thank you. |
It seems that there is a more general issue here - that developers using Angular have to wait weeks/months to upgrade to each new version of TypeScript. Is it possible that we could get to a point where Angular immediately supports each new version of TS once it drops? I'm not sure if that's even feasible, or if it makes sense, but it seems like a worthwhile goal. As always, thanks for the hard work. |
@fr0 That question was answered in #19587 (comment). Unlike syntax, the TypeScript compiler API would has breaking change in every minor version, so always require extra work on it. The supporting status can be checked at https://github.com/angular/angular-cli/blob/77d2cd3c1dcd0d41eb87697f8d21809f78b586db/packages/%40angular/cli/upgrade/version.ts#L169-L175 Technically if one only use TypeScript command line tool and JIT for Angular (with their own project configuration) would be able to use latest TypeScript immediately, like we can already use latest TypeScript in Plunker w/o Angular support. But most user need more than that. |
Btw, the discussions eluded the initial question : it will be up to the developer to choose if he/she wants to work in |
Actually |
To be fair, it's still an option, but with uglier syntax :) |
@trotyl Can you explain why ? Previous stricter checks introduced by TypeScript often produced errors in compilation of an app because of errors in Angular itself. |
@cyrilletuzi The |
@trotyl I've had to make my way to that block of code in CLI before, to explain the Angular -> TypeScript supported versions. It seems to me that ideally this information would be represented canonically somewhere in Angular core (and then referred to by CLI code) as it seems to me this is inevitably a property of Angular itself that would apply even to non-CLI users. Roughly akin to the browser support information. |
Could not agree more, @kylecordes. To that effect, I know that compiler feature landed somewhere in the road to 6.0 with 3ceee99. My assumption (without having tried it out myself) would be that as long as |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
TypeScript 2.7 is coming out in January. We need to get it supported within the v6 timeframe.
The text was updated successfully, but these errors were encountered: