build(bazel): Turning on strictPropertyInitialization for Angular. (#24572)

All errors for existing fields have been detected and suppressed with a
`!` assertion.

Issue/24571 is tracking proper clean up of those instances.

One-line change required in ivy/compilation.ts, because it appears that
the new syntax causes tsickle emitted node to no longer track their
original sourceFiles.

PR Close #24572
This commit is contained in:
Rado Kirov
2018-06-18 16:38:33 -07:00
committed by Miško Hevery
parent 39c7769c9e
commit c95437f15d
189 changed files with 1273 additions and 632 deletions

View File

@ -49,10 +49,14 @@ export class StaticReflector implements CompileReflector {
private staticCache = new Map<StaticSymbol, string[]>();
private conversionMap = new Map<StaticSymbol, (context: StaticSymbol, args: any[]) => any>();
private resolvedExternalReferences = new Map<string, StaticSymbol>();
private injectionToken: StaticSymbol;
private opaqueToken: StaticSymbol;
ROUTES: StaticSymbol;
private ANALYZE_FOR_ENTRY_COMPONENTS: StaticSymbol;
// TODO(issue/24571): remove '!'.
private injectionToken !: StaticSymbol;
// TODO(issue/24571): remove '!'.
private opaqueToken !: StaticSymbol;
// TODO(issue/24571): remove '!'.
ROUTES !: StaticSymbol;
// TODO(issue/24571): remove '!'.
private ANALYZE_FOR_ENTRY_COMPONENTS !: StaticSymbol;
private annotationForParentClassWithSummaryKind =
new Map<CompileSummaryKind, MetadataFactory<any>[]>();

View File

@ -421,7 +421,8 @@ class ForJitSerializer {
}
class FromJsonDeserializer extends ValueTransformer {
private symbols: StaticSymbol[];
// TODO(issue/24571): remove '!'.
private symbols !: StaticSymbol[];
constructor(
private symbolCache: StaticSymbolCache,

View File

@ -528,7 +528,8 @@ export interface CompileNgModuleSummary extends CompileTypeSummary {
}
export class CompileShallowModuleMetadata {
type: CompileTypeMetadata;
// TODO(issue/24571): remove '!'.
type !: CompileTypeMetadata;
rawExports: any;
rawImports: any;

View File

@ -40,7 +40,8 @@ const KEY_CONTEXT = {};
class FixupExpression extends o.Expression {
private original: o.Expression;
shared: boolean;
// TODO(issue/24571): remove '!'.
shared !: boolean;
constructor(public resolved: o.Expression) {
super(resolved.type);

View File

@ -116,7 +116,8 @@ function _trackWhitespace(mode: CssLexerMode) {
}
export class CssScanner {
peek: number;
// TODO(issue/24571): remove '!'.
peek !: number;
peekPeek: number;
length: number = 0;
index: number = -1;

View File

@ -83,9 +83,12 @@ export class ParsedCssResult {
export class CssParser {
private _errors: CssParseError[] = [];
private _file: ParseSourceFile;
private _scanner: CssScanner;
private _lastToken: CssToken;
// TODO(issue/24571): remove '!'.
private _file !: ParseSourceFile;
// TODO(issue/24571): remove '!'.
private _scanner !: CssScanner;
// TODO(issue/24571): remove '!'.
private _lastToken !: CssToken;
/**
* @param css the CSS code that will be parsed

View File

@ -55,33 +55,46 @@ enum _VisitorMode {
* @internal
*/
class _Visitor implements html.Visitor {
private _depth: number;
// TODO(issue/24571): remove '!'.
private _depth !: number;
// <el i18n>...</el>
private _inI18nNode: boolean;
private _inImplicitNode: boolean;
// TODO(issue/24571): remove '!'.
private _inI18nNode !: boolean;
// TODO(issue/24571): remove '!'.
private _inImplicitNode !: boolean;
// <!--i18n-->...<!--/i18n-->
private _inI18nBlock: boolean;
private _blockMeaningAndDesc: string;
private _blockChildren: html.Node[];
private _blockStartDepth: number;
// TODO(issue/24571): remove '!'.
private _inI18nBlock !: boolean;
// TODO(issue/24571): remove '!'.
private _blockMeaningAndDesc !: string;
// TODO(issue/24571): remove '!'.
private _blockChildren !: html.Node[];
// TODO(issue/24571): remove '!'.
private _blockStartDepth !: number;
// {<icu message>}
private _inIcu: boolean;
// TODO(issue/24571): remove '!'.
private _inIcu !: boolean;
// set to void 0 when not in a section
private _msgCountAtSectionStart: number|undefined;
private _errors: I18nError[];
private _mode: _VisitorMode;
// TODO(issue/24571): remove '!'.
private _errors !: I18nError[];
// TODO(issue/24571): remove '!'.
private _mode !: _VisitorMode;
// _VisitorMode.Extract only
private _messages: i18n.Message[];
// TODO(issue/24571): remove '!'.
private _messages !: i18n.Message[];
// _VisitorMode.Merge only
private _translations: TranslationBundle;
private _createI18nMessage:
(msg: html.Node[], meaning: string, description: string, id: string) => i18n.Message;
// TODO(issue/24571): remove '!'.
private _translations !: TranslationBundle;
// TODO(issue/24571): remove '!'.
private _createI18nMessage !: (
msg: html.Node[], meaning: string, description: string, id: string) => i18n.Message;
constructor(private _implicitTags: string[], private _implicitAttrs: {[k: string]: string[]}) {}

View File

@ -65,7 +65,8 @@ export class Container implements Node {
}
export class Icu implements Node {
public expressionPlaceholder: string;
// TODO(issue/24571): remove '!'.
public expressionPlaceholder !: string;
constructor(
public expression: string, public type: string, public cases: {[k: string]: Node},
public sourceSpan: ParseSourceSpan) {}

View File

@ -30,11 +30,16 @@ export function createI18nMessageFactory(interpolationConfig: InterpolationConfi
}
class _I18nVisitor implements html.Visitor {
private _isIcu: boolean;
private _icuDepth: number;
private _placeholderRegistry: PlaceholderRegistry;
private _placeholderToContent: {[phName: string]: string};
private _placeholderToMessage: {[phName: string]: i18n.Message};
// TODO(issue/24571): remove '!'.
private _isIcu !: boolean;
// TODO(issue/24571): remove '!'.
private _icuDepth !: number;
// TODO(issue/24571): remove '!'.
private _placeholderRegistry !: PlaceholderRegistry;
// TODO(issue/24571): remove '!'.
private _placeholderToContent !: {[phName: string]: string};
// TODO(issue/24571): remove '!'.
private _placeholderToMessage !: {[phName: string]: i18n.Message};
constructor(
private _expressionParser: ExpressionParser,

View File

@ -173,9 +173,12 @@ class _WriteVisitor implements i18n.Visitor {
// TODO(vicb): add error management (structure)
// Extract messages as xml nodes from the xliff file
class XliffParser implements ml.Visitor {
private _unitMlString: string|null;
private _errors: I18nError[];
private _msgIdToHtml: {[msgId: string]: string};
// TODO(issue/24571): remove '!'.
private _unitMlString !: string | null;
// TODO(issue/24571): remove '!'.
private _errors !: I18nError[];
// TODO(issue/24571): remove '!'.
private _msgIdToHtml !: {[msgId: string]: string};
private _locale: string|null = null;
parse(xliff: string, url: string) {
@ -261,7 +264,8 @@ class XliffParser implements ml.Visitor {
// Convert ml nodes (xliff syntax) to i18n nodes
class XmlToI18n implements ml.Visitor {
private _errors: I18nError[];
// TODO(issue/24571): remove '!'.
private _errors !: I18nError[];
convert(message: string, url: string) {
const xmlIcu = new XmlParser().parse(message, url, true);

View File

@ -112,7 +112,8 @@ export class Xliff2 extends Serializer {
}
class _WriteVisitor implements i18n.Visitor {
private _nextPlaceholderId: number;
// TODO(issue/24571): remove '!'.
private _nextPlaceholderId !: number;
visitText(text: i18n.Text, context?: any): xml.Node[] { return [new xml.Text(text.value)]; }
@ -190,9 +191,12 @@ class _WriteVisitor implements i18n.Visitor {
// Extract messages as xml nodes from the xliff file
class Xliff2Parser implements ml.Visitor {
private _unitMlString: string|null;
private _errors: I18nError[];
private _msgIdToHtml: {[msgId: string]: string};
// TODO(issue/24571): remove '!'.
private _unitMlString !: string | null;
// TODO(issue/24571): remove '!'.
private _errors !: I18nError[];
// TODO(issue/24571): remove '!'.
private _msgIdToHtml !: {[msgId: string]: string};
private _locale: string|null = null;
parse(xliff: string, url: string) {
@ -285,7 +289,8 @@ class Xliff2Parser implements ml.Visitor {
// Convert ml nodes (xliff syntax) to i18n nodes
class XmlToI18n implements ml.Visitor {
private _errors: I18nError[];
// TODO(issue/24571): remove '!'.
private _errors !: I18nError[];
convert(message: string, url: string) {
const xmlIcu = new XmlParser().parse(message, url, true);

View File

@ -74,9 +74,12 @@ function createLazyProperty(messages: any, id: string, valueFn: () => any) {
// Extract messages as xml nodes from the xtb file
class XtbParser implements ml.Visitor {
private _bundleDepth: number;
private _errors: I18nError[];
private _msgIdToHtml: {[msgId: string]: string};
// TODO(issue/24571): remove '!'.
private _bundleDepth !: number;
// TODO(issue/24571): remove '!'.
private _errors !: I18nError[];
// TODO(issue/24571): remove '!'.
private _msgIdToHtml !: {[msgId: string]: string};
private _locale: string|null = null;
parse(xtb: string, url: string) {
@ -152,7 +155,8 @@ class XtbParser implements ml.Visitor {
// Convert ml nodes (xtb syntax) to i18n nodes
class XmlToI18n implements ml.Visitor {
private _errors: I18nError[];
// TODO(issue/24571): remove '!'.
private _errors !: I18nError[];
convert(message: string, url: string) {
const xmlIcu = new XmlParser().parse(message, url, true);

View File

@ -60,10 +60,12 @@ export class TranslationBundle {
}
class I18nToHtmlVisitor implements i18n.Visitor {
private _srcMsg: i18n.Message;
// TODO(issue/24571): remove '!'.
private _srcMsg !: i18n.Message;
private _contextStack: {msg: i18n.Message, mapper: (name: string) => string}[] = [];
private _errors: I18nError[] = [];
private _mapper: (name: string) => string;
// TODO(issue/24571): remove '!'.
private _mapper !: (name: string) => string;
constructor(
private _i18nNodesByMsgId: {[msgId: string]: i18n.Node[]} = {}, private _locale: string|null,

View File

@ -12,8 +12,10 @@ export class HtmlTagDefinition implements TagDefinition {
private closedByChildren: {[key: string]: boolean} = {};
closedByParent: boolean = false;
requiredParents: {[key: string]: boolean};
parentToAdd: string;
// TODO(issue/24571): remove '!'.
requiredParents !: {[key: string]: boolean};
// TODO(issue/24571): remove '!'.
parentToAdd !: string;
implicitNamespacePrefix: string|null;
contentType: TagContentType;
isVoid: boolean;

View File

@ -84,8 +84,10 @@ class _Tokenizer {
private _index: number = -1;
private _line: number = 0;
private _column: number = -1;
private _currentTokenStart: ParseLocation;
private _currentTokenType: TokenType;
// TODO(issue/24571): remove '!'.
private _currentTokenStart !: ParseLocation;
// TODO(issue/24571): remove '!'.
private _currentTokenType !: TokenType;
private _expansionCaseStack: TokenType[] = [];
private _inInterpolation: boolean = false;

View File

@ -46,7 +46,8 @@ export class Parser {
class _TreeBuilder {
private _index: number = -1;
private _peek: lex.Token;
// TODO(issue/24571): remove '!'.
private _peek !: lex.Token;
private _rootNodes: html.Node[] = [];
private _errors: TreeError[] = [];

View File

@ -10,9 +10,12 @@ import {TagContentType, TagDefinition} from './tags';
export class XmlTagDefinition implements TagDefinition {
closedByParent: boolean = false;
requiredParents: {[key: string]: boolean};
parentToAdd: string;
implicitNamespacePrefix: string;
// TODO(issue/24571): remove '!'.
requiredParents !: {[key: string]: boolean};
// TODO(issue/24571): remove '!'.
parentToAdd !: string;
// TODO(issue/24571): remove '!'.
implicitNamespacePrefix !: string;
contentType: TagContentType = TagContentType.PARSABLE_DATA;
isVoid: boolean = false;
ignoreFirstLf: boolean = false;

View File

@ -11,8 +11,10 @@ import {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from '../../../src/ml
class Unparser implements AstVisitor {
private static _quoteRegExp = /"/g;
private _expression: string;
private _interpolationConfig: InterpolationConfig;
// TODO(issue/24571): remove '!'.
private _expression !: string;
// TODO(issue/24571): remove '!'.
private _interpolationConfig !: InterpolationConfig;
unparse(ast: AST, interpolationConfig: InterpolationConfig) {
this._expression = '';

View File

@ -19,9 +19,12 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
template: '',
})
export class I18nComponent {
count: number;
sex: string;
sexB: string;
// TODO(issue/24571): remove '!'.
count !: number;
// TODO(issue/24571): remove '!'.
sex !: string;
// TODO(issue/24571): remove '!'.
sexB !: string;
response: any = {getItemsList: (): any[] => []};
}

View File

@ -20,7 +20,8 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
it('should support dotted selectors', async(() => {
@Directive({selector: '[dot.name]'})
class MyDir {
@Input('dot.name') value: string;
// TODO(issue/24571): remove '!'.
@Input('dot.name') value !: string;
}
TestBed.configureTestingModule({

View File

@ -99,8 +99,10 @@ export class MockResourceLoader extends ResourceLoader {
}
class _PendingRequest {
resolve: (result: string) => void;
reject: (error: any) => void;
// TODO(issue/24571): remove '!'.
resolve !: (result: string) => void;
// TODO(issue/24571): remove '!'.
reject !: (error: any) => void;
promise: Promise<string>;
constructor(public url: string) {

View File

@ -7,6 +7,7 @@
"experimentalDecorators": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"noFallthroughCasesInSwitch": true,
"module": "es2015",
"moduleResolution": "node",