@ -78,7 +78,7 @@ export function convertDirectiveMetadataToExpression(
|
||||
/**
|
||||
* Gets a valid property name from the given text. If the text cannot be used
|
||||
* as unquoted identifier, the name will be wrapped in a string literal.
|
||||
*/
|
||||
*/
|
||||
function getPropertyName(name: string): string|ts.StringLiteral {
|
||||
// Matches the most common identifiers that do not need quotes. Constructing a
|
||||
// regular expression that matches the ECMAScript specification in order to determine
|
||||
|
@ -122,7 +122,7 @@ export class DecoratorRewriter {
|
||||
|null {
|
||||
try {
|
||||
return ts
|
||||
.transform(prop, [ctx => this.importRewriterFactory.create(ctx, this.newSourceFile !)])
|
||||
.transform(prop, [ctx => this.importRewriterFactory.create(ctx, this.newSourceFile!)])
|
||||
.transformed[0];
|
||||
} catch (e) {
|
||||
// If the error is for an unresolved identifier, we want to return "null" because
|
||||
|
@ -11,11 +11,11 @@ import {dirname, resolve} from 'path';
|
||||
import * as ts from 'typescript';
|
||||
|
||||
import {ImportManager} from '../../../utils/import_manager';
|
||||
import {Import, getImportOfIdentifier} from '../../../utils/typescript/imports';
|
||||
import {getImportOfIdentifier, Import} from '../../../utils/typescript/imports';
|
||||
import {getValueSymbolOfDeclaration} from '../../../utils/typescript/symbol';
|
||||
|
||||
import {getPosixPath} from './path_format';
|
||||
import {ResolvedExport, getExportSymbolsOfFile} from './source_file_exports';
|
||||
import {getExportSymbolsOfFile, ResolvedExport} from './source_file_exports';
|
||||
|
||||
|
||||
/**
|
||||
@ -116,7 +116,7 @@ export class ImportRewriteTransformerFactory {
|
||||
*/
|
||||
private _getSourceFileExports(sourceFile: ts.SourceFile): ResolvedExport[] {
|
||||
if (this.sourceFileExports.has(sourceFile)) {
|
||||
return this.sourceFileExports.get(sourceFile) !;
|
||||
return this.sourceFileExports.get(sourceFile)!;
|
||||
}
|
||||
|
||||
const sourceFileExports = getExportSymbolsOfFile(sourceFile, this.typeChecker);
|
||||
|
@ -123,7 +123,7 @@ function runUndecoratedClassesMigration(
|
||||
/** Gets the update recorder for the specified source file. */
|
||||
function getUpdateRecorder(sourceFile: ts.SourceFile): UpdateRecorder {
|
||||
if (updateRecorders.has(sourceFile)) {
|
||||
return updateRecorders.get(sourceFile) !;
|
||||
return updateRecorders.get(sourceFile)!;
|
||||
}
|
||||
const treeRecorder = tree.beginUpdate(relative(basePath, sourceFile.fileName));
|
||||
const recorder: UpdateRecorder = {
|
||||
@ -146,7 +146,9 @@ function runUndecoratedClassesMigration(
|
||||
treeRecorder.remove(namedBindings.getStart(), namedBindings.getWidth());
|
||||
treeRecorder.insertRight(namedBindings.getStart(), newNamedBindings);
|
||||
},
|
||||
commitUpdate() { tree.commitUpdate(treeRecorder); }
|
||||
commitUpdate() {
|
||||
tree.commitUpdate(treeRecorder);
|
||||
}
|
||||
};
|
||||
updateRecorders.set(sourceFile, recorder);
|
||||
return recorder;
|
||||
|
@ -10,7 +10,7 @@ import {Reference} from '@angular/compiler-cli/src/ngtsc/imports';
|
||||
import {PartialEvaluator, ResolvedValue} from '@angular/compiler-cli/src/ngtsc/partial_evaluator';
|
||||
import * as ts from 'typescript';
|
||||
|
||||
import {NgDecorator, getAngularDecorators} from '../../utils/ng_decorators';
|
||||
import {getAngularDecorators, NgDecorator} from '../../utils/ng_decorators';
|
||||
import {getPropertyNameText} from '../../utils/typescript/property_name';
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@ import {hasExplicitConstructor} from '../../utils/typescript/class_declaration';
|
||||
import {findBaseClassDeclarations} from '../../utils/typescript/find_base_classes';
|
||||
import {getImportOfIdentifier} from '../../utils/typescript/imports';
|
||||
|
||||
import {UnexpectedMetadataValueError, convertDirectiveMetadataToExpression} from './decorator_rewrite/convert_directive_metadata';
|
||||
import {convertDirectiveMetadataToExpression, UnexpectedMetadataValueError} from './decorator_rewrite/convert_directive_metadata';
|
||||
import {DecoratorRewriter} from './decorator_rewrite/decorator_rewriter';
|
||||
import {hasDirectiveDecorator, hasInjectableDecorator} from './ng_declaration_collector';
|
||||
import {UpdateRecorder} from './update_recorder';
|
||||
@ -316,7 +316,9 @@ export class UndecoratedClassesTransform {
|
||||
}
|
||||
|
||||
/** Records all changes that were made in the import manager. */
|
||||
recordChanges() { this.importManager.recordChanges(); }
|
||||
recordChanges() {
|
||||
this.importManager.recordChanges();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a TypeScript decorator node from the specified declaration metadata. Returns
|
||||
|
Reference in New Issue
Block a user