AI 资讯
TypeScript Generic Constraints in Depth: `extends`, `keyof`, and the Patterns That Prevent Runtime Errors
TypeScript Generic Constraints in Depth: extends , keyof , and the Patterns That Prevent Runtime Errors This article was written with the assistance of AI, under human supervision and review. Most TypeScript runtime errors stem from unconstrained generics that accept anything and crash on nothing. Teams write function get<T>(obj: T, key: string) and ship code that compiles cleanly but throws Cannot read property 'undefined' of undefined in production. The compiler stays silent because the generic accepts any type and the key accepts any string—no constraint exists to prove the key belongs to the object. Generic constraints solve this by restricting what types a generic parameter can accept. The extends keyword establishes a boundary—the generic must satisfy a specific shape. The keyof operator extracts valid keys from that shape. Together they form a type-level contract that makes illegal property access unrepresentable. The corrected signature function get<T, K extends keyof T>(obj: T, key: K): T[K] proves at compile time that key exists on obj , eliminating the entire class of property-access errors. This distinction is critical. Unconstrained generics provide no safety beyond what any offers. Constrained generics encode domain rules directly into the type system, shifting entire categories of bugs left from runtime to compile time. The patterns that follow demonstrate how production codebases use extends and keyof to build type-safe APIs that fail fast during development instead of silently in production. Key Takeaways Generic constraints with extends restrict type parameters to specific shapes, preventing the compiler from accepting types that would cause runtime failures. The keyof operator extracts object keys as a union type, enabling type-safe property access when combined with extends keyof constraints. Combining T extends SomeType with K extends keyof T creates a compile-time proof that a key exists on an object, eliminating property-access errors. Conditi
AI 资讯
How I Let an AI Agent Save a Draft on DEV
Reading a public website and changing something inside a signed-in account are not the same kind of job. I wanted an AI agent to collect the first 10 Hacker News stories, explain how it gathered them, and place that work inside my DEV editor. Save the article as a draft. Do not publish it. The hard part was not finding the stories. It was giving the agent enough access to finish inside my signed-in account without giving it permission to publish. That instruction contained two jobs with different access needs: Read public data from Hacker News. Change private account state by creating a draft in my signed-in DEV account. Using a full browser for the first job would add machinery and access that the result did not need. The public fetch path had neither the authenticated context nor the authority required for the second job. The useful question was not “Which browser tool should do everything?” It was “Where does this task actually cross into a browser?” Disclosure: I work on Unchained, SearchAgentSky, and Unbrowser. This article was prepared with AI assistance and reviewed before publication. The public step needed only fetch I initially opened Hacker News in a lightweight page session and queried its story links. It worked—but that did not mean it was necessary. Hacker News has a public API . The same result could be produced with ordinary HTTP: const base = " https://hacker-news.firebaseio.com/v0 " ; const ids = await fetch ( ` ${ base } /topstories.json` ). then ( r => r . json ()); const stories = await Promise . all ( ids . slice ( 0 , 10 ). map ( async ( id , index ) => { const story = await fetch ( ` ${ base } /item/ ${ id } .json` ). then ( r => r . json ()); return { rank : index + 1 , title : story . title , url : story . url ?? `https://news.ycombinator.com/item?id= ${ id } ` }; })); console . log ( JSON . stringify ( stories , null , 2 )); At 2026-07-19T03:19:04Z , the page query returned 30 Hacker News story anchors. At 2026-07-19T03:35:29.670Z , fetch
科技前沿
OPERATING SYSTEM
**🙄 فى كتاب chapter الصدمة دي هي بالظبط اللي حسيت بيها وأنا بقرأ أول “operating system: three easy Pieces “ ‘OSTEP’. 🖤اهلا بيكم ! يارب تكونوا بخير 💯 حابه اشارك معاكم رحلتى مع قراءة الكتاب ونستفيد منه سوا قبل ما نعرف هو !!!! ولا لا OS is virtual machine 🤔 !!!!دا يعنى ايه ووظيفته ايه OS تعالوا الاول نعرف ال موجودة فى الكمبيوتر ولا لا ؟؟؟؟ RAM وال CPUزى ال HARDWARE وهل هو قطعة ::هنبدأ من الاخر موجود على الكمبيوتر SW هو عبارة عن HW يسيدى مش قطعة OSال .على الجهازINSTALL ولازم يبقى ووظيفته ايه؟؟؟ OS طب يعنى ايه ‘OS’ اختصار “OPERATING SYSTEM”. .“يعنى نظام تشغيل “ .👁🗨👁🗨 تعالوا نعرف معنى ” نظام تشغيل” ونفسرها نظام تشغيل يعنى مسئول عن 1_ “HWالنظام “من غيره مش هيبقى فيه نظام خصوصا لقطع ال . يعنى بناخد منه الاذن للعمليات HW ببعضه وكمان بيدير ال HWيعنى هو بيربط ال 👏 . (Order)من الاخر بيخلق “النظام” 2_.”التشغيل “هو المسئول عن تشغيل البرامج Learn about Medium’s values هو اللي بيتحكم في دورة حياة البرنامج بالكامل؛هو اللي بيبدأ تشغيله في الذاكرة،OSيعني الـ وبيحدد هو محتاج إيه من إمكانيات الجهاز عشان يشتغل بكفاءة وبيفضل مراقبه ويحميه طول ما هوشغال ، ولحد ما تقفليه بنفسك 🌹 .ويقوم هو بتنظيف الذاكرة وتوفير المساحة لغيره 🧐::وظيفته بقا بيخلي البرنامج يشتغل بسهولة:1️⃣ لأنه بيخلق للبرنامج بيئة وهمية مريحة، وبيخفي عنه كل التعقيدات والأسلاك بتاعة الهاردوير عشان يشتغل بسلاسة 2️⃣: بيسمح للبرامج إنها تشارك الذاكرة بين كل البرامج بالعدل RAM بيشتغل كعسكري مرور بيوزع مساحة الـ . وبيحمي كل برنامج في مساحته الخاصة 3️⃣: بيمكن البرامج إنها تتعامل مع الأجهزة بيعمل كـ “وسيط” أو مترجم بيوصل كود البرنامج بالقطع الحقيقية (زي الشاشة أو الهارد) .عشان ينفذ أوامره فوراً بيعمل التلات حاجات دول إزاي في نفس الوقت وبمنتهى السلاسة؟ ؟؟؟OS طب الـ بيعملهم يسيدى عن طريق أكبر خدعة سحرية في عالم الكمبيوتروهي الـ Virtualization👌 كنت حابة جداً أكلمكم المرة دي عن خدعة الـ “Virtualization” 💎 😌👁👁اللي اتكلمنا عليها في العنوان، بس لقيت البوست هيبقى طويل أوي عليكم ✔🔥!!وعشان متعبكمش معايا.. هنخليها للبوست الجاي إن شاء الله 💯✅!!بيعمل الخدعة دي إزاي OSاستنوا البوست الجاى عشان نعرف الـ 💋.دمتم بخير **
AI 资讯
Birdfy’s solar-powered smart feeder is down to one of its best prices
Birdfy has kicked off a midyear sale, taking up to 40 percent off a range of its smart bird feeders. One of the best deals is on Netvue’s Birdfy Feeder AI-Powered Smart Bird Feeder with Camera, which has dropped to $149.99 at Birdfy and is its second-best price to date. The bundle, which includes a […]
开发者
Beyond Happy Path Engineering: Time
Clock drift, deadline mismatches, retries, and TTL behavior keep causing real incidents. Network companion: https://blog.gaborkoos.com/posts/2026-07-01-Beyond-Happy-Path-Engineering-the-Network/ submitted by /u/OtherwisePush6424 [link] [留言]
AI 资讯
‘Odyssey’ director Christopher Nolan calls AI an obvious ‘Trojan horse’
"Everybody knows the Greeks are inside."
AI 资讯
Speech To Markdown
Harness local AI for notes Discussion | Link
AI 资讯
Prelint
Prevent product drift in AI-written code Discussion | Link
AI 资讯
US Marshals arrest the Tate brothers in Miami
The manosphere influencers Andrew and Tristan Tate were arrested Saturday in Miami by US Marshals in relation to new rape and sex trafficking charges in England. According to the Associated Press, British authorities are seeking the brothers' extradition. The new charges facing Andrew Tate include seven counts of rape, three of sex trafficking, three counts […]
AI 资讯
Nonprofit Current AI is racing to build the World Wide Web of AI, free for all
Current AI, a non-profit building AI that leaves no one culture behind, has made remarkable progress across devices, AI chat and more.
AI 资讯
The Clapper was a bad smart home gadget — and a viral sensation
Clap on. Clap off. Well, more like, Clap, pause for half a beat but no longer because otherwise it'll stop hearing you, clap again because you waited too long, clap louder and faster, that didn't work, clap two more times, and suddenly: on. The Clapper didn't always work - and even when it did, it […]
开源项目
🔥 seakee / CPA-Manager-Plus - A self-hosted CPA / CLIProxyAPI management panel and observa
GitHub热门项目 | A self-hosted CPA / CLIProxyAPI management panel and observability dashboard for requests, usage, cost, quota, failures, and account health. | Stars: 1,907 | 393 stars this week | 语言: TypeScript
开源项目
🔥 bytecodealliance / wasmtime - A lightweight WebAssembly runtime that is fast, secure, and
GitHub热门项目 | A lightweight WebAssembly runtime that is fast, secure, and standards-compliant | Stars: 18,382 | 17 stars today | 语言: Rust
开源项目
🔥 cocoindex-io / cocoindex - Incremental engine for long horizon agents 🌟 Star if you lik
GitHub热门项目 | Incremental engine for long horizon agents 🌟 Star if you like it! | Stars: 10,904 | 52 stars today | 语言: Rust
开源项目
🔥 Gitlawb / openclaude - runs anywhere. uses anything
GitHub热门项目 | runs anywhere. uses anything | Stars: 30,148 | 31 stars today | 语言: TypeScript
开源项目
🔥 super-productivity / super-productivity - Super Productivity is an advanced todo list app with integra
GitHub热门项目 | Super Productivity is an advanced todo list app with integrated Timeboxing and time tracking capabilities. It also comes with integrations for Jira, GitLab, GitHub and Open Project. | Stars: 20,717 | 28 stars today | 语言: TypeScript
开源项目
🔥 pucherot / Pi.Alert - WIFI / LAN intruder detector. Check the devices connected an
GitHub热门项目 | WIFI / LAN intruder detector. Check the devices connected and alert you with unknown devices. It also warns of the disconnection of "always connected" devices | Stars: 2,695 | 18 stars today | 语言: JavaScript
开源项目
🔥 GoogleChrome / chrome-extensions-samples - Chrome Extensions Samples
GitHub热门项目 | Chrome Extensions Samples | Stars: 17,673 | 4 stars today | 语言: JavaScript
开源项目
🔥 evidence-dev / evidence - Business intelligence as code: build fast, interactive data
GitHub热门项目 | Business intelligence as code: build fast, interactive data visualizations in SQL and markdown | Stars: 6,656 | 57 stars today | 语言: JavaScript
开源项目
🔥 Canner / WrenAI - GenBI (Generative BI) for AI agents, an open-source, governe
GitHub热门项目 | GenBI (Generative BI) for AI agents, an open-source, governed text-to-SQL through an open context layer that turns natural-language questions into trusted dashboards, charts, and SQL across 20+ data sources, such as BigQuery, Snowflake, PostgreSQL, ClickHouse, Amazon Redshift, Databricks and more. | Stars: 16,057 | 96 stars today | 语言: Python