Skip to content

Commit 5c241b8

Browse files
committed
add strict mode for js scripts
1 parent ef38dce commit 5c241b8

File tree

5 files changed

+58
-5
lines changed

5 files changed

+58
-5
lines changed

Diff for: jscomp/test/test_promise_bind.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
22

3-
var Promise = require("./promise.js");
3+
var $$Promise = require("./promise.js");
44

5-
var v = Promise.f;
5+
var v = $$Promise.f;
66

77
exports.v = v;
88
/* Promise Not a pure module */

Diff for: lib/bsb

+6
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@ var bsb_exe = __filename + ".exe"
1616
var LAST_SUCCESS_BUILD_STAMP = 0
1717

1818
// All clients of type MiniWebSocket
19+
/**
20+
* @type {any[]}
21+
*/
1922
var wsClients = []
2023
var watch_mode = false
2124
var verbose = false
25+
/**
26+
* @type {string | undefined}
27+
*/
2228
var postBuild = undefined
2329
var useWebSocket = false
2430
var webSocketPort = 9999

Diff for: lib/jsconfig.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"alwaysStrict": true
4+
// , "noImplicitAny": true
5+
// , "strictNullChecks": true
6+
, "target": "es2018"
7+
// target need be set up
8+
// otherwise some method is missing
9+
, "module": "commonjs"
10+
// setup to understand commonjs module
11+
}
12+
13+
14+
, "files": [
15+
"./bsb"
16+
]
17+
}

Diff for: scripts/jsconfig.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"alwaysStrict": true
4+
, "noImplicitAny": true
5+
// , "strictNullChecks": true
6+
, "target": "es2018"
7+
// target need be set up
8+
// otherwise some method is missing
9+
, "module": "commonjs"
10+
// setup to understand commonjs module
11+
}
12+
}

Diff for: scripts/runtimeDeps.js

+21-3
Original file line numberDiff line numberDiff line change
@@ -282,16 +282,27 @@ async function stdlibNinja(){
282282
}
283283
)
284284
}
285-
285+
/**
286+
*
287+
* @param {string} text
288+
*/
286289
function getDeps(text) {
290+
/**
291+
* @type {string[]}
292+
*/
287293
var deps = []
288294
text.replace(/(\/\*[\w\W]*?\*\/|\/\/[^\n]*|[.$]r)|\brequire\s*\(\s*["']([^"']*)["']\s*\)/g, function(_, ignore, id) {
289295
if (!ignore)
290296
deps.push(id);
297+
return "" // TODO: examine the regex
291298
});
292299
return deps;
293300
}
294301

302+
/**
303+
*
304+
* @param {string} x
305+
*/
295306
function baseName(x) {
296307
return x.substr(0, x.indexOf('.'))
297308
}
@@ -361,7 +372,7 @@ function runJSCheckAsync(depsMap){
361372
* @param {string[]} output
362373
* @param {string[]} inputs
363374
* @param {DepsMap} depsMap
364-
* @param {any[]} overrides
375+
* @param {Override[]} overrides
365376
*/
366377
function build_stmt(output, inputs,depsMap, overrides = [] ){
367378
var stmt = `build ${output.join(' ')} : cc ${inputs.join(' ')}`
@@ -386,7 +397,11 @@ function build_stmt(output, inputs,depsMap, overrides = [] ){
386397
return stmt
387398
}
388399

389-
400+
/**
401+
*
402+
* @typedef {{key : string, value : string}} Override
403+
*
404+
*/
390405

391406

392407
/**
@@ -406,6 +421,9 @@ function generateNinja(depsMap,allTargets){
406421
var output_cmi = mod + ".cmi"
407422
var input_ml = mod + ".ml"
408423
var input_mli = mod + ".mli"
424+
/**
425+
* @type {Override[]}
426+
*/
409427
var overrides = []
410428
if(mod.endsWith('Labels')){
411429
overrides.push({key:'bsc_flags',value : '$bsc_flags -nolabels'})

0 commit comments

Comments
 (0)