( name: string, value: string, type: string | null, pure: boolean, isClosureCompilerEnabled?: boolean, )
| 3467 | // See standard InvokeFunctionExpr pure flag in output AST: |
| 3468 | // https://github.com/angular/angular/blob/5b525f9/packages/compiler/src/output/output_ast.ts#L445 |
| 3469 | function createStaticField( |
| 3470 | name: string, |
| 3471 | value: string, |
| 3472 | type: string | null, |
| 3473 | pure: boolean, |
| 3474 | isClosureCompilerEnabled?: boolean, |
| 3475 | ): string { |
| 3476 | const typeSuffix = type ? `: ${type}` : ''; |
| 3477 | const nocollapse = isClosureCompilerEnabled ? '/** @nocollapse */\n ' : ''; |
| 3478 | const tsignore = '// @ts-ignore'; |
| 3479 | // `// @ts-ignore` only covers the line directly below it, so the initializer has to start on the |
| 3480 | // `static <name> =` line. Breaking after `=` would leave the guard covering the declaration |
| 3481 | // instead of the value it was emitted for. ngtsc emits this on one line too. |
| 3482 | // |
| 3483 | // TODO(parity): `// @ts-ignore` only covers the initializer's first line, so properties emitted |
| 3484 | // after multi-line `hostBindings` or `template` functions land on uncovered continuation lines |
| 3485 | // (see `tests/emit_suppressions.test.ts`). |
| 3486 | if (!pure) { |
| 3487 | return ` ${nocollapse}${tsignore}\n static ${name}${typeSuffix} = ${value};\n`; |
| 3488 | } |
| 3489 | const pureComment = isClosureCompilerEnabled ? '/** @pureOrBreakMyCode */' : '/*@__PURE__*/'; |
| 3490 | // ngtsc attaches the pure annotation as a synthetic comment during its own emit, so it always |
| 3491 | // lands right in front of the call. This output is compiled by a downstream `tsc`, whose |
| 3492 | // emitter drops a comment sitting between `=` and the initializer whenever it rewrites the |
| 3493 | // property (stripping the type annotation, or downleveling the static field to |
| 3494 | // `Class.ɵcmp = ...`), but preserves it as leading trivia of an initializer that starts on its |
| 3495 | // own line. The initializer line gets its own `// @ts-ignore`, since the one above `static` no |
| 3496 | // longer reaches it. |
| 3497 | return ( |
| 3498 | ` ${nocollapse}${tsignore}\n` + |
| 3499 | ` static ${name}${typeSuffix} =\n` + |
| 3500 | ` ${tsignore}\n` + |
| 3501 | ` ${pureComment} ${value};\n` |
| 3502 | ); |
| 3503 | } |
| 3504 | |
| 3505 | function compileFactoryField( |
| 3506 | factoryRes: any, |
no outgoing calls
no test coverage detected