alt
alt copied to clipboard
issue with typescript definition file
I am using the alt typescript definition file and running into issues with the actions
field of the AltJS.ActionsClass
.
Here is what my code looks like:
class AbstractActions implements AltJS.ActionsClass {
constructor(alt:AltJS.Alt){}
dispatch: ( ...payload:Array<any>) => void;
actions:AltJS.Actions;
}
interface IRedditActions {
fetchPosts();
}
export class RedditActions extends AbstractActions implements IRedditActions {
fetchPosts() {
this.dispatch();
RedditActions.fetchData().then((data)=> {
this.actions.updatePosts(data);
});
}
updatePosts(posts) {
this.dispatch(posts);
}
}
However, on this line:
this.actions.updatePosts(data);
I get this error:
Property 'updatePosts' does not exist on type `{ [action:string]: Action; }`
Is there anything I am doing wrong?
Having similar problems when calling actions. Somehow the methods of ActionsClasses are not bound correctly. There would be the possibility to call actions via the constants Alt generates (e.g. MyActions.UPDATE_ACTION) but of course the typescript compiler is not happy with this.
I would love to hear from @goatslacker or @Shearerbeard about the state of Alt+Typescript. I'm getting the feeling the bindings are far from working...
I'm trying to free up some time to look into this today. What version of alt / TypeScript are you running? The definitions were created and tested under TS 1.5 beta and alt 0.16.x.
Sent from my iPhone
On Nov 18, 2015, at 2:08 AM, Shady [email protected] wrote:
Having similar problems when calling actions. Somehow the methods of ActionsClasses are not bound correctly. There would be the possibility to call actions via the constants Alt generates (e.g. MyActions.UPDATE_ACTION) but of course the typescript compiler is not happy with this.
I would love to hear from @goatslacker or @Shearerbeard about the state of Alt+Typescript. I'm getting the feeling the bindings are far from working...
— Reply to this email directly or view it on GitHub.
@Shearerbeard TS 1.6.2, Alt 0.17.8. I ran alt-tests.ts and I'm getting an error when trying to call actions. Something must have changed how Alt binds the actions
EDIT: Tried using TS 1.6.2 but Alt 0.16.10. Same error when executing the tests: Uncaught TypeError: Cannot read property 'split' of undefined
at the line return this.hello.split("");
. Meaning this
, which is a member of TestStore, is not bound correctly inside of alt.createActions
Could be related to https://github.com/goatslacker/alt/issues/630?