Skip to content

13.2.17 - primitiveTypeConstructs breaking change, type definition doesn't match runtime #1614

@kevbost

Description

@kevbost

primitiveTypeConstructs now uses Object.assign() instead of the deleted function ‎src/util/object-assign.ts which expects a plain object, but the TypeScript type still expects a function. This has a large effect on my codebase because I am using onCreateComponent to identify a very specific situation where a type needed an override, and then primitiveTypeConstructs to define that type.

This happened in PR #1562

Type still states: primitiveTypeConstructs?: (struct: PrimitiveTypeStruct) => Partial<PrimitiveTypeStruct>
Runtime expects: primitiveTypeConstructs?: Partial<PrimitiveTypeStruct>


I am able to move forward with the following change, but it should have been called out -anywhere- before the release was published, and the type definitions need to be fixed.

Previous (no longer does anything):

generateApi({
  primitiveTypeConstructs: (constructs) => {
    return {
      ...constructs, // <-- these spreads were previously required to make this work, I don't remember why
      string: {
        ...(constructs.string), // <-- some extra type overrides were here to make errors go away
        $default: () => 'string',
        FeatureFlag: () => 'FeatureFlag',
      },
    }
  },
  // [...etc]
})

Working:

generateApi({
  primitiveTypeConstructs: {
    string: {
      $default: 'string', // <-- this has to be present in the object or else i get a crash during generation
      FeatureFlag: 'FeatureFlag',
    },
  },
  // [...etc]
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions