[@types/deep-freeze] - allow functions to be called with out error (#37096)

* allow functions to be called

* lint

* fix ups
This commit is contained in:
Joel Brenstrum 2019-08-06 04:59:40 +12:00 committed by Nathan Shively-Sanders
parent 53b0020a89
commit 07b144b70a
2 changed files with 8 additions and 4 deletions

View File

@ -5,3 +5,6 @@ class Foo {
}
const foo = df(new Foo());
const items = df([{id: 0, name: 'first'}]);
const functionTest = df({id: 0, name: 'first', update: (blah: boolean) => blah});
functionTest.update(true);

View File

@ -2,7 +2,7 @@
// Project: https://github.com/substack/deep-freeze
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Aluan Haddad <https://github.com/aluanhaddad>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
// TypeScript Version: 3.1
export = deepFreeze;
@ -11,7 +11,8 @@ declare function deepFreeze<T extends Function>(f: T): T;
declare function deepFreeze<T>(o: T): deepFreeze.DeepReadonly<T>;
declare namespace deepFreeze {
type DeepReadonly<T> = {
readonly [P in keyof T]: DeepReadonly<T[P]>
};
type DeepReadonly<T> =
T extends (...args: any) => any
? T
: { readonly [P in keyof T]: DeepReadonly<T[P]> };
}