mswjs / data

Data modeling and relation library for testing JavaScript applications.

Home Page:https://npm.im/@mswjs/data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nested arrays are not supported in model definition

smashercosmo opened this issue · comments

Consider this case:

const db = factory({
  entity: {
    id: primaryKey(datatype.uuid),
    name: String,
    matrix: () => [[0,0,0], [1,1,1], [2,2,2]]
  }
})

This results in TS error

Property 'matrix' is incompatible with index signature.
  Type '() => number[][]' is not assignable to type 'ModelValueTypeGetter | NullableProperty<any> | OneOf<any, boolean> | ManyOf<any, boolean> | NestedModelDefinition'.
    Type '() => number[][]' is not assignable to type 'ModelValueTypeGetter'.
      Type 'number[][]' is not assignable to type 'ModelValueType'.
        Type 'number[][]' is not assignable to type 'PrimitiveValueType[]'.
          Type 'number[]' is not assignable to type 'PrimitiveValueType'.
            Type 'number[]' is not assignable to type 'string'.

Neither nested objects, at least in type definition.