razetime / bqn-vscode

BQN programming language vscode plugin (symbol input, syntax highlighting)
MIT License
22 stars 6 forks source link

Add prettier/eslint, rewrite extension.ts, change shortcuts, and other cleanups #12

Closed mk12 closed 1 year ago

mk12 commented 1 year ago

This is a stack of five changes to make this extension do what I want. I've made it in separate commits so they can be reviewed in turn. Feel free to accept some or all of them.

1. Add prettier, eslint, and minor fixes

2. Refactor and clean up extension

3. Improve keyboard shortcuts

4. Add clearImportsAndLoadScript

5. Add saveBeforeLoadScript config setting

razetime commented 1 year ago

Wow. I only have one problem, \\d should give \d, since every input method maps backslash to backslash. Otherwise i think this is amazing and I'll merge it after a test soon.

mk12 commented 1 year ago

Ah, yeah that makes sense. I'll amend it so that \\ produces a single backslash. (My goal in rewriting that logic was just to make it work consistently, since before it seemed to not work sometimes though I couldn't find an exact repro.)

mk12 commented 1 year ago

All right, I changed the backslash behavior and also added a 5th commit that adds a saveBeforeLoadScript setting.

razetime commented 1 year ago

I am getting a strange error when i run vsce on the new code:

$ vsce package
Executing prepublish script 'npm run vscode:prepublish'...

> bqn-language@0.1.0 vscode:prepublish
> npm run compile

> bqn-language@0.1.0 compile
> tsc -p ./

src/extension.ts:123:21 - error TS2769: No overload matches this call.
  The last overload gave the following error.
    Argument of type '(Promise<void> | Thenable<boolean>)[]' is not assignable to parameter of type 'Iterable<void | PromiseLike<void>>'.
      The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types.
        Type 'IteratorResult<Promise<void> | Thenable<boolean>, any>' is not assignable to type 'IteratorResult<void | PromiseLike<void>, any>'.
          Type 'IteratorYieldResult<Promise<void> | Thenable<boolean>>' is not assignable to type 'IteratorResult<void | PromiseLike<void>, any>'.
            Type 'IteratorYieldResult<Promise<void> | Thenable<boolean>>' is not assignable to type 'IteratorYieldResult<void | PromiseLike<void>>'.
              Type 'Promise<void> | Thenable<boolean>' is not assignable to type 'void | PromiseLike<void>'.
                Type 'Thenable<boolean>' is not assignable to type 'void | PromiseLike<void>'.
                  Type 'Thenable<boolean>' is not assignable to type 'PromiseLike<void>'.
                    Types of property 'then' are incompatible.
                      Type '{ <TResult>(onfulfilled?: ((value: boolean) => TResult | Thenable<TResult>) | undefined, onrejected?: ((reason: any) => TResult | Thenable<TResult>) | undefined): Thenable<...>; <TResult>(onfulfilled?: ((value: boolean) => TResult | Thenable<...>) | undefined, onrejected?: ((reason: any) => void) | undefined): Thena...' is not assignable to type '<TResult1 = void, TResult2 = never>(onfulfilled?: ((value: void) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => PromiseLike<...>'.
                        Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible.
                          Type '((value: void) => any) | null | undefined' is not assignable to type '((value: boolean) => any) | undefined'.
                            Type 'null' is not assignable to type '((value: boolean) => any) | undefined'.

123   await Promise.all(tasks);
                        ~~~~~

  node_modules/typescript/lib/lib.es2015.iterable.d.ts:226:5
    226     all<T>(values: Iterable<T | PromiseLike<T>>): Promise<T[]>;
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The last overload is declared here.

Found 1 error.

 ERROR  npm failed with exit code 2
mk12 commented 1 year ago

Huh, vsce package worked for me earlier. I can investigate later today. Maybe try npm install first if you haven’t already (since one of my commits updates some dependencies)?

mk12 commented 1 year ago

Ok, yes it's because I upgraded typescript from ^3.9.10 to ^4.9.4. I reproduced your error when I tried to compile after reverting the typescript and @types/node dependencies back to their old versions. If you npm install first, then vsce package should succeed.

razetime commented 1 year ago

ah, make sense. i'll get it published today.