Skip to content
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

[4.2.3] Compilation with declaration files fails for mixins, usual compilation passes #44304

Closed
canonic-epicure opened this issue May 27, 2021 · 0 comments · Fixed by #49440
Closed
Assignees
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status. Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@canonic-epicure
Copy link

Bug Report

Hello,

I'm a mixin evangelist, perhaps you've seen my blog posts on the topic:
https://www.bryntum.com/blog/the-mixin-pattern-in-typescript-all-you-need-to-know/
https://www.bryntum.com/blog/the-mixin-pattern-in-typescript-all-you-need-to-know-part-2/
https://bryntum.github.io/chronograph/docs/modules/_src_guides_advancedfeatures_.html#mixins

The main advantage of using mixins instead of classic single class inheritance, is that mixins allows you to organize the hierarchy as a graph, instead of a tree, and write polymorphic code in the type-safe way.

However, when using mixins, enabling the generation of the declaration files fails when using certain form of class extension lambda. It works with another form, see below. In both cases, the compilation w/o declaration files works fine.

The issue is that, as a user, I expect, that if compilation passes, the declaration files generation should "just work". And currently, you can have your project to fully typecheck, but generation of declaration files will fail.

🔎 Search Terms

declaration files mixin

🕗 Version & Regression Information

I've tried with TypeScript 4.2.3 and 4.4.0-dev.20210527

Playground link

The reproducible case is reduced to a bare minimum. The full mixin library looks like this

🙁 Actual behavior

As you can see in the playground, the declaration of XmlElement2 fails with

'extends' clause of exported class 'XmlElement2' has or is using private name 'XmlElement2'.

The very similar declaration of XmlElement works, even that it also uses the private name XmlElement. However, the generated type for the parent property is any, which is incorrect, but at least it does not fail.

The reason I'm using the declaration form of XmlElement2 is that it supports decorators. Try un-commenting the decorator in the XmlElement declaration and see that it fails with another error.

So currently, I can either have decorators supported or declaration files, but not both.

🙂 Expected behavior

I expect the declaration file generation to always succeed, if regular compilation completes w/o errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status. Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
5 participants