new 9.1.7 content on structural-directives is unfinished?
See original GitHub issueπ Docs or angular.io bug report
Description
IfLoadedDirective missing lines and is very difficult to understand.
π¬ Minimal Reproduction
Whatβs the affected URL?**
Reproduction Steps**
The content:
export type Loaded = { type: 'loaded', data: T };
export type Loading = { type: 'loading' };
export type LoadingState = Loaded | Loading;
export class IfLoadedDirective {
@Input('ifLoaded') set state(state: LoadingState) {}
static ngTemplateGuard_state(dir: IfLoadedDirective, expr: LoadingState): expr is Loaded { return true; };
export interface Person {
name: string;
}
@Component({
template: `{{ state.data }}`,
})
export class AppComponent {
state: LoadingState;
}
Expected vs Actual Behavior**
expecting valid typescript that follows angular style guide
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Structural directives - Angular
This guide is about structural directives and provides conceptual information on how such directives work, how Angular interprets their shorthand syntax,Β ...
Read more >Getting Started with Custom Structural Directives in Angular
Introduction Angular comes with many built-in directives. Some of them (eg. NgIf, NgModel or FormControlDirective) are used daily by AngularΒ ...
Read more >ISO 6707-1:2004(en), Building and civil engineering β Vocabulary ...
International Standards are drafted in accordance with the rules given in the ISO/IEC Directives, Part 2. The main task of technical committees is...
Read more >Dobson Ranch Golf AssociatioN - Arizona Golf Association
Table of Contents ... Minimum content will include sections on club news, ... Report from the βTreasurerβ, Unfinished Business, New Business,Β ...
Read more >CITY OF HAMMOND, LOUISIANA UNIFIED ... - Hammond.org
location of any structure or property in relation to its zoning district. ... recommendations regarding any new building construction, ... B. Contents.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @bbarry, the language service is currently being updated to work identically to the real compilation, including type guards. This is still work in progress and not yet available.
I have been able to get the context guard working at compilation but it doesnβt appear correct according to VsCode still.
My full working code is:
ng serve
now correctly reports template errors. My editor (Vs Code) still has anany
type for the value though and if I changeNgLetContext<T = any>
toNgLetContext<T = unknown>
I get language service errors.I believe this is due to a bug in the language service though, perhaps https://github.com/angular/vscode-ng-language-service/issues/880
On the issue here of documentation, it looks like this page has been updated with working code at least. Should this be closed?
I think it could be more clear. For example the title section
describes these properties and directs you to a page seemingly for more information, but the only lines on that page with relevant βmore informationβ are links back to this section:
(irrelevant link not copied here) and
I think it would be better if the directive relevant properties were all in the template type checking guide and not in the structural directives page at all. All that the structural directives page should say on the matter is that there are applications of type checking for structural directives and direct the user to the type check guide which should talk about both template guard properties and input coercion (which are really very similar things and have similar solutions).