Skip to content

Unrecognized self-referencing @scope/package #46175

Closed
@Conaclos

Description

@Conaclos

Bug Report

🔎 Search Terms

  • self-referencing
  • self-referencing package
  • node12
  • module resolution

🕗 Version & Regression Information

TypeScript 4.5 Beta and TypeScript Nightly

🙁 Actual behavior

Given the next package.json:

{
    "name": "@scope/package",
    "type": "module",
    "main": "./compiled/src/index.cjs",
    "exports": {
        "import": "./compiled/src/index.js",
        "require": "./compiled/src/index.cjs"
    },
    ...
}

And the following tsconfig.json:

{
    "module": "node12",
    ...
}

The following code does not compile:

import * as src from "@scope/package"

The obtained error is Cannot find module '@scope/package' or its corresponding type declarations.

🙂 Expected behavior

TSC currently compile self-referencing package that has unscoped names. TSC should also compile self-referencing scoped packages such as @scope/package.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions