Skip to content

Commit be167d9

Browse files
committed
https://github.com/microsoft/TypeScript/issues/59329
0 parents  commit be167d9

9 files changed

+92
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This file includes multiple different types of imports. Specifying different
2+
// "module" and "moduleResolution" compiler options will result in different
3+
// imports working (or not). That behavior is expected. But when the "typeRoots"
4+
// compiler option is explicitly set to the default value, the number of
5+
// resolved imports changes. That behavior is unexpected.
6+
7+
import { file } from "pkg"
8+
import { file as index} from "pkg/index"
9+
import { file as indexJs} from "pkg/index.js"
10+
import {file as internal} from "pkg/internal"
11+
import {file as internalJs} from "pkg/internal.js"
12+
import {file as external} from "pkg/external"
13+
import {file as externalJs} from "pkg/external.js"
14+
import {file as exports} from "pkg/exports"

package-lock.json

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"dependencies": {
3+
"@types/pkg": "file:pkg",
4+
"typescript": "^5.5.4"
5+
},
6+
"scripts": {
7+
"test": "tsc"
8+
}
9+
}

pkg/external.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const file = "external"

pkg/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const file = "index"

pkg/internal.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const file = "internal"

pkg/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "@types/pkg",
3+
"version": "1.0.0",
4+
"types": "./index.d.ts",
5+
"exports": {
6+
"exports": "./external.d.ts"
7+
}
8+
}

tsconfig.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"files": ["index.ts"],
3+
"compilerOptions": {
4+
"noEmit": true,
5+
6+
// When "typeRoots" is not specified, this project has 8 compiler errors.
7+
// When "typeRoots" is specified, this project has 1 compiler error.
8+
// Other configs that
9+
// "typeRoots": ["./node_modules/@types"],
10+
11+
"module": "Node16",
12+
"moduleResolution": "Node16",
13+
// Preserve/Node10, Preserve/Bundler, and ES2015+/Bundler all have
14+
// differences in behavior depending on the presence of "typeRoots".
15+
// "moduleResolution": "Node10",
16+
// "moduleResolution": "Bundler"
17+
// "module": "Preserve",
18+
// "module": "ES2015",
19+
// "module": "ES2020",
20+
// "module": "ES2022",
21+
// "module": "ESNext",
22+
}
23+
}

0 commit comments

Comments
 (0)