-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathindex.test-d.ts
34 lines (28 loc) · 908 Bytes
/
index.test-d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import {expectType} from 'tsd';
import {Component as ReactComponent} from 'react';
import autoBindReact from './react.js';
import autoBind from './index.js';
const foo = {
bar: 'bar',
method(_foo: string) {
return this.bar;
},
};
expectType<typeof foo>(autoBind(foo));
expectType<typeof foo>(autoBind(foo, {include: ['foo', /bar/]}));
expectType<typeof foo>(autoBind(foo, {exclude: ['foo', /bar/]}));
// eslint-disable-next-line @typescript-eslint/no-extraneous-class, @typescript-eslint/no-unused-vars
class Foo {
constructor() {
autoBind(this);
}
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
class Bar extends ReactComponent {
constructor(props: Record<string, unknown>) {
super(props);
expectType<this>(autoBindReact(this));
expectType<this>(autoBindReact(this, {include: ['foo', /bar/]}));
expectType<this>(autoBindReact(this, {exclude: ['foo', /bar/]}));
}
}