Skip to content

Commit 2cfa608

Browse files
kitsonkry
authored andcommitted
Support CheckJS
1 parent 0501330 commit 2cfa608

10 files changed

+28
-15
lines changed

js/compiler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ export class DenoCompiler
152152
// arguments
153153
private readonly _options: Readonly<ts.CompilerOptions> = {
154154
allowJs: true,
155+
checkJs: true,
155156
module: ts.ModuleKind.AMD,
156157
outDir: "$deno$",
157158
// TODO https://github.com/denoland/deno/issues/23

tests/error_008_checkjs.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// console.log intentionally misspelled to trigger a type error
2+
consol.log("hello world!");
3+
4+
// the following error should be ignored and not output to the console
5+
// @ts-ignore
6+
const foo = new Foo();

tests/error_008_checkjs.js.out

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[WILDCARD]/tests/error_008_checkjs.jsILDCARD] - error TS2552: Cannot find name 'consol'. Did you mean 'console'?
2+
3+
ILDCARD] consol.log("hello world!");
4+
[WILDCARD]~~~~~~
5+
6+
$asset$/lib.deno_runtime.d.tsILDCARD]
7+
[WILDCARD]declare const console: console_.Console;
8+
[WILDCARD]~~~~~~~
9+
[WILDCARD]'console' is declared here.
10+
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
define(["exports"], function(exports) {
2-
exports.loaded = true;
3-
});
1+
export const loaded = true;
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
define(["exports"], function(exports) {
2-
exports.loaded = true;
3-
});
1+
export const loaded = true;

tests/subdir/mt_javascript.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
define(["exports"], function(exports) {
2-
exports.loaded = true;
3-
});
1+
export const loaded = true;

tests/subdir/mt_text_ecmascript.j3.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
define(["exports"], function(exports) {
2-
exports.loaded = true;
3-
});
1+
export const loaded = true;

tests/subdir/mt_text_javascript.j1.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
define(["exports"], function(exports) {
2-
exports.loaded = true;
3-
});
1+
export const loaded = true;

tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"compilerOptions": {
3+
"allowJs": true,
34
"allowUnreachableCode": false,
45
"baseUrl": ".",
6+
"checkJs": true,
57
"module": "esnext",
68
"moduleResolution": "node",
79
"noImplicitReturns": true,

website/app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,12 @@ function generate(
148148
};
149149
}
150150

151+
// @ts-ignore
151152
c3.generate({
152153
bindto: id,
153154
size: {
154155
height: 300,
156+
// @ts-ignore
155157
width: window.chartWidth || 375 // TODO: do not use global variable
156158
},
157159
data: {
@@ -200,6 +202,7 @@ export async function drawChartsFromBenchmarkData(dataUrl) {
200202
const sha1ShortList = sha1List.map(sha1 => sha1.substring(0, 6));
201203

202204
const viewCommitOnClick = _sha1List => d => {
205+
// @ts-ignore
203206
window.open(
204207
`https://github.com/denoland/deno/commit/${_sha1List[d["index"]]}`
205208
);
@@ -229,6 +232,7 @@ export async function drawChartsFromBenchmarkData(dataUrl) {
229232
*/
230233
export async function drawChartsFromTravisData() {
231234
const viewPullRequestOnClick = _prNumberList => d => {
235+
// @ts-ignore
232236
window.open(
233237
`https://github.com/denoland/deno/pull/${_prNumberList[d["index"]]}`
234238
);

0 commit comments

Comments
 (0)