9148c358d0
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
5.8 KiB
5.8 KiB
id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
| id | title | category | status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | verification_status | tags | raw_sources | last_reinforced | github_commit | tech_stack | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| wiki-2026-0508-ambient-declarations | Ambient Declarations | 10_Wiki/Topics | verified | self |
|
none | A | 0.9 | applied |
|
2026-05-10 | pending |
|
Ambient Declarations
매 한 줄
"매 type-only declarations — 매 describe shapes that exist elsewhere". 매 TypeScript (Anders Hejlsberg, 2012) 매 since v0.8 매
.d.tsfiles. 매 DefinitelyTyped (2014) → @types/* npm scope (2016) → TS 4.x package "exports" + types (2021) → TS 5.7 (2026 stable) 매--isolatedDeclarations매 fast .d.ts emit.
매 핵심
매 ambient 의 의미
- Ambient: 매 declaration only, 매 no implementation. 매 emit 매 not 매 produce JS.
.d.tsfiles: 매 declarations only. 매 imports 매 type-erased.declarekeyword: 매 inside.tsfiles 매 declare 매 ambient binding.
매 use cases
- Type 3rd-party JS library (no built-in types).
- Type global runtime (browser, Node, custom).
- Augment existing module/global.
- Distribute types separate from JS (npm "types" field).
- Emit minimal API surface from TS source.
매 응용
- @types/ packages* — DefinitelyTyped community types.
- Global augmentation — extend
Window,process.env. - Module augmentation — add methods to existing module's interface.
- Asset typing —
*.svg*.cssimport as module.
💻 패턴
Basic ambient module (3rd-party JS)
// types/legacy-lib.d.ts
declare module "legacy-lib" {
export function greet(name: string): string;
export interface Config { timeout: number }
export default class Client {
constructor(cfg: Config);
send(msg: string): Promise<void>;
}
}
Ambient global
// types/globals.d.ts
declare global {
var __APP_VERSION__: string;
interface Window {
analytics?: { track(event: string, props?: object): void };
}
namespace NodeJS {
interface ProcessEnv {
DATABASE_URL: string;
REDIS_URL: string;
}
}
}
export {}; // 매 file 의 module 의 만듦 — augmentation 매 valid
Module augmentation (extend existing)
// add-toJSON.d.ts
import "express";
declare module "express" {
interface Request {
user?: { id: string; role: "admin" | "user" };
requestId: string;
}
}
// Now in any file: req.user is typed
Asset module typing
// assets.d.ts
declare module "*.svg" {
const url: string;
export default url;
}
declare module "*.css" {
const classes: { readonly [key: string]: string };
export default classes;
}
declare module "*.json" {
const value: unknown;
export default value;
}
Triple-slash directive (legacy, still used)
/// <reference types="node" />
/// <reference path="./vendor.d.ts" />
declare inside .ts file
// app.ts
declare const FEATURE_FLAGS: { newCheckout: boolean };
declare function gtag(cmd: string, ...args: unknown[]): void;
if (FEATURE_FLAGS.newCheckout) gtag("event", "view_new_checkout");
Conditional types via ambient
// react-augmentation.d.ts
import "react";
declare module "react" {
interface CSSProperties {
"--theme-color"?: string;
"--theme-radius"?: string;
}
}
// Now: <div style={{ "--theme-color": "blue" }}/> typechecks
tsconfig declarations
{
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": false,
"isolatedDeclarations": true,
"types": ["node", "vitest/globals"],
"typeRoots": ["./node_modules/@types", "./types"]
}
}
Library author (publish .d.ts)
// package.json
{
"name": "my-lib",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
}
}
매 결정 기준
| 상황 | Approach |
|---|---|
| 3rd-party JS lib, no types | Check @types/lib first; else write .d.ts |
| Add field to req/res in Express/Fastify | Module augmentation |
| Type custom Vite/Webpack asset import | Wildcard module decl |
| Globals (browser/Node) | declare global { ... } + export {} |
| Library publish | TS source → emit .d.ts (declaration: true) |
기본값: 매 prefer @types/* package, 매 fall back 매 hand-written .d.ts, 매 augmentation 매 last resort (subtle to debug).
🔗 Graph
- 부모: TypeScript · TypeScript 타입 시스템 (TypeScript Type System)
- 변형: Global Augmentation
- 응용: DefinitelyTyped
- Adjacent: tsconfig.json · Conditional Types
🤖 LLM 활용
언제: 매 untyped JS interop, 매 global runtime typing, 매 library distribution, 매 framework extension points.
언제 X: 매 internal TS code (use regular interface/type), 매 enforcement need (declarations 매 erased — runtime check 매 separate).
❌ 안티패턴
anyeverywhere in .d.ts: 매 type loss 의 propagation. 매unknown+ narrow.- Augmenting without
export {}: 매 file 매 script 의 treated, 매 augmentation silently fails. - Triple-slash in modern code: 매 prefer
tsconfig "types"array. - Global pollution: 매 every helper 매 global 의 declare → namespace clashes.
🧪 검증 / 중복
- Verified (TypeScript Handbook "Declaration Files", DefinitelyTyped contribution guide, TS 5.7 release notes).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — full content (.d.ts, declare, augmentation patterns) |