MCPcopy Index your code
hub / github.com/tinyplex/tinybase / tsCheck

Function tsCheck

gulpfile.mjs:483–526  ·  view source on GitHub ↗
(dir)

Source from the content-addressed store, hash-verified

481};
482
483const tsCheck = async (dir) => {
484 const path = await import('path');
485 const {default: tsc} = await import('typescript');
486 const {analyzeTsConfig} = await import('ts-unused-exports');
487 const {fileNames, options} = await getTsOptions(dir);
488 const results = tsc
489 .getPreEmitDiagnostics(
490 tsc.createProgram(
491 fileNames.filter(
492 (fileName) => !fileName.startsWith('test/unit/core/types'),
493 ),
494 options,
495 ),
496 )
497 .filter((result) => !result.file?.fileName.includes('/node_modules/'));
498 if (results.length > 0) {
499 const resultText = results
500 .map((result) => {
501 const {file, messageText, start} = result;
502 const {line, character} = file.getLineAndCharacterOfPosition(start);
503 return `${file.fileName}:${line}:${character}\n${JSON.stringify(
504 messageText,
505 )}`;
506 })
507 .join('\n\n');
508 throw resultText;
509 }
510 const unusedResults = Object.entries(
511 analyzeTsConfig(`${path.resolve(dir)}/tsconfig.json`, [
512 '--excludeDeclarationFiles',
513 '--excludePathsFromReport=' +
514 'build.ts;ui-react/common.ts;' +
515 ALL_MODULES.map((module) => `${module}.ts`).join(';'),
516 ]).unusedExports,
517 )
518 .map(
519 ([file, exps]) =>
520 `${file}: ${exps.map((exp) => exp.exportName).join(', ')}`,
521 )
522 .join('\n');
523 if (unusedResults != '') {
524 throw `Unused exports for ${dir} in: \n${unusedResults}`;
525 }
526};
527
528const compileModule = async (module, dir = DIST_DIR, min = false) => {
529 const {default: esbuild} = await import('rollup-plugin-esbuild');

Callers 1

tsFunction · 0.85

Calls 1

getTsOptionsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…