build: enable TSLint on the packages folder

This commit is contained in:
Victor Berchet 2017-07-27 16:13:16 -07:00 committed by Alex Rickabaugh
parent e64b54b67b
commit 9479a106bb
50 changed files with 146 additions and 125 deletions

View File

@ -201,7 +201,7 @@ export class AnimationAstBuilderVisitor implements AnimationDslVisitor {
} else { } else {
styles.push(styleTuple as ɵStyleData); styles.push(styleTuple as ɵStyleData);
} }
}) });
} else { } else {
styles.push(metadata.styles); styles.push(metadata.styles);
} }

View File

@ -29,8 +29,8 @@ export class AnimationEngine {
this._transitionEngine = new TransitionAnimationEngine(driver, normalizer); this._transitionEngine = new TransitionAnimationEngine(driver, normalizer);
this._timelineEngine = new TimelineAnimationEngine(driver, normalizer); this._timelineEngine = new TimelineAnimationEngine(driver, normalizer);
this._transitionEngine.onRemovalComplete = this._transitionEngine.onRemovalComplete = (element: any, context: any) =>
(element: any, context: any) => { this.onRemovalComplete(element, context); } this.onRemovalComplete(element, context);
} }
registerTrigger( registerTrigger(

View File

@ -490,6 +490,7 @@ export class TransitionAnimationEngine {
// this method is designed to be overridden by the code that uses this engine // this method is designed to be overridden by the code that uses this engine
public onRemovalComplete = (element: any, context: any) => {}; public onRemovalComplete = (element: any, context: any) => {};
/** @internal */
_onRemovalComplete(element: any, context: any) { this.onRemovalComplete(element, context); } _onRemovalComplete(element: any, context: any) { this.onRemovalComplete(element, context); }
constructor(public driver: AnimationDriver, private _normalizer: AnimationStyleNormalizer) {} constructor(public driver: AnimationDriver, private _normalizer: AnimationStyleNormalizer) {}

View File

@ -427,17 +427,17 @@ export function main() {
it('should throw an error when an input variable is not provided when invoked and is not a default value', it('should throw an error when an input variable is not provided when invoked and is not a default value',
() => { () => {
expect(() => {invokeAnimationSequence(rootElement, [style({color: '{{ color }}'})])}) expect(() => invokeAnimationSequence(rootElement, [style({color: '{{ color }}'})]))
.toThrowError(/Please provide a value for the animation param color/); .toThrowError(/Please provide a value for the animation param color/);
expect( expect(
() => {invokeAnimationSequence( () => invokeAnimationSequence(
rootElement, rootElement,
[ [
style({color: '{{ start }}'}), style({color: '{{ start }}'}),
animate('{{ time }}', style({color: '{{ end }}'})), animate('{{ time }}', style({color: '{{ end }}'})),
], ],
buildParams({start: 'blue', end: 'red'}))}) buildParams({start: 'blue', end: 'red'})))
.toThrowError(/Please provide a value for the animation param time/); .toThrowError(/Please provide a value for the animation param time/);
}); });
}); });

View File

@ -182,7 +182,7 @@ export function main() {
const trans = buildTransition(result, element, false, true) !; const trans = buildTransition(result, element, false, true) !;
expect(trans.timelines[0].keyframes).toEqual([ expect(trans.timelines[0].keyframes).toEqual([
{offset: 0, color: 'red'}, {offset: 1, color: 'green'} {offset: 0, color: 'red'}, {offset: 1, color: 'green'}
]) ]);
}); });
it('should match `1` and `0` state styles on a `true <=> false` boolean transition given boolean values', it('should match `1` and `0` state styles on a `true <=> false` boolean transition given boolean values',
@ -195,7 +195,7 @@ export function main() {
const trans = buildTransition(result, element, false, true) !; const trans = buildTransition(result, element, false, true) !;
expect(trans.timelines[0].keyframes).toEqual([ expect(trans.timelines[0].keyframes).toEqual([
{offset: 0, color: 'orange'}, {offset: 1, color: 'blue'} {offset: 0, color: 'orange'}, {offset: 1, color: 'blue'}
]) ]);
}); });
describe('aliases', () => { describe('aliases', () => {

View File

@ -15,8 +15,11 @@ import {HttpParams} from './params';
* All values are optional and will override default values if provided. * All values are optional and will override default values if provided.
*/ */
interface HttpRequestInit { interface HttpRequestInit {
headers?: HttpHeaders, reportProgress?: boolean, params?: HttpParams, headers?: HttpHeaders;
responseType?: 'arraybuffer'|'blob'|'json'|'text', withCredentials?: boolean, reportProgress?: boolean;
params?: HttpParams;
responseType?: 'arraybuffer'|'blob'|'json'|'text';
withCredentials?: boolean;
} }
/** /**

View File

@ -120,7 +120,10 @@ export interface HttpUserEvent<T> { type: HttpEventType.User; }
* *
* @experimental * @experimental
*/ */
export interface HttpJsonParseError { error: Error, text: string, } export interface HttpJsonParseError {
error: Error;
text: string;
}
/** /**
* Union type for all possible events on the response stream. * Union type for all possible events on the response stream.
@ -233,7 +236,7 @@ export class HttpHeaderResponse extends HttpResponseBase {
status: update.status !== undefined ? update.status : this.status, status: update.status !== undefined ? update.status : this.status,
statusText: update.statusText || this.statusText, statusText: update.statusText || this.statusText,
url: update.url || this.url || undefined, url: update.url || this.url || undefined,
}) });
} }
} }

View File

@ -268,27 +268,26 @@ export class HttpXhrBackend implements HttpBackend {
// The upload progress event handler, which is only registered if // The upload progress event handler, which is only registered if
// progress events are enabled. // progress events are enabled.
const onUpProgress = const onUpProgress = (event: ProgressEvent) => {
(event: ProgressEvent) => { // Upload progress events are simpler. Begin building the progress
// Upload progress events are simpler. Begin building the progress // event.
// event. let progress: HttpUploadProgressEvent = {
let progress: HttpUploadProgressEvent = { type: HttpEventType.UploadProgress,
type: HttpEventType.UploadProgress, loaded: event.loaded,
loaded: event.loaded, };
};
// If the total number of bytes being uploaded is available, include // If the total number of bytes being uploaded is available, include
// it. // it.
if (event.lengthComputable) { if (event.lengthComputable) {
progress.total = event.total; progress.total = event.total;
} }
// Send the event. // Send the event.
observer.next(progress); observer.next(progress);
} };
// By default, register for load and error events. // By default, register for load and error events.
xhr.addEventListener('load', onLoad); xhr.addEventListener('load', onLoad);
xhr.addEventListener('error', onError); xhr.addEventListener('error', onError);
// Progress events are only enabled if requested. // Progress events are only enabled if requested.

View File

@ -56,11 +56,11 @@ export function main() {
}); });
describe('throws an error', () => { describe('throws an error', () => {
it('when request method is not JSONP', it('when request method is not JSONP',
() => {expect(() => backend.handle(SAMPLE_REQ.clone<never>({method: 'GET'}))) () => expect(() => backend.handle(SAMPLE_REQ.clone<never>({method: 'GET'})))
.toThrowError(JSONP_ERR_WRONG_METHOD)}); .toThrowError(JSONP_ERR_WRONG_METHOD));
it('when response type is not json', it('when response type is not json',
() => {expect(() => backend.handle(SAMPLE_REQ.clone<never>({responseType: 'text'}))) () => expect(() => backend.handle(SAMPLE_REQ.clone<never>({responseType: 'text'})))
.toThrowError(JSONP_ERR_WRONG_RESPONSE_TYPE)}); .toThrowError(JSONP_ERR_WRONG_RESPONSE_TYPE));
it('when callback is never called', (done: DoneFn) => { it('when callback is never called', (done: DoneFn) => {
backend.handle(SAMPLE_REQ).subscribe(undefined, (err: HttpErrorResponse) => { backend.handle(SAMPLE_REQ).subscribe(undefined, (err: HttpErrorResponse) => {
expect(err.status).toBe(0); expect(err.status).toBe(0);
@ -69,7 +69,7 @@ export function main() {
done(); done();
}); });
document.mockLoad(); document.mockLoad();
}) });
}); });
}); });
} }

View File

@ -13,7 +13,7 @@ export function main() {
describe('initialization', () => { describe('initialization', () => {
it('should be empty at construction', () => { it('should be empty at construction', () => {
const body = new HttpParams(); const body = new HttpParams();
expect(body.toString()).toEqual('') expect(body.toString()).toEqual('');
}); });
it('should parse an existing url', () => { it('should parse an existing url', () => {

View File

@ -271,7 +271,7 @@ export function main() {
done(); done();
}); });
factory.mock.mockFlush(200, 'OK', 'Test'); factory.mock.mockFlush(200, 'OK', 'Test');
}) });
}); });
describe('corrects for quirks', () => { describe('corrects for quirks', () => {
it('by normalizing 1223 status to 204', (done: DoneFn) => { it('by normalizing 1223 status to 204', (done: DoneFn) => {

View File

@ -64,7 +64,7 @@ export function main() {
}); });
describe('HttpXsrfCookieExtractor', () => { describe('HttpXsrfCookieExtractor', () => {
let document: {[key: string]: string}; let document: {[key: string]: string};
let extractor: HttpXsrfCookieExtractor let extractor: HttpXsrfCookieExtractor;
beforeEach(() => { beforeEach(() => {
document = { document = {
cookie: 'XSRF-TOKEN=test', cookie: 'XSRF-TOKEN=test',

View File

@ -126,7 +126,7 @@ export class HttpClientTestingBackend implements HttpBackend, HttpTestingControl
const requests = open.map(testReq => { const requests = open.map(testReq => {
const url = testReq.request.urlWithParams.split('?')[0]; const url = testReq.request.urlWithParams.split('?')[0];
const method = testReq.request.method; const method = testReq.request.method;
return `${method} ${url}` return `${method} ${url}`;
}) })
.join(', '); .join(', ');
throw new Error(`Expected no open requests, found ${open.length}: ${requests}`); throw new Error(`Expected no open requests, found ${open.length}: ${requests}`);

View File

@ -96,7 +96,7 @@ export class CodeGenerator {
} }
} }
if (!transContent) { if (!transContent) {
missingTranslation = MissingTranslationStrategy.Ignore missingTranslation = MissingTranslationStrategy.Ignore;
} }
const {compiler: aotCompiler} = compiler.createAotCompiler(ngCompilerHost, { const {compiler: aotCompiler} = compiler.createAotCompiler(ngCompilerHost, {
translations: transContent, translations: transContent,

View File

@ -203,11 +203,9 @@ class TypeCheckingHost implements ts.CompilerHost {
} }
writeFile: ts.WriteFileCallback = writeFile: ts.WriteFileCallback =
() => { throw new Error('Unexpected write in diagnostic program'); } () => { throw new Error('Unexpected write in diagnostic program'); };
getCurrentDirectory(): string { getCurrentDirectory(): string { return this.host.getCurrentDirectory(); }
return this.host.getCurrentDirectory();
}
getDirectories(path: string): string[] { return this.host.getDirectories(path); } getDirectories(path: string): string[] { return this.host.getDirectories(path); }

View File

@ -136,12 +136,11 @@ export function performCompilation(
const rootFileNames = files.map(f => path.normalize(f)); const rootFileNames = files.map(f => path.normalize(f));
const addGeneratedFileName = const addGeneratedFileName = (fileName: string) => {
(fileName: string) => { if (fileName.startsWith(basePath) && TS_EXT.exec(fileName)) {
if (fileName.startsWith(basePath) && TS_EXT.exec(fileName)) { rootFileNames.push(fileName);
rootFileNames.push(fileName); }
} };
}
if (ngOptions.flatModuleOutFile && !ngOptions.skipMetadataEmit) { if (ngOptions.flatModuleOutFile && !ngOptions.skipMetadataEmit) {
const {host: bundleHost, indexName, errors} = const {host: bundleHost, indexName, errors} =

View File

@ -63,7 +63,7 @@ function transformSourceFile(
const result = ts.visitEachChild(node, visitNode, context); const result = ts.visitEachChild(node, visitNode, context);
if (declarations.length) { if (declarations.length) {
inserts.push({priorTo: result, declarations}) inserts.push({priorTo: result, declarations});
} }
return result; return result;
} }
@ -113,7 +113,7 @@ export function getExpressionLoweringTransformFactory(requestsMap: RequestsMap):
return (context: ts.TransformationContext) => (sourceFile: ts.SourceFile): ts.SourceFile => { return (context: ts.TransformationContext) => (sourceFile: ts.SourceFile): ts.SourceFile => {
const requests = requestsMap.getRequests(sourceFile); const requests = requestsMap.getRequests(sourceFile);
if (requests && requests.size) { if (requests && requests.size) {
return transformSourceFile(sourceFile, requests, context) return transformSourceFile(sourceFile, requests, context);
} }
return sourceFile; return sourceFile;
}; };
@ -155,12 +155,11 @@ export class LowerMetadataCache implements RequestsMap {
let identNumber = 0; let identNumber = 0;
const freshIdent = () => '\u0275' + identNumber++; const freshIdent = () => '\u0275' + identNumber++;
const requests = new Map<number, LoweringRequest>(); const requests = new Map<number, LoweringRequest>();
const replaceNode = const replaceNode = (node: ts.Node) => {
(node: ts.Node) => { const name = freshIdent();
const name = freshIdent(); requests.set(node.pos, {name, kind: node.kind, location: node.pos, end: node.end});
requests.set(node.pos, {name, kind: node.kind, location: node.pos, end: node.end}); return {__symbolic: 'reference', name};
return {__symbolic: 'reference', name}; };
}
const substituteExpression = (value: MetadataValue, node: ts.Node): MetadataValue => { const substituteExpression = (value: MetadataValue, node: ts.Node): MetadataValue => {
if (node.kind === ts.SyntaxKind.ArrowFunction || if (node.kind === ts.SyntaxKind.ArrowFunction ||

View File

@ -9,8 +9,7 @@
import * as path from 'path'; import * as path from 'path';
import * as ts from 'typescript'; import * as ts from 'typescript';
import {ModuleFilenameResolver} from './api'; import {CompilerOptions, ModuleFilenameResolver} from './api';
import {CompilerOptions} from './api';
const EXT = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/; const EXT = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/;
const DTS = /\.d\.ts$/; const DTS = /\.d\.ts$/;

View File

@ -32,7 +32,7 @@ export class TypeScriptNodeEmitter {
} }
statements[0] = ts.setSyntheticLeadingComments( statements[0] = ts.setSyntheticLeadingComments(
statements[0], statements[0],
[{kind: ts.SyntaxKind.MultiLineCommentTrivia, text: preamble, pos: -1, end: -1}]) [{kind: ts.SyntaxKind.MultiLineCommentTrivia, text: preamble, pos: -1, end: -1}]);
} }
return [newSourceFile, converter.getNodeMap()]; return [newSourceFile, converter.getNodeMap()];
} }
@ -279,7 +279,7 @@ class _NodeEmitterVisitor implements StatementVisitor, ExpressionVisitor {
return this.record( return this.record(
expr, ts.createCall( expr, ts.createCall(
expr.fn.visitExpression(this, null), /* typeArguments */ undefined, expr.fn.visitExpression(this, null), /* typeArguments */ undefined,
expr.args.map(arg => arg.visitExpression(this, null)))) expr.args.map(arg => arg.visitExpression(this, null))));
} }
visitInstantiateExpr(expr: InstantiateExpr): RecordedNode<ts.NewExpression> { visitInstantiateExpr(expr: InstantiateExpr): RecordedNode<ts.NewExpression> {

View File

@ -15,8 +15,7 @@ import * as ts from 'typescript';
import {CompilerHost as AotCompilerHost, CompilerHostContext} from '../compiler_host'; import {CompilerHost as AotCompilerHost, CompilerHostContext} from '../compiler_host';
import {TypeChecker} from '../diagnostics/check_types'; import {TypeChecker} from '../diagnostics/check_types';
import {CompilerHost, CompilerOptions, DiagnosticCategory} from './api'; import {CompilerHost, CompilerOptions, Diagnostic, DiagnosticCategory, EmitFlags, Program} from './api';
import {Diagnostic, EmitFlags, Program} from './api';
import {LowerMetadataCache, getExpressionLoweringTransformFactory} from './lower_expressions'; import {LowerMetadataCache, getExpressionLoweringTransformFactory} from './lower_expressions';
import {getAngularEmitterTransformFactory} from './node_emitter_transform'; import {getAngularEmitterTransformFactory} from './node_emitter_transform';
@ -144,7 +143,7 @@ class AngularCompilerProgram implements Program {
} }
private get structuralDiagnostics(): Diagnostic[] { private get structuralDiagnostics(): Diagnostic[] {
return this.analyzedModules && this._structuralDiagnostics return this.analyzedModules && this._structuralDiagnostics;
} }
private get stubs(): GeneratedFile[] { private get stubs(): GeneratedFile[] {
@ -171,7 +170,7 @@ class AngularCompilerProgram implements Program {
} }
private get generatedFiles(): GeneratedFile[] { private get generatedFiles(): GeneratedFile[] {
return this._generatedFiles || (this._generatedFiles = this.generateFiles()) return this._generatedFiles || (this._generatedFiles = this.generateFiles());
} }
private get typeChecker(): TypeChecker { private get typeChecker(): TypeChecker {
@ -343,7 +342,7 @@ function createProgramWithStubsHost(
generatedFiles: GeneratedFile[], originalProgram: ts.Program, generatedFiles: GeneratedFile[], originalProgram: ts.Program,
originalHost: ts.CompilerHost): ts.CompilerHost { originalHost: ts.CompilerHost): ts.CompilerHost {
interface FileData { interface FileData {
g: GeneratedFile g: GeneratedFile;
s?: ts.SourceFile; s?: ts.SourceFile;
} }
return new class implements ts.CompilerHost { return new class implements ts.CompilerHost {

View File

@ -110,12 +110,14 @@ const summaryResolver = new AotSummaryResolver(
staticSymbolCache); staticSymbolCache);
export class DiagnosticContext { export class DiagnosticContext {
// tslint:disable
_analyzedModules: NgAnalyzedModules; _analyzedModules: NgAnalyzedModules;
_staticSymbolResolver: StaticSymbolResolver|undefined; _staticSymbolResolver: StaticSymbolResolver|undefined;
_reflector: StaticReflector|undefined; _reflector: StaticReflector|undefined;
_errors: {e: any, path?: string}[] = []; _errors: {e: any, path?: string}[] = [];
_resolver: CompileMetadataResolver|undefined; _resolver: CompileMetadataResolver|undefined;
_refletor: StaticReflector; _refletor: StaticReflector;
// tslint:enable
constructor( constructor(
public service: ts.LanguageService, public program: ts.Program, public service: ts.LanguageService, public program: ts.Program,

View File

@ -45,7 +45,7 @@ describe('symbol query', () => {
options.basePath = '/quickstart'; options.basePath = '/quickstart';
const aotHost = new CompilerHost(program, options, host, {verboseInvalidExpression: true}); const aotHost = new CompilerHost(program, options, host, {verboseInvalidExpression: true});
context = new DiagnosticContext(service, program, checker, aotHost); context = new DiagnosticContext(service, program, checker, aotHost);
query = getSymbolQuery(program, checker, sourceFile, emptyPipes) query = getSymbolQuery(program, checker, sourceFile, emptyPipes);
}); });
it('should be able to get undefined for an unknown symbol', () => { it('should be able to get undefined for an unknown symbol', () => {

View File

@ -437,12 +437,11 @@ describe('ngc command-line', () => {
throw new Error(`Expected ${fileName} to be emitted (outDir: ${outDir})`); throw new Error(`Expected ${fileName} to be emitted (outDir: ${outDir})`);
} }
}; };
const shouldNotExist = const shouldNotExist = (fileName: string) => {
(fileName: string) => { if (fs.existsSync(path.resolve(outDir, fileName))) {
if (fs.existsSync(path.resolve(outDir, fileName))) { throw new Error(`Did not expect ${fileName} to be emitted (outDir: ${outDir})`);
throw new Error(`Did not expect ${fileName} to be emitted (outDir: ${outDir})`); }
} };
}
it('should be able to generate a flat module library', () => { it('should be able to generate a flat module library', () => {
writeConfig(` writeConfig(`

View File

@ -14,5 +14,5 @@ export interface AotCompilerOptions {
translations?: string; translations?: string;
missingTranslation?: MissingTranslationStrategy; missingTranslation?: MissingTranslationStrategy;
enableLegacyTemplate?: boolean; enableLegacyTemplate?: boolean;
enableSummariesForJit?: boolean enableSummariesForJit?: boolean;
} }

View File

@ -621,7 +621,7 @@ export class StaticReflector implements CompileReflector {
} }
return simplifyInContext(context, value, depth, references + 1); return simplifyInContext(context, value, depth, references + 1);
} }
return simplify(value) return simplify(value);
}); });
} }
return IGNORE; return IGNORE;

View File

@ -142,7 +142,7 @@ export function findNode(nodes: Node[], position: number): HtmlAstPath {
return true; return true;
} }
} }
} };
visitAll(visitor, nodes); visitAll(visitor, nodes);

View File

@ -228,7 +228,7 @@ export class ReadVarExpr extends Expression {
set(value: Expression): WriteVarExpr { set(value: Expression): WriteVarExpr {
if (!this.name) { if (!this.name) {
throw new Error(`Built in variable ${this.builtin} can not be assigned to.`) throw new Error(`Built in variable ${this.builtin} can not be assigned to.`);
} }
return new WriteVarExpr(this.name, value, null, this.sourceSpan); return new WriteVarExpr(this.name, value, null, this.sourceSpan);
} }

View File

@ -28,7 +28,7 @@ describe('compiler (unbundled Angular)', () => {
describe('aot source mapping', () => { describe('aot source mapping', () => {
const componentPath = '/app/app.component.ts'; const componentPath = '/app/app.component.ts';
const ngComponentPath = 'ng:///app/app.component.ts' const ngComponentPath = 'ng:///app/app.component.ts';
let rootDir: MockDirectory; let rootDir: MockDirectory;
let appDir: MockDirectory; let appDir: MockDirectory;

View File

@ -490,7 +490,7 @@ export function main() {
.toEqual( .toEqual(
'<span someAttr="ok">foo</span><div>{count, plural, =0 {<p title="foo"></p>}}</div>'); '<span someAttr="ok">foo</span><div>{count, plural, =0 {<p title="foo"></p>}}</div>');
}); });
}) });
}); });
} }

View File

@ -31,5 +31,5 @@ export function main() {
expect(Object.keys(args).length).toBe(20); expect(Object.keys(args).length).toBe(20);
}); });
}); });
}) });
} }

View File

@ -6,23 +6,21 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {ParseError, ParseErrorLevel, ParseLocation, ParseSourceFile, ParseSourceSpan} from '../src/parse_util' import {ParseError, ParseErrorLevel, ParseLocation, ParseSourceFile, ParseSourceSpan} from '../src/parse_util';
export function main() { export function main() {
describe( describe('ParseError', () => {
'ParseError', it('should reflect the level in the message', () => {
() => { const file = new ParseSourceFile(`foo\nbar\nfoo`, 'url');
it('should reflect the level in the message', () => { const start = new ParseLocation(file, 4, 1, 0);
const file = new ParseSourceFile(`foo\nbar\nfoo`, 'url'); const end = new ParseLocation(file, 6, 1, 2);
const start = new ParseLocation(file, 4, 1, 0); const span = new ParseSourceSpan(start, end);
const end = new ParseLocation(file, 6, 1, 2);
const span = new ParseSourceSpan(start, end);
const fatal = new ParseError(span, 'fatal', ParseErrorLevel.ERROR); const fatal = new ParseError(span, 'fatal', ParseErrorLevel.ERROR);
expect(fatal.toString()).toEqual('fatal ("foo\n[ERROR ->]bar\nfoo"): url@1:0'); expect(fatal.toString()).toEqual('fatal ("foo\n[ERROR ->]bar\nfoo"): url@1:0');
const warning = new ParseError(span, 'warning', ParseErrorLevel.WARNING); const warning = new ParseError(span, 'warning', ParseErrorLevel.WARNING);
expect(warning.toString()).toEqual('warning ("foo\n[WARNING ->]bar\nfoo"): url@1:0'); expect(warning.toString()).toEqual('warning ("foo\n[WARNING ->]bar\nfoo"): url@1:0');
}); });
}); });
} }

View File

@ -45,11 +45,10 @@ export class ApplicationInitStatus {
const asyncInitPromises: Promise<any>[] = []; const asyncInitPromises: Promise<any>[] = [];
const complete = const complete = () => {
() => { this._done = true;
this._done = true; this.resolve();
this.resolve(); };
}
if (this.appInits) { if (this.appInits) {
for (let i = 0; i < this.appInits.length; i++) { for (let i = 0; i < this.appInits.length; i++) {

View File

@ -52,11 +52,9 @@ export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChan
// Keeps track of records where custom track by is the same, but item identity has changed // Keeps track of records where custom track by is the same, but item identity has changed
private _identityChangesHead: IterableChangeRecord_<V>|null = null; private _identityChangesHead: IterableChangeRecord_<V>|null = null;
private _identityChangesTail: IterableChangeRecord_<V>|null = null; private _identityChangesTail: IterableChangeRecord_<V>|null = null;
private _trackByFn: TrackByFunction<V> private _trackByFn: TrackByFunction<V>;
constructor(trackByFn?: TrackByFunction<V>) { constructor(trackByFn?: TrackByFunction<V>) { this._trackByFn = trackByFn || trackByIdentity; }
this._trackByFn = trackByFn || trackByIdentity;
}
get collection() { return this._collection; } get collection() { return this._collection; }

View File

@ -466,7 +466,8 @@ export function createNgModuleRef(
class NgModuleRef_ implements NgModuleData, InternalNgModuleRef<any> { class NgModuleRef_ implements NgModuleData, InternalNgModuleRef<any> {
private _destroyListeners: (() => void)[] = []; private _destroyListeners: (() => void)[] = [];
private _destroyed: boolean = false; private _destroyed: boolean = false;
public _providers: any[]; /** @internal */
_providers: any[];
constructor( constructor(
private _moduleType: Type<any>, public _parent: Injector, private _moduleType: Type<any>, public _parent: Injector,

View File

@ -1882,7 +1882,7 @@ export function main() {
class Cmp { class Cmp {
exp: string; exp: string;
log: any[] = []; log: any[] = [];
callback = (event: any) => { this.log.push(`${event.phaseName} => ${event.toState}`); } callback = (event: any) => this.log.push(`${event.phaseName} => ${event.toState}`);
} }
TestBed.configureTestingModule({ TestBed.configureTestingModule({

View File

@ -35,7 +35,7 @@ export function main() {
return () => { return () => {
const initStatus = injector.get(ApplicationInitStatus); const initStatus = injector.get(ApplicationInitStatus);
initStatus.donePromise.then(() => { expect(completerResolver).toBe(true); }); initStatus.donePromise.then(() => { expect(completerResolver).toBe(true); });
} };
}; };
promise = new Promise((res) => { resolve = res; }); promise = new Promise((res) => { resolve = res; });
TestBed.configureTestingModule({ TestBed.configureTestingModule({

View File

@ -1353,7 +1353,7 @@ export function main() {
tpl: TemplateRef<any>; tpl: TemplateRef<any>;
@Input() @Input()
outerTpl: TemplateRef<any> outerTpl: TemplateRef<any>;
constructor(public cdRef: ChangeDetectorRef) {} constructor(public cdRef: ChangeDetectorRef) {}
log(id: string) { log.push(`inner-${id}`); } log(id: string) { log.push(`inner-${id}`); }

View File

@ -83,14 +83,17 @@ export class DefaultValueAccessor implements ControlValueAccessor {
this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled); this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
} }
/** @internal */
_handleInput(value: any): void { _handleInput(value: any): void {
if (!this._compositionMode || (this._compositionMode && !this._composing)) { if (!this._compositionMode || (this._compositionMode && !this._composing)) {
this.onChange(value); this.onChange(value);
} }
} }
/** @internal */
_compositionStart(): void { this._composing = true; } _compositionStart(): void { this._composing = true; }
/** @internal */
_compositionEnd(value: any): void { _compositionEnd(value: any): void {
this._composing = false; this._composing = false;
this._compositionMode && this.onChange(value); this._compositionMode && this.onChange(value);

View File

@ -41,7 +41,7 @@ export function main() {
return e; return e;
} }
function otherObservableValidator() { return of ({'other': true}) } function otherObservableValidator() { return of ({'other': true}); }
describe('FormGroup', () => { describe('FormGroup', () => {
describe('value', () => { describe('value', () => {

View File

@ -1116,7 +1116,7 @@ export function main() {
tick(100); tick(100);
expect(resultArr.length) expect(resultArr.length)
.toEqual(2, `Expected original observable to be canceled on the next value change.`) .toEqual(2, `Expected original observable to be canceled on the next value change.`);
})); }));

View File

@ -1,3 +1,11 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {Component, Directive, EventEmitter, Input, Output, Type} from '@angular/core'; import {Component, Directive, EventEmitter, Input, Output, Type} from '@angular/core';
import {ComponentFixture, TestBed, async, fakeAsync, tick} from '@angular/core/testing'; import {ComponentFixture, TestBed, async, fakeAsync, tick} from '@angular/core/testing';
import {AbstractControl, ControlValueAccessor, FormControl, FormGroup, FormsModule, NG_VALIDATORS, NG_VALUE_ACCESSOR, NgControl, NgForm, ReactiveFormsModule, Validators} from '@angular/forms'; import {AbstractControl, ControlValueAccessor, FormControl, FormGroup, FormsModule, NG_VALIDATORS, NG_VALUE_ACCESSOR, NgControl, NgForm, ReactiveFormsModule, Validators} from '@angular/forms';

View File

@ -123,7 +123,7 @@ export function main() {
// depending on the browser, we might ge an exception // depending on the browser, we might ge an exception
} }
try { try {
sanitizeHtml(defaultDoc, '<form><input name="nextSibling" /></form>') sanitizeHtml(defaultDoc, '<form><input name="nextSibling" /></form>');
} catch (e) { } catch (e) {
// depending on the browser, we might ge an exception // depending on the browser, we might ge an exception
} }

View File

@ -444,8 +444,11 @@ function match(segmentGroup: UrlSegmentGroup, route: Route, segments: UrlSegment
if (!res) { if (!res) {
return { return {
matched: false, consumedSegments: <any[]>[], lastChild: 0, positionalParamSegments: {}, matched: false,
} consumedSegments: <any[]>[],
lastChild: 0,
positionalParamSegments: {},
};
} }
return { return {

View File

@ -1128,7 +1128,7 @@ class ActivateRoutes {
const children: {[outletName: string]: any} = nodeChildrenAsMap(route); const children: {[outletName: string]: any} = nodeChildrenAsMap(route);
const contexts = route.value.component ? context.children : parentContexts; const contexts = route.value.component ? context.children : parentContexts;
forEach(children, (v: any, k: string) => {this.deactivateRouteAndItsChildren(v, contexts)}); forEach(children, (v: any, k: string) => this.deactivateRouteAndItsChildren(v, contexts));
if (context.outlet) { if (context.outlet) {
// Destroy the component // Destroy the component

View File

@ -64,7 +64,7 @@ export function forEach<K, V>(map: {[key: string]: V}, callback: (v: V, k: strin
export function waitForMap<A, B>( export function waitForMap<A, B>(
obj: {[k: string]: A}, fn: (k: string, a: A) => Observable<B>): Observable<{[k: string]: B}> { obj: {[k: string]: A}, fn: (k: string, a: A) => Observable<B>): Observable<{[k: string]: B}> {
if (Object.keys(obj).length === 0) { if (Object.keys(obj).length === 0) {
return of ({}) return of ({});
} }
const waitHead: Observable<B>[] = []; const waitHead: Observable<B>[] = [];

View File

@ -1070,7 +1070,7 @@ describe('Integration', () => {
return map.call(of (null), () => { return map.call(of (null), () => {
log.push('resolver2'); log.push('resolver2');
observer.next(null); observer.next(null);
observer.complete() observer.complete();
}); });
} }
}, },

View File

@ -259,9 +259,9 @@ describe('Evaluator', () => {
const expr = findVar(source, 'a'); const expr = findVar(source, 'a');
expect(evaluator.evaluateNode(expr !.initializer !)).toEqual([ expect(evaluator.evaluateNode(expr !.initializer !)).toEqual([
{provide: 'someValue', useFactory: {__symbolic: 'reference', name: lambdaTemp}} {provide: 'someValue', useFactory: {__symbolic: 'reference', name: lambdaTemp}}
]) ]);
}); });
}) });
}); });
function sourceFileOf(text: string): ts.SourceFile { function sourceFileOf(text: string): ts.SourceFile {

View File

@ -1,3 +1,11 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import * as fs from 'fs'; import * as fs from 'fs';
import * as ts from 'typescript'; import * as ts from 'typescript';
@ -70,7 +78,7 @@ export class MockNode implements ts.Node {
public kind: ts.SyntaxKind = ts.SyntaxKind.Identifier, public flags: ts.NodeFlags = 0, public kind: ts.SyntaxKind = ts.SyntaxKind.Identifier, public flags: ts.NodeFlags = 0,
public pos: number = 0, public end: number = 0) {} public pos: number = 0, public end: number = 0) {}
getSourceFile(): ts.SourceFile { return null as any as ts.SourceFile; } getSourceFile(): ts.SourceFile { return null as any as ts.SourceFile; }
getChildCount(sourceFile?: ts.SourceFile): number { return 0 } getChildCount(sourceFile?: ts.SourceFile): number { return 0; }
getChildAt(index: number, sourceFile?: ts.SourceFile): ts.Node { return null as any as ts.Node; } getChildAt(index: number, sourceFile?: ts.SourceFile): ts.Node { return null as any as ts.Node; }
getChildren(sourceFile?: ts.SourceFile): ts.Node[] { return []; } getChildren(sourceFile?: ts.SourceFile): ts.Node[] { return []; }
getStart(sourceFile?: ts.SourceFile): number { return 0; } getStart(sourceFile?: ts.SourceFile): number { return 0; }
@ -90,12 +98,14 @@ export class MockNode implements ts.Node {
export class MockIdentifier extends MockNode implements ts.Identifier { export class MockIdentifier extends MockNode implements ts.Identifier {
public text: string; public text: string;
// tslint:disable
public _primaryExpressionBrand: any; public _primaryExpressionBrand: any;
public _memberExpressionBrand: any; public _memberExpressionBrand: any;
public _leftHandSideExpressionBrand: any; public _leftHandSideExpressionBrand: any;
public _incrementExpressionBrand: any; public _incrementExpressionBrand: any;
public _unaryExpressionBrand: any; public _unaryExpressionBrand: any;
public _expressionBrand: any; public _expressionBrand: any;
// tslint:enable
constructor( constructor(
public name: string, public kind: ts.SyntaxKind.Identifier = ts.SyntaxKind.Identifier, public name: string, public kind: ts.SyntaxKind.Identifier = ts.SyntaxKind.Identifier,
@ -106,6 +116,7 @@ export class MockIdentifier extends MockNode implements ts.Identifier {
} }
export class MockVariableDeclaration extends MockNode implements ts.VariableDeclaration { export class MockVariableDeclaration extends MockNode implements ts.VariableDeclaration {
// tslint:disable-next-line
public _declarationBrand: any; public _declarationBrand: any;
constructor( constructor(
@ -130,7 +141,7 @@ export class MockSymbol implements ts.Symbol {
getDeclarations(): ts.Declaration[] { return [this.node]; } getDeclarations(): ts.Declaration[] { return [this.node]; }
getDocumentationComment(): ts.SymbolDisplayPart[] { return []; } getDocumentationComment(): ts.SymbolDisplayPart[] { return []; }
// TODO(vicb): removed in TS 2.2 // TODO(vicb): removed in TS 2.2
getJsDocTags(): any[]{return []}; getJsDocTags(): any[] { return []; }
static of (name: string): MockSymbol { return new MockSymbol(name); } static of (name: string): MockSymbol { return new MockSymbol(name); }
} }
@ -139,6 +150,7 @@ export function expectNoDiagnostics(diagnostics: ts.Diagnostic[]) {
for (const diagnostic of diagnostics) { for (const diagnostic of diagnostics) {
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
const {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); const {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
// tslint:disable-next-line:no-console
console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
} }
expect(diagnostics.length).toBe(0); expect(diagnostics.length).toBe(0);
@ -159,7 +171,7 @@ export function allChildren<T>(node: ts.Node, cb: (node: ts.Node) => T): T {
return result; return result;
} }
return allChildren(child, cb); return allChildren(child, cb);
}) });
} }
export function findClass(sourceFile: ts.SourceFile, name: string): ts.ClassDeclaration|undefined { export function findClass(sourceFile: ts.SourceFile, name: string): ts.ClassDeclaration|undefined {

View File

@ -9,6 +9,7 @@ module.exports = (gulp) => () => {
// todo(vicb): add .js files when supported // todo(vicb): add .js files when supported
// see https://github.com/palantir/tslint/pull/1515 // see https://github.com/palantir/tslint/pull/1515
'./modules/**/*.ts', './modules/**/*.ts',
'./packages/**/*.ts',
'./tools/**/*.ts', './tools/**/*.ts',
'./*.ts', './*.ts',

View File

@ -144,9 +144,6 @@ export declare class DefaultValueAccessor implements ControlValueAccessor {
onChange: (_: any) => void; onChange: (_: any) => void;
onTouched: () => void; onTouched: () => void;
constructor(_renderer: Renderer2, _elementRef: ElementRef, _compositionMode: boolean); constructor(_renderer: Renderer2, _elementRef: ElementRef, _compositionMode: boolean);
_compositionEnd(value: any): void;
_compositionStart(): void;
_handleInput(value: any): void;
registerOnChange(fn: (_: any) => void): void; registerOnChange(fn: (_: any) => void): void;
registerOnTouched(fn: () => void): void; registerOnTouched(fn: () => void): void;
setDisabledState(isDisabled: boolean): void; setDisabledState(isDisabled: boolean): void;