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

Add generator blueprint for prototype extensions #88

Closed
dwickern opened this issue Jan 5, 2018 · 5 comments
Closed

Add generator blueprint for prototype extensions #88

dwickern opened this issue Jan 5, 2018 · 5 comments
Assignees

Comments

@dwickern
Copy link
Contributor

dwickern commented Jan 5, 2018

We should generate a .d.ts with prototype extensions.

Prototype extensions are controlled by EXTEND_PROTOTYPES:
https://guides.emberjs.com/v2.3.0/configuring-ember/disabling-prototype-extensions/

We can't conditionally enable types based on this so the best we can do is generate a .d.ts which the user can edit.

Array prototype extensions should be enabled by default for apps and disabled for addons. Function prototype extensions should be disabled by default probably. We haven't implemented string prototype extensions.

declare global {
    interface Array<T> extends Ember.ArrayPrototypeExtensions<T> {}
    interface Function extends Ember.FunctionPrototypeExtensions {}
}
@dfreeman
Copy link
Member

Function prototype extensions should be disabled by default probably.

AFAIK array prototype extensions are the only ones that aren't already deprecated/slated for deprecation, so it makes sense to me that they'd be the only ones enabled by default.

@dwickern
Copy link
Contributor Author

Can a blueprint detect if it's an addon vs. app for the array prototype extensions?

@dfreeman
Copy link
Member

dfreeman commented Jan 26, 2018

In most cases yes, though the addon story for e-c-ts is a little bit of an oddball, since having it as a devDependency means it's technically only installed for the addon's dummy app. We may have to settle for checking if the project name is dummy and basing the decision on that (or the presence of an addon/ directory, or any number of other good-enough hacks)

@chriskrycho
Copy link
Member

Looking at what I have for this in #108 and the discussion above: it looks like the function prototype extensions should probably be included but commented out to make it easy for people to “flip a switch” and turn them on?

@AvremelM
Copy link

AvremelM commented Nov 2, 2018

Just a heads up: enabling interface Function extends Ember.FunctionPrototypeExtensions { } causes typing errors when using ember-decorators' class decorators for me.

[ts] Unable to resolve signature of class decorator when called as an expression. Type 'Function' is not assignable to type 'void | typeof Badge'. Type 'Function' is not assignable to type 'typeof TooltipBadge'.

Hope this helps anyone coming across that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants