denoland / vscode_deno

Visual Studio Code plugin for Deno
https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno
MIT License
1.47k stars 143 forks source link

Property 'cron' does not exist on type 'typeof Deno'.deno-ts(2339) #1137

Closed devsheva closed 2 months ago

devsheva commented 2 months ago

Describe the bug I have tried to enable unstable Cron API, but what i get is this Property 'cron' does not exist on type 'typeof Deno'.deno-ts(2339)

To Reproduce

deno.jsonc

{
  "unstable": ["cron"],
  "exclude": ["dist", "node_modules"],
  "compilerOptions": {
    "lib": ["deno.window", "DOM", "DOM.Iterable", "ESNext"],
    "strict": true,
    "allowJs": true
  }
}

Put this in any file


Deno.cron('Log a message', '* * * * *', () => {
  console.log('This will print once a minute.')
})

Expected behavior

It should not lead to type error.

Screenshots

Screenshot 2024-07-27 at 01 20 07

Versions

vscode: 1.91.1 deno:1.45.4 extension: 3.38.0

nayeemrmn commented 2 months ago

Include deno.unstable in compilerOptions.lib:

{
  "unstable": ["cron"],
  "exclude": ["dist", "node_modules"],
  "compilerOptions": {
    "lib": ["deno.window", "deno.unstable", "DOM", "DOM.Iterable", "ESNext"],
    "strict": true,
    "allowJs": true
  }
}
devsheva commented 2 months ago

oh, that worked. maybe it should be added to docs?