refactor: early compatibility with TypeScript 3.5 (#31174)

This commit fixes a couple of issues with TS 3.5 compatibility in order to
unblock migration of g3. Mostly 'any's are added, and there are no behavior
changes.

PR Close #31174
This commit is contained in:
Alex Rickabaugh 2019-06-20 13:15:57 -07:00 committed by Kara Erickson
parent 34eaafdf40
commit fad03c3c14
3 changed files with 12 additions and 8 deletions

View File

@ -418,8 +418,9 @@ export class MetadataCollector {
const maybeFunc = maybeGetSimpleFunction(functionDeclaration); const maybeFunc = maybeGetSimpleFunction(functionDeclaration);
if (name) { if (name) {
if (!metadata) metadata = {}; if (!metadata) metadata = {};
metadata[name] = // TODO(alxhub): The literal here is not valid FunctionMetadata.
maybeFunc ? recordEntry(maybeFunc.func, node) : {__symbolic: 'function'}; metadata[name] = maybeFunc ? recordEntry(maybeFunc.func, node) :
({ __symbolic: 'function' } as any);
} }
} }
break; break;
@ -448,13 +449,15 @@ export class MetadataCollector {
if (typeof enumValue === 'number') { if (typeof enumValue === 'number') {
nextDefaultValue = enumValue + 1; nextDefaultValue = enumValue + 1;
} else if (name) { } else if (name) {
// TODO(alxhub): 'left' here has a name propery which is not valid for
// MetadataSymbolicSelectExpression.
nextDefaultValue = { nextDefaultValue = {
__symbolic: 'binary', __symbolic: 'binary',
operator: '+', operator: '+',
left: { left: {
__symbolic: 'select', __symbolic: 'select',
expression: recordEntry({__symbolic: 'reference', name: enumName}, node), name expression: recordEntry({__symbolic: 'reference', name: enumName}, node), name
} } as any,
}; };
} else { } else {
nextDefaultValue = nextDefaultValue =

View File

@ -555,7 +555,7 @@ export class Evaluator {
return !operand; return !operand;
} }
} }
let operatorText: string; let operatorText: '+'|'-'|'~'|'!';
switch (prefixUnaryExpression.operator) { switch (prefixUnaryExpression.operator) {
case ts.SyntaxKind.PlusToken: case ts.SyntaxKind.PlusToken:
operatorText = '+'; operatorText = '+';

View File

@ -907,7 +907,7 @@ export class CompileMetadataResolver {
let isOptional = false; let isOptional = false;
let token: any = null; let token: any = null;
if (Array.isArray(param)) { if (Array.isArray(param)) {
param.forEach((paramEntry) => { param.forEach((paramEntry: any) => {
if (createHost.isTypeOf(paramEntry)) { if (createHost.isTypeOf(paramEntry)) {
isHost = true; isHost = true;
} else if (createSelf.isTypeOf(paramEntry)) { } else if (createSelf.isTypeOf(paramEntry)) {
@ -918,11 +918,12 @@ export class CompileMetadataResolver {
isOptional = true; isOptional = true;
} else if (createAttribute.isTypeOf(paramEntry)) { } else if (createAttribute.isTypeOf(paramEntry)) {
isAttribute = true; isAttribute = true;
token = paramEntry.attributeName; token = (paramEntry as any).attributeName;
} else if (createInject.isTypeOf(paramEntry)) { } else if (createInject.isTypeOf(paramEntry)) {
token = paramEntry.token; token = (paramEntry as any).token;
} else if ( } else if (
createInjectionToken.isTypeOf(paramEntry) || paramEntry instanceof StaticSymbol) { createInjectionToken.isTypeOf(paramEntry) ||
(paramEntry as any) instanceof StaticSymbol) {
token = paramEntry; token = paramEntry;
} else if (isValidType(paramEntry) && token == null) { } else if (isValidType(paramEntry) && token == null) {
token = paramEntry; token = paramEntry;