Passing undefined to initialPosition throws an error

Setting "initialPosition": undefined throws the following error:

Diagram.initialPosition value is not an instance of Point: undefined

However, at least according to TypeScript types, undefined is allowed:

(property) initialPosition?: go.Point | undefined

Same for initialScale.

goJS 2.3.19

Expected behavior is that I can pass undefined and it uses the default value.

Where do you see that in the go.d.ts file?

The Diagram.position property is declared:

    get position(): Point;
    set position(value: Point);

The Diagram constructor is defined to take DiagramInitOptions, which is defined as:

export type DiagramInitOptions = Partial<Diagram | {
    [P in DiagramEventName]?: ((e: DiagramEvent) => void);
} | DiagramInitStrings>;

Partial is defined: Documentation - Utility Types
But that does not explicitly say you can provide the property with an undefined value. I really don’t like the distinction between not specifying a property and specifying it with an undefined value, but there is a difference.

I see. Actually what I wrote were not the TypeScript types but the “interpretation” of the Types according to my TypeScript config.

Indeed the Partial makes it possible to assign undefined to any property.
This could be prevent by a specific TypeScript configration flag: exactOptionalPropertyTypes

Will try to experiment with this flag.