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
Issue with imports - TypeScript < 4 #498
Comments
To anyone looking for a quick workaround:
|
You need TypeScript 4.x. The syntax import Sequelize, { DataTypes, Model, Optional } from 'sequelize'; imports the Sequelize namespace, which is used later in the mixin declarations: getCustomer!: Sequelize.BelongsToGetAssociationMixin<Customer>; |
Hmm, let me try again to reproduce the problem. |
No luck. I've tried with Sequelize 6.3.5 and 6.5.0. I've tried with TypeScript 4.0.5 and 4.2.2. The generated code works for me, while your workaround code gives me an error:
My tsconfig.json looks like: {
"compilerOptions": {
"allowJs": false,
"checkJs": false,
"strict": true,
"declaration": false,
"module": "commonjs",
"noImplicitAny": true,
"esModuleInterop": true,
"preserveConstEnums": true,
"removeComments": false,
"sourceMap": true,
"target": "ES6",
"skipLibCheck": true,
"typeRoots": [
"node_modules/@types"
]
}
} |
I can replicate this issue: "typescript": "^4.1.5" The "quick workaround" #498 (comment) didn't work for me. |
I found a resolution by changing my tsconfig "allowSyntheticDefaultImports": true |
I think it works for me because I have
in my tsconfig.json. @Davste93 can you try that? |
Thanks for the lead, I had to do a few changes to have it working: replace.sync({
files: './src/models/*.ts',
from: /import Sequelize, \{ DataTypes, Model, Optional \} from 'sequelize';/g,
to: "import { DataTypes, Model, Optional } from 'sequelize';\nimport * as Sequelize from 'sequelize';"
}); |
Fixed in 0.8.2 |
Is anyone using this with TypeScript?
Not sure why the generated code is doing:
Instead of:
I don't know if Sequelize went from default to named exports, but it seems that this is not working as per sequelize 6.5.0.
The text was updated successfully, but these errors were encountered: