summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2018-08-17 00:28:02 +0900
committerRyan Dahl <ry@tinyclouds.org>2018-08-17 12:43:21 -0400
commit565a21eb0eee61048f6f770bfb24a03131fbc958 (patch)
treeb27ab704ef8ed6b77a74b62d8697588ad8f862b9
parent87a061785e7ac795b9b3ef262d382dbfe6887eda (diff)
chore: format files in tests/
-rw-r--r--js/runtime.ts47
-rw-r--r--tests/010_set_interval.ts6
-rw-r--r--tests/async_error.ts3
-rw-r--r--tests/async_error.ts.out4
-rw-r--r--tests/error_001.ts4
-rwxr-xr-xtools/format.py1
6 files changed, 32 insertions, 33 deletions
diff --git a/js/runtime.ts b/js/runtime.ts
index fdfbbe799..a0fd6d622 100644
--- a/js/runtime.ts
+++ b/js/runtime.ts
@@ -344,30 +344,29 @@ class TypeScriptHost implements ts.LanguageServiceHost {
containingFile: string
): ts.ResolvedModule[] {
//util.log("resolveModuleNames", { moduleNames, reusedNames });
- return moduleNames
- .map(name => {
- let resolvedFileName;
- if (name === "deno") {
- resolvedFileName = resolveModuleName("deno.d.ts", ASSETS);
- } else if (name === "typescript") {
- resolvedFileName = resolveModuleName("typescript.d.ts", ASSETS);
- } else {
- resolvedFileName = resolveModuleName(name, containingFile);
- }
- // According to the interface we shouldn't return `undefined` but if we
- // fail to return the same length of modules to those we cannot resolve
- // then TypeScript fails on an assertion that the lengths can't be
- // different, so we have to return an "empty" resolved module
- // TODO: all this does is push the problem downstream, and TypeScript
- // will complain it can't identify the type of the file and throw
- // a runtime exception, so we need to handle missing modules better
- resolvedFileName = resolvedFileName || "";
- // This flags to the compiler to not go looking to transpile functional
- // code, anything that is in `/$asset$/` is just library code
- const isExternalLibraryImport = resolvedFileName.startsWith(ASSETS);
- // TODO: we should be returning a ts.ResolveModuleFull
- return { resolvedFileName, isExternalLibraryImport };
- });
+ return moduleNames.map(name => {
+ let resolvedFileName;
+ if (name === "deno") {
+ resolvedFileName = resolveModuleName("deno.d.ts", ASSETS);
+ } else if (name === "typescript") {
+ resolvedFileName = resolveModuleName("typescript.d.ts", ASSETS);
+ } else {
+ resolvedFileName = resolveModuleName(name, containingFile);
+ }
+ // According to the interface we shouldn't return `undefined` but if we
+ // fail to return the same length of modules to those we cannot resolve
+ // then TypeScript fails on an assertion that the lengths can't be
+ // different, so we have to return an "empty" resolved module
+ // TODO: all this does is push the problem downstream, and TypeScript
+ // will complain it can't identify the type of the file and throw
+ // a runtime exception, so we need to handle missing modules better
+ resolvedFileName = resolvedFileName || "";
+ // This flags to the compiler to not go looking to transpile functional
+ // code, anything that is in `/$asset$/` is just library code
+ const isExternalLibraryImport = resolvedFileName.startsWith(ASSETS);
+ // TODO: we should be returning a ts.ResolveModuleFull
+ return { resolvedFileName, isExternalLibraryImport };
+ });
}
}
diff --git a/tests/010_set_interval.ts b/tests/010_set_interval.ts
index e013d00bc..f58cc3fcd 100644
--- a/tests/010_set_interval.ts
+++ b/tests/010_set_interval.ts
@@ -1,7 +1,7 @@
const id = setInterval(function() {
- console.log("test")
+ console.log("test");
}, 200);
setTimeout(function() {
- clearInterval(id)
-}, 500)
+ clearInterval(id);
+}, 500);
diff --git a/tests/async_error.ts b/tests/async_error.ts
index 12dee11eb..7ce25d0cb 100644
--- a/tests/async_error.ts
+++ b/tests/async_error.ts
@@ -1,9 +1,8 @@
-
console.log("hello");
const foo = async () => {
console.log("before error");
throw Error("error");
-}
+};
foo();
console.log("world");
diff --git a/tests/async_error.ts.out b/tests/async_error.ts.out
index 1290629b1..c98c79bfc 100644
--- a/tests/async_error.ts.out
+++ b/tests/async_error.ts.out
@@ -1,8 +1,8 @@
hello
before error
Error: error
- at foo ([WILDCARD]tests/async_error.ts:5:9)
- at eval ([WILDCARD]tests/async_error.ts:8:1)
+ at foo ([WILDCARD]tests/async_error.ts:4:9)
+ at eval ([WILDCARD]tests/async_error.ts:7:1)
at eval (<anonymous>)
at execute (deno/js/runtime.ts:[WILDCARD])
at FileModule.compileAndRun (deno/js/runtime.ts:[WILDCARD])
diff --git a/tests/error_001.ts b/tests/error_001.ts
index 624bc55da..ab6e17a52 100644
--- a/tests/error_001.ts
+++ b/tests/error_001.ts
@@ -3,7 +3,7 @@ function foo() {
}
function bar() {
- foo()
+ foo();
}
-bar()
+bar();
diff --git a/tools/format.py b/tools/format.py
index f2d94a6f4..51bf2c1fb 100755
--- a/tools/format.py
+++ b/tools/format.py
@@ -23,6 +23,7 @@ run(["yapf", "-i"] + find_exts("tools/", ".py") +
find_exts("build_extra", ".py"))
run(["node", prettier, "--write"] + find_exts("js/", ".js", ".ts") +
+ find_exts("tests/", ".js", ".ts") +
["rollup.config.js", "tsconfig.json", "tslint.json"])
# Requires rustfmt 0.8.2 (flags were different in previous versions)