refactor(ngcc): abstract task selection behind an interface (#32427)

This change does not alter the current behavior, but makes it easier to
introduce `TaskQueue`s implementing different task selection algorithms,
for example to support executing multiple tasks in parallel (while
respecting interdependencies between them).

Inspired by/Based on @alxhub's prototype: alxhub/angular@cb631bdb1

PR Close #32427
This commit is contained in:
George Kalpakas
2019-08-27 17:36:25 +03:00
committed by Matias Niemelä
parent 0cf94e3ed5
commit 2844dd2972
9 changed files with 468 additions and 13 deletions

View File

@ -8,6 +8,28 @@
import * as ts from 'typescript';
import {AbsoluteFsPath, FileSystem, absoluteFrom} from '../../src/ngtsc/file_system';
/**
* A list (`Array`) of partially ordered `T` items.
*
* The items in the list are partially ordered in the sense that any element has either the same or
* higher precedence than any element which appears later in the list. What "higher precedence"
* means and how it is determined is implementation-dependent.
*
* See [PartiallyOrderedSet](https://en.wikipedia.org/wiki/Partially_ordered_set) for more details.
* (Refraining from using the term "set" here, to avoid confusion with JavaScript's
* [Set](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set).)
*
* NOTE: A plain `Array<T>` is not assignable to a `PartiallyOrderedList<T>`, but a
* `PartiallyOrderedList<T>` is assignable to an `Array<T>`.
*/
export interface PartiallyOrderedList<T> extends Array<T> {
_partiallyOrdered: true;
map<U>(callbackfn: (value: T, index: number, array: PartiallyOrderedList<T>) => U, thisArg?: any):
PartiallyOrderedList<U>;
slice(...args: Parameters<Array<T>['slice']>): PartiallyOrderedList<T>;
}
export function getOriginalSymbol(checker: ts.TypeChecker): (symbol: ts.Symbol) => ts.Symbol {
return function(symbol: ts.Symbol) {
return ts.SymbolFlags.Alias & symbol.flags ? checker.getAliasedSymbol(symbol) : symbol;