<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>类型驱动 on PlumePHP</title><link>https://plumephp.com/tags/%E7%B1%BB%E5%9E%8B%E9%A9%B1%E5%8A%A8/</link><description>Recent content in 类型驱动 on PlumePHP</description><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Mon, 28 Sep 2026 12:00:00 +0800</lastBuildDate><atom:link href="https://plumephp.com/tags/%E7%B1%BB%E5%9E%8B%E9%A9%B1%E5%8A%A8/index.xml" rel="self" type="application/rss+xml"/><item><title>类型驱动开发：以类型为契约的 Type-First 工程实践</title><link>https://plumephp.com/typescript-type-first-development/</link><pubDate>Mon, 28 Sep 2026 12:00:00 +0800</pubDate><guid>https://plumephp.com/typescript-type-first-development/</guid><description>&lt;h2 id="引言"&gt;引言&lt;/h2&gt;
&lt;p&gt;TDD（测试驱动开发）主张「先写失败测试，再写实现」；Type-First 主张「先写类型，再写实现」——让 &lt;strong&gt;TypeScript 编译器在动手写逻辑前就把接口契约焊死&lt;/strong&gt;。这不是「多用类型」的口号，而是一套可执行的流程：定义输入/输出类型 → 用 &lt;code&gt;satisfies&lt;/code&gt;/泛型约束锁住形状 → 实现逻辑直到「编译通过 + 类型收窄正确」→ 用测试验证行为而非形状。类型与测试从此各司其职：&lt;strong&gt;类型管形状，测试管行为&lt;/strong&gt;。本文将把这条路径拆成可落地的工程实践。&lt;/p&gt;</description></item></channel></rss>