denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
97.33k stars 5.36k forks source link

`Deno.Signal` does not exist on type `typeof Deno` showed even with `--unstable` flag on Deno 1.14 #12119

Closed lambdalisue closed 3 years ago

lambdalisue commented 3 years ago

Using Deno.Signal.SIGTERM shows the following type error even we specify --unstable flag on Deno 1.14.

Check file:///Users/alisue/ghq/github.com/vim-denops/denops.vim/test.ts
error: TS2551 [ERROR]: Property 'Signal' does not exist on type 'typeof Deno'. 'Deno.Signal' is an unstable API. Did you forget to run with the '--unstable' flag, or did you mean 'signal'?
const a = Deno.Signal.SIGTERM;
               ~~~~~~
    at file:///Users/alisue/ghq/github.com/vim-denops/denops.vim/test.ts:1:16

    'signal' is declared here.
      export function signal(sig: Signal): SignalStream;
                      ~~~~~~
        at asset:///lib.deno.unstable.d.ts:651:19

The command we used was

deno test --no-run --unstable test.ts

And the code we used was

const a = Deno.Signal.SIGTERM

We know that the API changes a bit (https://deno.com/blog/v1.14#changes-to-os-signals-apis) but string version didn't work on Windows so we need to stick on Deno.Signal.SIGTERM at least for now...

lambdalisue commented 3 years ago

In case someone faced similar issue, our workaround for this issue for now is Does not work.

// deno-lint-ignore no-explicit-any
proc.kill((Deno as any).Signal.SIGTERM);
lambdalisue commented 3 years ago

I'm sorry, I thought Deno.Signal.SIGTERM is still available on Deno 1.14. My bad.