Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/language-service/src/expression_diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,7 @@ export function getExpressionScope(

class ExpressionDiagnosticsVisitor extends RecursiveTemplateAstVisitor {
private path: TemplateAstPath;
// TODO(issue/24571): remove '!'.
private directiveSummary !: CompileDirectiveSummary;
private directiveSummary: CompileDirectiveSummary|undefined;

diagnostics: Diagnostic[] = [];

Expand Down
9 changes: 3 additions & 6 deletions packages/language-service/src/expression_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ export class TypeDiagnostic {

// AstType calculatetype of the ast given AST element.
export class AstType implements AstVisitor {
// TODO(issue/24571): remove '!'.
public diagnostics !: TypeDiagnostic[];
public diagnostics: TypeDiagnostic[] = [];

constructor(
private scope: SymbolTable, private query: SymbolQuery,
Expand Down Expand Up @@ -338,8 +337,7 @@ export class AstType implements AstVisitor {
return this.resolvePropertyRead(this.query.getNonNullableType(this.getType(ast.receiver)), ast);
}

// TODO(issue/24571): remove '!'.
private _anyType !: Symbol;
private _anyType: Symbol|undefined;
private get anyType(): Symbol {
let result = this._anyType;
if (!result) {
Expand All @@ -348,8 +346,7 @@ export class AstType implements AstVisitor {
return result;
}

// TODO(issue/24571): remove '!'.
private _undefinedType !: Symbol;
private _undefinedType: Symbol|undefined;
private get undefinedType(): Symbol {
let result = this._undefinedType;
if (!result) {
Expand Down
2 changes: 0 additions & 2 deletions packages/language-service/src/locate_symbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ export function locateSymbol(info: AstResult, position: number): SymbolInfo|unde
}

// See if this attribute matches the selector of any directive on the element.
// TODO(ayazhafiz): Consider caching selector matches (at the expense of potentially
// very high memory usage).
const attributeSelector = `[${ast.name}=${ast.value}]`;
const parsedAttribute = CssSelector.parse(attributeSelector);
if (!parsedAttribute.length) return;
Expand Down
37 changes: 9 additions & 28 deletions packages/language-service/src/typescript_symbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@ export function getPipesTable(

class TypeScriptSymbolQuery implements SymbolQuery {
private typeCache = new Map<BuiltinType, Symbol>();
// TODO(issue/24571): remove '!'.
private pipesCache !: SymbolTable;
private pipesCache: SymbolTable|undefined;

constructor(
private program: ts.Program, private checker: ts.TypeChecker, private source: ts.SourceFile,
private fetchPipes: () => SymbolTable) {}

getTypeKind(symbol: Symbol): BuiltinType { return typeKindOf(this.getTsTypeOf(symbol)); }
getTypeKind(symbol: Symbol): BuiltinType {
const type = symbol instanceof TypeWrapper ? symbol.tsType : undefined;
return typeKindOf(type);
}

getBuiltinType(kind: BuiltinType): Symbol {
let result = this.typeCache.get(kind);
Expand Down Expand Up @@ -205,21 +207,6 @@ class TypeScriptSymbolQuery implements SymbolQuery {
}
}
}

private getTsTypeOf(symbol: Symbol): ts.Type|undefined {
const type = getTypeWrapper(symbol);
return type && type.tsType;
}
}

function getTypeWrapper(symbol: Symbol): TypeWrapper|undefined {
let type: TypeWrapper|undefined = undefined;
if (symbol instanceof TypeWrapper) {
type = symbol;
} else if (symbol.type instanceof TypeWrapper) {
type = symbol.type;
}
return type;
}

function typeCallable(type: ts.Type): boolean {
Expand Down Expand Up @@ -290,9 +277,8 @@ class TypeWrapper implements Symbol {
return selectSignature(this.tsType, this.context, types);
}

indexed(argument: Symbol, value: any): Symbol|undefined {
const type = getTypeWrapper(argument);
if (!type) return;
indexed(type: Symbol, value: any): Symbol|undefined {
if (!(type instanceof TypeWrapper)) return;

const typeKind = typeKindOf(type.tsType);
switch (typeKind) {
Expand All @@ -318,11 +304,7 @@ class TypeWrapper implements Symbol {

const typeReference = (this.tsType as ts.TypeReference);
let typeArguments: ReadonlyArray<ts.Type>|undefined;
if (this.context.checker.getTypeArguments) {
typeArguments = this.context.checker.getTypeArguments(typeReference);
} else {
typeArguments = typeReference.typeArguments;
}
typeArguments = this.context.checker.getTypeArguments(typeReference);
if (!typeArguments) return undefined;
return typeArguments.map(ta => new TypeWrapper(ta, this.context));
}
Expand Down Expand Up @@ -603,8 +585,7 @@ class PipesTable implements SymbolTable {
const INDEX_PATTERN = /[\\/]([^\\/]+)[\\/]\1\.d\.ts$/;

class PipeSymbol implements Symbol {
// TODO(issue/24571): remove '!'.
private _tsType !: ts.Type;
private _tsType: ts.Type|undefined;
public readonly kind: DeclarationKind = 'pipe';
public readonly language: string = 'typescript';
public readonly container: Symbol|undefined = undefined;
Expand Down
13 changes: 5 additions & 8 deletions packages/language-service/test/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,11 @@ const summaryResolver = new AotSummaryResolver(
staticSymbolCache);

export class DiagnosticContext {
// tslint:disable
// TODO(issue/24571): remove '!'.
_analyzedModules !: NgAnalyzedModules;
_staticSymbolResolver: StaticSymbolResolver|undefined;
_reflector: StaticReflector|undefined;
_errors: {e: any, path?: string}[] = [];
_resolver: CompileMetadataResolver|undefined;
// tslint:enable
private _analyzedModules: NgAnalyzedModules|undefined;
private _staticSymbolResolver: StaticSymbolResolver|undefined;
private _reflector: StaticReflector|undefined;
private _errors: {e: any, path?: string}[] = [];
private _resolver: CompileMetadataResolver|undefined;

constructor(
public service: ts.LanguageService, public program: ts.Program,
Expand Down