Solucionado (ver solução)
Solucionado
(ver solução)
4
respostas

Erro ao executar projeto após a integração com o MySQL

Mesmo eu inserindo o código idêntico ao do instrutor, o erro abaixo é apresentado ao rodar a aplicação:

node_modules/sequelize-typescript/dist/model/model/model.d.ts:48:5 - error TS2416: Property 'reload' in type 'Model<TModelAttributes, TCreationAttributes>' is not assignable to the same property in base type 'Model<TModelAttributes, TCreationAttributes>'. Type '(options?: import("D:/repos/livraria-api/node_modules/sequelize/types/lib/model").FindOptions) => Promise' is not assignable to type '(options?: import("D:/repos/livraria-api/node_modules/sequelize/types/lib/model").FindOptions) => import("D:/repos/livraria-api/node_modules/sequelize/types/lib/promise").Promise'. Type 'Promise' is missing the following properties from type 'Bluebird': caught, error, lastly, bind, and 38 more.

48 reload(options?: FindOptions): Promise; ~

node_modules/sequelize-typescript/dist/model/table/table.d.ts:3:78 - error TS2344: Type 'M' does not satisfy the constraint 'Model<any, any>'. Type 'import("D:/repos/livraria-api/node_modules/sequelize-typescript/dist/model/model/model").Model<any, any>' is not assignable to type 'import("D:/repos/livraria-api/node_modules/sequelize/types/lib/model").Model<any, any>'. The types returned by 'reload(...)' are incompatible between these types. Type 'Promise' is missing the following properties from type 'Bluebird<Model<any, any>>': caught, error, lastly, bind, and 38 more.

3 export declare function Table(options: TableOptions): Function; ~

node_modules/sequelize-typescript/dist/sequelize/sequelize/sequelize.d.ts:12:5 - error TS2416: Property 'model' in type 'Sequelize' is not assignable to the same property in base type 'Sequelize'. Type '<TCreationAttributes, TModelAttributes>(model: string | ModelType<TCreationAttributes, TModelAttributes>) => ModelCtor<Model<any, any>>' is not assignable to type '(modelName: string) => ModelCtor<Model<any, any>>'. Type 'import("D:/repos/livraria-api/node_modules/sequelize-typescript/dist/model/model/model").ModelCtor<import("D:/repos/livraria-api/node_modules/sequelize-typescript/dist/model/model/model").Model<any, any>>' is not assignable to type 'import("D:/repos/livraria-api/node_modules/sequelize/types/lib/model").ModelCtor<import("D:/repos/livraria-api/node_modules/sequelize/types/lib/model").Model<any, any>>'. Type 'ModelCtor<Model<any, any>>' is not assignable to type 'new () => Model<any, any>'. Construct signature return types 'Model<any, any>' and 'Model<any, any>' are incompatible. The types of 'set' are incompatible between these types. Type '{ <K extends keyof import("D:/repos/livraria-api/node_modules/sequelize-typescript/dist/model/model/model").Model<any, any>>(key: K, value: import("D:/repos/livraria-api/node_modules/sequelize-typescript/dist/model/model/model").Model<any, any>[K], options?: import("D:/repos/livraria-api/node_modules/sequelize/types...' is not assignable to type '{ <K extends keyof import("D:/repos/livraria-api/node_modules/sequelize/types/lib/model").Model<any, any>>(key: K, value: import("D:/repos/livraria-api/node_modules/sequelize/types/lib/model").Model<any, any>[K], options?: import("D:/repos/livraria-api/node_modules/sequelize/types/lib/model").SetOptions): import("D:...'. Types of parameters 'keys' and 'keys' are incompatible. Type 'Partial<import("D:/repos/livraria-api/node_modules/sequelize/types/lib/model").Model<any, any>>' is not assignable to type 'Partial<import("D:/repos/livraria-api/node_modules/sequelize-typescript/dist/model/model/model").Model<any, any>>'. The types of 'reload(...).then' are incompatible between these types. Type '{ (onFulfill?: (value: Model<any, any>) => Resolvable, onReject?: (error: any) => Resolvable): Bluebird; <TResult1 = Model<any, any>, TResult2 = never>(onfulfilled?: (value: Model<...>) => Resolvable<...>, onrejected?: (reason: any) => Resolvable<...>): Bluebird<...>; }' is not assignable to type '<TResult1 = Model<any, any>, TResult2 = never>(onfulfilled?: (value: Model<any, any>) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike<...>) => Promise<...>'. Types of parameters 'onFulfill' and 'onfulfilled' are incompatible. Types of parameters 'value' and 'value' are incompatible. Type 'import("D:/repos/livraria-api/node_modules/sequelize/types/lib/model").Model<any, any>' is not assignable to type 'import("D:/repos/livraria-api/node_modules/sequelize-typescript/dist/model/model/model").Model<any, any>'.

12 model<TCreationAttributes, TModelAttributes>(model: string | ModelType<TCreationAttributes, TModelAttributes>): ModelCtor;

4 respostas

Consegui resolver a partir de uma dúvida anterior aqui do próprio fórum. Obrigado

Opa, tudo bem? Estou com problema semelhante. Pode indicar qual foi a duvida que te ajudou a resolver seu problema? Ja tentei de tudo.

Resolvido : A quem interessar, apaguei as pastas dist, node_modules e o arquivo package.json original. Coloquei o package.json disponibilizado pelo curso na pasta principal e executei npm install no terminal.

solução!

Resolvi executando o comando: npm install sequelize@6.1 sequelize-typescript@2