From 4aae472c0f2e30161cf772f5e750d51932fa8e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kov=C3=A1cs?= Date: Sat, 11 Mar 2017 02:09:55 +0100 Subject: [PATCH] [knockout] Update KnockoutComponentTypes.Loader.getConfig signature (#15065) * [knockout] Update KnockoutComponentTypes.Loader.getConfig signature Callback in method signature is missing a null type, so when trying to call the callback with null (which is a valid scenario), strict null check fails. * [knockout] Fix failing build of tests with TypeScript 2.0 * [knockout] Fix failing build of tests with TypeScript 2.0 * [knockout] Fix failing build of tests with TypeScript 2.0 * [knockout] Fix failing build of tests with TypeScript 2.0 --- knockout/index.d.ts | 2 +- knockout/test/templatingBehaviors.ts | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/knockout/index.d.ts b/knockout/index.d.ts index a28d06a220..570d0ee830 100644 --- a/knockout/index.d.ts +++ b/knockout/index.d.ts @@ -658,7 +658,7 @@ declare namespace KnockoutComponentTypes { } interface Loader { - getConfig? (componentName: string, callback: (result: ComponentConfig) => void): void; + getConfig? (componentName: string, callback: (result: ComponentConfig | null) => void): void; loadComponent? (componentName: string, config: ComponentConfig, callback: (result: Definition) => void): void; loadTemplate? (componentName: string, templateConfig: any, callback: (result: Node[]) => void): void; loadViewModel? (componentName: string, viewModelConfig: any, callback: (result: any) => void): void; diff --git a/knockout/test/templatingBehaviors.ts b/knockout/test/templatingBehaviors.ts index 7052b716f5..b69cb080f8 100644 --- a/knockout/test/templatingBehaviors.ts +++ b/knockout/test/templatingBehaviors.ts @@ -1,12 +1,31 @@ -/// /// +// Jasmine definitions +declare function describe(desc: string, f: () => void): void; +declare function it(desc: string, f: () => void): void; +declare function beforeEach(action: (done: DoneFn) => void, timeout?: number): void; +declare function expect(spy: Function): jasmine.Matchers; +declare function expect(actual: any): jasmine.Matchers; + +interface DoneFn extends Function { + (): void; + + /** fails the spec and indicates that it has completed. If the message is an Error, Error.message is used */ + fail: (message?: Error|string) => void; +} + declare namespace jasmine { interface Matchers { + toEqual(expected: any, expectationFailOutput?: any): boolean; + toBeDefined(expectationFailOutput?: any): boolean; + toBeNull(expectationFailOutput?: any): boolean; toContainHtml(expected: string): boolean; toContainText(expected: string): boolean; + not: Matchers; } } +//End Jasmine definitions + var dummyTemplateEngine = function (templates?) { var inMemoryTemplates = templates || {};