mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-17 07:20:23 +00:00
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
export = autoBind;
|
||||
|
||||
declare function autoBind(
|
||||
obj: { [key: string]: PropertyDescriptor },
|
||||
options?: autoBind.Options
|
||||
): PropertyDescriptorMap;
|
||||
|
||||
declare namespace autoBind {
|
||||
interface Options {
|
||||
overwriteDefinition?: boolean;
|
||||
resolveContext?: (context: any) => any;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import d = require('d');
|
||||
import autoBind = require('d/auto-bind');
|
||||
import lazy = require('d/lazy');
|
||||
|
||||
class Account {}
|
||||
Object.defineProperties(Account.prototype, {
|
||||
deposit: d(() => {}),
|
||||
withdraw: d(() => {}),
|
||||
balance: d.gs(() => {}),
|
||||
});
|
||||
|
||||
d('foo'); // $ExpectType PropertyDescriptor
|
||||
d('foo', { enumerable: true }); // $ExpectType PropertyDescriptor
|
||||
d('c', 'foo'); // $ExpectType PropertyDescriptor
|
||||
d('c', 'foo', { enumerable: true }); // $ExpectType PropertyDescriptor
|
||||
|
||||
d('c', 'foo'); // $ExpectType PropertyDescriptor
|
||||
d('e', 'foo'); // $ExpectType PropertyDescriptor
|
||||
d('w', 'foo'); // $ExpectType PropertyDescriptor
|
||||
d('ce', 'foo'); // $ExpectType PropertyDescriptor
|
||||
d('cw', 'foo'); // $ExpectType PropertyDescriptor
|
||||
d('ew', 'foo'); // $ExpectType PropertyDescriptor
|
||||
d('cew', 'foo'); // $ExpectType PropertyDescriptor
|
||||
d('foo', 'foo'); // $ExpectError
|
||||
|
||||
d.gs('c', { enumerable: true }); // $ExpectType PropertyDescriptor
|
||||
d.gs('c', () => ({}), { enumerable: true }); // $ExpectType PropertyDescriptor
|
||||
d.gs(() => ({})); // $ExpectType PropertyDescriptor
|
||||
d.gs(null, () => ({})); // $ExpectType PropertyDescriptor
|
||||
d.gs(undefined, () => ({})); // $ExpectType PropertyDescriptor
|
||||
d.gs('c', () => ({})); // $ExpectType PropertyDescriptor
|
||||
d.gs('c', null, () => ({})); // $ExpectType PropertyDescriptor
|
||||
d.gs('c', undefined, () => ({})); // $ExpectType PropertyDescriptor
|
||||
d.gs('c', null, () => ({}), { enumerable: true }); // $ExpectType PropertyDescriptor
|
||||
d.gs('c', undefined, () => ({}), { enumerable: true }); // $ExpectType PropertyDescriptor
|
||||
|
||||
d.gs('c', () => ({})); // $ExpectType PropertyDescriptor
|
||||
d.gs('e', () => ({})); // $ExpectType PropertyDescriptor
|
||||
d.gs('ce', () => ({})); // $ExpectType PropertyDescriptor
|
||||
d.gs('cew', () => ({})); // $ExpectError
|
||||
|
||||
class Foo {
|
||||
_count: number;
|
||||
}
|
||||
|
||||
Object.defineProperties(
|
||||
Foo.prototype,
|
||||
autoBind({
|
||||
increment: d(function(this: any) {
|
||||
++this._count;
|
||||
}),
|
||||
})
|
||||
);
|
||||
autoBind(
|
||||
{
|
||||
increment: d(function(this: any) {
|
||||
++this._count;
|
||||
}),
|
||||
},
|
||||
{ overwriteDefinition: true }
|
||||
);
|
||||
autoBind(
|
||||
{
|
||||
increment: d(function(this: any) {
|
||||
++this._count;
|
||||
}),
|
||||
},
|
||||
{
|
||||
resolveContext(ctx: any) {
|
||||
return ctx;
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
Object.defineProperties(
|
||||
Foo.prototype,
|
||||
lazy({
|
||||
items: d(() => {
|
||||
return [];
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
const foo = new Foo();
|
||||
(foo as any).items.push(1, 2); // foo.items array created and defined directly on foo
|
||||
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
// Type definitions for d 1.0
|
||||
// Project: https://github.com/medikoo/d#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
export = d;
|
||||
|
||||
declare function d(value: any, options?: PropertyDescriptor): PropertyDescriptor;
|
||||
declare function d(flags: d.Flags, value: any, options?: PropertyDescriptor): PropertyDescriptor;
|
||||
|
||||
declare namespace d {
|
||||
function gs(flags: GetSetFlags, options: PropertyDescriptor): PropertyDescriptor;
|
||||
function gs(flags: GetSetFlags, get: (...args: any[]) => any, options: PropertyDescriptor): PropertyDescriptor;
|
||||
function gs(
|
||||
get: (...args: any[]) => any,
|
||||
set?: ((...args: any[]) => any) | null,
|
||||
options?: PropertyDescriptor
|
||||
): PropertyDescriptor;
|
||||
function gs(
|
||||
get: ((...args: any[]) => any) | null | undefined,
|
||||
set: (...args: any[]) => any,
|
||||
options?: PropertyDescriptor
|
||||
): PropertyDescriptor;
|
||||
function gs(
|
||||
flags: GetSetFlags,
|
||||
get: (...args: any[]) => any,
|
||||
set?: ((...args: any[]) => any) | null,
|
||||
options?: PropertyDescriptor
|
||||
): PropertyDescriptor;
|
||||
function gs(
|
||||
flags: GetSetFlags,
|
||||
get: ((...args: any[]) => any) | null | undefined,
|
||||
set: (...args: any[]) => any,
|
||||
options?: PropertyDescriptor
|
||||
): PropertyDescriptor;
|
||||
|
||||
type GetSetFlags = 'c' | 'e' | 'ce';
|
||||
type Flags = GetSetFlags | 'w' | 'cw' | 'ew' | 'cew';
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
export = lazy;
|
||||
|
||||
declare function lazy(obj: { [key: string]: PropertyDescriptor }): PropertyDescriptorMap;
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"auto-bind.d.ts",
|
||||
"lazy.d.ts",
|
||||
"d-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user