D
Deno

help

Declaration merging for external packages

TTheBejbiborn8/6/2023
Hi! I'm using unoCSS with Deno Fresh and have been attempting to use the attributify preset (https://unocss.dev/presets/attributify#preact). However for the type inference to work this preset requires to override preact's JSXInternal namespace declaration (which I think is quite a popular pattern with frontend / fullstack frameworks) and I can't quite get how to do it in Deno (and if it's even possible). Tl;DR How can one do the following in Deno?
declare module 'preact' {
namespace JSX {
interface HTMLAttributes extends AttributifyAttributes {}
}
}
declare module 'preact' {
namespace JSX {
interface HTMLAttributes extends AttributifyAttributes {}
}
}
UnoCSS
The instant on-demand Atomic CSS engine
Mmarvinh.8/6/2023
Do you have a repo to play with? Would love to take a look
TTheBejbiborn8/6/2023
I'm not sure if there is a need for any particular setup / repo to test this. It's not even that strictly related to Fresh, I think it's a generic topic (declaration merging with namespaces declared by external packages). I think you can start a new empty Fresh project with deno run -A -r https://fresh.deno.dev and just try to override preact's JSXInternal namespace with anything.
Mmarvinh.8/6/2023
I've had the need to add new attributes to DOM elements in JSX in this PR https://github.com/denoland/fresh/pull/1532/files#diff-57f52880cb65e10f7786f9329753db959231602f3a292ff85c396997b6123ebaR22-R28 Does that work with uno? (haven't used uno in the past, so no idea)
TTheBejbiborn8/6/2023
That works actually! Thanks! Leaving the snippet for anybody who finds this thread:
declare global {
namespace preact.createElement.JSX {
// deno-lint-ignore no-empty-interface
interface HTMLAttributes extends AttributifyAttributes {}
}
}
declare global {
namespace preact.createElement.JSX {
// deno-lint-ignore no-empty-interface
interface HTMLAttributes extends AttributifyAttributes {}
}
}
I keep this in my uno.config.ts for convenience. To make this thread more generic for module augumentation (not strictly preact / deno fresh) could you explain how did you get to the preact.createElement.JSX? (for anybody looking for the module augumentation typescript docs: https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation)

Looking for more? Join the community!

Recommended Posts
Deno.serve AbortController onError. How?When I run my new Deno.serve() updated implementation I get a type error. Perhaps I'm doing it wrongLocalStorage OverrideI'm using a library (@supabase/supabase-js), and I'm compiling my Deno app into an executable, howevBad implementation of X25519?I can't generate a shared secret with the current implementation of X25519 ```ts const alice = awaiResize image/convert on uploadHi there, I want to store images uploaded in webp format at 200x200px. Has anyone done something likI cant import the Zustand module from deno.I leave a photo of what it shows when I put the url to the import map. And try to cache the module.Sub hosting SAAS appWhat technologies are behind the Deno Deploy feature, where you can set up your own domain name? I What should my entry point be on Deno Deploy?Only ever used firebase before. I'm getting a 502 bad gateway error when deploying my website.tsParticles & DenoHi, I’m working on a personal project with Deno & Lume. I’m trying to use tsParticles with preact. Looking for a library to pretty print </br>, <a>, etc tagsAs that title says, I'm looking for a library that can pretty print a string containing the mentioneImporting `puppeteer-cluster` from esm.sh causes `does not provide an export named 'default'` errorWhen importing `https://esm.sh/puppeteer-cluster@0.23.0` I get the following error: ``` error: UncauDeno linting not workingHello everyone, I enabled deno for a subpath in my project (`./supabase`) but unfortunately I'm not deno_pythonI'm trying to use Python with Deno with https://deno.land/x/python@0.2.7 What should I do to enable Deno VS Code plugin too aggressive in auto-completionI'm new to Deno and learning through some tutorials. I'm using VS Code and have the Deno plugin enabhow to exit all async command in deno task?consider this code ```json { "tasks": { "dev-server": "deno run --watch --allow-read --allow-nnode-pre-gyp install failing inside docker containerI'm building something that depends on a library with a native component (pulsar-client) and it doesSet a cookie in GET and retrieve in POSTbeen tryinig to do this for a couple hours now. Basically I want a way to return the user to the pr