From c16e921dbc6474097b91b7e546432fa4e39a8c83 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 4 Dec 2017 11:00:57 -0800 Subject: [PATCH] chai: Use `export as namespace` instead of `declare module` --- types/chai/chai-tests.ts | 8 ++++---- types/chai/index.d.ts | 28 ++++++++++++++-------------- types/chai/tslint.json | 6 +----- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/types/chai/chai-tests.ts b/types/chai/chai-tests.ts index fba32ec840..f6133d22c3 100644 --- a/types/chai/chai-tests.ts +++ b/types/chai/chai-tests.ts @@ -432,8 +432,8 @@ function empty() { [].should.be.empty; expect(['foo']).not.to.be.empty; ['foo'].should.not.be.empty; - expect(new FakeArgs).to.be.empty; - (new FakeArgs).should.be.empty; + expect(new FakeArgs()).to.be.empty; + (new FakeArgs()).should.be.empty; expect({ arguments: 0 }).not.to.be.empty; ({ arguments: 0 }).should.not.be.empty; expect({}).to.be.empty; @@ -454,8 +454,8 @@ function empty() { expect(['foo']).to.be.empty; ['foo'].should.be.empty; - expect(new FakeArgs).not.to.be.empty; - (new FakeArgs).should.not.be.empty; + expect(new FakeArgs()).not.to.be.empty; + (new FakeArgs()).should.not.be.empty; expect({ arguments: 0 }).to.be.empty; ({ arguments: 0 }).should.be.empty; diff --git a/types/chai/index.d.ts b/types/chai/index.d.ts index 8c19f1f54a..999885f260 100644 --- a/types/chai/index.d.ts +++ b/types/chai/index.d.ts @@ -26,20 +26,20 @@ declare namespace Chai { version: string; } - export interface ExpectStatic extends AssertionStatic { + interface ExpectStatic extends AssertionStatic { fail(actual?: any, expected?: any, message?: string, operator?: Operator): void; } - export interface AssertStatic extends Assert { + interface AssertStatic extends Assert { } - export interface AssertionStatic { + interface AssertionStatic { (target: any, message?: string): Assertion; } - export type Operator = string; // "==" | "===" | ">" | ">=" | "<" | "<=" | "!=" | "!=="; + type Operator = string; // "==" | "===" | ">" | ">=" | "<" | "<=" | "!=" | "!=="; - export type OperatorComparable = boolean | null | number | string | undefined | Date; + type OperatorComparable = boolean | null | number | string | undefined | Date; interface ShouldAssertion { equal(value1: any, value2: any, message?: string): void; @@ -256,7 +256,7 @@ declare namespace Chai { (object: Object, property: string, message?: string): Assertion; } - export interface Assert { + interface Assert { /** * @param expression Expression to test for truthiness. * @param message Message to display on error. @@ -1587,7 +1587,7 @@ declare namespace Chai { doesNotHaveAllDeepKeys(object: T, keys: Array | { [key: string]: any }, message?: string): void; } - export interface Config { + interface Config { /** * Default: false */ @@ -1604,7 +1604,7 @@ declare namespace Chai { truncateThreshold: number; } - export class AssertionError { + class AssertionError { constructor(message: string, _props?: any, ssf?: Function); name: string; message: string; @@ -1614,11 +1614,11 @@ declare namespace Chai { } declare const chai: Chai.ChaiStatic; +export = chai; +export as namespace chai; -declare module "chai" { - export = chai; -} - -interface Object { - should: Chai.Assertion; +declare global { + interface Object { + should: Chai.Assertion; + } } diff --git a/types/chai/tslint.json b/types/chai/tslint.json index f99183c97d..1f19065e56 100644 --- a/types/chai/tslint.json +++ b/types/chai/tslint.json @@ -3,12 +3,8 @@ "rules": { "ban-types": false, "callable-types": false, - "new-parens": false, - "no-declare-current-package": false, "no-empty-interface": false, "no-redundant-jsdoc-2": false, - "no-single-declare-module": false, - "no-unnecessary-generics": false, - "strict-export-declare-modifiers": false + "no-unnecessary-generics": false } }