test(typescript): add ts_project angular test (#2636)
Co-authored-by: Jason Bedard <jason+github@jbedard.ca>
diff --git a/packages/typescript/test/ts_project/ngc/BUILD.bazel b/packages/typescript/test/ts_project/ngc/BUILD.bazel
new file mode 100644
index 0000000..b8bcf8b
--- /dev/null
+++ b/packages/typescript/test/ts_project/ngc/BUILD.bazel
@@ -0,0 +1,22 @@
+load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test")
+load("//packages/typescript:index.bzl", "ts_project")
+
+ts_project(
+ name = "ngc",
+ srcs = [
+ "comp.ng.html",
+ "component.ts",
+ ],
+ extends = "//packages/typescript/test/ts_project:tsconfig-base.json",
+ tsc = "@npm//@angular/compiler-cli/bin:ngc",
+ tsconfig = ":tsconfig.json",
+ deps = [
+ "@npm//@angular/core",
+ ],
+)
+
+generated_file_test(
+ name = "test",
+ src = "component.js_",
+ generated = ":component.js",
+)
diff --git a/packages/typescript/test/ts_project/ngc/comp.ng.html b/packages/typescript/test/ts_project/ngc/comp.ng.html
new file mode 100644
index 0000000..c38b0fe
--- /dev/null
+++ b/packages/typescript/test/ts_project/ngc/comp.ng.html
@@ -0,0 +1 @@
+<div>{{thing}}</div>
diff --git a/packages/typescript/test/ts_project/ngc/component.js_ b/packages/typescript/test/ts_project/ngc/component.js_
new file mode 100644
index 0000000..4fb9378
--- /dev/null
+++ b/packages/typescript/test/ts_project/ngc/component.js_
@@ -0,0 +1,22 @@
+import { Component } from '@angular/core';
+import * as i0 from "@angular/core";
+export class Comp {
+ constructor() {
+ this.thing = '';
+ }
+}
+Comp.ɵfac = function Comp_Factory(t) { return new (t || Comp)(); };
+Comp.ɵcmp = i0.ɵɵdefineComponent({ type: Comp, selectors: [["ng-component"]], decls: 2, vars: 1, template: function Comp_Template(rf, ctx) { if (rf & 1) {
+ i0.ɵɵelementStart(0, "div");
+ i0.ɵɵtext(1);
+ i0.ɵɵelementEnd();
+ } if (rf & 2) {
+ i0.ɵɵadvance(1);
+ i0.ɵɵtextInterpolate(ctx.thing);
+ } }, encapsulation: 2 });
+(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(Comp, [{
+ type: Component,
+ args: [{
+ templateUrl: './comp.ng.html',
+ }]
+ }], null, null); })();
diff --git a/packages/typescript/test/ts_project/ngc/component.ts b/packages/typescript/test/ts_project/ngc/component.ts
new file mode 100644
index 0000000..c1c397b
--- /dev/null
+++ b/packages/typescript/test/ts_project/ngc/component.ts
@@ -0,0 +1,8 @@
+import {Component} from '@angular/core';
+
+@Component({
+ templateUrl: './comp.ng.html',
+})
+export class Comp {
+ thing: string = '';
+}
diff --git a/packages/typescript/test/ts_project/ngc/tsconfig.json b/packages/typescript/test/ts_project/ngc/tsconfig.json
new file mode 100644
index 0000000..aa68a02
--- /dev/null
+++ b/packages/typescript/test/ts_project/ngc/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "extends": "../tsconfig-base.json",
+ "compilerOptions": {
+ "module": "es2015",
+ "moduleResolution": "node",
+ "composite": false,
+ "experimentalDecorators": true
+ }
+}
\ No newline at end of file