Skip to content
This repository was archived by the owner on Sep 2, 2023. It is now read-only.
This repository was archived by the owner on Sep 2, 2023. It is now read-only.

Warn on thenable required #333

@benjamingr

Description

@benjamingr

Hey,

First of all sorry if this was discussed before - I haven't been an active modules team member for a while :]

How does everyone feel about warning on thenables being imported?

I raised this up after discussing this case with Kyle Simpson last year in the promise use cases session in the summit and then completely forgot about it. Basically something like:

// myModule.mjs
const thenable = {
  then(onFulfilled, onRejected) {
    // do something
  }
}
export default thenable;

Then on the other side if someone does import('./myModule.mjs') they will get (arguably) surprising results. It's probably not a common problem but a very annoying one when you do get it probably.

We can:

  • Ignore this, as this is technically working as intended.
  • Warn when this happens by default. (I've tried looking for places this is done intentionally and haven't found any).
  • Expose a Symbol that allows opting out of this behaviour and importing the module as an object.
  • Throw wheh someone imports a thenable.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions