Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): init method should use all attributes #12431

Closed
wants to merge 1 commit into from
Closed

fix(types): init method should use all attributes #12431

wants to merge 1 commit into from

Conversation

zaggino
Copy link
Contributor

@zaggino zaggino commented Jun 26, 2020

When you try to compile the example from https://github.com/sequelize/sequelize/blob/master/docs/manual/other-topics/typescript.md

You get an error:

error TS2345: Argument of type '{ id: { type: DataTypes.IntegerDataTypeConstructor; autoIncrement: boolean; primaryKey: boolean; }; name: { type: DataTypes.StringDataType; allowNull: false; }; preferredName: { ...; }; }' is not assignable to parameter of type 'ModelAttributes<User, UserCreationAttributes>'.

This fixes that error.

cc @hsource from #12405

@hsource
Copy link
Contributor

hsource commented Jun 27, 2020

Ah, my bad! I think I'd accidentally changed it when I was testing it.

Looks great!

@sushantdhiman
Copy link
Contributor

Error: /home/travis/build/sequelize/sequelize/types/test/models/User.ts:50:3

ERROR: 50:3  expect  TypeScript@4.0 compile error: 

Argument of type '{ firstName: DataTypes.StringDataTypeConstructor; lastName: DataTypes.StringDataTypeConstructor; username: DataTypes.StringDataTypeConstructor; groupId: DataTypes.NumberDataTypeConstructor; }' is not assignable to parameter of type 'ModelAttributes<User, UserAttributes>'.

  Property 'id' is missing in type '{ firstName: DataTypes.StringDataTypeConstructor; lastName: DataTypes.StringDataTypeConstructor; username: DataTypes.StringDataTypeConstructor; groupId: DataTypes.NumberDataTypeConstructor; }' but required in type 'ModelAttributes<User, UserAttributes>'.

@sushantdhiman
Copy link
Contributor

@zaggino You should be able to run linting locally

@hsource
Copy link
Contributor

hsource commented Jun 27, 2020

I'm going to go ahead and also just make the Typescript example better and tested. I'll do that in a separate pull request

@hsource
Copy link
Contributor

hsource commented Jun 27, 2020

Thanks again for the fix and sorry for the earlier error in the types! I've incorporated it into a larger fix and update of the documentation in #12435

@zaggino zaggino closed this Jun 27, 2020
@zaggino zaggino deleted the patch-2 branch June 27, 2020 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants