Skip to content

Replace preferTsExts by a smart ordering #868

Description

@theKashey

continuation of #837, #529, #648

ts-node has one quite confusing, but quite explainable issue - it adds .ts to the resolve.extensions. However - adds to the end, which breaks code user expectations about how file resolving should work.

So - how it should work

  • js should be preferred over ts when preferTsExts is not set.
  • ts should be preferred over js when preferTsExts is set.
  • 😅ts and js should be preferred over css and less.

How it works

However - the current logic adds ts or after everything, or before everything.

While - should do it relative to js position - just after jsx?, or just before.

The problem

preferTsExts is still not documented, and, honestly, should not be documented. It shall work out of the box. 5 months ago, when I run into the issue, I've resolved it by manually hoisting extensions, hopefully, it's now supported out of the box.

But the problem is not closed unless default behavior is broken.

What would you say about changing this moment? js and ts should be in one "group", so let's make it a bit more "smart".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions