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.0 KiB
5.0 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-readonly | TypeScript readonly | 10_Wiki/Topics | verified | self |
|
none | A | 0.9 | applied |
|
2026-05-10 | pending |
|
TypeScript readonly
매 한 줄
"매 compile-time 매 immutability marker — runtime enforcement 의 X". 매 TS 의 의 의 mutation prevention 의 의 매 type-system level —
readonlykeyword,Readonly<T>,ReadonlyArray<T>,as const매 4 가지 form. 매 runtime freeze 가 의 매Object.freeze의 의.
매 핵심
매 4 가지 form
- Property modifier:
interface User { readonly id: string }— assign once. - Mapped type:
Readonly<T>— all props readonly (shallow). - Array variants:
readonly T[]또는ReadonlyArray<T>— no.push,.pop, etc. as const: literal narrowing + deep readonly tuple/object literal.
매 핵심 행동
- 매 compile-time only — JS runtime 의 의 effect 의 X.
- Variance:
T[]is assignable toreadonly T[](covariant), but not vice-versa. - Shallow:
Readonly<{ a: { b: 1 } }>매 a is readonly, a.b 의 X.
매 응용
- Public API: function param 매
readonly T[]— caller 의 mutation 의 의 의 의. - Redux / Zustand state — 매 immutability invariant.
- Config object —
as const매 literal type. - Tuple destructuring —
const point = [1, 2] as const. - Discriminated union literals —
type Status = "ok" | "fail"viaas const.
💻 패턴
Property readonly
interface User { readonly id: string; name: string }
const u: User = { id: "1", name: "A" };
u.name = "B"; // OK
u.id = "2"; // Error: cannot assign to 'id' because it is a read-only
Readonly<T> mapped
type Frozen<T> = Readonly<T>;
const cfg: Frozen<{ host: string; port: number }> = { host: "x", port: 80 };
cfg.host = "y"; // Error
Deep readonly
type DeepReadonly<T> = {
readonly [K in keyof T]: T[K] extends object ? DeepReadonly<T[K]> : T[K];
};
const data: DeepReadonly<{ user: { id: number } }> = { user: { id: 1 } };
data.user.id = 2; // Error
readonly T[] in API
function sum(xs: readonly number[]): number {
// xs.push(1); // Error
return xs.reduce((a, b) => a + b, 0);
}
sum([1, 2, 3]); // OK
sum(new Array(3).fill(0)); // OK
as const (literal narrowing)
const ROLES = ["admin", "user", "guest"] as const;
type Role = typeof ROLES[number]; // "admin" | "user" | "guest"
const config = { host: "localhost", port: 80 } as const;
// type: { readonly host: "localhost"; readonly port: 80 }
Tuple as const
function point() { return [1, 2] as const; } // [1, 2] 매 readonly tuple
const [x, y] = point();
Combine with branded type
type ImmutableUser = Readonly<{ id: string & { __brand: "UserId" }; email: string }>;
Runtime + type (Object.freeze + as const)
function deepFreeze<T>(o: T): Readonly<T> {
Object.freeze(o);
for (const k of Object.keys(o as object) as (keyof T)[]) {
const v = o[k];
if (v && typeof v === "object" && !Object.isFrozen(v)) deepFreeze(v);
}
return o;
}
const FROZEN = deepFreeze({ a: { b: 1 } });
매 결정 기준
| 상황 | Approach |
|---|---|
| Public function param | readonly T[] |
| Config / constants | as const |
| Class field 매 once-set | readonly modifier |
| Runtime guarantee 필요 | Object.freeze (or Immer) |
| Deep immutability type | Custom DeepReadonly<T> |
기본값: 매 input param 매 readonly, 매 constants 매 as const. 매 runtime needed 시 Immer.
🔗 Graph
- 부모: TypeScript · Immutability
- 응용: Redux Toolkit · Zustand · Type-Level Programming
- Adjacent: Branded Types · Discriminated_Unions · Variance · Mapped Types
🤖 LLM 활용
언제: API design (input param immutability), config typing, state management types. 언제 X: Runtime tamper-proof 필요 (use freeze), JS-only project.
❌ 안티패턴
readonly가 deep 일 거라 가정: 매 shallow only —DeepReadonly사용.ascast 으로 우회: 매 escape hatch — type system 의 매 무용.Readonly<T>+ReadonlyArray<T>혼동: object vs array, Mapped vs interface.- Mutating returned
readonlyarray (viaas): 매 compile pass 의 매 runtime corruption. - Class field
readonly의 매 setter 통한 mutation: 매 readonly 가 매 init time 만. - Public API 매
T[](mutable): 매 caller 의 의 mutation 가능 — 항상readonly T[]권장.
🧪 검증 / 중복
- Verified (TypeScript handbook, TC39 records & tuples proposal, MS TypeScript blog).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — readonly forms, as const, DeepReadonly pattern |