-
Notifications
You must be signed in to change notification settings - Fork 40
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
Usage with typescript? #17
Comments
That's a shame to confess, but I still didn't get to use TypeScript (just a bit of Flow). A pr to add types for the library would be much appreciated. |
yes we need this feature |
It's weird, on my side if I try
It doesnt trigger an error but simply doesnt let me debug at all |
@azukaar do you have the extension installed? |
@zalmoxisus yeah yeah I do,, and it tells me "No store found. Make sure to follow the instructions.". Even AFTER actions are indeed triggered |
@azukaar @yann-stepienik-cko see the notes about environment. By default it works only when If that's not the case, please share a simple repo I could run. I tried your snippet and it works as expected. |
@zalmoxisus I've been able to make it work by adding a NODE_ENV thanks ! @xaviergonz if you're still unable to use the plugin with TS feel free to chekcout my code ! Here is the repo : https://github.com/azukaar/react-typescript-mobx-webpack |
FYI I reproduced this when TypeScript target language is es6, but not es5. |
@WearyMonkey seems like the class is not extended (since it's in commonjs/es5 from inside the lib). You can try to do it on your side like here. Where You can also create a decorator like here. |
I'm experiencing this issue in a Babel setup including
Mobx itself works fine, but upon adding that |
For what it's worth I just added a declare module 'mobx-remotedev' {
export default function<T>(store: T): T
} I also added the following lines to {
"compilerOptions": {
"baseUrl": ".",
"paths": {
"*": ["@types/*"]
}
}
} This is obviously not the full declaration, but it's enough in my case. And it also works with React Native debugger which is just awesome. |
HI @zalmoxisus, i absolutely hate Redux but i love their devtool. I also love Mobx and hate their devtools. to make matters complicated, i love Typescript but i also hate Babel. is there a way for me to enjoy this wonderful package without using babel at all? |
@BlackFenix2 yes, we just need |
@zalmoxisus i made a PR adding index.d.ts. its minimal but it should work. |
Thanks @BlackFenix2! I published it as |
NP, ill give it a try now! i might make another PR to add more detailed Typescript definitions. |
terribly sorry, but i should of declared |
NP, thanks for working on this @BlackFenix2! |
i submitted another PR to address the index.d.ts bug #38 i also included a basic RemoteDevConfig object definition. |
Thanks @BlackFenix2! It's published as |
I tried out the new version, the TypeDefinitions are there but i am still getting the error: this is my base code:
and this is where i add the stores to my provider:
and this is the line that throws an error for me in lib/dev.js: i may be a little stumped at this point. im going to try and use the repo recommend by @azukaar |
https://github.com/azukaar/react-typescript-mobx-webpack now we got to figure out a way to get this working with zero babel. |
@BlackFenix2 does TS use that definition we added? Maybe it should be in |
@zalmoxisus the default function is getting the type definitons below.
i know the error happens at line 50 in dev.js when the call method is invoked
since the lib directory is compiled we might be able to use Typescript to compile the files rather than Babel, like in this fork: it is behind your main branch. but i can attempt to add this to my fork and test the package locally. ill investigate. |
Almost forgot to mention, if i use this .babelrc config and tsconfig.json remotedev works perfectly for me .babelrc tsconfig.json
i have it all working on my github repo https://github.com/BlackFenix2/Portfolio the live site is react.erniefrancisiv.com/todo .redux devtools wont work here since production, but feel free to fork my repo and check for yourself. |
All i figued out is that dev.js bugs out when i do not transpose my classes to fuctions with Babel. line:
with babel 7:
without babel:
|
this PR #40 should fix the typescript issues. |
Thanks for fixing it @BlackFenix2! I also added you as a collaborator for this repo. |
Please update docs how to use it with typescript and how to export |
Given this base code:
I tried:
But it gives:
Uncaught TypeError: Cannot call a class as a function
So then I tried decorating the AppStore class itself as:
And then it gives
Uncaught TypeError: Class constructor AppStore cannot be invoked without 'new' at new store (C:\VSProjects\SkirmishJs\server\node_modules\mobx-remotedev\lib\dev.js:48:67)
Is there a way to make it work using typescript classes?
PS: typescript types for the library would be cool too :)
The text was updated successfully, but these errors were encountered: