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

Adding an delete alias for better named imports #60

Closed
jdalrymple opened this issue Nov 8, 2018 · 1 comment
Closed

Adding an delete alias for better named imports #60

jdalrymple opened this issue Nov 8, 2018 · 1 comment

Comments

@jdalrymple
Copy link

I ran into this problem when using rollup specifically, but the issue occurs anytime someone attempts to perform a named import. ie.

import { post, get, delete } from 'ky'

The problem here is that delete is a restricted keyword and causes issues when imported and called. One suggestion is to rename it during the import like:

import { post, get, delete as del } from 'ky'

But this doesnt really solve the problem that the export is still confusing.

As a suggestion, i think adding 'del', which would just be an alias for delete would remove this problem:

import { del } from 'ky'
@jdalrymple jdalrymple changed the title Include a del alias function Adding an delete alias for better named imports Nov 8, 2018
@sindresorhus
Copy link
Owner

Ky is a default export. The methods are not named exports. I'm not sure why Rollup lets you use named exports for it (you should open a Rollup issue about that), but that's definitely incorrect. Using named exports also decreases readability as it's not immediately clear what get() refers to in a large file without going all the way up to look at the import statement.

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

2 participants