Skip to content

Commit 7f7a22f

Browse files
authored
feat: support signal inputs, queries and model (#2303)
Fixes #2246. Closes #2255
1 parent 97a3210 commit 7f7a22f

File tree

21 files changed

+60
-3056
lines changed

21 files changed

+60
-3056
lines changed

.eslintignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ node_modules
44
src/config/setup-jest.ts
55
coverage
66
website
7-
src/transformers/downlevel_decorators_transform
8-
src/ngtsc
7+
src/transformers/jit_transform.js

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ website/.yarn/*
1414
!.yarn/versions
1515
!/e2e/full-ivy-lib/node_modules
1616
!/e2e/partial-ivy-lib/node_modules
17+
18+
# Generated by `yarn build-transformers-bundle` automatically.
19+
src/transformers/jit_transform.js

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules/
33
src/**/__snapshots__/
44
e2e/__tests__/__snapshots__/
55
CHANGELOG.md
6+
src/transformers/jit_transform.js
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Component, input } from '@angular/core';
2+
import { TestBed } from '@angular/core/testing';
3+
4+
test('signal inputs', () => {
5+
@Component({
6+
selector: 'greet',
7+
standalone: true,
8+
template: 'Name: {{name()}}',
9+
})
10+
class GreetCmp {
11+
name = input.required<string>();
12+
}
13+
14+
@Component({
15+
standalone: true,
16+
imports: [GreetCmp],
17+
template: '<greet [name]="name" />',
18+
})
19+
class TestCmp {
20+
name = 'John';
21+
}
22+
23+
const fixture = TestBed.createComponent(TestCmp);
24+
fixture.detectChanges();
25+
26+
expect(fixture.nativeElement.textContent).toBe('Name: John');
27+
});

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@
2727
"testing"
2828
],
2929
"scripts": {
30-
"build": "tsc -p tsconfig.build.json",
30+
"build-transformers-bundle": "esbuild --bundle src/transformers/jit_transform.d.ts --platform=node --external:typescript --outfile=./src/transformers/jit_transform.js --format=cjs --define:import.meta.url=import_meta_url --inject:./src/transformers/esm_interop_inject.cjs && cp src/transformers/jit_transform.js build/transformers/jit_transform.js",
31+
"build": "tsc -p tsconfig.build.json && yarn build-transformers-bundle",
3132
"lint": "eslint --ext .js,.ts .",
3233
"lint-fix": "eslint --fix --ext .js,.ts .",
3334
"lint-prettier": "prettier \"**/*.{yml,yaml,md}\" --write",
3435
"lint-prettier-ci": "prettier \"**/*.{yml,yaml,md}\" --check",
3536
"pretest": "tsc -p tsconfig.spec.json --noEmit",
36-
"test": "jest",
37+
"test": "yarn build && jest",
3738
"test-examples": "node scripts/test-examples.js",
3839
"doc": "cd website && yarn start",
3940
"doc:build": "cd website && yarn build",

src/compiler/ng-jest-compiler.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { type TsJestAstTransformer, TsCompiler, type ConfigSet } from 'ts-jest';
22
import type * as ts from 'typescript';
33

4-
import { constructorParametersDownlevelTransform } from '../transformers/downlevel-ctor';
4+
import { angularJitApplicationTransform } from '../transformers/jit_transform';
55
import { replaceResources } from '../transformers/replace-resources';
66

77
export class NgJestCompiler extends TsCompiler {
@@ -112,6 +112,9 @@ export class NgJestCompiler extends TsCompiler {
112112
}
113113

114114
protected _makeTransformers(customTransformers: TsJestAstTransformer): ts.CustomTransformers {
115+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
116+
const program = this.program!;
117+
115118
return {
116119
...super._makeTransformers(customTransformers).after,
117120
...super._makeTransformers(customTransformers).afterDeclarations,
@@ -120,8 +123,7 @@ export class NgJestCompiler extends TsCompiler {
120123
beforeTransformer.factory(this, beforeTransformer.options),
121124
),
122125
replaceResources(this),
123-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
124-
constructorParametersDownlevelTransform(this.program!),
126+
angularJitApplicationTransform(program),
125127
] as Array<ts.TransformerFactory<ts.SourceFile> | ts.CustomTransformerFactory>,
126128
};
127129
}

src/ngtsc/reflection/index.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)