Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion types/bardjs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ declare namespace bard {
/**
* Assert a failure in mocha, without condition
*/
function assertFail(message: string): Chai.AssertionError;
function assertFail(message: string): Chai.AssertionError<never>;

/**
* Prepare ngMocked module definition that makes real $http and $q calls
Expand Down
10 changes: 9 additions & 1 deletion types/chai/chai-tests.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference types="node" />
import { assert, config, expect, Should, use, util } from "chai";
import { assert, AssertionError, config, expect, Should, use, util } from "chai";

const should = Should();

Expand Down Expand Up @@ -2242,3 +2242,11 @@ function configuringDeepEqual() {
});
};
}

function assertionErrorChecks() {
// @ts-expect-error Missing message
new AssertionError();
new AssertionError("foo");
new AssertionError("foo", {});
new AssertionError("foo", {}, () => {});
}
88 changes: 42 additions & 46 deletions types/chai/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
import deepEqual = require("deep-eql");
import { AssertionError as ImportedAssertionError } from "assertion-error";

declare global {
namespace Chai {
type Message = string | (() => string);
type ObjectProperty = string | symbol | number;
export type Message = string | (() => string);
export type ObjectProperty = string | symbol | number;

interface PathInfo {
export interface PathInfo {
parent: object;
name: string;
value?: any;
exists: boolean;
}

interface Constructor<T> {
export interface Constructor<T> {
new(...args: any[]): T;
}

interface ErrorConstructor {
export interface ErrorConstructor {
new(...args: any[]): Error;
}

interface ChaiUtils {
export interface ChaiUtils {
addChainableMethod(
// object to define the method on, e.g. chai.Assertion.prototype
ctx: object,
Expand Down Expand Up @@ -76,9 +77,9 @@ declare global {
eql: typeof deepEqual;
}

type ChaiPlugin = (chai: ChaiStatic, utils: ChaiUtils) => void;
export type ChaiPlugin = (chai: ChaiStatic, utils: ChaiUtils) => void;

interface ChaiStatic {
export interface ChaiStatic {
expect: ExpectStatic;
should(): Should;
/**
Expand All @@ -103,7 +104,7 @@ declare global {
}

// chai.Assertion.prototype.assert arguments
type AssertionArgs = [
export type AssertionArgs = [
any, // expression to be tested
Message, // message or function that returns message to display if expression fails
Message, // negatedMessage or function that returns negatedMessage to display if expression fails
Expand Down Expand Up @@ -147,25 +148,25 @@ declare global {

export type OperatorComparable = boolean | null | number | string | undefined | Date;

interface ShouldAssertion {
export interface ShouldAssertion {
equal(value1: any, value2: any, message?: string): void;
Throw: ShouldThrow;
throw: ShouldThrow;
exist(value: any, message?: string): void;
}

interface Should extends ShouldAssertion {
export interface Should extends ShouldAssertion {
not: ShouldAssertion;
fail(message?: string): never;
fail(actual: any, expected: any, message?: string, operator?: Operator): never;
}

interface ShouldThrow {
export interface ShouldThrow {
(actual: Function, expected?: string | RegExp, message?: string): void;
(actual: Function, constructor: Error | Function, expected?: string | RegExp, message?: string): void;
}

interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
export interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
not: Assertion;
deep: Deep;
ordered: Ordered;
Expand Down Expand Up @@ -231,7 +232,7 @@ declare global {
oneOf: OneOf;
}

interface LanguageChains {
export interface LanguageChains {
to: Assertion;
be: Assertion;
been: Assertion;
Expand All @@ -249,7 +250,7 @@ declare global {
does: Assertion;
}

interface NumericComparison {
export interface NumericComparison {
above: NumberComparer;
gt: NumberComparer;
greaterThan: NumberComparer;
Expand All @@ -266,25 +267,25 @@ declare global {
within(start: Date, finish: Date, message?: string): Assertion;
}

interface NumberComparer {
export interface NumberComparer {
(value: number | Date, message?: string): Assertion;
}

interface TypeComparison {
export interface TypeComparison {
(type: string, message?: string): Assertion;
instanceof: InstanceOf;
instanceOf: InstanceOf;
}

interface InstanceOf {
export interface InstanceOf {
(constructor: any, message?: string): Assertion;
}

interface CloseTo {
export interface CloseTo {
(expected: number, delta: number, message?: string): Assertion;
}

interface Nested {
export interface Nested {
include: Include;
includes: Include;
contain: Include;
Expand All @@ -293,15 +294,15 @@ declare global {
members: Members;
}

interface Own {
export interface Own {
include: Include;
includes: Include;
contain: Include;
contains: Include;
property: Property;
}

interface Deep extends KeyFilter {
export interface Deep extends KeyFilter {
be: Assertion;
equal: Equal;
equals: Equal;
Expand All @@ -317,38 +318,38 @@ declare global {
own: Own;
}

interface Ordered {
export interface Ordered {
members: Members;
}

interface KeyFilter {
export interface KeyFilter {
keys: Keys;
members: Members;
}

interface Equal {
export interface Equal {
(value: any, message?: string): Assertion;
}

interface ContainSubset {
export interface ContainSubset {
(expected: any): Assertion;
}

interface Property {
export interface Property {
(name: string | symbol, value: any, message?: string): Assertion;
(name: string | symbol, message?: string): Assertion;
}

interface OwnPropertyDescriptor {
export interface OwnPropertyDescriptor {
(name: string | symbol, descriptor: PropertyDescriptor, message?: string): Assertion;
(name: string | symbol, message?: string): Assertion;
}

interface Length extends LanguageChains, NumericComparison {
export interface Length extends LanguageChains, NumericComparison {
(length: number, message?: string): Assertion;
}

interface Include {
export interface Include {
(value: any, message?: string): Assertion;
keys: Keys;
deep: Deep;
Expand All @@ -359,41 +360,41 @@ declare global {
oneOf: OneOf;
}

interface OneOf {
export interface OneOf {
(list: readonly unknown[], message?: string): Assertion;
}

interface Match {
export interface Match {
(regexp: RegExp, message?: string): Assertion;
}

interface Keys {
export interface Keys {
(...keys: string[]): Assertion;
(keys: readonly any[] | Object): Assertion;
}

interface Throw {
export interface Throw {
(expected?: string | RegExp, message?: string): Assertion;
(constructor: Error | Function, expected?: string | RegExp, message?: string): Assertion;
}

interface RespondTo {
export interface RespondTo {
(method: string, message?: string): Assertion;
}

interface Satisfy {
export interface Satisfy {
(matcher: Function, message?: string): Assertion;
}

interface Members {
export interface Members {
(set: readonly any[], message?: string): Assertion;
}

interface PropertyChange {
export interface PropertyChange {
(object: Object, property?: string, message?: string): DeltaAssertion;
}

interface DeltaAssertion extends Assertion {
export interface DeltaAssertion extends Assertion {
by(delta: number, msg?: string): Assertion;
}

Expand Down Expand Up @@ -2128,13 +2129,7 @@ declare global {
deepEqual: <L, R>(expected: L, actual: R) => void;
}

export class AssertionError {
constructor(message: string, _props?: any, ssf?: Function);
name: string;
message: string;
showDiff: boolean;
stack: string;
}
export type { ImportedAssertionError as AssertionError };
}
}

Expand All @@ -2143,6 +2138,7 @@ export function use(fn: Chai.ChaiPlugin): Chai.ChaiStatic;
export const util: Chai.ChaiUtils;
export const config: Chai.Config;
export const Assertion: Chai.AssertionStatic;
export const AssertionError: typeof ImportedAssertionError;
export function should(): Chai.Should;
export function Should(): Chai.Should;
export const assert: Chai.AssertStatic;
Expand Down
3 changes: 2 additions & 1 deletion types/chai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"http://chaijs.com/"
],
"dependencies": {
"@types/deep-eql": "*"
"@types/deep-eql": "*",
"assertion-error": "^2.0.1"
},
"devDependencies": {
"@types/chai": "workspace:.",
Expand Down
16 changes: 8 additions & 8 deletions types/diffie-hellman/diffie-hellman-tests.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import * as dh from "diffie-hellman";

const dh1 = dh.getDiffieHellman("modp1");
// $ExpectType DiffieHellmanGroup || Pick<DiffieHellman, "generateKeys" | "computeSecret" | "getPrime" | "getGenerator" | "getPublicKey" | "getPrivateKey" | "verifyError">
// $ExpectType DiffieHellmanGroup
dh1;
// $ExpectType Buffer || Buffer<ArrayBufferLike>
// $ExpectType Buffer || NonSharedBuffer
dh1.generateKeys();
// $ExpectType string
dh1.generateKeys("hex");
// $ExpectType Buffer || Buffer<ArrayBufferLike>
// $ExpectType Buffer || NonSharedBuffer
dh1.getPrime();
// $ExpectType string
dh1.getPrime("hex");
// $ExpectType Buffer || Buffer<ArrayBufferLike>
// $ExpectType Buffer || NonSharedBuffer
dh1.getGenerator();
// $ExpectType string
dh1.getGenerator("hex");
const pk = dh1.getPublicKey();
// $ExpectType Buffer || Buffer<ArrayBufferLike>
// $ExpectType Buffer || NonSharedBuffer
pk;
// $ExpectType string
dh1.getPublicKey("hex");
// $ExpectType Buffer || Buffer<ArrayBufferLike>
// $ExpectType Buffer || NonSharedBuffer
dh1.getPrivateKey();
// $ExpectType string
dh1.getPrivateKey("hex");
// $ExpectType Buffer || Buffer<ArrayBufferLike>
// $ExpectType Buffer || NonSharedBuffer
dh1.computeSecret(pk);
// $ExpectType Buffer || Buffer<ArrayBufferLike>
// $ExpectType Buffer || NonSharedBuffer
dh1.computeSecret(pk.toString("hex"), "hex");
// $ExpectType string
dh1.computeSecret(pk.toString("hex"), "hex", "hex");
Expand Down
4 changes: 4 additions & 0 deletions types/expect-cookies/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
{
"name": "Dolan Murvihill",
"githubUsername": "dmurvihill"
},
{
"name": "Gregory Langlais",
"githubUsername": "gregl83"
}
]
}
Loading