rip-lang 3.10.0 → 3.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/typecheck.js +16 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rip-lang",
3
- "version": "3.10.0",
3
+ "version": "3.10.2",
4
4
  "description": "A modern language that compiles to JavaScript",
5
5
  "type": "module",
6
6
  "main": "src/compiler.js",
package/src/typecheck.js CHANGED
@@ -11,6 +11,7 @@
11
11
  // type errors mapped back to Rip source positions.
12
12
 
13
13
  import { Compiler } from './compiler.js';
14
+ import { createRequire } from 'module';
14
15
  import { readFileSync, existsSync, readdirSync } from 'fs';
15
16
  import { resolve, relative, dirname } from 'path';
16
17
  import { buildLineMap } from './sourcemaps.js';
@@ -210,9 +211,19 @@ const dim = (s) => isColor ? `\x1b[2m${s}\x1b[0m` : s;
210
211
  const bold = (s) => isColor ? `\x1b[1m${s}\x1b[0m` : s;
211
212
 
212
213
  export async function runCheck(targetDir, opts = {}) {
213
- const ts = await import('typescript').then(m => m.default || m);
214
214
  const rootPath = resolve(targetDir);
215
215
 
216
+ let ts;
217
+ try {
218
+ const req = createRequire(resolve(rootPath, 'package.json'));
219
+ ts = req('typescript');
220
+ } catch {
221
+ try { ts = await import('typescript').then(m => m.default || m); } catch {
222
+ console.error('TypeScript is required for type checking. Install with: bun add -d typescript');
223
+ return 1;
224
+ }
225
+ }
226
+
216
227
  if (!existsSync(rootPath)) {
217
228
  console.error(red(`Error: directory not found: ${targetDir}`));
218
229
  return 1;
@@ -351,7 +362,10 @@ export async function runCheck(targetDir, opts = {}) {
351
362
  const totalFiles = compiled.size;
352
363
 
353
364
  if (totalErrors === 0 && totalWarnings === 0) {
354
- console.log(`\n${bold('✓')} ${typedFiles} typed file${typedFiles !== 1 ? 's' : ''} checked, no errors found`);
365
+ const summary = typedFiles > 0
366
+ ? `${typedFiles} typed file${typedFiles !== 1 ? 's' : ''} checked, no errors found`
367
+ : `${totalFiles} file${totalFiles !== 1 ? 's' : ''} found, none have type annotations`;
368
+ console.log(`\n${bold('✓')} ${summary}`);
355
369
  if (compileErrors > 0) {
356
370
  console.log(dim(` (${compileErrors} file${compileErrors !== 1 ? 's' : ''} had compile errors)`));
357
371
  }