Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript error TS1271: Decorator function return type is 'Record<..., unknown>' but is expected to be 'void' or 'any'. #194

Closed
jdanyow opened this issue Apr 2, 2022 · 2 comments · Fixed by #195

Comments

@jdanyow
Copy link
Contributor

jdanyow commented Apr 2, 2022

I think there's a regression in the typedefs for version 1.3.1.

TypeScript error TS1271: Decorator function return type is 'Record<..., unknown>' but is expected to be 'void' or 'any'.

https://github.com/github/catalyst/pull/190/files#diff-0609e410282ce718628c6b5977007b6a14a3edef8f178c61d749d134249ae52f

Changing the typedefs sorts it for me:

/**
 * Target is a decorator which - when assigned to a property field on the
 * class - will override that class field, turning it into a Getter which
 * returns a call to `findTarget(this, key)` where `key` is the name of the
 * property field. In other words, `@target foo` becomes a getter for
 * `findTarget(this, 'foo')`.
 */
- export declare function target<K extends string>(proto: Record<K, unknown>, key: K): Record<K, unknown>;
  export declare function target<K extends string>(proto: Record<K, unknown>, key: K): void; 
/**
 * Targets is a decorator which - when assigned to a property field on the
 * class - will override that class field, turning it into a Getter which
 * returns a call to `findTargets(this, key)` where `key` is the name of the
 * property field. In other words, `@targets foo` becomes a getter for
 * `findTargets(this, 'foo')`.
 */
- export declare function targets<K extends string>(proto: Record<K, unknown>, key: K): Record<K, unknown>;
  export declare function targets<K extends string>(proto: Record<K, unknown>, key: K): void;
//# sourceMappingURL=target.d.ts.map

node_modules/@github/catalyst/lib/target.d.ts

@keithamus
Copy link
Member

Looks reasonable. Would you like to open a PR that applies this fix?

jdanyow added a commit to jdanyow/catalyst that referenced this issue Apr 4, 2022
@koddsson
Copy link
Contributor

koddsson commented Apr 4, 2022

Maybe we should look into writing tests in TypeScript so we can catch errors like this in CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants