include option typescript type check doesn't accept strings
See original GitHub issueWhat are you doing?
class User extends Model {
}
User.belongsTo(Country)
User.findAll({include: ['Country']}) // => raises error
User.findAll({include: ['Country'] as any}) // => works fine
What do you expect to happen?
No error in the first call.
What is actually happening?
lib/models/index.ts:17:19 - error TS2345: Argument of type '{ include: string[]; }' is not assignable to parameter of type 'FindOptions'.
Types of property 'include' are incompatible.
Type 'string[]' is not assignable to type 'Includeable[]'.
Type 'string' is not assignable to type 'Includeable'.
Environment
Sequelize version: 5.9.0 Node Version: 8 OS: Mojave 10.14.5 If TypeScript related: 3.4.4
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Property 'includes' does not exist on type 'string[]'
The includes method on Array is supported since ES7 (ES2016). The above will add a missing library ... The TypeScript compiler options are...
Read more >Documentation - Advanced Types - TypeScript
This page lists some of the more advanced ways in which you can model types, it works in tandem with the Utility Types...
Read more >Documentation - Everyday Types - TypeScript
In this chapter, we'll cover some of the most common types of values you'll find in JavaScript code, and explain the corresponding ways...
Read more >Documentation - Do's and Don'ts - TypeScript
Don't ever use the types Number , String , Boolean , Symbol , or Object These types ... Don't ever have a generic...
Read more >Documentation - Narrowing - TypeScript
Since string is the only common type that both x and y could take on, TypeScript knows that x and y must be...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think that it is ambiguous to specify two option instead of one. I feel myself in nineties when I see that: back then people had to understand machines. Right now, if a software knows what I mean it just does that without asking additional questions aka options.
Woundn’t it be so much easier to read:
<OFFTOPIC> I don’t even tell you how much easier it would be to have this then its expanded nested hashes equivalent:
But that is a story for another time.
This has since been resolved, the issue isn’t present in Sequelize 6 anymore
I also agree that specifying the name of the association:
is generally better than specifying a model+as pair: