grafana / cuetsy

Experimental CUE->TypeScript exporter
Apache License 2.0
106 stars 8 forks source link

`null` types are unsupported #79

Closed sdboyer closed 1 year ago

sdboyer commented 1 year ago

The following CUE:

nullType: null @cuetsy(kind="type")
nullInUnion: string | null @cuetsy(kind="type")
nullDefault: "foo" | "bar" | *null @cuetsy(kind="type")
obj: {
    nullField: null
} @cuetsy(kind="interface")

Should this output, or something close:


export type nullType = null;

export type nullInUnion = string | null;

export type nullDefault = "foo" | "bar" | null;

export const defaultnullDefault: nullDefault = null;

export interface obj {
    nullField: null
}

But instead, we get:

export type nullType = %!s(<nil>);

export type nullInUnion = %!s(PANIC=String method: runtime error: invalid memory address or nil pointer dereference);

export type nullDefault = %!s(PANIC=String method: runtime error: invalid memory address or nil pointer dereference);

export const defaultnullDefault: nullDefault = %!s(<nil>);

export interface obj %!s(PANIC=String method: runtime error: invalid memory address or nil pointer dereference)

This is now codified in the testdata/imports/nulltype.txtar test.