Skip to content

Commit

Permalink
fix: make the code compatible with TypeScript 2.9.x
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondfeng committed May 31, 2018
1 parent 7d8345c commit 37aba50
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 65 deletions.
4 changes: 2 additions & 2 deletions packages/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
"glob": "^7.1.2",
"mocha": "^5.1.1",
"nyc": "^11.7.1",
"prettier": "^1.12.1",
"prettier": "^1.13.3",
"rimraf": "^2.6.2",
"source-map-support": "^0.5.5",
"strong-docs": "^3.0.1",
"tslint": "^5.9.1",
"typescript": "^2.8.1"
"typescript": "^2.9.1"
},
"bin": {
"lb-tsc": "./bin/compile-package.js",
Expand Down
6 changes: 3 additions & 3 deletions packages/context/src/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export interface InjectionMetadata {
*/
export interface Injection<ValueType = BoundValue> {
target: Object;
member?: string | symbol;
member?: string;
methodDescriptorOrParameterIndex?:
| TypedPropertyDescriptor<ValueType>
| number;
Expand Down Expand Up @@ -102,7 +102,7 @@ export function inject(
metadata = Object.assign({decorator: '@inject'}, metadata);
return function markParameterOrPropertyAsInjected(
target: Object,
member: string | symbol,
member: string,
methodDescriptorOrParameterIndex?:
| TypedPropertyDescriptor<BoundValue>
| number,
Expand Down Expand Up @@ -296,7 +296,7 @@ function resolveAsSetter(ctx: Context, injection: Injection) {
*/
export function describeInjectedArguments(
target: Object,
method?: string | symbol,
method?: string,
): Readonly<Injection>[] {
method = method || '';
const meta = MetadataInspector.getAllParameterMetadata<Readonly<Injection>>(
Expand Down
4 changes: 2 additions & 2 deletions packages/metadata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ method parameters. Please note `M` is a map for methods/properties/parameters.
protected mergeWithInherited(
inheritedMetadata: M,
target: Object,
member?: string | symbol,
member?: string,
descriptorOrIndex?: TypedPropertyDescriptor<any> | number,
): M {
// ...
Expand All @@ -304,7 +304,7 @@ protected mergeWithInherited(
protected mergeWithOwn(
ownMetadata: M,
target: Object,
member?: string | symbol,
member?: string,
descriptorOrIndex?: TypedPropertyDescriptor<any> | number,
): M {
// ...
Expand Down
47 changes: 22 additions & 25 deletions packages/metadata/src/decorator-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class DecoratorFactory<
*/
static getTargetName(
target: Object,
member?: string | symbol,
member?: string,
descriptorOrIndex?: TypedPropertyDescriptor<any> | number,
) {
let name =
Expand All @@ -151,7 +151,7 @@ export class DecoratorFactory<
* @param target Class or the prototype
* @param member Method name
*/
static getNumberOfParameters(target: Object, member?: string | symbol) {
static getNumberOfParameters(target: Object, member?: string) {
if (target instanceof Function && !member) {
// constructor
return target.length;
Expand Down Expand Up @@ -210,7 +210,7 @@ export class DecoratorFactory<
protected mergeWithInherited(
inheritedMetadata: M,
target: Object,
member?: string | symbol,
member?: string,
descriptorOrIndex?: TypedPropertyDescriptor<any> | number,
): M {
throw new Error('mergeWithInherited() is not implemented');
Expand All @@ -232,7 +232,7 @@ export class DecoratorFactory<
protected mergeWithOwn(
ownMetadata: M,
target: Object,
member?: string | symbol,
member?: string,
descriptorOrIndex?: TypedPropertyDescriptor<any> | number,
): M {
throw new Error('mergeWithOwn() is not implemented');
Expand All @@ -254,7 +254,7 @@ export class DecoratorFactory<
*/
protected decorate(
target: Object,
member?: string | symbol,
member?: string,
descriptorOrIndex?: TypedPropertyDescriptor<any> | number,
) {
const targetName = DecoratorFactory.getTargetName(
Expand Down Expand Up @@ -349,7 +349,7 @@ export class ClassDecoratorFactory<T> extends DecoratorFactory<
protected mergeWithInherited(
inheritedMetadata: T,
target: Object,
member?: string | symbol,
member?: string,
descriptorOrIndex?: TypedPropertyDescriptor<any> | number,
) {
return this.withTarget(<T>this.inherit(inheritedMetadata), target);
Expand All @@ -358,7 +358,7 @@ export class ClassDecoratorFactory<T> extends DecoratorFactory<
protected mergeWithOwn(
ownMetadata: T,
target: Object,
member?: string | symbol,
member?: string,
descriptorOrIndex?: TypedPropertyDescriptor<any> | number,
) {
if (ownMetadata != null) {
Expand Down Expand Up @@ -400,7 +400,7 @@ export class PropertyDecoratorFactory<T> extends DecoratorFactory<
protected mergeWithInherited(
inheritedMetadata: MetadataMap<T>,
target: Object,
propertyName?: string | symbol,
propertyName?: string,
descriptorOrIndex?: TypedPropertyDescriptor<any> | number,
) {
inheritedMetadata = inheritedMetadata || {};
Expand All @@ -415,7 +415,7 @@ export class PropertyDecoratorFactory<T> extends DecoratorFactory<
protected mergeWithOwn(
ownMetadata: MetadataMap<T>,
target: Object,
propertyName?: string | symbol,
propertyName?: string,
descriptorOrParameterIndex?: TypedPropertyDescriptor<any> | number,
) {
ownMetadata = ownMetadata || {};
Expand All @@ -430,7 +430,7 @@ export class PropertyDecoratorFactory<T> extends DecoratorFactory<
}

create(): PropertyDecorator {
return (target: Object, propertyName: string | symbol) =>
return (target: Object, propertyName: string) =>
this.decorate(target, propertyName);
}

Expand Down Expand Up @@ -464,7 +464,7 @@ export class MethodDecoratorFactory<T> extends DecoratorFactory<
protected mergeWithInherited(
inheritedMetadata: MetadataMap<T>,
target: Object,
methodName?: string | symbol,
methodName?: string,
methodDescriptor?: TypedPropertyDescriptor<any> | number,
) {
inheritedMetadata = inheritedMetadata || {};
Expand All @@ -479,7 +479,7 @@ export class MethodDecoratorFactory<T> extends DecoratorFactory<
protected mergeWithOwn(
ownMetadata: MetadataMap<T>,
target: Object,
methodName?: string | symbol,
methodName?: string,
methodDescriptor?: TypedPropertyDescriptor<any> | number,
) {
ownMetadata = ownMetadata || {};
Expand All @@ -498,7 +498,7 @@ export class MethodDecoratorFactory<T> extends DecoratorFactory<
create(): MethodDecorator {
return (
target: Object,
methodName: string | symbol,
methodName: string,
descriptor: TypedPropertyDescriptor<any>,
) => this.decorate(target, methodName, descriptor);
}
Expand Down Expand Up @@ -533,7 +533,7 @@ export class ParameterDecoratorFactory<T> extends DecoratorFactory<
private getOrInitMetadata(
meta: MetadataMap<T[]>,
target: Object,
methodName?: string | symbol,
methodName?: string,
) {
const method = methodName ? methodName : '';
let methodMeta = meta[method];
Expand All @@ -550,7 +550,7 @@ export class ParameterDecoratorFactory<T> extends DecoratorFactory<
protected mergeWithInherited(
inheritedMetadata: MetadataMap<T[]>,
target: Object,
methodName?: string | symbol,
methodName?: string,
parameterIndex?: TypedPropertyDescriptor<any> | number,
) {
inheritedMetadata = inheritedMetadata || {};
Expand All @@ -570,7 +570,7 @@ export class ParameterDecoratorFactory<T> extends DecoratorFactory<
protected mergeWithOwn(
ownMetadata: MetadataMap<T[]>,
target: Object,
methodName?: string | symbol,
methodName?: string,
parameterIndex?: TypedPropertyDescriptor<any> | number,
) {
ownMetadata = ownMetadata || {};
Expand All @@ -592,11 +592,8 @@ export class ParameterDecoratorFactory<T> extends DecoratorFactory<
}

create(): ParameterDecorator {
return (
target: Object,
methodName: string | symbol,
parameterIndex: number,
) => this.decorate(target, methodName, parameterIndex);
return (target: Object, methodName: string, parameterIndex: number) =>
this.decorate(target, methodName, parameterIndex);
}

/**
Expand Down Expand Up @@ -642,7 +639,7 @@ export class MethodParameterDecoratorFactory<T> extends DecoratorFactory<
*/
private getParameterIndex(
target: Object,
methodName?: string | symbol,
methodName?: string,
methodDescriptor?: TypedPropertyDescriptor<any> | number,
) {
const numOfParams = DecoratorFactory.getNumberOfParameters(
Expand Down Expand Up @@ -674,7 +671,7 @@ export class MethodParameterDecoratorFactory<T> extends DecoratorFactory<
protected mergeWithInherited(
inheritedMetadata: MetadataMap<T[]>,
target: Object,
methodName?: string | symbol,
methodName?: string,
methodDescriptor?: TypedPropertyDescriptor<any> | number,
) {
inheritedMetadata = inheritedMetadata || {};
Expand Down Expand Up @@ -703,7 +700,7 @@ export class MethodParameterDecoratorFactory<T> extends DecoratorFactory<
protected mergeWithOwn(
ownMetadata: MetadataMap<T[]>,
target: Object,
methodName?: string | symbol,
methodName?: string,
methodDescriptor?: TypedPropertyDescriptor<any> | number,
) {
ownMetadata = ownMetadata || {};
Expand All @@ -726,7 +723,7 @@ export class MethodParameterDecoratorFactory<T> extends DecoratorFactory<
create(): MethodDecorator {
return (
target: Object,
methodName: string | symbol,
methodName: string,
descriptor: TypedPropertyDescriptor<any>,
) => this.decorate(target, methodName, descriptor);
}
Expand Down
14 changes: 7 additions & 7 deletions packages/metadata/src/inspector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class MetadataInspector {
key: MetadataKey<T, DecoratorType>,
value: T,
target: Object,
member?: string | symbol,
member?: string,
) {
Reflector.defineMetadata(key.toString(), value, target, member);
}
Expand Down Expand Up @@ -108,7 +108,7 @@ export class MetadataInspector {
static getMethodMetadata<T>(
key: MetadataKey<T, MethodDecorator>,
target: Object,
methodName?: string | symbol,
methodName?: string,
options?: InspectionOptions,
): T | undefined {
methodName = methodName || '';
Expand Down Expand Up @@ -148,7 +148,7 @@ export class MetadataInspector {
static getPropertyMetadata<T>(
key: MetadataKey<T, PropertyDecorator>,
target: Object,
propertyName: string | symbol,
propertyName: string,
options?: InspectionOptions,
): T | undefined {
const meta: MetadataMap<T> =
Expand All @@ -170,7 +170,7 @@ export class MetadataInspector {
static getAllParameterMetadata<T>(
key: MetadataKey<T, ParameterDecorator>,
target: Object,
methodName?: string | symbol,
methodName?: string,
options?: InspectionOptions,
): T[] | undefined {
methodName = methodName || '';
Expand All @@ -194,7 +194,7 @@ export class MetadataInspector {
static getParameterMetadata<T>(
key: MetadataKey<T, ParameterDecorator>,
target: Object,
methodName: string | symbol,
methodName: string,
index: number,
options?: InspectionOptions,
): T | undefined {
Expand All @@ -214,7 +214,7 @@ export class MetadataInspector {
*/
static getDesignTypeForProperty(
target: Object,
propertyName: string | symbol,
propertyName: string,
): Function {
return TSReflector.getMetadata('design:type', target, propertyName);
}
Expand All @@ -226,7 +226,7 @@ export class MetadataInspector {
*/
static getDesignTypeForMethod(
target: Object,
methodName: string | symbol,
methodName: string,
): DesignTimeMethodMetadata {
const type = TSReflector.getMetadata('design:type', target, methodName);
const parameterTypes = TSReflector.getMetadata(
Expand Down
Loading

0 comments on commit 37aba50

Please sign in to comment.