Skip to content

Commit d709cf3

Browse files
MaxGraeydcodeIO
authored andcommitted
Improve decorator declarations (AssemblyScript#426)
i.e. add a dummy `TypedPropertyDescriptor<T>`
1 parent 3b1852b commit d709cf3

File tree

1 file changed

+47
-9
lines changed

1 file changed

+47
-9
lines changed

std/assembly/index.d.ts

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -912,28 +912,66 @@ declare function trace(msg: string, n?: i32, a0?: f64, a1?: f64, a2?: f64, a3?:
912912

913913
// Decorators
914914

915+
interface TypedPropertyDescriptor<T> {
916+
configurable?: boolean;
917+
enumerable?: boolean;
918+
writable?: boolean;
919+
value?: T;
920+
get?(): T;
921+
set?(value: T): void;
922+
}
923+
915924
/** Annotates an element as a program global. */
916-
declare function global(target: Function, propertyKey: string, descriptor: any): void;
925+
declare function global(
926+
target: any,
927+
propertyKey: string,
928+
descriptor: TypedPropertyDescriptor<any>
929+
): TypedPropertyDescriptor<any> | void;
917930

918931
/** Annotates a method as a binary operator overload for the specified `token`. */
919-
declare function operator(token: string): (target: any, propertyKey: string, descriptor: any) => void;
932+
declare function operator(token: string): (
933+
target: any,
934+
propertyKey: string,
935+
descriptor: TypedPropertyDescriptor<Function>
936+
) => TypedPropertyDescriptor<Function> | void;
937+
920938
declare namespace operator {
921939
/** Annotates a method as a binary operator overload for the specified `token`. */
922-
export function binary(token: string): (target: any, propertyKey: string, descriptor: any) => void;
940+
export function binary(token: string): (
941+
target: any,
942+
propertyKey: string,
943+
descriptor: TypedPropertyDescriptor<Function>
944+
) => TypedPropertyDescriptor<Function> | void;
923945
/** Annotates a method as an unary prefix operator overload for the specified `token`. */
924-
export function prefix(token: string): (target: any, propertyKey: string, descriptor: any) => void;
946+
export function prefix(token: string): (
947+
target: any,
948+
propertyKey: string,
949+
descriptor: TypedPropertyDescriptor<Function>
950+
) => TypedPropertyDescriptor<Function> | void;
925951
/** Annotates a method as an unary postfix operator overload for the specified `token`. */
926-
export function postfix(token: string): (target: any, propertyKey: string, descriptor: any) => void;
952+
export function postfix(token: string): (
953+
target: any,
954+
propertyKey: string,
955+
descriptor: TypedPropertyDescriptor<Function>
956+
) => TypedPropertyDescriptor<Function> | void;
927957
}
928958

929959
/** Annotates a class as being unmanaged with limited capabilities. */
930-
declare function unmanaged(target: Function): any;
960+
declare function unmanaged(constructor: Function): void;
931961

932962
/** Annotates a class as being sealed / non-derivable. */
933-
declare function sealed(target: Function): any;
963+
declare function sealed(constructor: Function): void;
934964

935965
/** Annotates a method or function as always inlined. */
936-
declare function inline(target: any, propertyKey: any, descriptor: any): any;
966+
declare function inline(
967+
target: any,
968+
propertyKey: string,
969+
descriptor: TypedPropertyDescriptor<Function>
970+
): TypedPropertyDescriptor<Function> | void;
937971

938972
/** Annotates an explicit external name of a function or global. */
939-
declare function external(target: any, propertyKey: any, descriptor: any): any;
973+
declare function external(namespace: string, name: string): (
974+
target: any,
975+
propertyKey: string,
976+
descriptor: TypedPropertyDescriptor<Function>
977+
) => TypedPropertyDescriptor<Function> | void;

0 commit comments

Comments
 (0)