Cannot import decorators-legacy in V7
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- typescript
- Lĩnh vực
- documentation
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- HTML
- Star
- 30
- Fork
- 171
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của sequelize/website
-
docs: Managed Postgres callout + optional Appwrite link on postgres.mdx?Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Update Migration.mdĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Error: Only HasMany associations support include.separateCó thể làm lại được @SippieCup đã nhận 197 ngày trước và không có pull request nào đang mở. Đang mở
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 55/100
Tất cả issue của sequelize/website
Issue tương tự
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 87/100
adri0/scadustats#128 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
WordPress/hosting-handbook#506 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Docs: refresh target-app-parity and file-format-parity against mainCó thể đã có người làm @vangel76 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
storytold/photocraft#4417 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
📖 docs: Docker Compose quick start doesn't mention editing the project values in src/hive.yamlĐang mởdocumentation help wanted needs-triage
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 75/100
hivecommons/hive#11606 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation good first issue launch
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
FlologixAI/etchwork#4 ·