array in schema type produces invalid array type in typescript interface
blackholegalaxy opened this issue · comments
Steps to reproduce
- On a typescript enabled project
- Generate a new service with schemas
In the schema, define a property with array
type:
et schema = {
// !<DEFAULT> code: schema_header
title: 'Bootcamps',
description: 'Bootcamps database.',
// !end
// !code: schema_definitions // !end
// Required fields.
required: [
// !code: schema_required // !end
],
// Fields with unique values.
uniqueItemProperties: [
// !code: schema_unique // !end
],
// Fields in the model.
properties: {
// !code: schema_properties
id: { type: 'ID' },
address: { $ref: 'place/address.json' },
userIds: {
type: 'array',
items: {
type: 'ID',
faker: { fk: 'users:next' }
},
},
deletedAt: { $ref: 'common.json#/definitions/deleted_at' },
// !end
},
// !code: schema_more // !end
};
- Then
generate all
Expected behavior
It should produce a valid typescript interface.ts
like:
export interface BootcampBase {
// !<DEFAULT> code: interface
address: {
base: string;
complement: string;
city: string;
zipcode: string;
state: string;
country: string
};
userIds: string[]; // or any[] <------ HERE
deletedAt: number;
// !end
}
Actual behavior
It produces the interface.ts
with improper array
type:
export interface BootcampBase {
// !<DEFAULT> code: interface
address: {
base: string;
complement: string;
city: string;
zipcode: string;
state: string;
country: string
};
userIds: array; // <------ HERE
deletedAt: number;
// !end
}
System configuration
Tell us about the applicable parts of your setup.
Module versions (especially the part that's not working):
feathers-plus 0.7.80
NodeJS version:
Tested on 8.15.0 and 10.x versions
Operating System:
OsX Mojave and Windows 10
I remember coming across this. It's on my laundry list of typescript improvements but I haven't had a chance to look at this in a long time. I'm hoping to today, fingers crossed
Maybe we could use this to generate the interfaces (or maybe we already do, I'm not sure)
The people handling typescript for the generator will have to submit a PR.
I think this is fixed now?
Thanks for noticing this. Published with f+/cli and generator, both v0.8.0.