@ -114,8 +114,8 @@ export class ImportManager {
|
||||
}
|
||||
|
||||
if (existingImport) {
|
||||
const propertyIdentifier = ts.createIdentifier(symbolName !);
|
||||
const generatedUniqueIdentifier = this._getUniqueIdentifier(sourceFile, symbolName !);
|
||||
const propertyIdentifier = ts.createIdentifier(symbolName!);
|
||||
const generatedUniqueIdentifier = this._getUniqueIdentifier(sourceFile, symbolName!);
|
||||
const needsGeneratedUniqueName = generatedUniqueIdentifier.text !== symbolName;
|
||||
const importName = needsGeneratedUniqueName ? generatedUniqueIdentifier : propertyIdentifier;
|
||||
|
||||
@ -186,7 +186,7 @@ export class ImportManager {
|
||||
this.updatedImports.forEach((expressions, importDecl) => {
|
||||
const sourceFile = importDecl.getSourceFile();
|
||||
const recorder = this.getUpdateRecorder(sourceFile);
|
||||
const namedBindings = importDecl.importClause !.namedBindings as ts.NamedImports;
|
||||
const namedBindings = importDecl.importClause!.namedBindings as ts.NamedImports;
|
||||
const newNamedBindings = ts.updateNamedImports(
|
||||
namedBindings,
|
||||
namedBindings.elements.concat(expressions.map(
|
||||
@ -211,8 +211,8 @@ export class ImportManager {
|
||||
name = `${baseName}_${counter++}`;
|
||||
} while (!this.isUniqueIdentifierName(sourceFile, name));
|
||||
|
||||
this._recordUsedIdentifier(sourceFile, name !);
|
||||
return ts.createIdentifier(name !);
|
||||
this._recordUsedIdentifier(sourceFile, name!);
|
||||
return ts.createIdentifier(name!);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -221,7 +221,7 @@ export class ImportManager {
|
||||
*/
|
||||
private isUniqueIdentifierName(sourceFile: ts.SourceFile, name: string) {
|
||||
if (this.usedIdentifierNames.has(sourceFile) &&
|
||||
this.usedIdentifierNames.get(sourceFile) !.indexOf(name) !== -1) {
|
||||
this.usedIdentifierNames.get(sourceFile)!.indexOf(name) !== -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -230,7 +230,7 @@ export class ImportManager {
|
||||
// is unique in the given declaration scope and we just return false.
|
||||
const nodeQueue: ts.Node[] = [sourceFile];
|
||||
while (nodeQueue.length) {
|
||||
const node = nodeQueue.shift() !;
|
||||
const node = nodeQueue.shift()!;
|
||||
if (ts.isIdentifier(node) && node.text === name) {
|
||||
return false;
|
||||
}
|
||||
@ -254,6 +254,6 @@ export class ImportManager {
|
||||
if (!commentRanges || !commentRanges.length) {
|
||||
return nodeEndPos;
|
||||
}
|
||||
return commentRanges[commentRanges.length - 1] !.end;
|
||||
return commentRanges[commentRanges.length - 1]!.end;
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,9 @@ export interface ResolvedTemplate {
|
||||
* If the template is declared inline within a TypeScript source file, the line and
|
||||
* character are based on the full source file content.
|
||||
*/
|
||||
getCharacterAndLineOfPosition: (pos: number) => { character: number, line: number };
|
||||
getCharacterAndLineOfPosition: (pos: number) => {
|
||||
character: number, line: number
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,8 +105,8 @@ export class NgComponentTemplateVisitor {
|
||||
content: property.initializer.text,
|
||||
inline: true,
|
||||
start: templateStartIdx,
|
||||
getCharacterAndLineOfPosition:
|
||||
pos => ts.getLineAndCharacterOfPosition(sourceFile, pos + templateStartIdx)
|
||||
getCharacterAndLineOfPosition: pos =>
|
||||
ts.getLineAndCharacterOfPosition(sourceFile, pos + templateStartIdx)
|
||||
});
|
||||
}
|
||||
if (propertyName === 'templateUrl' && ts.isStringLiteralLike(property.initializer)) {
|
||||
|
@ -9,7 +9,7 @@
|
||||
import * as ts from 'typescript';
|
||||
import {getCallDecoratorImport} from './typescript/decorators';
|
||||
|
||||
export type CallExpressionDecorator = ts.Decorator & {
|
||||
export type CallExpressionDecorator = ts.Decorator&{
|
||||
expression: ts.CallExpression;
|
||||
};
|
||||
|
||||
@ -30,8 +30,8 @@ export function getAngularDecorators(
|
||||
.filter(({importData}) => importData && importData.importModule.startsWith('@angular/'))
|
||||
.map(({node, importData}) => ({
|
||||
node: node as CallExpressionDecorator,
|
||||
name: importData !.name,
|
||||
moduleName: importData !.importModule,
|
||||
importNode: importData !.node
|
||||
name: importData!.name,
|
||||
moduleName: importData!.importModule,
|
||||
importNode: importData!.node
|
||||
}));
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ function getTargetTsconfigPath(project: WorkspaceProject, targetName: string): s
|
||||
*/
|
||||
function getWorkspaceConfigGracefully(tree: Tree): any {
|
||||
const path = defaultWorkspaceConfigPaths.find(filePath => tree.exists(filePath));
|
||||
const configBuffer = tree.read(path !);
|
||||
const configBuffer = tree.read(path!);
|
||||
|
||||
if (!path || !configBuffer) {
|
||||
return null;
|
||||
|
@ -30,5 +30,5 @@ export function supportsPrompt(): boolean {
|
||||
* create prompts.
|
||||
*/
|
||||
export function getInquirer(): Inquirer {
|
||||
return resolvedInquirerModule !;
|
||||
return resolvedInquirerModule!;
|
||||
}
|
||||
|
@ -7,7 +7,8 @@
|
||||
*/
|
||||
|
||||
import * as ts from 'typescript';
|
||||
import {Import, getImportOfIdentifier} from './imports';
|
||||
|
||||
import {getImportOfIdentifier, Import} from './imports';
|
||||
|
||||
export function getCallDecoratorImport(
|
||||
typeChecker: ts.TypeChecker, decorator: ts.Decorator): Import|null {
|
||||
|
@ -20,7 +20,7 @@ export function isFunctionLikeDeclaration(node: ts.Node): node is ts.FunctionLik
|
||||
* parentheses or as expression. e.g. "(((({exp}))))()". The function should return the
|
||||
* TypeScript node referring to the inner expression. e.g "exp".
|
||||
*/
|
||||
export function unwrapExpression(node: ts.Expression | ts.ParenthesizedExpression): ts.Expression {
|
||||
export function unwrapExpression(node: ts.Expression|ts.ParenthesizedExpression): ts.Expression {
|
||||
if (ts.isParenthesizedExpression(node) || ts.isAsExpression(node)) {
|
||||
return unwrapExpression(node.expression);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user