Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow exports map entries to point at
.ts
source files (#48563)
* Probably works * Add tests * Update baselines for module option rename
- Loading branch information
Showing
9 changed files
with
306 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
tests/baselines/reference/nodeModulesExportsSourceTs(module=node16).errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
44 changes: 44 additions & 0 deletions
44
tests/baselines/reference/nodeModulesExportsSourceTs(module=node16).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
29 changes: 29 additions & 0 deletions
29
tests/baselines/reference/nodeModulesExportsSourceTs(module=node16).symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
|
32 changes: 32 additions & 0 deletions
32
tests/baselines/reference/nodeModulesExportsSourceTs(module=node16).types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
34 changes: 34 additions & 0 deletions
34
tests/baselines/reference/nodeModulesExportsSourceTs(module=nodenext).errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
44 changes: 44 additions & 0 deletions
44
tests/baselines/reference/nodeModulesExportsSourceTs(module=nodenext).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
29 changes: 29 additions & 0 deletions
29
tests/baselines/reference/nodeModulesExportsSourceTs(module=nodenext).symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
|
32 changes: 32 additions & 0 deletions
32
tests/baselines/reference/nodeModulesExportsSourceTs(module=nodenext).types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
28
tests/cases/conformance/node/nodeModulesExportsSourceTs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |