denoland / fresh

The next-gen web framework.
https://fresh.deno.dev
MIT License
12.53k stars 648 forks source link

Setting up a Fresh project to work with Deno KV is obscure #2344

Open skybrian opened 8 months ago

skybrian commented 8 months ago

If I create a project using ‘deno init’ then the Language Server (and therefore VS Code) can type-check code that uses Deno KV by default. (Though it won’t run unless you enable Deno KV, since it’s an unstable API.)

If I create a new Fresh project then it doesn’t work.

The reason for this is the reference declarations at the top of main.ts. To enable type checking for unstable API’s, turning on unstable API’s in either VS Code’s settings or in deno.json doesn’t work. You need to edit main.ts and add a reference declaration.

(Actually the reference declaration can be anywhere, but main.ts is the logical place to put it.)

This seems needlessly obscure. My suggestion: enable type-checking for unstable API’s by default. There is still another step to actually use them, but this is more consistent with non-Fresh projects and with the ‘deno check’ command.

skybrian commented 8 months ago

More context: Deno changed in early January to always type-check unstable API's.

See: https://github.com/denoland/deno/pull/21825