@mixin and @mixes support
See original GitHub issueFirst off, well done on v2. It is looking like a huge step forward from v1. 👏
I saw that @mixin
is supported but are there plans to support @mixes
as well.
I noticed from the source that @mixin
is handled like an interface; would it be better if @mixin
was handled like a type-def instead? This could make the handling of @mixes
easier.
For example, the following code:
/**
* @mixin A
* @property {string} one
* @property {string} two
*/
...
/**
* @typedef {Object} B
* @mixes A
* @property {string} three
*/
… would produce the following types:
declare type A = {
one: string;
two: string;
}
declare type B = A & {
three: string;
}
Interfaces, and class extensions could still be handled by @interface
and @extends
If you are yet to think about or work on this, and you agree with using types for @mixin
/@mixes
, I will start putting together a PR.
Let me know what you think? ❤️
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Sass: @mixin and @include
Mixins allow you to define styles that can be re-used throughout your stylesheet. ... Once Sass added support for hyphens to match CSS's...
Read more >Mixin - Wikipedia
Some languages do not support mixins on the language level, but can easily mimic them by copying methods from one object to another...
Read more >Mixins - The Modern JavaScript Tutorial
The simplest way to implement a mixin in JavaScript is to make an object with useful methods, so that we can easily merge...
Read more >What is a mixin and why is it useful? - Stack Overflow
The point of a mixin is to create a type that can be "mixed in" to any other type via inheritance without affecting...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey @marcandrews, happy new year!
Have you had a chance to take a look at this?
@englercj Hello! Firstly: great job with the library! Probably this issue will be good place to my problem in https://github.com/asyncapi/parser-js/pull/118 PR. If you had time to understand the problem and suggest solution, if I’m doing something wrong, or maybe the library has a bug in my case, I’d appreciate it.
So… I have a definition for mixins like:
and then I use those mixins to extend class like:
As you can see I want to have
ChannelParameter
class inside the@asyncapi/parser
module and also types for methods extended from mixinsMixinDescription
andMixinSpecificationExtensions
. Everything works as expected, but (I don’t know) mixins have generateddeclare namespace {MixinsName}
with methods definition anddeclare interface {MixinsName}
without any content, something like:And here is a problem, because
Tag
is a model inside the@asyncapi/parser
module and it’s not visible by namespace. I tried making something like:to generate types for mixins inside the
@asyncapi/parser
, but then I haven’t types for methods from mixins inside the type of mixes class… Any advice how to handle generation mixins inside the module and also generation of methods from mixins iinside the extended classes? I created the small script to remove generated namespaces outside the module@asyncapi/parser
, but I don’t like this solution. Thanks for the help!