Skip to content

Commit

Permalink
Fix types for @Property decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
cole-abbeduto-particle committed Feb 19, 2025
1 parent d468a28 commit 769d94c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions lib/service/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ function property (options) {

/**
* @param {any} originalProp
* @param {ClassFieldDecoratorContext} context
* @param {ClassFieldDecoratorContext | ClassGetterDecoratorContext} context
*/
function propertyDecorator(originalProp, context) {
if (context.kind !== 'field') {
throw new Error(`Decorator "property" attempted to be used on ${context.kind}`);
if (context.kind !== 'field' && context.kind !== 'getter') {
throw new Error(`@property decorator attempted to be used on ${context.kind}`);
}
options.name = options.name || context.name.toString();
assertMemberNameValid(options.name);
Expand Down Expand Up @@ -169,7 +169,7 @@ function method(options) {
*/
function methodDecorator(originalFn, context) {
if (context.kind !== 'method') {
throw new Error(`Decorator "method" attempted to be used on ${context.kind}`);
throw new Error(`@method decorator attempted to be used on ${context.kind}`);
}
// Use the provided name or the method's name from the context.
options.name = options.name || context.name.toString();
Expand Down Expand Up @@ -239,7 +239,7 @@ function signal(options) {
*/
function signalDecorator(originalFn, context) {
if (context.kind !== 'method') {
throw new Error(`Decorator "signal" attempted to be used on ${context.kind}`);
throw new Error(`@signal decorator attempted to be used on ${context.kind}`);
}
options.name = options.name || context.name.toString();
assertMemberNameValid(options.name);
Expand Down
6 changes: 3 additions & 3 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ declare module '@particle/dbus-next' {
static configureMembers(members: { properties?: { [key: string]: PropertyOptions }, methods?: { [key: string]: MethodOptions }, signals?: { [key: string]: SignalOptions } }): void;
static emitPropertiesChanged(iface: Interface, changedProperties: { [key: string]: any }, invalidatedProperties: string[]): void
}
export function property(opts: PropertyOptions): (prop: any, ctx: ClassFieldDecoratorContext) => typeof prop;
export function method(opts: MethodOptions): (method: any, ctx: ClassMethodDecoratorContext) => typeof method;
export function signal(opts: SignalOptions): (method: any, ctx: ClassMethodDecoratorContext) => typeof method;
export function property<T>(opts: PropertyOptions): (prop: T, ctx: ClassFieldDecoratorContext | ClassGetterDecoratorContext) => T;
export function method<T>(opts: MethodOptions): (method: T, ctx: ClassMethodDecoratorContext) => T;
export function signal<T>(opts: SignalOptions): (method: T, ctx: ClassMethodDecoratorContext) => T;
}
export class Variant<T = any> {
signature: string;
Expand Down

0 comments on commit 769d94c

Please sign in to comment.