Skip to content

Allow exports map entries to point at .ts source files #48563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
tests/cases/conformance/node/index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations.
tests/cases/conformance/node/index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary.


==== tests/cases/conformance/node/index.ts (2 errors) ====
// esm format file
import { Thing } from "inner/other";
~~~~~~~~~~~~~
!!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations.
export const a = (await import("inner")).x();
~
!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary.
import {a as a2} from "package";
==== tests/cases/conformance/node/node_modules/inner/index.ts (0 errors) ====
// esm format file
export { x } from "./other.js";
==== tests/cases/conformance/node/node_modules/inner/other.ts (0 errors) ====
// esm format file
export interface Thing {}
export const x: () => Thing = null as any;
==== tests/cases/conformance/node/package.json (0 errors) ====
{
"name": "package",
"private": true,
"type": "module",
"exports": "./index.ts"
}
==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ====
{
"name": "inner",
"private": true,
"type": "module",
"exports": "./index.ts"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//// [tests/cases/conformance/node/nodeModulesExportsSourceTs.ts] ////

//// [index.ts]
// esm format file
import { Thing } from "inner/other";
export const a = (await import("inner")).x();
import {a as a2} from "package";
//// [index.ts]
// esm format file
export { x } from "./other.js";
//// [other.ts]
// esm format file
export interface Thing {}
export const x: () => Thing = null as any;
//// [package.json]
{
"name": "package",
"private": true,
"type": "module",
"exports": "./index.ts"
}
//// [package.json]
{
"name": "inner",
"private": true,
"type": "module",
"exports": "./index.ts"
}

//// [other.js]
export const x = null;
//// [index.js]
// esm format file
export { x } from "./other.js";
//// [index.js]
export const a = (await import("inner")).x();


//// [other.d.ts]
export interface Thing {
}
export declare const x: () => Thing;
//// [index.d.ts]
export { x } from "./other.js";
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
=== tests/cases/conformance/node/index.ts ===
// esm format file
import { Thing } from "inner/other";
>Thing : Symbol(Thing, Decl(index.ts, 1, 8))

export const a = (await import("inner")).x();
>a : Symbol(a, Decl(index.ts, 2, 12))
>(await import("inner")).x : Symbol(x, Decl(index.ts, 1, 8))
>"inner" : Symbol("tests/cases/conformance/node/node_modules/inner/index", Decl(index.ts, 0, 0))
>x : Symbol(x, Decl(index.ts, 1, 8))

import {a as a2} from "package";
>a : Symbol(a, Decl(index.ts, 2, 12))
>a2 : Symbol(a2, Decl(index.ts, 3, 8))

=== tests/cases/conformance/node/node_modules/inner/index.ts ===
// esm format file
export { x } from "./other.js";
>x : Symbol(x, Decl(index.ts, 1, 8))

=== tests/cases/conformance/node/node_modules/inner/other.ts ===
// esm format file
export interface Thing {}
>Thing : Symbol(Thing, Decl(other.ts, 0, 0))

export const x: () => Thing = null as any;
>x : Symbol(x, Decl(other.ts, 2, 12))
>Thing : Symbol(Thing, Decl(other.ts, 0, 0))

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
=== tests/cases/conformance/node/index.ts ===
// esm format file
import { Thing } from "inner/other";
>Thing : any

export const a = (await import("inner")).x();
>a : import("tests/cases/conformance/node/node_modules/inner/other").Thing
>(await import("inner")).x() : import("tests/cases/conformance/node/node_modules/inner/other").Thing
>(await import("inner")).x : () => import("tests/cases/conformance/node/node_modules/inner/other").Thing
>(await import("inner")) : typeof import("tests/cases/conformance/node/node_modules/inner/index")
>await import("inner") : typeof import("tests/cases/conformance/node/node_modules/inner/index")
>import("inner") : Promise<typeof import("tests/cases/conformance/node/node_modules/inner/index")>
>"inner" : "inner"
>x : () => import("tests/cases/conformance/node/node_modules/inner/other").Thing

import {a as a2} from "package";
>a : import("tests/cases/conformance/node/node_modules/inner/other").Thing
>a2 : import("tests/cases/conformance/node/node_modules/inner/other").Thing

=== tests/cases/conformance/node/node_modules/inner/index.ts ===
// esm format file
export { x } from "./other.js";
>x : () => import("tests/cases/conformance/node/node_modules/inner/other").Thing

=== tests/cases/conformance/node/node_modules/inner/other.ts ===
// esm format file
export interface Thing {}
export const x: () => Thing = null as any;
>x : () => Thing
>null as any : any
>null : null

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
tests/cases/conformance/node/index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations.
tests/cases/conformance/node/index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary.


==== tests/cases/conformance/node/index.ts (2 errors) ====
// esm format file
import { Thing } from "inner/other";
~~~~~~~~~~~~~
!!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations.
export const a = (await import("inner")).x();
~
!!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary.
import {a as a2} from "package";
==== tests/cases/conformance/node/node_modules/inner/index.ts (0 errors) ====
// esm format file
export { x } from "./other.js";
==== tests/cases/conformance/node/node_modules/inner/other.ts (0 errors) ====
// esm format file
export interface Thing {}
export const x: () => Thing = null as any;
==== tests/cases/conformance/node/package.json (0 errors) ====
{
"name": "package",
"private": true,
"type": "module",
"exports": "./index.ts"
}
==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ====
{
"name": "inner",
"private": true,
"type": "module",
"exports": "./index.ts"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//// [tests/cases/conformance/node/nodeModulesExportsSourceTs.ts] ////

//// [index.ts]
// esm format file
import { Thing } from "inner/other";
export const a = (await import("inner")).x();
import {a as a2} from "package";
//// [index.ts]
// esm format file
export { x } from "./other.js";
//// [other.ts]
// esm format file
export interface Thing {}
export const x: () => Thing = null as any;
//// [package.json]
{
"name": "package",
"private": true,
"type": "module",
"exports": "./index.ts"
}
//// [package.json]
{
"name": "inner",
"private": true,
"type": "module",
"exports": "./index.ts"
}

//// [other.js]
export const x = null;
//// [index.js]
// esm format file
export { x } from "./other.js";
//// [index.js]
export const a = (await import("inner")).x();


//// [other.d.ts]
export interface Thing {
}
export declare const x: () => Thing;
//// [index.d.ts]
export { x } from "./other.js";
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
=== tests/cases/conformance/node/index.ts ===
// esm format file
import { Thing } from "inner/other";
>Thing : Symbol(Thing, Decl(index.ts, 1, 8))

export const a = (await import("inner")).x();
>a : Symbol(a, Decl(index.ts, 2, 12))
>(await import("inner")).x : Symbol(x, Decl(index.ts, 1, 8))
>"inner" : Symbol("tests/cases/conformance/node/node_modules/inner/index", Decl(index.ts, 0, 0))
>x : Symbol(x, Decl(index.ts, 1, 8))

import {a as a2} from "package";
>a : Symbol(a, Decl(index.ts, 2, 12))
>a2 : Symbol(a2, Decl(index.ts, 3, 8))

=== tests/cases/conformance/node/node_modules/inner/index.ts ===
// esm format file
export { x } from "./other.js";
>x : Symbol(x, Decl(index.ts, 1, 8))

=== tests/cases/conformance/node/node_modules/inner/other.ts ===
// esm format file
export interface Thing {}
>Thing : Symbol(Thing, Decl(other.ts, 0, 0))

export const x: () => Thing = null as any;
>x : Symbol(x, Decl(other.ts, 2, 12))
>Thing : Symbol(Thing, Decl(other.ts, 0, 0))

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
=== tests/cases/conformance/node/index.ts ===
// esm format file
import { Thing } from "inner/other";
>Thing : any

export const a = (await import("inner")).x();
>a : import("tests/cases/conformance/node/node_modules/inner/other").Thing
>(await import("inner")).x() : import("tests/cases/conformance/node/node_modules/inner/other").Thing
>(await import("inner")).x : () => import("tests/cases/conformance/node/node_modules/inner/other").Thing
>(await import("inner")) : typeof import("tests/cases/conformance/node/node_modules/inner/index")
>await import("inner") : typeof import("tests/cases/conformance/node/node_modules/inner/index")
>import("inner") : Promise<typeof import("tests/cases/conformance/node/node_modules/inner/index")>
>"inner" : "inner"
>x : () => import("tests/cases/conformance/node/node_modules/inner/other").Thing

import {a as a2} from "package";
>a : import("tests/cases/conformance/node/node_modules/inner/other").Thing
>a2 : import("tests/cases/conformance/node/node_modules/inner/other").Thing

=== tests/cases/conformance/node/node_modules/inner/index.ts ===
// esm format file
export { x } from "./other.js";
>x : () => import("tests/cases/conformance/node/node_modules/inner/other").Thing

=== tests/cases/conformance/node/node_modules/inner/other.ts ===
// esm format file
export interface Thing {}
export const x: () => Thing = null as any;
>x : () => Thing
>null as any : any
>null : null

28 changes: 28 additions & 0 deletions tests/cases/conformance/node/nodeModulesExportsSourceTs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// @module: node16,nodenext
// @declaration: true
// @filename: index.ts
// esm format file
import { Thing } from "inner/other";
export const a = (await import("inner")).x();
import {a as a2} from "package";
// @filename: node_modules/inner/index.ts
// esm format file
export { x } from "./other.js";
// @filename: node_modules/inner/other.ts
// esm format file
export interface Thing {}
export const x: () => Thing = null as any;
// @filename: package.json
{
"name": "package",
"private": true,
"type": "module",
"exports": "./index.ts"
}
// @filename: node_modules/inner/package.json
{
"name": "inner",
"private": true,
"type": "module",
"exports": "./index.ts"
}