Skip to content

Commit 9fb19ff

Browse files
committed
refactor: fixup TS types
1 parent 5b5dc5c commit 9fb19ff

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

decorators.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {debounce as db, throttle as th, ThrottleOptions} from './index'
22

3-
export function throttle(wait = 0, opts: ThrottleOptions = {}) {
4-
return (proto: unknown, name: string, descriptor: PropertyDescriptor) => {
3+
export function throttle(wait = 0, opts: ThrottleOptions = {}): MethodDecorator {
4+
return (proto: unknown, name: string | symbol, descriptor: PropertyDescriptor) => {
55
if (!descriptor || typeof descriptor.value !== 'function') {
66
throw new Error('debounce can only decorate functions')
77
}
@@ -11,8 +11,8 @@ export function throttle(wait = 0, opts: ThrottleOptions = {}) {
1111
}
1212
}
1313

14-
export function debounce(wait = 0, opts: ThrottleOptions = {}) {
15-
return (proto: unknown, name: string, descriptor: PropertyDescriptor) => {
14+
export function debounce(wait = 0, opts: ThrottleOptions = {}): MethodDecorator {
15+
return (proto: unknown, name: string | symbol, descriptor: PropertyDescriptor) => {
1616
if (!descriptor || typeof descriptor.value !== 'function') {
1717
throw new Error('debounce can only decorate functions')
1818
}

test/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('throttle', () => {
7272
})
7373

7474
it('exposes `this`', async () => {
75-
fn = throttle(function (this: object) {
75+
fn = throttle(function (this: unknown) {
7676
calls.push(this)
7777
}, 100)
7878
const receiver = {}
@@ -132,7 +132,7 @@ describe('debounce (throttle with {start: false, middle: false})', () => {
132132
})
133133

134134
it('exposes `this`', async () => {
135-
fn = debounce(function (this: object) {
135+
fn = debounce(function (this: unknown) {
136136
calls.push(this)
137137
}, 100)
138138
const receiver = {}

0 commit comments

Comments
 (0)