-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
How to add TypeScript signatures #52
Comments
Probably something about generics, do you have an example of the type you have now? I'm assuming glint. |
Hi. The helper function itself is typed in main (https://github.com/adopted-ember-addons/ember-set-helper/blob/main/ember-set-helper/src/helpers/set.ts). yet the V2 version (with types) is not published to npm. I am not fully sure how to build and publish to npm with types, so help is appreciated |
So you are just waiting for the new version to be published, got it. |
Let me explain a bit. Take the Counter example. This is my attempt at converting it to TypeScript: // app/components/counter.ts
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
interface CounterSignature {
Args: {
onClick: (count: number) => void;
}
}
export default class Counter extends Component<CounterSignature> {
@tracked count = 0;
@action
updateCount() {
this.count++;
if (this.args.onClick) {
this.args.onClick(this.count);
}
}
} But this results in a TypeScript error here: <!-- usage -->
// Error: Type 'string' is not assignable to type '(count: number) => void'
<Counter @onClick={{set this "currentCount"}} /> I'm a little at a loss as to how to proceed. |
Give v3.0.0 of this addon a try |
@knownasilya I get the following error on 3.0.0:
|
same |
@gabrielflorit @cah-brian-gantzler Can you try with I now get types in glint by (…we could perhaps consider to make it possible to also |
Will try it. I like the |
Working correctly now. Thanks |
Has this been released @cah-brian-gantzler ? When using
I get following error:
|
@MichalBryxi: Currently, the import is |
I'm having a bit of a hard time understanding how to type the signature here. E.g. what would be the TS signature for the example in the README?
The text was updated successfully, but these errors were encountered: