Types and nullability

Meta: nullability is the page's main attraction. Most readers won't have seen GraphQL-style T! outside of a schema and may misread it as "definitely-null" or "force-unwrap."

Built-in types

The ! sigil

Lists, nullability matrix

written meaning
[T] nullable list of nullable T
[T]! non-null list of nullable T
[T!] nullable list of non-null T
[T!]! non-null list of non-null T

Null propagation

Type variables

Type hints / casts: ::

Meta: :: deserves a worked example showing the difference between a type hint (narrowing/disambiguation, e.g. [] :: [String!]! binding a type variable) and a type cast (coercion, e.g. myUrl :: URL!). The runtime-assertion behavior for non-null casts is a footgun worth a short callout.

Coercion rules