angular/packages/core/test/render3
Paul Gschwendtner abdc7e4578 feat(compiler-cli): support type-checking for generic signal inputs (#53521)
This commit adds the last remaining piece for signal input
type-checking. Bound values to signal inputs are already checked
properly at this point, but inference of generic directive/component
types through their inputs is not implemented.

This commit fixes this. To achieve this, there are a couple of potential
solutions. The generics of a directive are inferred based on input
value expressions using a so-called type constructor. The constructor
looks something like this:

```
const _ctor = <T>(v: Pick<Dir<T>, 'input1', 'input2'>) => Dir<T>;

_ctor({input1: expr1, input2: expr2});
```

This works very well for non-signal inputs where the class member is
directly holding the input values. For signal inputs, this does NOT
work because the class member will actually hold the `InputSignal`
instance. There are a couple of solutions to this:

1. Calling `_ctor` with an `InputSignal<typeof value>`
2. Converting the `_ctor` input signal fields to their write types
   (unwrapping the input signals).

We've decided to go with the second option as TypeScript is very
sensitive with assignments and its checks. i.e. co-variance,
contravariance or bivariance. Semantically it makes more sense to unwrap
the input signal "write type" directly and "assign to it". This is safer
and conceptually also easier to follow. A type constructor continues to
only receive the "expresison values". This simplifies code as well.

It's worth noting that the unwrapping as per option 2 also comes at a
cost. We need to be able to generate imports in type constructors. This
was not possible until the previous commit because inline type constructors
did not have an associated type-check block `Environment` and we were
missing access to expression translation and correct import generation.

Overall, solution 2 is now implemented as works as expected. This commit
adds additional unit tests to ensure this.

PR Close #53521
2023-12-13 15:44:00 -08:00
..
i18n refactor(core): remove debug data structures (#48281) 2022-11-30 09:27:59 -08:00
instructions refactor(core): decouple effects from change detection (#51049) 2023-09-12 08:12:56 -07:00
interfaces ci: add lint error for files with missing trailing new-line (#42478) 2021-06-04 13:31:03 -07:00
ivy refactor(core): remove unnecessary reflect-metadata import. (#49673) 2023-04-03 19:17:02 -07:00
jit build: align with internal tsconfig options (#51728) 2023-09-12 11:39:42 -07:00
styling_next refactor(core): Ensure that previousOrParentTNode always belongs to current TView. (#38707) 2020-09-28 16:15:58 -04:00
util refactor(core): add a new stringifier for runtime errors which includes debug info such as the file path and line number (#51919) 2023-10-09 15:57:03 -07:00
BUILD.bazel refactor(core): Synchronously emit the current signal value in toObservable (#49894) 2023-04-25 09:27:38 -07:00
change_detection_spec.ts refactor(core): drop unused fields from the RootContext (#46806) 2022-08-05 09:58:06 -07:00
component_ref_spec.ts fix(core): expose input transform function on ComponentFactory and ComponentMirror (#50713) 2023-06-22 09:47:15 -07:00
deps_tracker_spec.ts feat(core): show runtime error for orphan component rendering (#52061) 2023-10-10 15:30:26 -07:00
di_spec.ts refactor(core): decouple effects from change detection (#51049) 2023-09-12 08:12:56 -07:00
es2015-tsconfig.json fix(core): destroy hooks not set up for useClass provider using forwardRef (#44281) 2021-11-30 11:56:05 -05:00
global_utils_spec.ts feat(core): introduce getDirectiveMetadata global debugging utility (#41525) 2021-04-13 16:06:32 -07:00
i18n_debug_spec.ts build: bundle spec files for saucelabs legacy job (#44281) 2021-11-30 11:56:04 -05:00
imported_renderer2.ts refactor(core): Remove dead unit test code (#51223) 2023-08-01 12:10:57 -07:00
instructions_spec.ts refactor(core): handle #24571 todos. (#49221) 2023-06-14 12:33:44 +02:00
integration_spec.ts feat(core): support TypeScript 4.8 (#47038) 2022-08-16 16:02:47 +00:00
is_shape_of.ts refactor(core): Better use of Object.keys() (#51153) 2023-07-25 09:17:46 -07:00
is_shape_of_spec.ts ci: add lint error for files with missing trailing new-line (#42478) 2021-06-04 13:31:03 -07:00
jit_environment_spec.ts feat(compiler-cli): support type-checking for generic signal inputs (#53521) 2023-12-13 15:44:00 -08:00
list_reconciliation_spec.ts perf(core): optimize memory allocation when reconcilling lists (#52245) 2023-12-08 15:00:13 -08:00
load_domino.ts fix(platform-server): bundle @angular/domino in via esbuild (#49229) 2023-02-28 13:34:50 -08:00
matchers.ts refactor(core): Better use of Object.keys() (#51153) 2023-07-25 09:17:46 -07:00
matchers_spec.ts refactor(core): serialize info about templates used to create embedded views (#49382) 2023-03-14 14:22:08 -07:00
metadata_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
multi_map_spec.ts perf(core): optimize memory allocation when reconcilling lists (#52245) 2023-12-08 15:00:13 -08:00
node_selector_matcher_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
providers_helper.ts test(core): convert providers test utility to TestBed (#46527) 2022-06-27 15:15:00 -07:00
providers_spec.ts test(core): use TestBed & JIT instead of handwritten defs in providers_spec (#46527) 2022-06-27 15:15:00 -07:00
query_spec.ts test(core): refactor tests to use TestBed instead of hand-written instructions (#46561) 2022-06-28 21:28:21 -07:00
reactivity_spec.ts refactor(core): sanitize reactivity tests (#52632) 2023-11-08 08:51:50 -08:00
testing_spec.ts test: update tests to account for karma-jasmine v5.0.0 2022-07-18 19:19:00 +02:00
utils.ts build: update to jasmine 4.0 (#45558) 2022-04-11 16:25:28 +00:00
view_fixture.ts refactor(core): decouple effects from change detection (#51049) 2023-09-12 08:12:56 -07:00
view_utils_spec.ts fix(core): Store ICU state in LView rather than in TView (#39233) 2020-10-21 18:33:00 -07:00