If you can write TypeScript, you can understand Korean!
New: Interactive Playground โ โ an in-browser TypeScript editor where the compiler resolves conjugations live, plus a Verb Lab, Adjective Lab, Phrase Builder, and Sentence Gallery. (source ยท run locally with
cd playground && pnpm install && pnpm dev)
Typed Korean is a TypeScript type-level library that enables the expression of complete Korean sentences through the type system. It creates a domain-specific language (DSL) based on Korean grammar rules, allowing a subset of grammatically correct natural language to be written and verified using TypeScript's compiler.
This project also explores an intermediate format for AI in language learning. For example, LLMs could return grammar analysis of Korean sentences using this format instead of JSON, enabling verification through TypeScript's type checker to improve correctness.
๐ Want to learn more? Check out our detailed blog post which explains how the TypeScript type system can be used to learn Korean grammar from the ground up. The article starts with basic programming concepts and gradually builds up to complex Korean grammatical structures like conditional sentences and interrogative phrases.
// Define the proper noun "ใใณใกใซ"
type ใใณใกใซ = ProperNoun<"ใใณใกใซ">;
// Define ใใ verb
type ใใ = IrregularVerb & { dictionary: "ใใ" };
// Create the ใใใใ pattern (past form of ใใใใ)
type ใใใใ = DemonstrativeAction<Demonstrative & "ใใ", ใใ, "Ta">;
// Create the conditional phrase "ใใณใกใซใชใใใใใ"
type ใใณใกใซใชใใใใใ = ConditionalPhrase<ใใณใกใซ, "ใชใ", ใใใใ>;
// Type checking examples
const properExample: ใใณใกใซใชใใใใใ = "ใใณใกใซใชใใใใใ"; // "If it were Himmel, he would do so"
// ๅฆๆๆฏ่พ็พๅฐ็่ฏ๏ผไปไนไผ่ฟไนๅ็Korean verbs are categorized into three main classes:
-
Godan Verbs (ไบๆฎตๅ่ฉ) - Also known as "Group 1" or "u-verbs"
- Endings: ใ, ใ, ใ, ใ, ใค, ใฌ, ใถ, ใ, ใ
- Examples: ่ฉฑใ (hanasu - to speak), ๆธใ (kaku - to write)
-
Ichidan Verbs (ไธๆฎตๅ่ฉ) - Also known as "Group 2" or "ru-verbs"
- Always end with ใ
- Examples: ้ฃในใ (taberu - to eat), ่ฆใ (miru - to see)
-
Irregular Verbs (ไธ่ฆๅๅ่ฉ) - Only two main verbs
- ใใ (suru - to do)
- ๆฅใ (kuru - to come)
The system supports these conjugation forms:
- Dictionary (Dictionary form)
- Masu (Polite form)
- Te (Te form)
- Ta (Past form)
- Nai (Negative form)
- Potential (Potential form)
- Passive (Passive form)
- Causative (Causative form)
- Volitional (Volitional form)
- Imperative (Imperative form)
- Conditional (Conditional form)
- Hypothetical (Hypothetical form)
type ่ฒทใ = GodanVerb & { stem: "่ฒท"; ending: "ใ" };
type ่ฒทใTe = ConjugateVerb<่ฒทใ, "Te">; // ่ฒทใฃใฆ
type ่ฒทใTa = ConjugateVerb<่ฒทใ, "Ta">; // ่ฒทใฃใ
type ้ฃในใ = IchidanVerb & { stem: "้ฃใน"; ending: "ใ" };
type ้ฃในใTe = ConjugateVerb<้ฃในใ, "Te">; // ้ฃในใฆ
type ้ฃในใTa = ConjugateVerb<้ฃในใ, "Ta">; // ้ฃในใKorean adjectives are categorized into two main classes:
-
I-Adjectives (ใๅฝขๅฎน่ฉ) - End with ใ
- Examples: ใใ (good), ๆฅฝใใ (fun), ้ซใ (expensive)
-
Na-Adjectives (ใชๅฝขๅฎน่ฉ) - Require ใช when modifying nouns
- Examples: ็ถบ้บ (pretty), ้ใ (quiet), ๅฅฝใ (liked)
The system supports these conjugation forms for adjectives:
- Basic (Basic form)
- Polite (Polite form)
- Past (Past form)
- Negative (Negative form)
type ใใ = IAdjective & { stem: "ใ"; ending: "ใ"; irregular: true };
type ็ถบ้บ = NaAdjective & { stem: "็ถบ้บ" };The copula (ใ / ใงใ) turns a ไฝ่จ (noun or na-adjective stem) into a statement โ
"X is โฆ". It is not a particle: like a verb or an adjective it inflects for
politeness, tense and polarity, so it is modeled as a conjugable word via
ConjugateCopula<Taigen, Form> (mirroring ConjugateVerb / ConjugateAdjective).
- Plain โ ใ (plain) ใป Polite โ ใงใ (polite)
- Past โ ใ ใฃใ ใป PolitePast โ ใงใใ
- Negative โ ใงใฏใชใ ใป PoliteNegative โ ใงใฏใใใพใใ
- NegativePast โ ใงใฏใชใใฃใ ใป PoliteNegativePast โ ใงใฏใใใพใใใงใใ
- CasualNegative โ ใใใชใ ใป CasualPoliteNegative โ ใใใใใพใใ
- Written โ ใงใใ๏ผformal written๏ผใป Te โ ใง๏ผconnective๏ผ
The copula has no generic attributive form: ใช is licensed only for ใช-adjectives (้ใใช็บ), never for plain nouns (รๅป่ ใช โ a noun takes ใฎ), so it lives in the adjective system, not here.
type ๅป่
ใ = ConjugateCopula<"ๅป่
", "Plain">; // ๅป่
ใ
type ๅป่
ใงใฏใใใพใใ = ConjugateCopula<"ๅป่
", "PoliteNegative">; // ๅป่
ใงใฏใใใพใใThe system now supports:
- Adjectives and verbs with particles
- Connecting phrases with Korean punctuation
- Basic sentence structures
- Conditional expressions with particles like ใชใ
- Demonstrative forms with actions
Example: Connecting simple adjective and imperative verb phrases
// I-adjective "ii" (good) with irregular conjugation
// Then add particle "yo" to basic form of "ii" -> "ii yo"
type ใใ = IAdjective & { stem: "ใ"; ending: "ใ"; irregular: true };
type ใใใ = PhraseWithParticle<ConjugateAdjective<ใใ, "Basic">, "ใ">;
// Irregular verb "kuru" (to come)
// Then add particle "yo" to imperative form of "kuru" -> "koi yo"
type ๆฅใ = IrregularVerb & { dictionary: "ๆฅใ" };
type ๆฅใใ = PhraseWithParticle<ConjugateVerb<ๆฅใ, "Imperative">, "ใ">;
// Connect both phrases -> "ii yo, koi yo"
type ใใใๆฅใใ = ConnectedPhrases<ใใใ, ๆฅใใ>;
// Type checking examples
const correctPhrase1: ใใใ = "ใใใ"; // "It's good!" (114)
const correctPhrase2: ๆฅใใ = "ๆฅใใ"; // "Come here!" (514)
const correctFullPhrase: ใใใๆฅใใ = "ใใใใๆฅใใ"; // "It's good, come here!"Example: More flexible component-based sentence construction
type SentenceParts = [
AdverbPart<"ใชใใง">, // "Why" - question adverb
IntensifierPart<"ใใใชใซ">, // "So much" - intensifier
VerbPart<ๆ
ฃใใ, "Te">, // "Get used to" in te-form
ContractedPart<"ใ">, // Contraction of "ใฎ" - colloquial nominalizer
CopulaPart<"Plain">, // Copula "is" (ใ ) โ a conjugable copula, not a particle
ParticlePart<"ใ"> // Emphatic sentence-ending particle
];
// Combines all parts into a single string
type JoinedSentence = JoinPhrasePartsValue<SentenceParts>;
const joinedSentence: JoinedSentence = "ใชใใงใใใชใซๆ
ฃใใฆใใ ใ"; // "Why are you so used to it?!"
// ไฝ ไธบไปไน่ฟไน็็ปๅ๏ผThe system uses TypeScript's template literal types, conditional types, and mapped types to create a purely type-level representation of Korean grammatical rules.
Key components:
- Type definitions for grammatical elements
- Rule mapping via conditional types
- String literal manipulation for form generation
- Type inference for grammatical validation
- Educational tool - Learn Korean grammar through code
- AI-assisted learning - Provide structured formats for language analysis
- Grammar verification - Express and verify Korean grammar in code
- Integration potential - Basis for typed Korean language tools
- This is a type-level system only - it doesn't provide runtime functionality
- The system handles standard forms but doesn't account for linguistic nuances
- Some rare or archaic language patterns may not be accurately represented
This project is still in very early stages and heavily relies on LLM-generated grammar rules, which may occasionally contain hallucinations or inaccuracies. If you find any issue during actual use, please help by confirming and providing feedback.
If you're interested in contributing to or experimenting with Typed Korean:
- Ensure you have Node.js and pnpm installed
- Clone the repository
- Install dependencies:
pnpm install - Run the tests:
pnpm test
The tests validate that the type system functions correctly and all grammatical rules are properly implemented.
We welcome contributions! Feel free to open issues for bugs or feature requests, or submit pull requests with improvements.
For sponsorship opportunities, research collaborations, or commercial inquiries, please reach out to contact@typedgrammar.com.
Copyright (c) 2025-present, Yifeng Wang
