mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
Discard context type checking
This commit is contained in:
Vendored
+3
-3
@@ -14,8 +14,8 @@ declare namespace unistUtilIs {
|
||||
* @param index Position of node in parent
|
||||
* @param parent Parent of node
|
||||
*/
|
||||
type TestFunction<C = {}> = (this: C, node: unknown, index?: number, parent?: Unist.Parent) => boolean | void;
|
||||
type Test<C = {}> = TestFunction<C> | Partial<Unist.Node> | string | null;
|
||||
type TestFunction = (node: unknown, index?: number, parent?: Unist.Parent) => boolean | void;
|
||||
type Test = TestFunction | Partial<Unist.Node> | string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,6 +31,6 @@ declare namespace unistUtilIs {
|
||||
* @param context Context object to invoke `test` with
|
||||
* @returns Whether test passed and `node` is a `Node` (object with `type` set to non-empty `string`).
|
||||
*/
|
||||
declare function unistUtilIs<C = {}>(test: unistUtilIs.Test<C> | Array<unistUtilIs.Test<C>>, node: unknown, index?: number, parent?: Unist.Parent, context?: any): boolean;
|
||||
declare function unistUtilIs(test: unistUtilIs.Test | unistUtilIs.Test[], node: unknown, index?: number, parent?: Unist.Parent, context?: any): boolean;
|
||||
|
||||
export = unistUtilIs;
|
||||
|
||||
@@ -20,15 +20,7 @@ is(test, node);
|
||||
is(test, node, 4, parent);
|
||||
is(test, node, 5, parent);
|
||||
|
||||
interface TestContext {
|
||||
some: string;
|
||||
}
|
||||
function testWithContext(this: TestContext, node: unknown) {}
|
||||
is<TestContext>(testWithContext, node);
|
||||
function testFunc(node: unknown) {}
|
||||
is(testFunc, node);
|
||||
|
||||
const wrongTestFunc: is.TestFunction = (node: unknown, n: string) => {}; // $ExpectError
|
||||
|
||||
interface OtherTestContext {
|
||||
some: number;
|
||||
}
|
||||
is<OtherTestContext>(testWithContext, node); // $ExpectError
|
||||
|
||||
Reference in New Issue
Block a user