1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | /// <amd-module name="@angular/compiler-cli/linker/src/file_linker/declaration_scope" />
|
---|
9 | /**
|
---|
10 | * This interface represents the lexical scope of a partial declaration in the source code.
|
---|
11 | *
|
---|
12 | * For example, if you had the following code:
|
---|
13 | *
|
---|
14 | * ```
|
---|
15 | * function foo() {
|
---|
16 | * function bar () {
|
---|
17 | * ɵɵngDeclareDirective({...});
|
---|
18 | * }
|
---|
19 | * }
|
---|
20 | * ```
|
---|
21 | *
|
---|
22 | * The `DeclarationScope` of the `ɵɵngDeclareDirective()` call is the body of the `bar()` function.
|
---|
23 | *
|
---|
24 | * The `FileLinker` uses this object to identify the lexical scope of any constant statements that
|
---|
25 | * might be generated by the linking process (i.e. where the `ConstantPool` lives for a set of
|
---|
26 | * partial linkers).
|
---|
27 | */
|
---|
28 | export interface DeclarationScope<TSharedConstantScope, TExpression> {
|
---|
29 | /**
|
---|
30 | * Get a `TSharedConstantScope` object that can be used to reference the lexical scope where any
|
---|
31 | * shared constant statements would be inserted.
|
---|
32 | *
|
---|
33 | * This object is generic because different AST implementations will need different
|
---|
34 | * `TConstantScope` types to be able to insert shared constant statements. For example in Babel
|
---|
35 | * this would be a `NodePath` object; in TS it would just be a `Node` object.
|
---|
36 | *
|
---|
37 | * If it is not possible to find such a shared scope, then constant statements will be wrapped up
|
---|
38 | * with their generated linked definition expression, in the form of an IIFE.
|
---|
39 | *
|
---|
40 | * @param expression the expression that points to the Angular core framework import.
|
---|
41 | * @returns a reference to a reference object for where the shared constant statements will be
|
---|
42 | * inserted, or `null` if it is not possible to have a shared scope.
|
---|
43 | */
|
---|
44 | getConstantScopeRef(expression: TExpression): TSharedConstantScope | null;
|
---|
45 | }
|
---|