Closed gilsdav closed 5 years ago
@luisfpg As you can see in https://www.w3schools.com/js/js_arrays.asp Array is deprecated, can you use export type Pets = Pet[];
instead of export type Pets = Array<Pet>;
?
Thank you
@gilsdav Why? Actually, that page says to avoid the Array constructor.
But as a TypeScript type definition, Array<string>
and string[]
are the same.
Quoted from https://www.typescriptlang.org/docs/handbook/basic-types.html:
TypeScript, like JavaScript, allows you to work with arrays of values. Array types can be written in one of two ways. In the first, you use the type of the elements followed by [] to denote an array of that element type:
let list: number[] = [1, 2, 3];
The second way uses a generic array type, Array: let list: Array<number> = [1, 2, 3];
Note that neither use new Array
.
@luisfpg You are right but I think it can be confusing because this javascript type exist just like String
. But in that case String
is deferent than string
.
This is why I never use Array
.
What do you think about ?
Source
https://gist.githubusercontent.com/kinlane/43934f44fd591a6ee59a45267d9e3066/raw/47f6d7115dd17749c408c55861638ffc22d995f4/sample-openapi-30.yaml
Expected
pets.ts :
Got
pets.ts :