summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2020-11-22 23:20:32 +0000
committerGitHub <noreply@github.com>2020-11-23 10:20:32 +1100
commite7fc7d7151fbfea07f0738f61c1932023ad761da (patch)
tree012da2cd33082116ac4a0026b4eaa4d5fcaf8c62
parente3f73d3ec0aa822c9d125374ec34b7d8d5dfc0a5 (diff)
fix(cli/tsc): allow non-standard extensions on imports (#8464)
-rw-r--r--cli/tests/075_import_local_query_hash.ts2
-rw-r--r--cli/tests/075_import_local_query_hash.ts.out2
-rw-r--r--cli/tests/integration_tests.rs5
-rw-r--r--cli/tsc/99_main_compiler.js11
4 files changed, 17 insertions, 3 deletions
diff --git a/cli/tests/075_import_local_query_hash.ts b/cli/tests/075_import_local_query_hash.ts
new file mode 100644
index 000000000..99c7ceab4
--- /dev/null
+++ b/cli/tests/075_import_local_query_hash.ts
@@ -0,0 +1,2 @@
+import "./001_hello.js?a=b#c";
+import "./002_hello.ts?a=b#c";
diff --git a/cli/tests/075_import_local_query_hash.ts.out b/cli/tests/075_import_local_query_hash.ts.out
new file mode 100644
index 000000000..340777742
--- /dev/null
+++ b/cli/tests/075_import_local_query_hash.ts.out
@@ -0,0 +1,2 @@
+[WILDCARD]Hello World
+Hello World
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index 512fceee3..43b9e091b 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -2418,6 +2418,11 @@ itest!(_074_worker_nested_error {
exit_code: 1,
});
+itest!(_075_import_local_query_hash {
+ args: "run 075_import_local_query_hash.ts",
+ output: "075_import_local_query_hash.ts.out",
+});
+
itest!(js_import_detect {
args: "run --quiet --reload js_import_detect.ts",
output: "js_import_detect.ts.out",
diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js
index 5ef9bca65..bb8458c93 100644
--- a/cli/tsc/99_main_compiler.js
+++ b/cli/tsc/99_main_compiler.js
@@ -150,7 +150,7 @@ delete Object.prototype.__proto__;
/** An object literal of the incremental compiler host, which provides the
* specific "bindings" to the Deno environment that tsc needs to work.
- *
+ *
* @type {ts.CompilerHost} */
const host = {
fileExists(fileName) {
@@ -299,7 +299,7 @@ delete Object.prototype.__proto__;
*/
/** The API that is called by Rust when executing a request.
- * @param {Request} request
+ * @param {Request} request
*/
function exec({ config, debug: debugFlag, rootNames }) {
setLogDebug(debugFlag, "TS");
@@ -309,6 +309,11 @@ delete Object.prototype.__proto__;
const { options, errors: configFileParsingDiagnostics } = ts
.convertCompilerOptionsFromJson(config, "", "tsconfig.json");
+ // The `allowNonTsExtensions` is a "hidden" compiler option used in VSCode
+ // which is not allowed to be passed in JSON, we need it to allow special
+ // URLs which Deno supports. So we need to either ignore the diagnostic, or
+ // inject it ourselves.
+ Object.assign(options, { allowNonTsExtensions: true });
const program = ts.createIncrementalProgram({
rootNames,
options,
@@ -338,7 +343,7 @@ delete Object.prototype.__proto__;
let hasStarted = false;
/** Startup the runtime environment, setting various flags.
- * @param {{ debugFlag?: boolean; legacyFlag?: boolean; }} msg
+ * @param {{ debugFlag?: boolean; legacyFlag?: boolean; }} msg
*/
function startup({ debugFlag = false }) {
if (hasStarted) {