Skip to content

Commit

Permalink
feat: support signal inputs, queries and model (#2303)
Browse files Browse the repository at this point in the history
Fixes #2246. Closes #2255
  • Loading branch information
devversion authored Feb 9, 2024
1 parent 97a3210 commit 7f7a22f
Show file tree
Hide file tree
Showing 21 changed files with 60 additions and 3,056 deletions.
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ node_modules
src/config/setup-jest.ts
coverage
website
src/transformers/downlevel_decorators_transform
src/ngtsc
src/transformers/jit_transform.js
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ website/.yarn/*
!.yarn/versions
!/e2e/full-ivy-lib/node_modules
!/e2e/partial-ivy-lib/node_modules

# Generated by `yarn build-transformers-bundle` automatically.
src/transformers/jit_transform.js
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules/
src/**/__snapshots__/
e2e/__tests__/__snapshots__/
CHANGELOG.md
src/transformers/jit_transform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Component, input } from '@angular/core';
import { TestBed } from '@angular/core/testing';

test('signal inputs', () => {
@Component({
selector: 'greet',
standalone: true,
template: 'Name: {{name()}}',
})
class GreetCmp {
name = input.required<string>();
}

@Component({
standalone: true,
imports: [GreetCmp],
template: '<greet [name]="name" />',
})
class TestCmp {
name = 'John';
}

const fixture = TestBed.createComponent(TestCmp);
fixture.detectChanges();

expect(fixture.nativeElement.textContent).toBe('Name: John');
});
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
"testing"
],
"scripts": {
"build": "tsc -p tsconfig.build.json",
"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",
"build": "tsc -p tsconfig.build.json && yarn build-transformers-bundle",
"lint": "eslint --ext .js,.ts .",
"lint-fix": "eslint --fix --ext .js,.ts .",
"lint-prettier": "prettier \"**/*.{yml,yaml,md}\" --write",
"lint-prettier-ci": "prettier \"**/*.{yml,yaml,md}\" --check",
"pretest": "tsc -p tsconfig.spec.json --noEmit",
"test": "jest",
"test": "yarn build && jest",
"test-examples": "node scripts/test-examples.js",
"doc": "cd website && yarn start",
"doc:build": "cd website && yarn build",
Expand Down
8 changes: 5 additions & 3 deletions src/compiler/ng-jest-compiler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type TsJestAstTransformer, TsCompiler, type ConfigSet } from 'ts-jest';
import type * as ts from 'typescript';

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

export class NgJestCompiler extends TsCompiler {
Expand Down Expand Up @@ -112,6 +112,9 @@ export class NgJestCompiler extends TsCompiler {
}

protected _makeTransformers(customTransformers: TsJestAstTransformer): ts.CustomTransformers {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const program = this.program!;

return {
...super._makeTransformers(customTransformers).after,
...super._makeTransformers(customTransformers).afterDeclarations,
Expand All @@ -120,8 +123,7 @@ export class NgJestCompiler extends TsCompiler {
beforeTransformer.factory(this, beforeTransformer.options),
),
replaceResources(this),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
constructorParametersDownlevelTransform(this.program!),
angularJitApplicationTransform(program),
] as Array<ts.TransformerFactory<ts.SourceFile> | ts.CustomTransformerFactory>,
};
}
Expand Down
12 changes: 0 additions & 12 deletions src/ngtsc/reflection/index.ts

This file was deleted.

Loading

0 comments on commit 7f7a22f

Please sign in to comment.