John Adams
`deno task dev` not working because `--watch` doesn't detect changes
Also you should consider updating your Mac. Sonoma 14.7.1 is available or you can upgrade to Squoia 15.1. Regardless, you're running nearly a whole year behind on security updates!
6 replies
`deno task dev` not working because `--watch` doesn't detect changes
If you want to test this you could try an experiment and have it log the current time, if it's not printing the new current time each time you save the file then there might be a problem.
6 replies
`deno task dev` not working because `--watch` doesn't detect changes
It's probably running correctly, when Watcher reruns your file it clears the terminal so you won't always see previous output. So if the output isn't changing then you'll have a hard time noticing that the file was rerun unless you have it print something different on each file change.
6 replies
Is there a way to use the import alias @/ using deno and vite?
You have to specify these shorthand alias names to point to actual url or packages in the
deno.json
file. If these are npm packages you can run in the terminal/command line deno install npm:<package_name>
and it will make the name alias for you. This blog has an example that might help. https://jrson.me/blog/path-aliases-with-import-maps-on-deno/ but you can also look at Deno's official documentation for it here:
https://docs.deno.com/runtime/fundamentals/configuration/#dependencies2 replies
Deno adds "| undefined" to everything
The record type is just defining object properties which function as a dictionary. In a dictionary it's possible to try to get a value which doesn't exist. For example, in your current code
objectList['itemOne']
returns a number array, but you can also do a call such as objectList['itemThree']
which doesn't exist, and will return undefined
. That's why records have return types of whatever value or undefined.
When you know for a fact that you're going to get an array back (or any other type), you can use typecasting to tell the compiler to stop warning you about the possibility for runtime errors using the as
keyword:
const numberArray: number[] = objectList['itemOne'] as number[]
Although I will note that I do not get any typescript errors when running your original code normally. This behavior is enabled by turning on additional features of the typescript compiler. Specifically I am able to get a similar result by adding this to the deno.json
:
7 replies