Skip to content

class-factory mixins in type declaration files are impossible. (allow implicit return types in declaration files somehow) #35715

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

Open
5 tasks done
trusktr opened this issue Dec 16, 2019 · 2 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@trusktr
Copy link
Contributor

trusktr commented Dec 16, 2019

Search Terms

When the compiler is set to emit declaration files, class-factory mixins are no longer allowed. This is yet another issue that prevents class-factory mixins from being adopted in library code that need to be publish as JS with sibling declaration files.

Suggestion

Allow implicit return types to be somehow representable in declaration files.

Use Cases

Enables many use cases that are otherwise impossible when emitting declaration files. I believe declaration files should support all features of TS.

Examples

Write a mixin function, and try to emit declaration files.

Workaround

As a workaround I publish TypeScript source files in my NPM packages, then I point the types field in package.json to my source entry point. I don't publish declaration files because I can't build them.

Pointing to source files opens up other cans of worms, and prior to TS 3.6.3 I was not able to point to source files due to pre-existing bugs in tsc in that scenario. After TS 3.6.3, I can successfully publish source files and point types to sources containing class-factory mixins, but I'm afraid this is brittle and can break with an upgrade to TS (just as it was broken from some point prior to v3.6.3).

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.
@trusktr
Copy link
Contributor Author

trusktr commented Dec 28, 2019

related: #35822

@trusktr
Copy link
Contributor Author

trusktr commented Dec 28, 2019

The workaround I mentioned above can encounter problems, because .ts files are not officially supported as the target of package.json "types" field. See: #35744

@RyanCavanaugh RyanCavanaugh added Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript labels Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants