mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Merge pull request #27376 from Microsoft/codeFixCannotFindModule_suggestion_falsePositive
Don't implicit-any diagnostic for json module
This commit is contained in:
commit
6bb1ff2214
@ -2270,7 +2270,7 @@ namespace ts {
|
||||
const sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
|
||||
if (sourceFile) {
|
||||
if (sourceFile.symbol) {
|
||||
if (resolvedModule.isExternalLibraryImport && !extensionIsTS(resolvedModule.extension)) {
|
||||
if (resolvedModule.isExternalLibraryImport && !resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
|
||||
errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference);
|
||||
}
|
||||
// merged symbol is module declaration symbol combined with all augmentations
|
||||
|
||||
@ -571,7 +571,8 @@ namespace FourSlash {
|
||||
public verifyNoErrors() {
|
||||
ts.forEachKey(this.inputFiles, fileName => {
|
||||
if (!ts.isAnySupportedFileExtension(fileName)
|
||||
|| !this.getProgram().getCompilerOptions().allowJs && !ts.extensionIsTS(ts.extensionFromPath(fileName))) return;
|
||||
|| Harness.getConfigNameFromFileName(fileName)
|
||||
|| !this.getProgram().getCompilerOptions().allowJs && !ts.resolutionExtensionIsTSOrJson(ts.extensionFromPath(fileName))) return;
|
||||
const errors = this.getDiagnostics(fileName).filter(e => e.category !== ts.DiagnosticCategory.Suggestion);
|
||||
if (errors.length) {
|
||||
this.printErrorLog(/*expectErrors*/ false, errors);
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @moduleResolution: node
|
||||
// @resolveJsonModule: true
|
||||
// @strict: true
|
||||
|
||||
// @Filename: /node_modules/foo/bar.json
|
||||
////{ "a": 0 }
|
||||
|
||||
// @Filename: /a.ts
|
||||
////import abs = require([|"foo/bar.json"|]);
|
||||
////abs;
|
||||
|
||||
verify.noErrors();
|
||||
goTo.file("/a.ts");
|
||||
verify.getSuggestionDiagnostics([]);
|
||||
Loading…
x
Reference in New Issue
Block a user