#1825·pkl

Support separating typealiases into separate files without stuttering

Author: FelixZYCreated Aug 17, 2026Updated Aug 17, 2026

Pkl uses type aliases to define enums and certain custom types:

pkl
typealias MyEnum = "apple" | "banana"

typealias SemVer = String(matches(Regex(#"^\d+\.\d+\.\d+$"#)))

However, if I put these in separate files, I get stuttering usages:

pkl
module Config

import "MyEnum.pkl"
import "SemVer.pkl"

my_enum: MyEnum.MyEnum? = null

version: Semver.Semver = "1.2.3"

I therefore propose supporting a special type of pkl file, a type file, one containing a(n almost) lone typealias:

pkl
module my.namespace.MyEnum

hidden apple = "Apple"
hidden banana = "Banana"

typealias MyEnum = apple | banana

which would allow usage without stuttering:

pkl
module Config

import "MyEnum.pkl"

my_enum: MyEnum = "banana"

Another way to see it is that if the only visible variable in the file has the same name as the file itself, it's automatically exposed without stuttering.

This could of course be expanded to apply to classes and other types as well, and maybe there is a place for it - in the beginning I struggled a lot with not being able to have a module amend a class from another module etc.. However, this requires more discussion and is likely out of scope for this feature request. In this request I'm specifically asking to be allowed to put my enums/typealiases in separate files without stutter.