From f47c521d35e5bba259365ab1485e61da927a6d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20B=C3=B6hm?= <188768+fb55@users.noreply.github.com> Date: Sun, 10 Apr 2022 14:25:31 +0100 Subject: [PATCH 1/2] refactor(tsconfig): Configure TS to be stricter --- tsconfig.json | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 3013032f..045b82d5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,27 +1,31 @@ { "compilerOptions": { /* Basic Options */ - "target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */, - "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, - // "lib": [], /* Specify library files to be included in the compilation. */ - "declaration": true /* Generates corresponding '.d.ts' file. */, - "declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */, - "sourceMap": true /* Generates corresponding '.map' file. */, - "outDir": "lib" /* Redirect output structure to the directory. */, - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + "target": "es5", + "module": "commonjs", + "lib": ["ES2015.Core"], + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "outDir": "lib", /* Strict Type-Checking Options */ - "strict": true /* Enable all strict type-checking options. */, + "strict": true, /* Additional Checks */ - "noUnusedLocals": true /* Report errors on unused locals. */, - "noUnusedParameters": true /* Report errors on unused parameters. */, - "noImplicitReturns": true /* Report error when not all code paths in function return a value. */, - "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */, + "exactOptionalPropertyTypes": true, + "forceConsistentCasingInFileNames": true, + "importsNotUsedAsValues": "error", + "isolatedModules": true, + "noFallthroughCasesInSwitch": true, + "noImplicitOverride": true, + "noImplicitReturns": true, + "noPropertyAccessFromIndexSignature": true, + "noUnusedLocals": true, + "noUnusedParameters": true, /* Module Resolution Options */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, + "esModuleInterop": true, "moduleResolution": "node", "resolveJsonModule": true }, From 57fc1ef21b5787a5996f6789ff1f6e315e24dcb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20B=C3=B6hm?= <188768+fb55@users.noreply.github.com> Date: Sun, 10 Apr 2022 14:28:08 +0100 Subject: [PATCH 2/2] Fix test --- scripts/trie/decode-trie.ts | 7 ------- scripts/trie/encode-trie.ts | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/scripts/trie/decode-trie.ts b/scripts/trie/decode-trie.ts index ccf6b0c6..5d5cc652 100644 --- a/scripts/trie/decode-trie.ts +++ b/scripts/trie/decode-trie.ts @@ -51,8 +51,6 @@ export function decodeNode( if (val !== -1) { const code = jumpOffset + i; - console.log("CODE", String.fromCharCode(code), i, val); - decodeNode( decodeMap, resultMap, @@ -63,11 +61,6 @@ export function decodeNode( } } else { for (let i = 0; i < branchLength; i++) { - console.log( - "BRANCH", - String.fromCharCode(decodeMap[branchIdx + i]) - ); - decodeNode( decodeMap, resultMap, diff --git a/scripts/trie/encode-trie.ts b/scripts/trie/encode-trie.ts index 3ef2d4d6..4a825143 100644 --- a/scripts/trie/encode-trie.ts +++ b/scripts/trie/encode-trie.ts @@ -1,5 +1,5 @@ import * as assert from "assert"; -import { TrieNode } from "./trie.js"; +import type { TrieNode } from "./trie.js"; function binaryLength(num: number) { return Math.ceil(Math.log2(num));