Sequelize-typescript: Question: If you guys use vscode, is it possible to get intellisense in create, update or build functions?

Created on 14 Jun 2017  路  3Comments  路  Source: RobinBuschmann/sequelize-typescript

const user = await User.build<User>(
    {
      email: '[email protected]', // <--- it would be so cool if i can get intellisense on which fields are available here.
      password: '123456',
      todos: [{ title: 'Do home work!' }, { title: 'Watch TV!' }]
    },
    {
      include: [Todo]
    }
  );

Most helpful comment

Hey man thanks, this lib is freaking awesome. Waiting to see it reached v1 soon.

All 3 comments

Hey @BruceHem, build can be called with a second generic:

````typescript
interface IUser {
email: string;
// ...
}

User.build({
email: ''
})
````

Or if you only need auto completion and don't care about what's optional or required, you can use typescripts build in mapped type Partial. With this approach you don't need to define an additional interface:

typescript User.build<User, Partial<User>>({ email: '' })
The problem with this approach is, that you will get auto completion for all your members within User - Which means function members as well. Thats why build<User, User>(Notice: I removed Partial here) is not a good idea .

Hey man thanks, this lib is freaking awesome. Waiting to see it reached v1 soon.

@BruceHem thank you very much :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nandox5 picture nandox5  路  3Comments

fareshan picture fareshan  路  3Comments

lilling picture lilling  路  4Comments

JustGreg picture JustGreg  路  4Comments

samanmohamadi picture samanmohamadi  路  5Comments