Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! feat(compiler): add support for the typeof keyword in templa…
…te expressions.
  • Loading branch information
JeanMeche committed Oct 15, 2024
commit 65e0fb9382066327e7316150fc7c902f9ebd2da5
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ export declare class TodoModule {
/****************************************************************************************************
* PARTIAL FILE: operators.js
****************************************************************************************************/
import { Component, NgModule } from '@angular/core';
import { Component, NgModule, Pipe } from '@angular/core';
import * as i0 from "@angular/core";
export class MyApp {
constructor() {
this.foo = { bar: 'baz' };
}
}
MyApp.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyApp, deps: [], target: i0.ɵɵFactoryTarget.Component });
MyApp.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "0.0.0-PLACEHOLDER", type: MyApp, selector: "ng-component", ngImport: i0, template: `
Expand All @@ -81,7 +84,9 @@ MyApp.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "0.0.0-
{{ +1 }}
{{ typeof {} === 'object' }}
{{ !(typeof {} === 'object') }}
`, isInline: true });
{{ typeof foo?.bar === 'string' }}
{{ typeof foo?.bar | identity }}
`, isInline: true, dependencies: [{ kind: "pipe", type: i0.forwardRef(() => IdentityPipe), name: "identity" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyApp, decorators: [{
type: Component,
args: [{
Expand All @@ -91,31 +96,50 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDE
{{ +1 }}
{{ typeof {} === 'object' }}
{{ !(typeof {} === 'object') }}
{{ typeof foo?.bar === 'string' }}
{{ typeof foo?.bar | identity }}
`,
standalone: false
}]
}] });
export class IdentityPipe {
transform(value) { return value; }
}
IdentityPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: IdentityPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
IdentityPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: IdentityPipe, name: "identity" });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: IdentityPipe, decorators: [{
type: Pipe,
args: [{ name: 'identity' }]
}] });
export class MyModule {
}
MyModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
MyModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyModule, declarations: [MyApp] });
MyModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyModule, declarations: [MyApp, IdentityPipe] });
MyModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyModule });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "0.0.0-PLACEHOLDER", ngImport: i0, type: MyModule, decorators: [{
type: NgModule,
args: [{ declarations: [MyApp] }]
args: [{ declarations: [MyApp, IdentityPipe] }]
}] });

/****************************************************************************************************
* PARTIAL FILE: operators.d.ts
****************************************************************************************************/
import * as i0 from "@angular/core";
export declare class MyApp {
foo: {
bar?: string;
};
static ɵfac: i0.ɵɵFactoryDeclaration<MyApp, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<MyApp, "ng-component", never, {}, {}, never, never, false, never>;
}
export declare class IdentityPipe {
transform(value: any): any;
static ɵfac: i0.ɵɵFactoryDeclaration<IdentityPipe, never>;
static ɵpipe: i0.ɵɵPipeDeclaration<IdentityPipe, "identity", false>;
}
export declare class MyModule {
static ɵfac: i0.ɵɵFactoryDeclaration<MyModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<MyModule, [typeof MyApp], never, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<MyModule, [typeof MyApp, typeof IdentityPipe], never, never>;
static ɵinj: i0.ɵɵInjectorDeclaration<MyModule>;
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, NgModule} from '@angular/core';
import {Component, NgModule, Pipe} from '@angular/core';

@Component({
template: `
Expand All @@ -7,12 +7,20 @@ import {Component, NgModule} from '@angular/core';
{{ +1 }}
{{ typeof {} === 'object' }}
{{ !(typeof {} === 'object') }}
Comment thread
JeanMeche marked this conversation as resolved.
{{ typeof foo?.bar === 'string' }}
{{ typeof foo?.bar | identity }}
`,
standalone: false
})
export class MyApp {
foo: {bar?: string} = {bar: 'baz'};
}

@NgModule({declarations: [MyApp]})
@Pipe ({name: 'identity'})
export class IdentityPipe {
transform(value: any) { return value; }
}

@NgModule({declarations: [MyApp, IdentityPipe]})
export class MyModule {
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
template: function MyApp_Template(rf, $ctx$) {
if (rf & 1) {
$i0$.ɵɵtext(0);
i0.ɵɵpipe(1, "identity");
} if (rf & 2) {
i0.ɵɵtextInterpolate5(" ", 1 + 2, " ", 1 % 2 + 3 / 4 * 5, " ", +1, " ", typeof i0.ɵɵpureFunction0(5, _c0) === "object", " ", !(typeof i0.ɵɵpureFunction0(6, _c0) === "object"), "\n");
i0.ɵɵtextInterpolate7(" ",
1 + 2, " ",
1 % 2 + 3 / 4 * 5, " ",
+1, " ",
typeof i0.ɵɵpureFunction0(9, _c0) === "object", " ",
!(typeof i0.ɵɵpureFunction0(10, _c0) === "object"), " ",
typeof (ctx.foo == null ? null : ctx.foo.bar) === "string", " ",
i0.ɵɵpipeBind1(1, 7, typeof (ctx.foo == null ? null : ctx.foo.bar)), "\n"
);
}
}