Skip to content

Commit

Permalink
Also fix completeness test
Browse files Browse the repository at this point in the history
  • Loading branch information
nvie committed Dec 28, 2023
1 parent abdcee2 commit 11a6c72
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
6 changes: 1 addition & 5 deletions bin/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ set -eu

BIN=$(dirname "$0")

list_exports() {
"$BIN/linenos" --all --types --exports "$1" | cut -f1 | sort -u
}

list_decoders() {
"$BIN/linenos" --all --exports src/index.ts | cut -f1 | sort -u
node bin/exported-decoders.mjs | sort -u
}

echo "==> Checking documentation" >&2
Expand Down
27 changes: 27 additions & 0 deletions bin/exported-decoders.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Project } from 'ts-morph';

const project = new Project({
tsConfigFilePath: './tsconfig.json',
});

// NOTE: This is a bit caveman-style. Ideally, we would write the loop below to
// check if these are _type_ exports or not. But I haven't figured out yet how
// to do that programmatically.
const NOT_DECODERS = new Set([
'Decoder',
'DecodeResult',
'DecoderType',
'JSONArray',
'JSONObject',
'JSONValue',
'Scalar',
]);

for (const src of project.getSourceFiles('src/index.ts')) {
for (const sym of src.getExportSymbols()) {
const name = sym.getName();
if (!NOT_DECODERS.has(name)) {
console.log(name);
}
}
}

0 comments on commit 11a6c72

Please sign in to comment.