/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import {MigrationRule} from '../update-tool/migration-rule'; import {getChangesForTarget, ValueOfChanges, VersionChanges} from '../update-tool/version-changes'; import { attributeSelectors, AttributeSelectorUpgradeData, classNames, ClassNameUpgradeData, constructorChecks, ConstructorChecksUpgradeData, cssSelectors, CssSelectorUpgradeData, elementSelectors, ElementSelectorUpgradeData, inputNames, InputNameUpgradeData, methodCallChecks, MethodCallUpgradeData, outputNames, OutputNameUpgradeData, propertyNames, PropertyNameUpgradeData, } from './data'; /** Upgrade data for the Angular CDK. */ export const cdkUpgradeData: RuleUpgradeData = { attributeSelectors, classNames, constructorChecks, cssSelectors, elementSelectors, inputNames, methodCallChecks, outputNames, propertyNames, }; /** * Interface that describes the upgrade data that needs to be defined when using the CDK * upgrade rules. */ export interface RuleUpgradeData { attributeSelectors: VersionChanges; classNames: VersionChanges; constructorChecks: VersionChanges; cssSelectors: VersionChanges; elementSelectors: VersionChanges; inputNames: VersionChanges; methodCallChecks: VersionChanges; outputNames: VersionChanges; propertyNames: VersionChanges; } /** * Gets the reduced upgrade data for the specified data key from the rule walker options. * * The function reads out the target version and upgrade data object from the rule options and * resolves the specified data portion that is specifically tied to the target version. */ export function getVersionUpgradeData>( r: MigrationRule, dataName: T): U[] { // Note that below we need to cast to `unknown` first TS doesn't infer the type of T correctly. return getChangesForTarget(r.targetVersion, r.upgradeData[dataName] as unknown as VersionChanges); }