Skip to content

preferTsExts breaks nyc coverage #1755

Closed
@cspotcode

Description

Note this likely only occurs in extremely rare cases. Tracking as a bug for proper documentation

This is fixed in #1694

nyc works by registering a JS setter on require.extensions[relevantExtension] which intercepts every time you set a value.
E.g. when you require.extensions['.js'] = someHook, nyc gets someHook and is able to wrap it.
For complex reasons, this is necessary.

If two different libraries decide to install require.extensions[] hooks, perhaps ts-node and something else, it's important that nyc's setter is preserved.

nyc ts-node ./install-yet-another-require-hook.ts

Our old preferTsExts behavior was removing nyc's setter when it re-ordered Object.keys(require.extensions)

Reproduction: https://github.com/TypeStrong/ts-node-repros/tree/preferTsExts-nyc-coverage

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions