refactor: Consistently use index access on index signature types. (#28937)
This change helps highlight certain misoptimizations with Closure compiler. It is also stylistically preferable to consistently use index access on index sig types. Roughly, when one sees '.foo' they know it is always checked for typos in the prop name by the type system (unless 'any'), while "['foo']" is always not. Once all angular repos are conforming this will become a tsetse.info check, enforced by bazel. PR Close #28937
This commit is contained in:
parent
2b974d4012
commit
03d2e5cb1d
|
@ -45,7 +45,7 @@ export class CssKeyframesDriver implements AnimationDriver {
|
||||||
let tab = '';
|
let tab = '';
|
||||||
keyframes.forEach(kf => {
|
keyframes.forEach(kf => {
|
||||||
tab = TAB_SPACE;
|
tab = TAB_SPACE;
|
||||||
const offset = parseFloat(kf.offset);
|
const offset = parseFloat(kf['offset']);
|
||||||
keyframeStr += `${tab}${offset * 100}% {\n`;
|
keyframeStr += `${tab}${offset * 100}% {\n`;
|
||||||
tab += TAB_SPACE;
|
tab += TAB_SPACE;
|
||||||
Object.keys(kf).forEach(prop => {
|
Object.keys(kf).forEach(prop => {
|
||||||
|
|
|
@ -65,7 +65,7 @@ export class InlineResourcesMetadataTransformer implements MetadataTransformer {
|
||||||
updateDecoratorMetadata(loader: StaticResourceLoader, arg: MetadataObject): MetadataObject {
|
updateDecoratorMetadata(loader: StaticResourceLoader, arg: MetadataObject): MetadataObject {
|
||||||
if (arg['templateUrl']) {
|
if (arg['templateUrl']) {
|
||||||
arg['template'] = loader.get(arg['templateUrl']);
|
arg['template'] = loader.get(arg['templateUrl']);
|
||||||
delete arg.templateUrl;
|
delete arg['templateUrl'];
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = arg['styles'] || [];
|
const styles = arg['styles'] || [];
|
||||||
|
@ -76,7 +76,7 @@ export class InlineResourcesMetadataTransformer implements MetadataTransformer {
|
||||||
styles.push(...styleUrls.map(styleUrl => loader.get(styleUrl)));
|
styles.push(...styleUrls.map(styleUrl => loader.get(styleUrl)));
|
||||||
if (styles.length > 0) {
|
if (styles.length > 0) {
|
||||||
arg['styles'] = styles;
|
arg['styles'] = styles;
|
||||||
delete arg.styleUrls;
|
delete arg['styleUrls'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return arg;
|
return arg;
|
||||||
|
|
|
@ -420,18 +420,18 @@ export class StaticSymbolResolver {
|
||||||
if (!filePath) {
|
if (!filePath) {
|
||||||
return {
|
return {
|
||||||
__symbolic: 'error',
|
__symbolic: 'error',
|
||||||
message:
|
message: `Could not resolve ${module} relative to ${
|
||||||
`Could not resolve ${module} relative to ${self.host.getMetadataFor(sourceSymbol.filePath)}.`,
|
self.host.getMetadataFor(sourceSymbol.filePath)}.`,
|
||||||
line: map.line,
|
line: map['line'],
|
||||||
character: map.character,
|
character: map['character'],
|
||||||
fileName: getOriginalName()
|
fileName: getOriginalName()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
__symbolic: 'resolved',
|
__symbolic: 'resolved',
|
||||||
symbol: self.getStaticSymbol(filePath, name),
|
symbol: self.getStaticSymbol(filePath, name),
|
||||||
line: map.line,
|
line: map['line'],
|
||||||
character: map.character,
|
character: map['character'],
|
||||||
fileName: getOriginalName()
|
fileName: getOriginalName()
|
||||||
};
|
};
|
||||||
} else if (functionParams.indexOf(name) >= 0) {
|
} else if (functionParams.indexOf(name) >= 0) {
|
||||||
|
|
|
@ -249,7 +249,7 @@ class ToJsonSerializer extends ValueTransformer {
|
||||||
*/
|
*/
|
||||||
visitStringMap(map: {[key: string]: any}, context: any): any {
|
visitStringMap(map: {[key: string]: any}, context: any): any {
|
||||||
if (map['__symbolic'] === 'resolved') {
|
if (map['__symbolic'] === 'resolved') {
|
||||||
return visitValue(map.symbol, this, context);
|
return visitValue(map['symbol'], this, context);
|
||||||
}
|
}
|
||||||
if (map['__symbolic'] === 'error') {
|
if (map['__symbolic'] === 'error') {
|
||||||
delete map['line'];
|
delete map['line'];
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {CompilerFacade, ExportedCompilerFacade} from './compiler_facade_interfac
|
||||||
export * from './compiler_facade_interface';
|
export * from './compiler_facade_interface';
|
||||||
|
|
||||||
export function getCompilerFacade(): CompilerFacade {
|
export function getCompilerFacade(): CompilerFacade {
|
||||||
const globalNg: ExportedCompilerFacade = global.ng;
|
const globalNg: ExportedCompilerFacade = global['ng'];
|
||||||
if (!globalNg || !globalNg.ɵcompilerFacade) {
|
if (!globalNg || !globalNg.ɵcompilerFacade) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Angular JIT compilation failed: '@angular/compiler' not loaded!\n` +
|
`Angular JIT compilation failed: '@angular/compiler' not loaded!\n` +
|
||||||
|
|
|
@ -568,7 +568,7 @@ export function updateStylingMap(
|
||||||
const classesValue = classesPlayerBuilder ?
|
const classesValue = classesPlayerBuilder ?
|
||||||
(classesInput as BoundPlayerFactory<{[key: string]: any}|string>) !.value :
|
(classesInput as BoundPlayerFactory<{[key: string]: any}|string>) !.value :
|
||||||
classesInput;
|
classesInput;
|
||||||
const stylesValue = stylesPlayerBuilder ? stylesInput !.value : stylesInput;
|
const stylesValue = stylesPlayerBuilder ? stylesInput !['value'] : stylesInput;
|
||||||
|
|
||||||
let classNames: string[] = EMPTY_ARRAY;
|
let classNames: string[] = EMPTY_ARRAY;
|
||||||
let applyAllClasses = false;
|
let applyAllClasses = false;
|
||||||
|
|
|
@ -70,8 +70,8 @@ export class FormBuilder {
|
||||||
updateOn = options.updateOn != null ? options.updateOn : undefined;
|
updateOn = options.updateOn != null ? options.updateOn : undefined;
|
||||||
} else {
|
} else {
|
||||||
// `options` are legacy form group options
|
// `options` are legacy form group options
|
||||||
validators = options.validator != null ? options.validator : null;
|
validators = options['validator'] != null ? options['validator'] : null;
|
||||||
asyncValidators = options.asyncValidator != null ? options.asyncValidator : null;
|
asyncValidators = options['asyncValidator'] != null ? options['asyncValidator'] : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue