Discard context type checking

This commit is contained in:
Junyoung Choi
2018-12-11 13:48:40 +09:00
parent 8fbdf7311a
commit d3ba03f756
2 changed files with 5 additions and 13 deletions
+3 -3
View File
@@ -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;
+2 -10
View File
@@ -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