Skip to content

Instantly share code, notes, and snippets.

View lucacasonato's full-sized avatar
🖥️
Programming

Luca Casonato lucacasonato

🖥️
Programming
View GitHub Profile
setInterval(() => console.log(import.meta.url), 1000);
export default "a";
@lucacasonato
lucacasonato / README.md
Last active April 3, 2021 22:43
FetchEvent polyfill in Deno, with demo

This example demonstrates how to polyfill the "fetch" event in Deno, and gives an example for how this can be used to run Cloudflare Workers in Deno.

To try it locally run the script below, and visit http://0.0.0.0:8080:

$ deno run --allow-net https://gist.githubusercontent.com/lucacasonato/1a30a4fa6ef6c053a93f271675ef93fc/raw/efcdc8e798604e194831830fcb962b50261384b3/example-worker.js
@lucacasonato
lucacasonato / .dprintrc.json
Created March 21, 2021 23:18
dprint config for deno with tabs
{
"$schema": "https://dprint.dev/schemas/v0.json",
"projectType": "openSource",
"incremental": true,
"typescript": {
"deno": true,
"useTabs": true
},
"includes": ["**/*.{ts,tsx,js,jsx}"],
"excludes": ["**/node_modules"],
@lucacasonato
lucacasonato / lucacasonato_e1_pgp_public_key.md
Last active July 8, 2023 12:09
Luca Casonato (E1) <hello@lcas.dev>

Meta

Key ID: 808AD7C0F245EA46

Subkeys: 412A10CA3031388A, 141C8B418031A4E6, 01A83EB62563811F

Setup GPG

git config --global user.signingkey 808AD7C0F245EA46

TypeScript type resolution without probing

Supporting expressing resolution entirely in code

Problem

TypeScript’s module resolution for type definitions currently heavily relies on probing. Some examples of this are how node_modules/ folders are probed for @types/ packages when a bare specifier is imported that does not provide it’s own types, or how importing a file with a .js extension will resolve types to a sibling file with a .d.ts extension instead.

Probing is problematic for us at Deno, because we are unable to perform any kind of probing when importing files using https:// specifiers. This is because it is neither side-effect free to perform probing on https:// (ie it is observable), and it is incredibly slow because of network round trip times. Non Deno TypeScript users have also reported similar issues with probing due to reliance on network file systems (microsoft/TypeScript#11979). Additionally, probing has a performance impact for all users regardl