Token导航 LogoToken导航TokenDH.com
前端设计需要联网github未标认证来源可访问许可证需确认审计通过

excess-property-checking超额财产检查

Agent Skill

excess-property-checking 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

216

周安装

9

GitHub Stars

2

下载量

72
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:excess-property-checking(超额财产检查)
来源仓库:https://github.com/marius-townhouse/effective-typescript-skills
仓库路径:skills/excess-property-checking
安装命令:
npx skills add https://github.com/marius-townhouse/effective-typescript-skills --skill excess-property-checking
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/marius-townhouse/effective-typescript-skills --skill excess-property-checking

简介

excess-property-checking 帮助理解 TypeScript 中对象字面量的超额属性检查机制。

  • 适用于避免因拼写错误导致的类型错误和运行时异常。
  • 区分结构类型与字面量类型的行为差异,提升类型安全性。
  • 通过 GitHub 安装,需确认项目启用严格类型检查模式。
  • 建议在接口定义中合理使用 never 类型约束可选字段。

SKILL.md

Distinguish Excess Property Checking from Type Checking

Overview

Object literals get special treatment: TypeScript flags unknown properties.

This catches typos and mistakes that structural typing would miss. But it only applies to object literals - understanding this distinction prevents confusion.

When to Use This Skill

  • Assigning object literals to typed variables
  • Confused why extra properties cause errors sometimes
  • Error disappears when using intermediate variable
  • Working with optional properties where typos are likely
  • Designing interfaces with many optional fields

The Iron Rule

ALWAYS remember: Excess property checking only applies to OBJECT LITERALS.

Remember:

  • Object literal → extra properties flagged
  • Variable assignment → structural typing applies
  • Type assertions → bypass excess property checking

Detection: The "Extra Property" Error

When you see "Object literal may only specify known properties", you've triggered excess property checking.

interface Room {
  numDoors: number;
  ceilingHeightFt: number;
}

// Excess property checking: Error!
const r: Room = {
  numDoors: 1,
  ceilingHeightFt: 10,
  elephant: 'present',
  // ~~~~~~~ Object literal may only specify known properties,
  //         and 'elephant' does not exist in type 'Room'
};

// Same value via intermediate variable: No error!
const obj = {
  numDoors: 1,
  ceilingHeightFt: 10,
  elephant: 'present',
};
const r2: Room = obj;  // OK - structural typing allows this

Why Excess Property Checking Exists

Structural typing is powerful but permissive. It allows extra properties, which can hide bugs:

interface Options {
  title: string;
  darkMode?: boolean;
}

function createWindow(options: Options) {
  if (options.darkMode) {
    setDarkMode();
  }
}

// Without excess property checking, this typo would be silent:
createWindow({
  title: 'Spider Solitaire',
  darkmode: true  // lowercase 'm' - TYPO!
  // ~~~~~~~ Object literal may only specify known properties,
  //         but 'darkmode' does not exist in type 'Options'.
  //         Did you mean to write 'darkMode'?
});

When Excess Property Checking Applies

ContextExcess Property Checking?
Object literal assigned to typed variableYes
Object literal as function argumentYes
Object literal as return valueYes
Variable assigned to typed variableNo
Type assertionNo
interface Point { x: number; y: number; }

// Object literal - checking applies
const p1: Point = { x: 1, y: 2, z: 3 };  // Error: 'z' not in Point

// Variable - checking does NOT apply
const temp = { x: 1, y: 2, z: 3 };
const p2: Point = temp;  // OK

// Type assertion - checking does NOT apply
const p3 = { x: 1, y: 2, z: 3 } as Point;  // OK (but bad practice)

When Excess Property Checking Helps

Catching Typos in Optional Properties

interface Config {
  logLevel?: 'debug' | 'info' | 'warn' | 'error';
  timeout?: number;
  retries?: number;
}

const config: Config = {
  loglevel: 'debug',  // Error: Did you mean 'logLevel'?
  timeout: 5000,
};

Preventing Wrong Property Names

interface User {
  firstName: string;
  lastName: string;
}

const user: User = {
  first_name: 'John',  // Error: Did you mean 'firstName'?
  last_name: 'Doe',    // Error: Did you mean 'lastName'?
};

Bypassing Excess Property Checking (When Intentional)

Use Index Signature for Known Extra Properties

interface Options {
  darkMode?: boolean;
  [otherOptions: string]: unknown;
}

const o: Options = { darkmode: true };  // OK now

Use Intermediate Variable

const options = { title: 'Game', extraProp: true };
createWindow(options);  // OK - excess checking skipped

Weak Types: A Related Check

"Weak" types have only optional properties. TypeScript adds a special check:

interface LineChartOptions {
  logscale?: boolean;
  invertedYAxis?: boolean;
  areaChart?: boolean;
}

const opts = { logScale: true };  // Note: capital 'S'
setOptions(opts);
// ~~~~ Type '{ logScale: boolean; }' has no properties in common
//      with type 'LineChartOptions'

This check applies even through intermediate variables (unlike regular excess property checking).

Common Mistakes

Mistake 1: Expecting Structural Typing to Catch Typos

// ❌ Typo passes silently because no excess property checking
const options = { darkmode: true };  // lowercase 'm'
const config: Options = options;     // No error!

// ✅ Use object literal for catching typos
const config: Options = { darkmode: true };  // Error caught!

Mistake 2: Using Type Assertion to Silence Errors

// ❌ Assertion bypasses the check
const config = { darkmode: true } as Options;

// ✅ Fix the typo instead
const config: Options = { darkMode: true };

Mistake 3: Confusion About Why Error Disappears

// This has an error
const p: Point = { x: 1, y: 2, z: 3 };

// Why doesn't this?
const temp = { x: 1, y: 2, z: 3 };
const p: Point = temp;

// Answer: Excess property checking only applies to object literals!

Pressure Resistance Protocol

1. "Just Add as Type"

Pressure: "The type assertion makes the error go away"

Response: Assertions bypass safety checks. Fix the actual issue.

Action: Correct the property name or update the type definition.

2. "TypeScript Is Being Too Strict"

Pressure: "Extra properties shouldn't matter"

Response: This catches real bugs like typos in optional fields.

Action: If you truly need extra properties, use an index signature.

3. "It Works With a Variable"

Pressure: "Just use an intermediate variable to avoid the error"

Response: That hides bugs. The error exists for a reason.

Action: Investigate why the extra property exists.

Red Flags - STOP and Reconsider

  • Using type assertion to silence excess property errors
  • Creating intermediate variables just to avoid checks
  • Confused why some assignments error and others don't
  • Thinking TypeScript is inconsistent about extra properties

Common Rationalizations (All Invalid)

ExcuseReality
"It's just an extra property"Extra properties often indicate typos
"Structural typing allows this"Object literals have stricter rules for good reason
"The assertion fixes it"Assertions hide bugs, they don't fix them

Quick Reference

ScenarioExcess Property Check?Example
Object literal to typed varYesconst x: T = {...}
Object literal as argumentYesfn({...})
Variable to typed varNoconst temp = {...}; const x: T = temp;
Type assertionNo{...} as T
Weak type (via variable)Checks for common propsSpecial case

The Bottom Line

Excess property checking catches bugs that structural typing would miss.

It only applies to object literals, not variables. This is intentional - it catches typos in property names, especially for optional properties. Don't bypass it with assertions or intermediate variables; instead, fix the underlying issue.

Reference

Based on "Effective TypeScript" by Dan Vanderkam, Item 11: Distinguish Excess Property Checking from Type Checking.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.85%
按下载量换算27

Claude

28.96%
按下载量换算21

Cursor

20.71%
按下载量换算15

Gemini CLI

10.47%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills