Suggest json files in completion when resolveJsonModule is set and module resolution is node#23915
Conversation
…dule resolution is node Fixes #23899
|
|
||
| if (isPathRelativeToScript(literalValue) || isRootedDiskPath(literalValue)) { | ||
| const extensions = getSupportedExtensions(compilerOptions); | ||
| const extensions = getSupportExtensionsForModuleResolution(compilerOptions); |
There was a problem hiding this comment.
Shouldn't we just change getSupportedExtensions? That's used by isSupportedSourceFileName which is used by watch.ts, and presumably we want to watch for changes to '.json' files if they're included in the program?
There was a problem hiding this comment.
isSupportedSourceFileName which internally uses getSupportedExtensions is used to see if the file name is valid when getting the fileNames to compile. We do not add json files then and we shouldnt because we only want to add them through module resolution.
| // @Filename: /project/index.ts | ||
| ////import { } from ".//**/"; | ||
|
|
||
| verify.completionsAt("", [], { isNewIdentifierLocation: true }); No newline at end of file |
There was a problem hiding this comment.
because module resolution strategy isnt "node" and hence json files wont be resolved.
| // @Filename: /project/index.ts | ||
| ////import { } from "/**/"; | ||
|
|
||
| verify.completionsAt("", ["test.json"], { isNewIdentifierLocation: true }); No newline at end of file |
There was a problem hiding this comment.
Nit: It would more realistically be node_modules/package-name/index.json.
Fixes #23899