Skip to content

ts-node treats symbolic links in node_modules as separate files #1064

@jakzo

Description

@jakzo

Expected Behavior

Compiling a project which contains a file and the project also includes an import of a symlink of that file in node_modules completes successfully, even if the file declares a global identifier which would cause a "duplicate identifier" error if they were two separate files.

Common monorepo setups such as Yarn workspaces create symlinks from node_modules to files in the source. Typescript treats a symbolic link from node_modules to a file as the same file it links to in order to prevent these issues. Note that this behaviour is only when the file is in node_modules.

Actual Behavior

ts-node emits a "duplicate identifier" error for this case.

Steps to reproduce the problem

Create a Yarn workspaces project and import a file from another package which declares an identifier globally, such as:

declare module "http" {
  class X {}
}

Minimal reproduction

https://github.com/jakzo/ts-node-symlink-issue

Specifications

  • ts-node version: ts-node v8.10.2
  • node version: node v12.16.3
  • TypeScript version: compiler v3.9.3
  • tsconfig.json, if you're using one:
{
  "include": ["./"],
  "exclude": ["node_modules"],
  "compilerOptions": {
    "moduleResolution": "node",
    "outDir": "./dist/",
    "types": ["node"]
  }
}
  • Operating system and version: Mac 15.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions