-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use empty object for invalid package json contents instead of undefin…
…ed (#34906) * Use empty object for invalid package json contents instead of undefined Fixes #34726 * Behave as if package json doesnt exist in case of invalid json in package json
- Loading branch information
1 parent
9a3ec5f
commit 47ec514
Showing
6 changed files
with
116 additions
and
9 deletions.
There are no files selected for viewing
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
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
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
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
53 changes: 53 additions & 0 deletions
53
tests/cases/fourslash/completionsImport_filteredByInvalidPackageJson_direct.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,53 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
//@noEmit: true | ||
|
||
//@Filename: /package.json | ||
////{ | ||
//// "mod" | ||
//// "dependencies": { | ||
//// "react": "*" | ||
//// } | ||
////} | ||
|
||
//@Filename: /node_modules/react/index.d.ts | ||
////export declare var React: any; | ||
|
||
//@Filename: /node_modules/react/package.json | ||
////{ | ||
//// "name": "react", | ||
//// "types": "./index.d.ts" | ||
////} | ||
|
||
//@Filename: /node_modules/fake-react/index.d.ts | ||
////export declare var ReactFake: any; | ||
|
||
//@Filename: /node_modules/fake-react/package.json | ||
////{ | ||
//// "name": "fake-react", | ||
//// "types": "./index.d.ts" | ||
////} | ||
|
||
//@Filename: /src/index.ts | ||
////const x = Re/**/ | ||
|
||
verify.completions({ | ||
marker: test.marker(""), | ||
isNewIdentifierLocation: true, | ||
includes: [{ | ||
name: "React", | ||
hasAction: true, | ||
source: "/node_modules/react/index", | ||
sortText: completion.SortText.AutoImportSuggestions | ||
}, | ||
{ | ||
name: "ReactFake", | ||
hasAction: true, | ||
source: "/node_modules/fake-react/index", | ||
sortText: completion.SortText.AutoImportSuggestions | ||
} | ||
], | ||
preferences: { | ||
includeCompletionsForModuleExports: true | ||
} | ||
}); |
37 changes: 37 additions & 0 deletions
37
tests/cases/fourslash/server/importSuggestionsCache_invalidPackageJson.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,37 @@ | ||
/// <reference path="../fourslash.ts" /> | ||
|
||
// @Filename: /jsconfig.json | ||
////{ | ||
//// "compilerOptions": { | ||
//// "module": "commonjs", | ||
//// }, | ||
////} | ||
|
||
// @Filename: /node_modules/@types/node/index.d.ts | ||
////declare module 'fs' { | ||
//// export function readFile(): void; | ||
////} | ||
////declare module 'util' { | ||
//// export function promisify(): void; | ||
////} | ||
|
||
// @Filename: /package.json | ||
////{ "mod" } | ||
|
||
// @Filename: /a.js | ||
//// | ||
////readF/**/ | ||
|
||
goTo.marker(""); | ||
verify.completions({ | ||
includes: { | ||
name: "readFile", | ||
source: "fs", | ||
hasAction: true, | ||
sortText: completion.SortText.AutoImportSuggestions, | ||
}, | ||
preferences: { | ||
includeCompletionsForModuleExports: true, | ||
includeInsertTextCompletions: true, | ||
}, | ||
}); |