Cannot import decorators-legacy in V7
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Documentazione
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- typescript
- Ambito
- documentation
Direzione di ricerca
Start with the v7 has-many documentation page and the decorators-legacy import shown there; compare it with the package entry points exposed by @sequelize/[email protected] using the provided TypeScript reproduction and tsconfig.json. Done means the documented example no longer produces the reported module-resolution error, with the relevant documentation or package behavior verified.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Issue Creation Checklist
- I understand that my issue will be automatically closed if I don't fill in the requested information
- I have read the contribution guidelines
Bug Description
The documentation explicitly indicates to use decorators to define all aspects related to a model.
From types, to relationships, and more.
However, I personally cannot get it to work, due to this issue in my VSCode editor
Cannot find module '@sequelize/core/decorators-legacy' or its corresponding type declarations.ts(2307)
Reproducible Example
- I use TypeScript
- Everything works fine without importing or trying to use decorators. I.e.:
import { Model, DataTypes, InferAttributes, InferCreationAttributes, CreationOptional } from '@sequelize/core'
import { RequestType } from '../types'
import { sequelize } from '../db'
class Request extends Model<InferAttributes<Request>, InferCreationAttributes<Request>> {
declare id: CreationOptional<number>
declare requestType: string
declare requestData: object
declare requester: string
declare createdAt: CreationOptional<Date>
declare updatedAt: CreationOptional<Date>
}
Request.init({
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
requestType: {
type: DataTypes.ENUM(
RequestType.EXPENV_AZURE,
RequestType.EXPENV_GCP,
RequestType.VM_AZURE,
RequestType.VM_GCP,
RequestType.RPA_AZURE,
RequestType.RPA_GCP,
RequestType.AZURE_RG
),
allowNull: true
},
requestData: {
type: DataTypes.JSON,
allowNull: false
},
requester: {
type: DataTypes.STRING,
allowNull: false
},
createdAt: {
type: DataTypes.DATE
},
updatedAt: {
type: DataTypes.DATE
}
}, { sequelize })
- The sequelize directory inside
node_modulesseems to have all the requested data
However, and as per a standard example on this page, the usual flow to use decorators
import { Model, DataTypes, InferAttributes, InferCreationAttributes, CreationOptional, NonAttribute } from '@sequelize/core'
import { PrimaryKey, Attribute, AutoIncrement, NotNull, HasMany, BelongsTo } from '@sequelize/core/decorators-legacy'
has the second line, no matter what else I have in my file, always throw this error:
Cannot find module '@sequelize/core/decorators-legacy' or its corresponding type declarations.ts(2307)
What do you expect to happen?
Find the module and not throw that error
What is actually happening?
Environment
- Sequelize version:
$ npm list @sequelize/core
[email protected]
└── @sequelize/[email protected]
- Node.js version:
$ node -v
v18.12.1
- If TypeScript related: TypeScript version:
npm list typescript
[email protected]
├─┬ [email protected]
│ └── [email protected]
└─┬ [email protected]
├─┬ @typescript-eslint/[email protected]
│ └─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
└── [email protected] deduped
tsconfig.json
{
"compilerOptions": {
"allowJs": false,
"declaration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist",
"rootDir": ".",
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"strictNullChecks": true,
"target": "es6",
"types": ["node"],
},
}
- Database & Version:
MySQL 8 - Connector library & Version:
[email protected]
Would you be willing to resolve this issue by submitting a Pull Request?
- Yes, I have the time and I know how to start.
- Yes, I have the time but I will need guidance.
- No, I don't have the time, but my company or I are supporting Sequelize through donations on OpenCollective.
- No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in resolving my issue.
Indicate your interest in the resolution of this issue by adding the 👍 reaction. Comments such as "+1" will be removed.
- Lingua principale
- HTML
- Stelle
- 30
- Fork
- 171
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di sequelize/website
-
docs: Managed Postgres callout + optional Appwrite link on postgres.mdx?Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 74/100
-
Update Migration.mdAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Error: Only HasMany associations support include.separateForse di nuovo libera @SippieCup l’ha presa 194 giorni fa e non c’è nessuna pull request aperta. Aperta
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 55/100
Tutte le issue di sequelize/website
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
zerocracy/judges-action#2730 ·
I maintainer di solito rispondono entro 8 giorni
-
feedback simulation workshop
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
githubnext/gh-aw-workshop#4417 ·
I maintainer di solito rispondono entro 1 giorno
-
documentation Good First Issue hacktoberfest Non-Code
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
hiero-ledger/hiero-sdk-js#4488 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
crazy-goat/rabbit-stream#830 ·
I maintainer di solito rispondono entro 1 giorno
-
sync-en
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno