今日已更新 327 条资讯 | 累计 29089 条内容
关于我们

标签:#p

找到 12025 篇相关文章

AI 资讯

Typing Vue 3 provide/inject Without Losing Autocomplete

Strict prop types and typed emits get most of the attention in Vue 3 + TypeScript setups, but provide / inject is where type safety quietly falls apart if you use the API the way the docs show it by default. inject() without a type hint returns unknown , which means every consumer of an injected value either casts it blindly or loses autocomplete entirely — and a typo in the injection key becomes a runtime undefined instead of a compile-time error. The Default Setup Is Untyped by Construction The naive version compiles, but gives you nothing: // Provider provide ( ' theme ' , currentTheme ); // Consumer const theme = inject ( ' theme ' ); // type: unknown Nothing here catches a typo in the key string, and nothing tells the consumer what shape theme actually has. Both problems come from using a plain string as the injection key. InjectionKey Fixes Both Problems at Once Vue exports an InjectionKey<T> type specifically for this. Define it once, typed, and both provide and inject become fully type-checked against the same symbol: // keys.ts import type { InjectionKey } from ' vue ' ; export interface Theme { mode : ' light ' | ' dark ' ; accentColor : string ; } export const ThemeKey : InjectionKey < Theme > = Symbol ( ' theme ' ); // Provider import { ThemeKey } from ' ./keys ' ; provide ( ThemeKey , { mode : ' dark ' , accentColor : ' #4f46e5 ' }); // Consumer import { ThemeKey } from ' ./keys ' ; const theme = inject ( ThemeKey ); // type: Theme | undefined The | undefined in that last type isn't a quirk — it's inject being honest that a consumer might render without a matching provider above it in the tree, which is a real runtime possibility TypeScript is right to force you to handle. Handling the undefined Case Without Littering ?. Everywhere The common mistake is providing a default value to silence the undefined type instead of actually checking for it: const theme = inject ( ThemeKey , { mode : ' light ' , accentColor : ' #000 ' }); // default masks missing pro

2026-08-07 原文 →
AI 资讯

Google Quietly Dropped 12 Free AI Tools. Developers Should Probably Care.

Hello, I'm Maneshwar. I'm building git-lrc, a Micro AI code reviewer that runs on every commit. It is free and source-available on Github. Star git-lrc to help devs discover the project. Do give it a try and share your feedback. A few years ago the AI conversation looked like this. "Should I pay $20?" "No, $200." "Actually this new tool is $39/month." My wallet started looking like it had gone through a startup funding winter. Then Google quietly walked into the room and started dropping free AI tools like Oprah handing out cars. "You get an AI IDE!" "You get a workflow builder!" "You get a GitHub coding agent!" ...except nobody really noticed because Google announced them across five different events, Labs pages, GitHub repos, and random blog posts. So I spent some time collecting the ones developers will actually find useful. No "AI that writes your wedding speech." No "AI that guesses your spirit animal." Just tools that can actually help you ship software. Bookmark this one. 1. Pomelli https://labs.google/pomelli If you've ever launched a side project, you already know the painful truth. Building the product is fun. Writing 37 LinkedIn posts explaining the product... not so much. Pomelli takes your website, understands what your product does, builds a brand profile, then generates social posts around it. Think of it as hiring an intern that actually reads your landing page before tweeting. Would I let it post automatically? No. Would I happily let it generate the first draft so I don't stare at a blinking cursor? Absolutely. Perfect for: Indie hackers SaaS founders Open-source maintainers pretending they enjoy marketing 2. Stitch https://stitch.withgoogle.com Remember when designing an app meant opening Figma... ...moving a button 3 pixels... ...asking for feedback... ...moving it back 3 pixels? Stitch skips a surprising amount of that. You describe the interface. Or upload a sketch. Or even paste a wireframe. It generates modern UI designs and can even produce

2026-08-07 原文 →
AI 资讯

Brendan Carr officially unleashes broadcast consolidation

The era of set broadcast ownership limits is officially over, after the Federal Communications Commission (FCC) voted Thursday to end the national ownership cap rule. The agency's two Republicans, Chair Brendan Carr and Commissioner Olivia Trusty, voted to end the ownership cap, which restricts broadcast owners from holding stations that reach a combined more than […]

2026-08-07 原文 →
开源项目

How we took malware advisories beyond npm

GitHub malware advisories no longer stop at npm. Here's how we wired OpenSSF's malicious-packages data into the Advisory Database, and why we built the pipeline paranoid. The post How we took malware advisories beyond npm appeared first on The GitHub Blog .

2026-08-07 原文 →
开发者

Designing a Movement Transaction System for a Sokoban Game

Context My multiplayer game Lights Out is based on a 2D grid. Entities can only ever be in exactly one grid tile. This makes the rule evaluation really simple and understandable. However, it doesn't really feel nice to play (which you know if you've ever played any of the PuzzleScript games). At the same time, the more content is in the game, the more complex and arbitrary the game rules become. I therefore introduced the Movement Transaction System into the code base to deal with this. This includes two sides: - The gameplay code on server side deals with transactions. This bundles all movement code (including rule evaluation) into a single system. - The visualization & prediction code on client side deals with visual interpolation for moves (introducing some juice into the gameplay feel), based on the transactions managed by the server. The Transaction A single transaction includes the movement delta, a list of entities that it has affected and some flags. A transaction then undergoes several stages: - Queued : Gameplay code has requested an entity to move - Issued : The visual interpolation for the transaction has started in the client, but the entities have not been moved from a gameplay perspective - Committed : The entities have now been moved onto their new tiles, the visual interpolation is finishing - Aborted : The transaction couldn't be committed as it would've violated gameplay rules. Visual interpolation is reversed. The Visual Interpolation Whenever a transaction is issued on server-side, the server tells the clients to start a visual interpolation based on the transaction. This information includes the desired duration of the interpolation, as well as some flags (like whether to use acceleration or do a linear interpolation). The client then updates the visual interpolation every frame, until the transaction is either aborted or the target position has been reached. Simplifying Gameplay Code This new system has made the gameplay code much simpler. I c

2026-08-07 原文 →