Skip to content

Commit 2c7b13b

Browse files
authored
Fix explainFiles on files under nodenext with types references (microsoft#46367)
* Fix explainFiles on files under nodenext with types references * Fix explainFiles crash on module nodenext
1 parent d16d777 commit 2c7b13b

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-1
lines changed

src/compiler/program.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ namespace ts {
685685
break;
686686
case FileIncludeKind.TypeReferenceDirective:
687687
({ pos, end } = file.typeReferenceDirectives[index]);
688-
packageId = file.resolvedTypeReferenceDirectiveNames?.get(toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), getModeForResolutionAtIndex(file, index))?.packageId;
688+
packageId = file.resolvedTypeReferenceDirectiveNames?.get(toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), file.impliedNodeFormat)?.packageId;
689689
break;
690690
case FileIncludeKind.LibReferenceDirective:
691691
({ pos, end } = file.libReferenceDirectives[index]);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// === /node_modules/react-hook-form/dist/index.d.ts ===
2+
// /// <reference types="[|react|]/*FIND ALL REFS*/" />
3+
// export type Foo = React.Whatever;
4+
// export function useForm(): any;
5+
6+
[
7+
{
8+
"definition": {
9+
"containerKind": "",
10+
"containerName": "",
11+
"fileName": "/node_modules/react-hook-form/dist/index.d.ts",
12+
"kind": "string",
13+
"name": "react",
14+
"textSpan": {
15+
"start": 22,
16+
"length": 5
17+
},
18+
"displayParts": [
19+
{
20+
"text": "\"react\"",
21+
"kind": "stringLiteral"
22+
}
23+
]
24+
},
25+
"references": [
26+
{
27+
"textSpan": {
28+
"start": 22,
29+
"length": 5
30+
},
31+
"fileName": "/node_modules/react-hook-form/dist/index.d.ts",
32+
"isWriteAccess": false,
33+
"isDefinition": false
34+
}
35+
]
36+
}
37+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/// <reference path="fourslash.ts" />
2+
// @Filename: /node_modules/react-hook-form/package.json
3+
//// {
4+
//// "name": "react-hook-form",
5+
//// "main": "dist/index.cjs.js",
6+
//// "module": "dist/index.esm.js",
7+
//// "types": "dist/index.d.ts",
8+
//// "exports": {
9+
//// "./package.json": "./package.json",
10+
//// ".": {
11+
//// "import": "./dist/index.esm.js",
12+
//// "require": "./dist/index.cjs.js",
13+
//// "types": "./dist/index.d.ts"
14+
//// }
15+
//// }
16+
//// }
17+
18+
// @Filename: /node_modules/react-hook-form/dist/index.cjs.js
19+
//// module.exports = {};
20+
21+
// @Filename: /node_modules/react-hook-form/dist/index.esm.js
22+
//// export function useForm() {}
23+
24+
// @Filename: /node_modules/react-hook-form/dist/index.d.ts
25+
//// /// <reference types="react/**/" />
26+
//// export type Foo = React.Whatever;
27+
//// export function useForm(): any;
28+
29+
// @Filename: /node_modules/react/index.d.ts
30+
//// declare namespace JSX {}
31+
//// declare namespace React { export interface Whatever {} }
32+
33+
// @Filename: /tsconfig.json
34+
//// {
35+
//// "compilerOptions": {
36+
//// "module": "nodenext",
37+
//// "explainFiles": true
38+
//// }
39+
//// "files": ["./index.ts"]
40+
//// }
41+
42+
// @Filename: /index.ts
43+
//// import { useForm } from "react-hook-form";
44+
45+
verify.baselineFindAllReferences("");

0 commit comments

Comments
 (0)