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

using ESM - model methods are broken #1369

Open
1 of 2 tasks
dcsan opened this issue Jul 24, 2022 · 0 comments
Open
1 of 2 tasks

using ESM - model methods are broken #1369

dcsan opened this issue Jul 24, 2022 · 0 comments

Comments

@dcsan
Copy link

dcsan commented Jul 24, 2022

Issue

when trying to use ES Modules, many of the default Model methods are missing from my classes.

image

interestingly the asset.save method doesn't throw an error?

where Asset is just a model:

@Table
export class Asset extends Model {

Versions

  • sequelize:
  • sequelize-typescript:
  • typescript:
├─┬ [email protected]
│ └── [email protected] deduped
└── [email protected]

└── [email protected]

├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
└── [email protected]

Issue type

  • bug report
  • feature request

Actual behavior

cannot call basic sequelize methods on any model such as MyModel.truncate() or MyModel.create()

where MyModel is a subclass of Model

Expected behavior

should be able to create!

Steps to reproduce

have to use ESM modules

Related code

This is all configuration bullshit. I'm putting my tsconfig and package.json below.

{
    "compilerOptions": {
        "rootDir": "src",
        "outDir": "./build",
        "lib": [
            "ESNext"
        ],
        "module": "NodeNext",
        "moduleResolution": "NodeNext",
        "target": "es2022",
        "esModuleInterop": true,
        "types": [
            "node"
        ],
        "sourceMap": true,
        "strict": true,
        "strictPropertyInitialization": false,
        "baseUrl": "./src",
        "paths": {
            "@sharedTypes/*": [
                "../../client/src/types/shared/*"
            ]
        },
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "skipLibCheck": true,
        "forceConsistentCasingInFileNames": true,
        "resolveJsonModule": true,
        "allowJs": false
    },
    "include": [
        "src/**/*",
        "../../client/src/types/**/*"
    ],
    "exclude": [
        "node_modules"
    ],
    "typedocOptions": {
        "entryPoints": [
            "src/server.ts"
        ],
        "out": "docs/build"
    },
    "ts-node": {
        "esm": true,
        "experimentalSpecifierResolution": "node",
        "require": [
            "tsconfig-paths/register"
        ]
    }
}

and top of package.json

{
    "name": "plugbot-server",
    "version": "0.0.3",
    "description": "A framework for extensible crypto related discord bots with plugins",
    "main": "index.js",
    "type": "module",

...

    "nodemonConfig": {
        "ignore": [
            "*.json"
        ],
        "events": {
            "start": "clear || cls"
        }
    }

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

No branches or pull requests

1 participant