Giter Site home page Giter Site logo

Comments (7)

babel-bot avatar babel-bot commented on June 11, 2024

Hey @qbx2! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

from babel.

nicolo-ribaudo avatar nicolo-ribaudo commented on June 11, 2024

The two syntaxes are equivalent (like choosing to use single vs double quotes in strings), and module is deprecated. I think Babel should keep the current behaviour.

from babel.

qbx2 avatar qbx2 commented on June 11, 2024

@nicolo-ribaudo In old TypeScript, you might be right. However in the latest TypeScript, 'module' is not deprecated and different from namespace.

from babel.

qbx2 avatar qbx2 commented on June 11, 2024

From https://www.typescriptlang.org/docs/handbook/namespaces.html ,

A note about terminology: Itā€™s important to note that in TypeScript 1.5, the nomenclature has changed. ā€œInternal modulesā€ are now ā€œnamespacesā€. ā€œExternal modulesā€ are now simply ā€œmodulesā€, as to align with ECMAScript 2015ā€™s terminology, (namely that module X { is equivalent to the now-preferred namespace X {).

This post outlines the various ways to organize your code using namespaces (previously ā€œinternal modulesā€) in TypeScript. As we alluded in our note about terminology, ā€œinternal modulesā€ are now referred to as ā€œnamespacesā€. Additionally, anywhere the module keyword was used when declaring an internal module, the namespace keyword can and should be used instead. This avoids confusing new users by overloading them with similarly named terms.

It seems that youā€™re talking that ā€™internal moduleā€™ is deprecated but Iā€™m talking that babel rewrites ā€˜external moduleā€™ to ā€˜namespace (internal module)ā€™

from babel.

qbx2 avatar qbx2 commented on June 11, 2024

The difference of two is: ā€˜moduleā€™ wonā€™t be shared across files. Unlike ā€˜moduleā€™, ā€˜namespaceā€™ can be shared across files if the name is equivalent. Therefore, it can lead to a name conflict to rewrite module to namespace.

from babel.

nicolo-ribaudo avatar nicolo-ribaudo commented on June 11, 2024

"external modules" are when you write import/export at the top level of the file, not the code you are showing (which is an internal module).

From the docs you quoted: "(namely that module X { is equivalent to the now-preferred namespace X {)."

from babel.

qbx2 avatar qbx2 commented on June 11, 2024

@nicolo-ribaudo Oh, there was my misunderstanding. Thank you for the clarification.

from babel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.