mswjs / data

Data modeling and relation library for testing JavaScript applications.
https://npm.im/@mswjs/data
MIT License
827 stars 52 forks source link

Nested arrays are not supported in model definition #162

Open smashercosmo opened 3 years ago

smashercosmo commented 3 years ago

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'.
SalahAdDin commented 8 months ago

Neither nested objects, at least in type definition.