Skip to content

Losing properties with custom formatter #2352

@MatheusLMessias

Description

@MatheusLMessias

Losing properties with custom formatter

When using a custom formatter, I’m intercepting NumberType. If it’s a number, I want it to return a property "tsType": "x" along with all the original properties of that field. However, when I fetch the definition with the method

const definition = this.childTypeFormatter.getDefinition(type);

the definition comes back empty.

I debugged the library and in the package ts-json-schema-generator/dist/src/CircularReferenceTypeFormatter.js I noticed that with the filled key (NumberType), the method

Object.assign(definition, this.childTypeFormatter.getDefinition(type));

is triggered before the value is populated. Because of that, my formatter is called, which looks for a valid key, but it has no value yet.

Is this the expected behavior?

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions