question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Help writing more TypeScript documentation

See original GitHub issue

When doing a query the manual says to do this:

const ourUser = await User.findByPk(1, {
    include: [User.associations.Project],
    rejectOnEmpty: true, // Specifying true here removes `null` from the return type!
  });

if we’re wanting to load multiple nested models, how should i go about doing this:

  const user = await User.findAll({
        attributes: ['id', 'name', 'email'],
        include: {
          model: Role,
          required: true,
          where: { projectId },

          include: [
            {
              model: Project,
              required: true
            },
            {
              model: Group,
              required: true,
              where: { code: 'cli' }
            }
          ]
        }
      });

Currently I’m getting the error

Type '{ model: typeof Role; required: boolean; where: { projectId: any; }; include: ({ model: typeof Project; required: boolean; } | { model: typeof Group; required: boolean; where: { code: string; }; })[]; }' is not assignable to type 'Includeable[]'.
  Object literal may only specify known properties, and 'model' does not exist in type 'Includeable[]'.ts(2322)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:26 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
jessepcommented, May 7, 2019

Sorry for the slow reply. @SimonSchick.

I’m sure this is is an ignorant question, but why is Model typed as a class instead of an interface now?

2reactions
jessepcommented, Apr 29, 2019

@SimonSchick First, just wanted to say thanks for all your work on this, i’m excited about using sequelize with typescript. Just wanted to chime in I do hope you find time to address these issues in v6. When I realized create wasn’t typesafe, I felt 😢😿😭

Read more comments on GitHub >

github_iconTop Results From Across the Web

The starting point for learning TypeScript
TypeScript Documentation. Get Started. Quick introductions based on your background or preference. TS for the New Programmer · TypeScript for JS ...
Read more >
Documenting Your TypeScript Projects: There Are Options
Whether you're a TypeScript developer, a JavaScript developer or any type of developer really, you most likely hate writing documentation.
Read more >
Writing more descriptive intellisense docs for Typescript Union ...
You can't really annotate union members. You can, however, express your union differently — by using overloads or by choosing to use an...
Read more >
Generating Documentation for TypeScript Projects
These annotations are all optional and the more you add, the more the compiler can help you. Compiling the TypeScript version results in ......
Read more >
Working with JavaScript in Visual Studio Code
While IntelliSense should just work for most JavaScript projects without any ... You can read more about writing d.ts in the TypeScript documentation....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found