8000 Supports `exports` pointing to a TypeScript file, which keeps consistent with `main` · Issue #48369 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content
Supports exports pointing to a TypeScript file, which keeps consistent with main #48369
Closed
@pd4d10

Description

@pd4d10

Bug Report

In some cases, we want to import from the source code instead of the compiled, which is perfectly implemented by the main field:

// package.json
{
  "main": "./src/index.ts"
}

While it seems not to work at the newly introduced exports field

🔎 Search Terms

#46452
#48084

🕗 Version & Regression Information

  • This is the behavior in every version (the latest stable and nightly versions) I tried

⏯ Playground Link

This is about the package.json behavior, and the playground seems can't reproduce it.

💻 Code

// the library's package.json
{
  "exports": {
    ".": "./src/index.ts"
  }
}
// trying to use this library
import { xxx } from 'my-lib'

🙁 Actual behavior

It would show a ts2037 error message:

Cannot find module 'my-lib' or its corresponding type declarations. ts(2307)

🙂 Expected behavior

Works correctly, just like the main field's behavior.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0