angular/packages/core/test
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
..
acceptance build: replace base64-js package with Node.js Buffer usage (#53464) 2023-12-11 14:04:06 -08:00
animation refactor(animations): deprecation of AnimationDriver.NOOP (#51843) 2023-09-22 12:15:45 -07:00
bundling refactor(compiler-cli): initial type-checking for signal inputs (#53521) 2023-12-13 15:44:00 -08:00
change_detection test(core): clean up unnecessary nesting in old tests (#52239) 2023-10-19 09:26:15 -07:00
compiler build: ensure bootstrap transitive runfiles are made available (#48521) 2022-12-19 19:50:41 +00:00
debug test(core): clean up unnecessary nesting in old tests (#52239) 2023-10-19 09:26:15 -07:00
di test(core): clean up unnecessary nesting in old tests (#52239) 2023-10-19 09:26:15 -07:00
dom test(core): clean up unnecessary nesting in old tests (#52239) 2023-10-19 09:26:15 -07:00
hydration refactor(core): adding hydration for content projection (#49454) 2023-03-21 17:42:53 +01:00
i18n test(core): clean up unnecessary nesting in old tests (#52239) 2023-10-19 09:26:15 -07:00
linker build: replace base64-js package with Node.js Buffer usage (#53464) 2023-12-11 14:04:06 -08:00
metadata test(core): clean up unnecessary nesting in old tests (#52239) 2023-10-19 09:26:15 -07:00
reflection refactor(core): remove unused logic from reflection capabilities (#45335) 2022-03-24 11:02:39 -07:00
render3 feat(compiler-cli): support type-checking for generic signal inputs (#53521) 2023-12-13 15:44:00 -08:00
sanitization test(core): clean up unnecessary nesting in old tests (#52239) 2023-10-19 09:26:15 -07:00
signals fix(core): remove signal equality check short-circuit (#53446) 2023-12-08 07:05:34 -08:00
strict_types refactor(core): rename ...WithMeta types to ...Declaration and alias to unknown (#41119) 2021-03-22 08:57:18 -07:00
testability test(core): clean up unnecessary nesting in old tests (#52239) 2023-10-19 09:26:15 -07:00
util test(core): clean up unnecessary nesting in old tests (#52239) 2023-10-19 09:26:15 -07:00
zone test(core): clean up unnecessary nesting in old tests (#52239) 2023-10-19 09:26:15 -07:00
application_config_spec.ts feat(core): add mergeApplicationConfig method (#49253) 2023-03-01 11:20:31 -08:00
application_init_spec.ts refactor(core): Separate application and platform files even more (#53371) 2023-12-08 14:29:46 -08:00
application_module_spec.ts test(core): clean up unnecessary nesting in old tests (#52239) 2023-10-19 09:26:15 -07:00
application_ref_integration_spec.ts refactor(platform-browser): update renderer to be able to remove ServerRendererFactory2 and EmulatedEncapsulationServerRenderer2 (#49630) 2023-04-05 11:42:57 -07:00
application_ref_spec.ts fix(core): Multiple subscribers to ApplicationRef.isStable should all see values (#53541) 2023-12-13 11:26:51 -08:00
BUILD.bazel build: replace base64-js package with Node.js Buffer usage (#53464) 2023-12-11 14:04:06 -08:00
component_fixture_spec.ts test(core): clean up unnecessary nesting in old tests (#52239) 2023-10-19 09:26:15 -07:00
defer_fixture_spec.ts fix(core): handle local refs when getDeferBlocks is invoked in tests (#52973) 2023-11-16 12:20:54 -08:00
dev_mode_spec.ts test(core): clean up unnecessary nesting in old tests (#52239) 2023-10-19 09:26:15 -07:00
directive_lifecycle_integration_spec.ts refactor(core): cleanup type any (#48623) 2023-01-04 12:15:16 -08:00
error_handler_spec.ts refactor(core): remove unused error handler logic (#46216) 2022-06-02 13:40:16 -07:00
event_emitter_spec.ts test(core): clean up unnecessary nesting in old tests (#52239) 2023-10-19 09:26:15 -07:00
fake_async_spec.ts test(core): clean up unnecessary nesting in old tests (#52239) 2023-10-19 09:26:15 -07:00
forward_ref_integration_spec.ts refactor(core): handle #24571 todos. (#49221) 2023-06-14 12:33:44 +02:00
runtime_error_spec.ts refactor(core): improve error message when dom node is not found (#49977) 2023-04-25 09:29:47 -07:00
test_bed_effect_spec.ts fix(core): effects wait for ngOnInit for their first run (#52473) 2023-11-01 08:07:35 -07:00
test_bed_spec.ts fix(core): avoid stale provider info when TestBed.overrideProvider is used (#52918) 2023-11-29 09:48:53 +01:00
transfer_state_spec.ts refactor(core): simplify state transfer escaping (#50201) 2023-05-10 11:31:34 -07:00
util_spec.ts test(core): clean up unnecessary nesting in old tests (#52239) 2023-10-19 09:26:15 -07:00