-
-
Notifications
You must be signed in to change notification settings - Fork 929
Mithril not support TypeScript generated classes. #733
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
Comments
@IMPinball, #618 is a bug about |
@Naddiseo You are correct in that the original bug was about this very thing. The conversation, though, immediately diverged to a proposal originally on Gitter (and that was what I was referencing), and there's no hope of getting that back to the original problem. Also, when people initially tried working on it, the proposal hadn't yet solidified. |
Was that meanwhile fixed ? |
@daslicht Unless you're compiling to ES2015, the original bug should be fixed. As for the current TypeScript type, the controller type technically should be this when targeting ES2015 (not yet safe to do so for browsers, if you're developing for the open web): type ControllerFunction<T> = ((...args: any[]) => T) & (new (...args: any[]) => T); But that would break a lot of existing code, simply because of the intersection type. I'm glad we're catching it now, when a large chunk of browsers still don't yet enable it by default, instead of a couple years down the road, when IE is obsolete, and 99% of clients that can run JS fully support ES2015. |
And for everyone else here: If you are curious about a long-term solution, and/or have any input/opinions on how it should be done, please check out #994. Closing for now. Please do notify me if it's not fixed and/or the TS definition file is wrong. I'm actively working on other corrections within it ATM, so that'll be added to the list of changes I need to make. |
Here is an example of how I dealt with the TypeScript class issue with Mithril by adding static controller and view methods to a TypeScript class:
A little convoluted, but it works. In general, I feel there is too much magic in how Mithril makes components which has led to confusion compared to just expecting each component to have a view or render method or be a function that returns a vdom (like discussed in issue #499) and/or having the developer manage the lifestyle of components like Maquette vdom expects. But, in any case, the above design pattern worked for me for making Mithril components in TypeScript. |
I just use next variant:
This method more universal, because allows using difference views and controllers in one components. |
Mithril not support TypeScript generated classes in components.
TypeScript generate nex class:
But in conmponent view i have empty cotroller =\
I found next block of code
In log i have: first - is my controller, second - is empty cobntroller =\
If make this class:
then work fine
The text was updated successfully, but these errors were encountered: