Skip to content

support for traceResolution #1128

Description

@mprinc

Desired Behavior

Would be great if ts-node would support tsconfig's traceResolution and provide resolution repport

Is this request related to a problem?

Kind of: I cannot trace and debug the mapping and resolution problems

Activity

  1. cspotcode commented on Oct 11, 2020

    @cspotcode
    Collaborator

    Can this flag be specified in a tsconfig file?

  2. mprinc commented on Oct 11, 2020

    @mprinc
    Author

    Hi, @cspotcode It can, but ts-node is not respecting/recognizing it.

  3. cspotcode commented on Nov 21, 2020

    @cspotcode
    Collaborator

    This ticket is marked "help wanted" to indicate that we will accept a pull request implementing this feature. To help you get started, here is some information about how traceResolution works internally:

    TypeScript communicates with your host environment through a Host. This Host implements filesystem access and other input-output functions. There is a trace function on the host. If implemented, TypeScript is able to output tracing information by calling this function. ts-node does not currently provide an implementation of the trace function.

    So to add support for trace output, you'll need to add an implementation of the trace function, ensuring we pass it via both the LanguageService and CompilerHost codepaths. Should be simple enough: console.log.bind(console)

    We'll also need a test case. Probably you can take one of our existing tests, add traceResolution to its tsconfig, and then use a regexp to verify that the stdout includes tracing messages.

  4. mprinc commented on Nov 25, 2020

    @mprinc
    Author

    So to add support for trace output, you'll need to add an implementation of the trace function, ensuring we pass it via both the LanguageService and CompilerHost codepaths. Should be simple enough: console.log.bind(console)

    Thanks @cspotcode, could you provide the references in the ts-node codebase, please?

  5. cspotcode commented on Nov 25, 2020

    @cspotcode
    Collaborator

    Here is where we create the LanguageServiceHost: https://github.com/TypeStrong/ts-node/blob/master/src/index.ts#L652
    Here is where we create the CompilerHost: https://github.com/TypeStrong/ts-node/blob/master/src/index.ts#L790

    TypeScript uses the "host" we give it for all interaction with the host environment, so as long as these hosts have a trace implementation, TypeScript should be able to log tracing messages.

    We'll need tests to verify that it works before we can merge.

    Thanks!

  6. added this to the 10.5.0 milestone on Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions