Skip to content

Commit

Permalink
refactor(*): fix type declation with this in typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
伍程凯 committed Jul 26, 2018
1 parent e8c2cea commit e15113e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
* cachedFunctionWithParam('figure', str => str.small())
* // => '<big>figure</big>'
*/
export default function cache (fn: (str: any) => any) {
export default function cache (fn: (str: any) => any): (str: any) => any {
const cache: { [propName: string]: any } = {}
return function cachedFn () {
return function cachedFn (this: any) {
const str = arguments[0]
const hit = cache[str]
return cache.hasOwnProperty(str) ? hit : (cache[str] = fn.apply(this, arguments))
Expand Down
2 changes: 1 addition & 1 deletion src/debounce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function debounce (
): (...args: any[]) => void {
let timer: any = null

return function (...args) {
return function (this: any, ...args) {
const later = () => {
timer = null
func.call(this, ...args)
Expand Down

0 comments on commit e15113e

Please sign in to comment.