Skip to content
DevMeme
6030 of 7435
TypeScript's Type System as a Japanese Grammar Linter
Languages Post #6602, on Mar 30, 2025 in TG

TypeScript's Type System as a Japanese Grammar Linter

Why is this Languages meme funny?

Level 1: If Code Could Teach Languages

Imagine you have a really strict teacher who usually teaches math, and their job is to check your math homework. Now, you hand this teacher your Japanese grammar homework instead. Surprisingly, the teacher actually checks it – in their very strict, rule-based way – and tells you if your Japanese sentence is put together correctly or not! Sounds funny, right? That’s basically what’s going on here.

In our case, the “teacher” is a part of the computer that usually checks for coding mistakes (it’s called a compiler, and specifically it’s used for a programming language called TypeScript). Normally, this teacher-compiler makes sure you didn’t, say, try to put a square peg in a round hole in your code (like adding a text to a number by accident). It’s very good at following rules. Someone had the clever idea to give this rule-following teacher the rules of Japanese grammar. So the compiler, while checking code, is also double-checking Japanese sentences. If the sentence parts aren’t in the right order or form, it would complain just like it does for code errors.

Why is this funny? Because it’s so unexpected! It’s like using a calculator to grade an English essay – those are two things you’d never mix. Here a tool built for programming is being used to teach/validate a human language. The phrase “If you can write TypeScript, you can understand Japanese” is a joking way to say: “TypeScript’s rules are as complicated as learning a new language, so if you mastered one, hey, you could master the other!” It also literally shows the computer acting as a language tutor. Seeing a coding program correct a Japanese sentence is cute and absurd, kind of like watching a strict robot suddenly help you with your poetry. It makes us laugh because it shows a very nerdy kind of creativity – turning a coding tool into a grammar coach – and it highlights how learning any complex system (be it a programming language or a spoken language) is all about understanding rules and patterns. In short, it’s funny and cool that the computer is wearing two hats: one as a programmer’s assistant and one as a Japanese teacher, all at the same time.

Level 2: TypeScript as Grammar Check

Let’s break down what’s going on in simpler terms. TypeScript is a programming language (or more accurately a superset of JavaScript) that adds a static type system. Static typing means you tell the computer what “type” of data you’re using (for example, a number, a string of text, a list of items, etc.), and the computer (via the compiler) makes sure you don’t mix things up incorrectly. It’s like having a really smart spell-checker for code: if you try to put a square peg in a round hole, TypeScript will underline it in red and complain. This helps developers catch errors early, before even running the program. That’s type safety in a nutshell.

Now, normally those types (number, string, or more complex ones like Array<User>) are used to describe pieces of a program. But in this meme, someone created a special set of types to describe pieces of the Japanese language! This special set of types is essentially a Domain-Specific Language, often called a DSL. A DSL is like a mini-language or a custom toolkit inside a programming language for a specific purpose. For example, you might have seen SQL, which is a DSL for database queries, or HTML, a DSL for webpage structure. Here, the purpose is modeling Japanese sentences. They literally wrote TypeScript code that represents Japanese grammar rules.

How does that work? They defined TypeScript types for different parts of speech and grammar elements. For instance, in the screenshot we see type やる = GodanVerb & { stem: "や"; ending: "る" };. This is defining the Japanese verb "やる" (which means "to do") as a type. They say it’s a GodanVerb (that’s a category of Japanese verb) and give it extra info: a stem "や" and an ending "る". In Japanese, verbs conjugate (change form) according to rules, and “Godan” is one class of verbs with certain endings. So this line is like teaching the compiler, “Hey, やる is a verb of this kind, and here’s how you break it down.” Another line, type 春日影 = ProperNoun<"春日影">;, declares "春日影" (likely a name, pronounced Kasugakage or Haruhi Kage in context) as a proper noun. So now the compiler knows "春日影" should be treated like a noun/name in a sentence.

They then combine these pieces to form a sentence. The snippet in the image shows an InterrogativePhrase type being used, presumably to build a question sentence. It likely looks something like this:

// Define a verb "to do"
type やる = GodanVerb & { stem: "や"; ending: "る" };

// Define a proper noun (name)
type 春日影 = ProperNoun<"春日影">;

// Now form a question: "Why did 春日影 do (it)?"
type なんで春日影やったの = InterrogativePhrase<
  WhyInterrogative,
  春日影,
  やる,
  "PastTense",  // perhaps this indicates the verb is in past tense "やった"
  "の"
>;

In this made-up code, WhyInterrogative might be a type that represents words like "why" (なんで/なぜ/どうして in Japanese), and the last two parameters "PastTense", "の" indicate we’re using the verb’s past form and adding the particle "の" at the end (which in Japanese can turn a sentence into a kind of explanatory question). The details might differ, but the concept is that InterrogativePhrase<...> will only be a valid type (i.e., compile without errors) if all these components fit together correctly according to the rules of Japanese grammar. If we tried to, say, put the verb in the wrong form or leave out the "の", the TypeScript compiler would throw an error, meaning “this sentence type doesn’t satisfy the grammar constraints.”

The funny part is seeing the TypeScript compiler’s usual behavior applied to something unusual. Normally, you might see an error like “foo is not assignable to type number” when you do something wrong in code. Here we see 'なんで春日影やったの' is declared but never used. ts(6196). That particular message is actually just a warning (not an error) saying we defined something and didn’t use it. But below that, we see suggestions (in the blue Quick Fix box) for other acceptable sentences: "なぜ春日影やったの", "なんで春日影やったの", "どうして春日影やったの". Those are three ways to say essentially the same question in Japanese (“Why did Haruhi Kage do it?” using different words for "why"). This means our type-based grammar system recognized those as well. It’s as if your code editor is saying, “By the way, here are some other grammatically correct sentences of the same type you could use.” That’s normally something you’d expect from a language-learning app or a grammar textbook, not from a coding tool!

In simpler terms: the developer turned the TypeScript compiler into a grammar checker for Japanese. The project name “Typed Japanese” and the line “If you can write TypeScript, you can understand Japanese!” are poking fun at how strict and elaborate TypeScript’s rules can be – but also highlighting that those same strict rules can be harnessed for something really cool (if a bit over-the-top). For a junior developer or someone new to TypeScript, the takeaway is: wow, types can do that?! It shows the extensibility of programming tools. Today it’s Japanese, tomorrow someone might use types to verify the format of music chords, or the logic of a board game, all at compile time. It’s a fun demonstration of thinking outside the box (or perhaps inside the type system’s box!) to solve a problem in an unconventional way.

Level 3: Compile-time Conjugation

For seasoned developers, this meme hits on the insane fun you can have with TypeScript’s advanced features. The screenshot shows a project called “🌸 Typed Japanese” with the cheeky tagline:

If you can write TypeScript, you can understand Japanese!

That tagline is a tongue-in-cheek nod to how complex TypeScript’s type system has become – so much so that wrangling TS generics and conditional types feels as challenging as mastering a foreign language’s grammar. And here, they’ve made that literal! The humor is in the idea that the TypeScript compiler is moonlighting as a Japanese grammar teacher. Seasoned devs know the compiler as that strict, pedantic friend who underlines every tiny mistake in red. Now imagine that friend not only telling you about null references and type mismatches, but also correcting your Japanese sentences. It’s both hilarious and oddly impressive.

Technically, what’s depicted is a Domain-Specific Language (DSL) for Japanese, built entirely with TypeScript types. The code snippet (with Japanese characters as type names and values) defines grammar constructs: GodanVerb for a class of verbs, ProperNoun<"春日影"> for a specific proper noun, and an InterrogativePhrase that likely composes a question from parts (like a “why” word, a subject, a verb in past tense, and the question particle “の”). The TypeScript compiler checks that these pieces are assembled correctly, just as it would normally check if function arguments or object properties are used correctly. The result? If you try to construct an improper sentence (the wrong type), it won’t compile! Essentially, a type error = a grammar error. This is compile-time conjugation and syntax checking, no runtime needed.

Experienced devs are chuckling because they recognize the sheer template literal type gymnastics involved. TypeScript’s template literal types (since TS 4.x) let you define patterns for strings. Here that’s likely used to ensure, for example, a verb’s kana ending matches its classification or that a question starts with an appropriate interrogative. The meme even shows a compiler message: 'なんで春日影やったの' is declared but never used. ts(6196). Normally that message is a mundane warning, but in this context it’s proof the sentence “Why did Haruhi Kage do (it)?” was successfully recognized by the type system (declared with no errors). The kicker is the VS Code “quick fix” suggestions listing alternatives: "なぜ春日影やったの" | "なんで春日影やったの" | "どうして春日影やったの". Those are different ways to say the same question (“why” can be なぜ, なんで, or どうして). Seeing the TypeScript language service offer Japanese phrasing suggestions is delightful and absurd. It suggests the DSL is comprehensive enough to know multiple correct synonyms for “why,” and thus it can recommend other valid sentences. This is the kind of clever Easter egg that makes seasoned devs lean back and go, “Wow, someone actually did that…”.

There’s also an underlying commentary on developer experience (DX) here. We normally use static types to make our code robust and self-documenting. Here that principle is extended to natural language – using static typing to enforce correct sentences. It’s a playful reminder that tools like TypeScript, which were made to catch bugs in JavaScript, can be repurposed in creative ways. Senior engineers who have bent frameworks or languages to strange purposes (like writing games in Excel or building CI pipelines in Bash scripts) appreciate this as part of the grand tradition of tech kludges and creative hacks. It’s half “Look how far we’ve come!” and half “Have we gone too far?”. After all, TypeScript was supposed to make web dev easier, and here we are effectively doing a compile-time language course in it. The humor lands because it captures that mix of admiration and exasperation: only a true TypeScript guru (or mad scientist) would attempt to teach Japanese through static type checks. And if you can follow along, well, you’ve basically leveled up to guru status yourself.

Level 4: Chomsky in the Compiler

At the most abstract level, this meme is showcasing a wild intersection of type theory and linguistics. It’s as if someone took Noam Chomsky’s formal grammar rules and said, “Hey, let’s enforce these with the TypeScript compiler!” In theoretical computer science, languages (both programming and natural) are often described by formal grammars. Typically, a compiler uses a grammar to parse code, but here the TypeScript type system itself is being used as the grammar checker for Japanese sentences. This leverages the fact that modern TypeScript’s type system is astonishingly powerful – in fact, essentially Turing-complete. That means you can perform arbitrary computations (or checks) at compile time using types alone. By creatively using conditional types, mapped types, and template literal types, a developer can encode rules like “a GodanVerb must end in the correct syllable” or “an InterrogativePhrase must contain a question particle like ‘の’ at the end.” This is akin to proving a theorem: the Curry–Howard correspondence in type theory equates types to propositions, and a successful compilation to a proof. Here the “proposition” being proven is “this Japanese sentence is grammatically correct”. It’s an unexpected application of compiler theory – turning the typechecker into a language tutor.

This level of type-level programming flirts with concepts from formal language theory. Japanese grammar, with its particles and verb conjugations, can be described by a set of production rules (much like a programming language grammar). In a sense, the TypeScript compiler is being coerced into recognizing a subset of a natural language, almost as if it were parsing code. Under the hood, each Japanese word becomes a type (e.g. やる as a Godan verb type with a specific stem and ending), and a sentence becomes a compounded type that only resolves (type-checks) if the pieces fit together in a valid order – mimicking a context-free grammar or even a dependent type system. This is profoundly nerdy: it’s illustrating that with enough type meta-programming, one can perform complex static analysis on structures way outside typical program logic. It harkens to the days of C++ template metaprogramming wizardry (which is also Turing-complete) where compile-time logic was used for crazy things like computing prime numbers or generating fractals. Here, instead of math, we’re encoding linguistics. In summary, the meme tickles the fancy of those who appreciate that beneath the friendly bloomed 🌸 interface lies a serious computational feat – a compiler acting as a formal grammar validator. It’s a beautiful absurdity where the rigorous world of static types validates the fluid, often nebulous world of human language.

Description

A screenshot of a webpage for a library called 'Typed Japanese', which has a cherry blossom emoji next to its name. The main heading boldly claims, 'If you can write TypeScript, you can understand Japanese!'. Below this is a blue button that says 'Open in StackBlitz'. The central part of the image is a code editor displaying TypeScript code. This code defines types like `GodanVerb` and `ProperNoun` using Japanese characters and then constructs a complex interrogative phrase, which is type-checked by the compiler. The editor shows a tooltip with a type definition. The text at the bottom explains the project's purpose: 'Typed Japanese is a TypeScript type-level library that enables the expression of complete Japanese sentences through the type system. It creates a domain-specific language (DSL) based on Japanese grammar rules, allowing a subset of grammatically correct natural language to be written and verified using TypeScript's compiler.' This meme is a highly technical joke about the power and complexity of TypeScript's Turing-complete type system. It showcases an extreme example of type-level programming, where the compiler is manipulated to enforce rules far beyond simple data types, in this case, the grammar of a natural language. It's humorous to senior developers who understand just how absurdly powerful and abusable a sophisticated type system can be

Comments

15
Anonymous ★ Top Pick Finally, a way to ensure my comments are not only grammatically correct but also type-safe. The PR reviews are going to be brutal: 'LGTM, but this haiku has a type error in the third line.'
  1. Anonymous ★ Top Pick

    Finally, a way to ensure my comments are not only grammatically correct but also type-safe. The PR reviews are going to be brutal: 'LGTM, but this haiku has a type error in the third line.'

  2. Anonymous

    Great - now my linter corrects my kanji stroke order and still complains the variable is declared but never used

  3. Anonymous

    Finally, a type system so advanced it can catch your grammatical errors before your Japanese teacher does - though explaining to your PM why you're importing a linguistics library into the codebase might require its own type definition for 'creative technical debt justification'

  4. Anonymous

    Finally, a type system strict enough to catch grammatical errors in your comments before they make it to code review. Now your compiler can judge both your TypeScript *and* your Japanese particle usage - because apparently, catching runtime errors wasn't humbling enough

  5. Anonymous

    TypeScript types so dense they parse Japanese grammar flawlessly - yet still choke on your team's Pull Request comments

  6. Anonymous

    TypeScript generics expressive enough to model Japanese morphology - our compiler now speaks keigo; pity the PRD is still typed as any

  7. Anonymous

    At last, a codebase where tsc rejects your grammar - now waiting for the PR that adds discriminated unions for honorifics and a strict keigo mode that instantly breaks half of product’s specs

  8. @Titanlove2 1y

    I can

  9. @GlassySundew 1y

    They just invented 1c

  10. アレックス 1y

    This is just making fun of autistic people

    1. @andrei_nik_kolesnikov 1y

      Speak for yourself, I'm enjoying it :)

      1. アレックス 1y

        I know I’m making a joke about Japanese speakers and programmers

  11. @dsmagikswsa 1y

    I need a typed English to understand what this mean lol

  12. @Johnny_bit 1y

    Nani?

  13. Good Bye, Mother-Not-Found 1y

    wait why do you want to play haruhikage (anime meme)

Use J and K for navigation