Modelling Swedish intestate succession in TypeScript
When someone in Sweden dies without a will, the Inheritance Code ( ärvdabalken , SFS 1958:637) decides who gets what. The rules fit on two printed pages. They are also a small, well-defined algorithm: a walk over a family tree with a fixed priority order, equal splits per branch, and a couple of special cases for spouses. I wrote that algorithm in TypeScript for a free calculator that answers…
Sweden's intestate succession law, as outlined in the Inheritance Code (ärvdabalken), dictates how assets are divided when someone dies without a will. This law is concise, fitting on just two printed pages, and follows a fixed order of priority, with equal splits per branch and special cases for spouses. The author has adapted this algorithm into a TypeScript calculator for Swedish users, providing a clear explanation of the law for developers who don't read Swedish.
The code is a single pure function, vemArver(input), which takes input and outputs who inherits, without any DOM or I/O operations. The law is structured into three classes of relatives: descendants, parents, and grandparents. Each class inherits only if all classes above it are empty. If a class member is deceased, their descendants or other relatives step into their place, with equal shares being taken.
The law also specifies that no other relatives, such as cousins, inherit, and if no heirs are found, the estate goes to Allmänna arvsfonden, the state inheritance fund.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.