Skip to content

Commit 151da14

Browse files
committed
Fix tslint errors
1 parent 0274483 commit 151da14

File tree

1 file changed

+32
-12
lines changed

1 file changed

+32
-12
lines changed

src/index.ts

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,32 @@ export const Reflection = Object.assign(Reflect, {
88
});
99

1010
export type Decorator = ClassDecorator | MemberDecorator;
11-
export type MemberDecorator = <T>(target: Target, propertyKey: PropertyKey, descriptor?: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
11+
export type MemberDecorator = <T>(target: Target,
12+
propertyKey: PropertyKey,
13+
descriptor?: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
1214
export type MetadataKey = string;
1315
export type MetadataValue = Function;
1416
export type PropertyKey = string | symbol;
1517
export type Target = object | Function;
1618

1719
const Metadata = new WeakMap();
1820

19-
export function defineMetadata(metadataKey: MetadataKey, metadataValue: MetadataValue, target: Target, propertyKey?: PropertyKey) {
21+
export function defineMetadata(metadataKey: MetadataKey,
22+
metadataValue: MetadataValue,
23+
target: Target, propertyKey?: PropertyKey) {
2024
return ordinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
2125
}
2226

23-
export function decorate(decorators: ClassDecorator[], target: Function): Function
24-
export function decorate(decorators: MemberDecorator[], target: object, propertyKey?: PropertyKey, attributes?: PropertyDescriptor): PropertyDescriptor | undefined
25-
export function decorate(decorators: Decorator[], target: Target, propertyKey?: PropertyKey, attributes?: PropertyDescriptor): Function | PropertyDescriptor | undefined {
26-
if (decorators.length === 0) throw new TypeError();
27+
export function decorate(decorators: ClassDecorator[], target: Function): Function;
28+
export function decorate(decorators: MemberDecorator[],
29+
target: object,
30+
propertyKey?: PropertyKey,
31+
attributes?: PropertyDescriptor): PropertyDescriptor | undefined;
32+
export function decorate(decorators: Decorator[],
33+
target: Target,
34+
propertyKey?: PropertyKey,
35+
attributes?: PropertyDescriptor): Function | PropertyDescriptor | undefined {
36+
if (decorators.length === 0) { throw new TypeError(); }
2737

2838
if (typeof target === 'function') {
2939
return decorateConstructor(decorators as ClassDecorator[], target);
@@ -61,30 +71,40 @@ function decorateConstructor(decorators: ClassDecorator[], target: Function): Fu
6171
return target;
6272
}
6373

64-
function decorateProperty(decorators: MemberDecorator[], target: Target, propertyKey: PropertyKey, descriptor?: PropertyDescriptor): PropertyDescriptor | undefined {
74+
function decorateProperty(decorators: MemberDecorator[],
75+
target: Target,
76+
propertyKey: PropertyKey,
77+
descriptor?: PropertyDescriptor): PropertyDescriptor | undefined {
6578
decorators.reverse().forEach((decorator: MemberDecorator) => {
6679
descriptor = decorator(target, propertyKey, descriptor) || descriptor;
6780
});
6881
return descriptor;
6982
}
7083

71-
function ordinaryDefineOwnMetadata(metadataKey: MetadataKey, metadataValue: MetadataValue, target: Target, propertyKey?: PropertyKey): void {
72-
if (propertyKey && !['string', 'symbol'].includes(typeof propertyKey)) throw new TypeError();
84+
function ordinaryDefineOwnMetadata(metadataKey: MetadataKey,
85+
metadataValue: MetadataValue,
86+
target: Target,
87+
propertyKey?: PropertyKey): void {
88+
if (propertyKey && !['string', 'symbol'].includes(typeof propertyKey)) { throw new TypeError(); }
7389

7490
(getMetadataMap(target, propertyKey) || createMetadataMap(target, propertyKey))
7591
.set(metadataKey, metadataValue);
7692
}
7793

78-
function ordinaryGetMetadata(metadataKey: MetadataKey, target: Target, propertyKey?: PropertyKey): Function | undefined {
94+
function ordinaryGetMetadata(metadataKey: MetadataKey,
95+
target: Target,
96+
propertyKey?: PropertyKey): Function | undefined {
7997
return !!ordinaryGetOwnMetadata(metadataKey, target, propertyKey)
8098
? ordinaryGetOwnMetadata(metadataKey, target, propertyKey)
8199
: Object.getPrototypeOf(target)
82100
? ordinaryGetMetadata(metadataKey, Object.getPrototypeOf(target), propertyKey)
83101
: undefined;
84102
}
85103

86-
function ordinaryGetOwnMetadata(metadataKey: MetadataKey, target: Target, propertyKey?: PropertyKey): Function | undefined {
87-
if (target === undefined) throw new TypeError();
104+
function ordinaryGetOwnMetadata(metadataKey: MetadataKey,
105+
target: Target,
106+
propertyKey?: PropertyKey): Function | undefined {
107+
if (target === undefined) { throw new TypeError(); }
88108
const metadataMap = getMetadataMap(target, propertyKey);
89109
return metadataMap && metadataMap.get(metadataKey);
90110
}

0 commit comments

Comments
 (0)