mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-03-15 14:05:47 -05:00
Fix bug: Return a resolution diagnostic for a .jsx import if --allowJs is turned off
This commit is contained in:
@@ -1580,13 +1580,19 @@ namespace ts {
|
||||
case Extension.Dts:
|
||||
// These are always allowed.
|
||||
return undefined;
|
||||
|
||||
case Extension.Tsx:
|
||||
return needJsx();
|
||||
case Extension.Jsx:
|
||||
return options.jsx ? undefined : Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set;
|
||||
|
||||
return needJsx() || needAllowJs();
|
||||
case Extension.Js:
|
||||
return options.allowJs ? undefined : Diagnostics.Module_0_was_resolved_to_1_but_allowJs_is_not_set;
|
||||
return needAllowJs();
|
||||
}
|
||||
|
||||
function needJsx() {
|
||||
return options.jsx ? undefined : Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set;
|
||||
}
|
||||
function needAllowJs() {
|
||||
return options.allowJs ? undefined : Diagnostics.Module_0_was_resolved_to_1_but_allowJs_is_not_set;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/a.ts(1,17): error TS6143: Module './jsx' was resolved to '/jsx.jsx', but '--allowJs' is not set.
|
||||
|
||||
|
||||
==== /a.ts (1 errors) ====
|
||||
import jsx from "./jsx";
|
||||
~~~~~~~
|
||||
!!! error TS6143: Module './jsx' was resolved to '/jsx.jsx', but '--allowJs' is not set.
|
||||
|
||||
==== /jsx.jsx (0 errors) ====
|
||||
// Test the error message if we have `--jsx` but not `--allowJw`.
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
//// [tests/cases/compiler/moduleResolutionWithExtensions_notSupported3.ts] ////
|
||||
|
||||
//// [jsx.jsx]
|
||||
// Test the error message if we have `--jsx` but not `--allowJw`.
|
||||
|
||||
|
||||
//// [a.ts]
|
||||
import jsx from "./jsx";
|
||||
|
||||
|
||||
//// [a.js]
|
||||
"use strict";
|
||||
@@ -0,0 +1,17 @@
|
||||
[
|
||||
"======== Resolving module './jsx' from '/a.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'NodeJs'.",
|
||||
"Loading module as file / folder, candidate module location '/jsx'.",
|
||||
"File '/jsx.ts' does not exist.",
|
||||
"File '/jsx.tsx' does not exist.",
|
||||
"File '/jsx.d.ts' does not exist.",
|
||||
"File '/jsx/package.json' does not exist.",
|
||||
"File '/jsx/index.ts' does not exist.",
|
||||
"File '/jsx/index.tsx' does not exist.",
|
||||
"File '/jsx/index.d.ts' does not exist.",
|
||||
"Loading module as file / folder, candidate module location '/jsx'.",
|
||||
"File '/jsx.js' does not exist.",
|
||||
"File '/jsx.jsx' exist - use it as a name resolution result.",
|
||||
"Resolving real path for '/jsx.jsx', result '/jsx.jsx'",
|
||||
"======== Module name './jsx' was successfully resolved to '/jsx.jsx'. ========"
|
||||
]
|
||||
@@ -0,0 +1,9 @@
|
||||
// @noImplicitReferences: true
|
||||
// @jsx: preserve
|
||||
// @traceResolution: true
|
||||
// Test the error message if we have `--jsx` but not `--allowJw`.
|
||||
|
||||
// @Filename: /jsx.jsx
|
||||
|
||||
// @Filename: /a.ts
|
||||
import jsx from "./jsx";
|
||||
Reference in New Issue
Block a user