angular/packages/compiler/src
Kristiyan Kostadinov f6da091228 refactor(compiler): introduce compiler infrastructure for input transforms (#50225)
Adds the necessary compiler changes to support input transform functions. The compiler output has changed in the following ways:

### Directive handler
The directive handler now extracts a reference to the input transform function and it resolves the type of its first parameter. It also asserts that the type can be referenced in the compiled output and that it doesn't clash with any pre-existing `ngAcceptInputType_` members.

### .d.ts
In the generated declaration files the compiler now inserts an `ngAcceptInputType_` member for each input with a `transform` function. The member's type corresponds to the type of the first parameter of the function, e.g.

```typescript
// foo.directive.ts
@Directive()
export class Foo {
  @Input({transform: (incomingValue: string) => parseInt(incomingValue)}) value: number;
}

// foo.directive.d.ts
export class Foo {
  value: number;
  static ngAcceptInputType_value: string;
}
```

### Type check block
If an input has `transform` function, the TCB will use the type of its first parameter for the setter type. This uses the same infrastructure as the `ngAcceptInputType_` members.

### Directive declaration
The generated runtime directive declaration call now includes the `transform` function in the `inputs` map, if the input is being transformed. The function will be picked up by the runtime in the next commit to do the actual transformation.

```typescript
// foo.directive.ts
@Directive()
export class Foo {
  @Input({transform: (incomingValue: string) => parseInt(incomingValue)}) value: number;
}

// foo.directive.js
export class Foo {
  ɵdir = ɵɵdefineDirective({
    inputs: {
      value: ['value', 'value', incomingValue => parseInt(incomingValue)]
    }
  });
}
```

PR Close #50225
2023-05-22 14:48:02 +00:00
..
compiler_util fix(compiler): incorrect code when non-null assertion is used after a safe access (#48801) 2023-01-25 18:31:37 +00:00
expression_parser fix(compiler): handle trailing comma in object literal (#49535) 2023-03-23 11:35:44 -07:00
i18n refactor(compiler): handle #24571 todos. (#49220) 2023-04-18 16:30:44 +00:00
ml_parser refactor(compiler): handle #24571 todos. (#49220) 2023-04-18 16:30:44 +00:00
output refactor(compiler): introduce internal transplanted type (#50104) 2023-05-09 14:41:14 -07:00
render3 refactor(compiler): introduce compiler infrastructure for input transforms (#50225) 2023-05-22 14:48:02 +00:00
schema fix(core): hardening attribute and property binding rules for <iframe> elements (#47964) 2022-11-09 00:47:56 -08:00
template/pipeline refactor(compiler): extract save/restore view logic to separate phase (#50008) 2023-05-08 14:30:13 -07:00
template_parser refactor: replace deprecated String.prototype.substr() (#45397) 2022-03-24 11:48:09 -07:00
assertions.ts refactor(compiler): remove unused assertion function (#44411) 2022-01-04 15:54:09 -08:00
chars.ts refactor(compiler): share isQuote() via chars.ts (#43129) 2021-08-16 13:07:23 -07:00
compiler.ts refactor(compiler): introduce internal transplanted type (#50104) 2023-05-09 14:41:14 -07:00
compiler_facade_interface.ts refactor(compiler): introduce compiler infrastructure for input transforms (#50225) 2023-05-22 14:48:02 +00:00
config.ts fix(core): update isDevMode to rely on ngDevMode (#47475) 2022-09-23 13:58:45 -07:00
constant_pool.ts refactor(compiler): handle #24571 todos. (#49220) 2023-04-18 16:30:44 +00:00
core.ts refactor(compiler): introduce compiler infrastructure for input transforms (#50225) 2023-05-22 14:48:02 +00:00
injectable_compiler_2.ts refactor(compiler-cli): only use a single type expression (#49136) 2023-04-03 19:20:00 -07:00
jit_compiler_facade.ts refactor(compiler): introduce compiler infrastructure for input transforms (#50225) 2023-05-22 14:48:02 +00:00
parse_util.ts refactor: replace deprecated String.prototype.substr() (#45397) 2022-03-24 11:48:09 -07:00
resource_loader.ts refactor(compiler): ensure compatibility with noImplicitOverride (#42512) 2021-07-12 13:11:14 -07:00
selector.ts feat(compiler): allow self-closing tags on custom elements (#48535) 2023-01-04 12:07:37 -08:00
shadow_css.ts refactor(compiler): Remove strictStyling option for ShadowCss (#48824) 2023-02-02 13:38:38 -08:00
style_url_resolver.ts refactor(compiler): make template preparser null-safe (#44411) 2022-01-04 15:54:10 -08:00
util.ts fix(localize): ensure transitively loaded compiler code is tree-shakable (#45405) 2022-04-21 11:09:39 -07:00
version.ts docs: fix package name in version.ts files in different packages (#41208) 2021-05-10 10:26:34 -04:00