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 declare namespace #1

Closed
wants to merge 1 commit into from
Closed

Add declare namespace #1

wants to merge 1 commit into from

Conversation

unional
Copy link

@unional unional commented Apr 15, 2016

This allows user to use the import * as Promise from 'any-promise';

@unional
Copy link
Author

unional commented Apr 15, 2016

palantir/tslint#1016 (comment)
@jkillian, I tried to do what you suggested back in the extends feature here, but in this case it doesn't work.

After the change, I can do import * as Promise from 'any-promise';
but when I try to use it:
image

Any idea?

@jkillian
Copy link

If you can do import * as Promise from 'any-promise';, you should definitely be able to use the Promise identifier in your code... maybe an IDE issue?

@unional
Copy link
Author

unional commented Apr 15, 2016

Interesting. I do see it is working like you said.

Will file an issue on vscode and likely tsc

@blakeembrey
Copy link
Member

I don't intend to support this, it's a hack and not valid ES6.

@unional
Copy link
Author

unional commented Apr 15, 2016

Argee to your direction.

For reference, currently the only way to import this library in ES6 syntax is either:

  • module: "commonjs" + allowSyntheticDefaultImports: "true", or
  • module: "system"

and Thus connects to microsoft/TypeScript#7398

@unional unional deleted the unional-patch-1 branch April 15, 2016 21:08
@blakeembrey
Copy link
Member

@unional Sorry that previous post was a little brief/harsh, I know we've had the discussion before 😄 I don't think we should be forcing non-ES6 imports into an ES6 syntax, it's just not possible unless TypeScript intends to emit the correct transformations at the JavaScript level (E.g. emit x = require('x') instead of x = require('x').default). For the correct transformations to be emitted, we'd need accurate type definitions anyway, and that's not the ES6 construct you'd be using.

@unional
Copy link
Author

unional commented Apr 15, 2016

It's all good. I said in the past that I was trying to setup the environment / framework in my company and one thing I tried to avoid is forcing them to understand and use both require() and import ... from ....

But as you know we discover the issue of the interop and today I'm "officially" abandoning that idea:

https://github.com/unional/typescript/blob/master/style-guide/default/modules.md#import-keyword

🌷

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

Successfully merging this pull request may close these issues.

3 participants