From d248d8ef30ec45758d94ba2407e230709b7634c2 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 5 Oct 2020 00:00:18 +0100 Subject: [PATCH] fix ts build system to use tsconfig.json This thing ignores your tsconfig.json if you provide input files Signed-off-by: Ian Jackson --- .gitignore | 1 + Makefile | 6 ++++-- templates/bigfloat.ts | 9 +++++---- tsconfig.json | 6 ++++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 2580622c..2dd99c4f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ templates/CC-BY-SA-4.0 save/lock /library/*/*.usvg *.tmp +.tsconfig.json diff --git a/Makefile b/Makefile index 43b4554b..4bb4c94c 100644 --- a/Makefile +++ b/Makefile @@ -80,8 +80,10 @@ $(CARGO_TARGET_DIR)/debug/server: $(CARGO_TARGET_DIR)/release/server: $(CARGO) build --release -templates/script.js: $(TS_SRC_FILES) tsconfig.json - tsc --outfile $@.tmp $(TS_SRC_FILES) 2>&1 \ +templates/script.js: tsconfig.json $(TS_SRC_FILES) + sed .tsconfig.json \ + '/^ *"files":/ s#:.*#:[$(foreach f,$(TS_SRC_FILES),"$f",)]#' + tsc --outfile $@.tmp -p .tsconfig.json 2>&1 \ | perl -pe 's/\((\d+),(\d+)\):/:$$1:$$2:/'; \ test "$${PIPESTATUS[*]}" = "0 0" mv -f $@.tmp $@ diff --git a/templates/bigfloat.ts b/templates/bigfloat.ts index 0fafc012..9535f472 100644 --- a/templates/bigfloat.ts +++ b/templates/bigfloat.ts @@ -62,6 +62,7 @@ namespace Bigfloats { export function unpack(p: Packed): Unpacked { let head = p.match(UNPACK_HEAD_RE); + if (head == null) throw('unpack Bigfloat '+p); UNPACK_LIMB_RE.lastIndex = 0; let limbs = []; let m; @@ -116,8 +117,8 @@ namespace Bigfloats { let newlimb = ms_limb_from_sign(v); let adj = 0; while (i < 0) { - this.limbs.unshift(newlimb); - this.exponent++; + v.limbs.unshift(newlimb); + v.exponent++; i++; adj++; } @@ -160,7 +161,7 @@ namespace Bigfloats { let ib = bv.exponent - e; if (ia >= av.limbs.length && ib >= bv.limbs.length) { // Oh actually these numbers are equal! - return function(){ return this.pack(); } + return function(){ return pack(av); } } let la = limb_lookup(av,ia); let lb = limb_lookup(bv,ib); @@ -169,7 +170,7 @@ namespace Bigfloats { let current = clone(av); let i = ia + extend_left_so_index_valid(current, ia); - let step; // floating! + let step : number; // actual floating point! if (avail > count+1) { step = avail / (count+1); } else { diff --git a/tsconfig.json b/tsconfig.json index de9dc7cf..7331aebf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,6 +8,8 @@ "dom" ], "strict": true, - "target": "es2015" - } + "target": "es2015", + "removeComments": false, + }, + "files": "--substituted by Makefile--", } -- 2.30.2