1 | /// <amd-module name="@angular/compiler-cli/ngcc/src/utils" />
|
---|
2 | /**
|
---|
3 | * @license
|
---|
4 | * Copyright Google LLC All Rights Reserved.
|
---|
5 | *
|
---|
6 | * Use of this source code is governed by an MIT-style license that can be
|
---|
7 | * found in the LICENSE file at https://angular.io/license
|
---|
8 | */
|
---|
9 | import * as ts from 'typescript';
|
---|
10 | import { AbsoluteFsPath, ReadonlyFileSystem } from '../../src/ngtsc/file_system';
|
---|
11 | import { DeclarationNode, KnownDeclaration } from '../../src/ngtsc/reflection';
|
---|
12 | /**
|
---|
13 | * A list (`Array`) of partially ordered `T` items.
|
---|
14 | *
|
---|
15 | * The items in the list are partially ordered in the sense that any element has either the same or
|
---|
16 | * higher precedence than any element which appears later in the list. What "higher precedence"
|
---|
17 | * means and how it is determined is implementation-dependent.
|
---|
18 | *
|
---|
19 | * See [PartiallyOrderedSet](https://en.wikipedia.org/wiki/Partially_ordered_set) for more details.
|
---|
20 | * (Refraining from using the term "set" here, to avoid confusion with JavaScript's
|
---|
21 | * [Set](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set).)
|
---|
22 | *
|
---|
23 | * NOTE: A plain `Array<T>` is not assignable to a `PartiallyOrderedList<T>`, but a
|
---|
24 | * `PartiallyOrderedList<T>` is assignable to an `Array<T>`.
|
---|
25 | */
|
---|
26 | export interface PartiallyOrderedList<T> extends Array<T> {
|
---|
27 | _partiallyOrdered: true;
|
---|
28 | map<U>(callbackfn: (value: T, index: number, array: PartiallyOrderedList<T>) => U, thisArg?: any): PartiallyOrderedList<U>;
|
---|
29 | slice(...args: Parameters<Array<T>['slice']>): PartiallyOrderedList<T>;
|
---|
30 | }
|
---|
31 | export declare function getOriginalSymbol(checker: ts.TypeChecker): (symbol: ts.Symbol) => ts.Symbol;
|
---|
32 | export declare function isDefined<T>(value: T | undefined | null): value is T;
|
---|
33 | export declare function getNameText(name: ts.PropertyName | ts.BindingName): string;
|
---|
34 | /**
|
---|
35 | * Parse down the AST and capture all the nodes that satisfy the test.
|
---|
36 | * @param node The start node.
|
---|
37 | * @param test The function that tests whether a node should be included.
|
---|
38 | * @returns a collection of nodes that satisfy the test.
|
---|
39 | */
|
---|
40 | export declare function findAll<T>(node: ts.Node, test: (node: ts.Node) => node is ts.Node & T): T[];
|
---|
41 | /**
|
---|
42 | * Does the given declaration have a name which is an identifier?
|
---|
43 | * @param declaration The declaration to test.
|
---|
44 | * @returns true if the declaration has an identifier for a name.
|
---|
45 | */
|
---|
46 | export declare function hasNameIdentifier(declaration: ts.Node): declaration is DeclarationNode & {
|
---|
47 | name: ts.Identifier;
|
---|
48 | };
|
---|
49 | /**
|
---|
50 | * Test whether a path is "relative".
|
---|
51 | *
|
---|
52 | * Relative paths start with `/`, `./` or `../` (or the Windows equivalents); or are simply `.` or
|
---|
53 | * `..`.
|
---|
54 | */
|
---|
55 | export declare function isRelativePath(path: string): boolean;
|
---|
56 | /**
|
---|
57 | * A `Map`-like object that can compute and memoize a missing value for any key.
|
---|
58 | *
|
---|
59 | * The computed values are memoized, so the factory function is not called more than once per key.
|
---|
60 | * This is useful for storing values that are expensive to compute and may be used multiple times.
|
---|
61 | */
|
---|
62 | export declare class FactoryMap<K, V> {
|
---|
63 | private factory;
|
---|
64 | private internalMap;
|
---|
65 | constructor(factory: (key: K) => V, entries?: readonly (readonly [K, V])[] | null);
|
---|
66 | get(key: K): V;
|
---|
67 | set(key: K, value: V): void;
|
---|
68 | }
|
---|
69 | /**
|
---|
70 | * Attempt to resolve a `path` to a file by appending the provided `postFixes`
|
---|
71 | * to the `path` and checking if the file exists on disk.
|
---|
72 | * @returns An absolute path to the first matching existing file, or `null` if none exist.
|
---|
73 | */
|
---|
74 | export declare function resolveFileWithPostfixes(fs: ReadonlyFileSystem, path: AbsoluteFsPath, postFixes: string[]): AbsoluteFsPath | null;
|
---|
75 | /**
|
---|
76 | * Determine whether a function declaration corresponds with a TypeScript helper function, returning
|
---|
77 | * its kind if so or null if the declaration does not seem to correspond with such a helper.
|
---|
78 | */
|
---|
79 | export declare function getTsHelperFnFromDeclaration(decl: DeclarationNode): KnownDeclaration | null;
|
---|
80 | /**
|
---|
81 | * Determine whether an identifier corresponds with a TypeScript helper function (based on its
|
---|
82 | * name), returning its kind if so or null if the identifier does not seem to correspond with such a
|
---|
83 | * helper.
|
---|
84 | */
|
---|
85 | export declare function getTsHelperFnFromIdentifier(id: ts.Identifier): KnownDeclaration | null;
|
---|
86 | /**
|
---|
87 | * An identifier may become repeated when bundling multiple source files into a single bundle, so
|
---|
88 | * bundlers have a strategy of suffixing non-unique identifiers with a suffix like $2. This function
|
---|
89 | * strips off such suffixes, so that ngcc deals with the canonical name of an identifier.
|
---|
90 | * @param value The value to strip any suffix of, if applicable.
|
---|
91 | * @returns The canonical representation of the value, without any suffix.
|
---|
92 | */
|
---|
93 | export declare function stripDollarSuffix(value: string): string;
|
---|
94 | export declare function stripExtension(fileName: string): string;
|
---|