face-hh / bussin

An esolang in TypeScript, for heaven's sake.
Apache License 2.0
566 stars 37 forks source link

trying to run a bsx file returned the error "unable to compile typescript #52

Closed voidwyrm-2 closed 7 months ago

voidwyrm-2 commented 7 months ago

using MacBook, btw

bussin % cd bussin-esolang 
bussin-esolang % npm run bussin ../helloworld.bsx

> bussin
> npx ts-node src/main.ts ../helloworld.bsx

/Users/[user]/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:859
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
src/main.ts:5:27 - error TS2307: Cannot find module 'readline/promises' or its corresponding type declarations.

5 import * as readline from 'readline/promises';
                            ~~~~~~~~~~~~~~~~~~~
src/main.ts:6:30 - error TS2307: Cannot find module 'fs' or its corresponding type declarations.

6 import { readFileSync } from "fs";
                               ~~~~
src/main.ts:10:12 - error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

10     input: process.stdin,
              ~~~~~~~
src/main.ts:11:13 - error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

11     output: process.stdout
               ~~~~~~~
src/main.ts:14:14 - error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

14 const args = process.argv;
                ~~~~~~~
src/main.ts:25:16 - error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor.  Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.

25 async function run(filename: string) {
                  ~~~
src/main.ts:32:18 - error TS2550: Property 'endsWith' does not exist on type 'string'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later.

32     if (filename.endsWith('.bsx')) {
                    ~~~~~~~~
src/main.ts:33:52 - error TS2304: Cannot find name '__dirname'.

33         const currencies = JSON.parse(readFileSync(__dirname + "/../src/utils/currencies.json", "utf-8")); // should work for /src/ and /dist/
                                                      ~~~~~~~~~
src/main.ts:38:24 - error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later.

38     const argMap = new Map();
                          ~~~
src/main.ts:39:19 - error TS7006: Parameter 'value' implicitly has an 'any' type.

39     args.forEach((value, index) => {
                     ~~~~~
src/main.ts:39:26 - error TS7006: Parameter 'index' implicitly has an 'any' type.

39     args.forEach((value, index) => {
                            ~~~~~
src/main.ts:51:16 - error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor.  Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option.

51 async function repl() {
                  ~~~~

    at createTSError (/Users/[user]/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/Users/[user]/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/Users/[user]/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/Users/[user]/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/Users/[user]/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1617:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/[user]/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) {
  diagnosticCodes: [
    2307, 2307, 2580,
    2580, 2580, 2705,
    2550, 2304, 2583,
    7006, 7006, 2705
  ]
}
ItsTato commented 7 months ago

What does your tsconfig.json look like?

Symmettry commented 7 months ago

Gotta get the types.

npm i —save-dev @types/node

Symmettry commented 7 months ago

I think phone might’ve screwed that reply, so just retype it if it doesn’t work

voidwyrm-2 commented 7 months ago

npm i —save-dev @types/node

one of the outputs of this command is 2 vulnerabilities (1 low, 1 moderate), should I be worried about that?

voidwyrm-2 commented 7 months ago

it does now work, though

ItsTato commented 7 months ago

it does now work, though

You should mark the issue as resolved then

Symmettry commented 7 months ago

npm i —save-dev @types/node

one of the outputs of this command is 2 vulnerabilities (1 low, 1 moderate), should I be worried about that?

no