You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since coffeescript is supported, i think it would be cool to have a typescript support also.
Expectation: run node_modules/sequelize-cli/bin/sequelize model:create --name Collection --attributes id:integer,name:string --typescript
Will produce a model which ends in '.ts' instead of '.js'.
Justification:
In projects where typescript is used, javascript files are sometimes ignored (because they are produced through typescript). Therefore, the model will be ignored by default. Afterwards, a developer must edit the model/migration.
Result:
Tiny bit of work removed when developing with typescript.
Reacted by Pascal Bayer, Vayrex, Peter Slivka, Felix Becker, Tom Piarulli, Darío Terrés, WonderBITSBot, Raphael Monte, Ken Howard, Niklas Sparfeld and 120 more
Reacted by limichange, vincentywx, William Cantin, Wolfgang Ederer, Alejandro Corredor, Leo Doldan, Rodri, Vitalie Calmîc and Anthony Luzquiños
Reacted by Flavie L., limichange, vincentywx, William Cantin, Rodrigo Alves, Jorge Arco, Wolfgang Ederer, Alejandro Corredor, Leo Doldan, Nicola Sanitate and 3 more
Reacted by limichange, vincentywx, William Cantin, Ross Holdway, Rodrigo Alves, Jorge Arco, Wolfgang Ederer, Alejandro Corredor, Leo Doldan, devconcept and 6 more
Reacted by Leo Doldan, Nicola Sanitate, aRtoo, Rodri, Vitalie Calmîc, Faris Tangastani and Anthony Luzquiños
The problem I see here is that the pattern I found to be the best for TypeScript is totally different than the approach sequelize-cli uses. The pattern of the exported closure and a static associate() method is really hard to type (how do you type the models parameter?). Using late imports works much better.
Well, putting just .ts instead of .js as suffix would do the job in terms of a TypeScript file is created. Additionally, i would expect, that the class syntax of TypeScript would be supported and the typings for properties.
class Test {
private someNumber: number;
private someString: string;
public function setSomeNumber(myNumber: number): void {
this.someNumber = myNumber;
}
public function getSomeNumber(): number {
return this.someNumber;
}
...
}
Sorry, you are right. Thought about another thing.
Regarding the TypeScript, it would be sufficient to have the .ts ending and some TypeScript syntax (lambda functions, ...).
Another feature would be to have the classes above instead of the current syntax:
I can define the above class, it will be derived from a sequlize-parent-model (or something).
Afterwards this class is scanned for its properties etc.
This thing would go into the direction of EntityFramework (C#) and Hibernate (Java).
Maybe it's even better to provide those possibilities in more generic way, like add an ability to provide user-defined template for those files. An I will be able to construct myself which dialect of javascript I use...
Reacted by Scott Cooper, Mitchell Garcia, limichange, Austin Cawley-Edwards, Nicolas Laplante, Boris Lemke, gharwood1, Denis Y., Sean Newell, Yuriy Kuzin and 15 more
@Mikhus YES! Native module support is required. The nice thing about your sample code is that you only introduce TypeScript to utilize QueryInterface. 👍
Please don't +1 issues. It clutters the thread without adding value to the discussion and spams maintainers with notifications. Use GitHub reactions to upvote features.
Reacted by Ken Howard, Naga Pavan Kumar Kunisetty, Nicolas Laplante, limichange, Ondrej Slinták, Pavlo, Nolan, Sean Newell, Andrew Gerst, Aakash Malhotra and 24 more
I assume the opinion has changed here since Sequelize 5 exports TypeScript types and could be of some value here. Would love type hints when writing my migrations as it's currently trial and error as the documentation often just says: "object" for options
@virgenherrera It doesn't make any sense to ignore it (if they seriously are). To work with databases and not to use TypeScript (which enforces types) seems rather ridiculous IMO.
We're hard at work at improving TypeScript support for the main repo and we'll work on CLI after we've done most of our planned changes. v7 will have much better TypeScript support but we're open to PRs of the community in the meantime
We're hard at work at improving TypeScript support for the main repo and we'll work on CLI after we've done most of our planned changes. v7 will have much better TypeScript support but we're open to PRs of the community in the meantime
We're hard at work at improving TypeScript support for the main repo and we'll work on CLI after we've done most of our planned changes. v7 will have much better TypeScript support but we're open to PRs of the community in the meantime
Any updates? It's 2025.
Since the last release of this ORM was on Nov 3, 2023, I think that no further updates will come to this project
Activity
Vayrex commentedon Aug 9, 2016
Really good proposition +1
felixfbecker commentedon Aug 28, 2016
The problem I see here is that the pattern I found to be the best for TypeScript is totally different than the approach sequelize-cli uses. The pattern of the exported closure and a static
associate()method is really hard to type (how do you type themodelsparameter?). Using late imports works much better.kenhowardpdx commentedon Dec 16, 2016
Does "Add TypeScript support" also include generating migrations? If so the only change there is to save the file as
.tsinstead of.js.sebastianwahn commentedon Dec 19, 2016
Well, putting just
.tsinstead of.jsas suffix would do the job in terms of a TypeScript file is created. Additionally, i would expect, that the class syntax of TypeScript would be supported and the typings for properties.felixfbecker commentedon Dec 19, 2016
What does this have to do with classes?
sebastianwahn commentedon Dec 19, 2016
Sorry, you are right. Thought about another thing.
Regarding the TypeScript, it would be sufficient to have the .ts ending and some TypeScript syntax (lambda functions, ...).
Another feature would be to have the classes above instead of the current syntax:
I can define the above class, it will be derived from a sequlize-parent-model (or something).
Afterwards this class is scanned for its properties etc.
This thing would go into the direction of EntityFramework (C#) and Hibernate (Java).
felixfbecker commentedon Dec 19, 2016
You are thinking about models, not migration files. A migration file just exports two functions, up and down.
Mikhus commentedon Jun 3, 2017
+1 to this. Actually it should look not simply as file saved with .ts extension, but contain a slightly different contents in it, for example:
So:
Maybe it's even better to provide those possibilities in more generic way, like add an ability to provide user-defined template for those files. An I will be able to construct myself which dialect of javascript I use...
kenhowardpdx commentedon Jun 5, 2017
@Mikhus YES! Native module support is required. The nice thing about your sample code is that you only introduce TypeScript to utilize QueryInterface. 👍
hronro commentedon Jul 30, 2017
+1
limichange commentedon Aug 7, 2017
+1
GeeWee commentedon Aug 16, 2017
+1
MarcoPasqualini commentedon Aug 21, 2017
+1
felixfbecker commentedon Aug 21, 2017
Please don't +1 issues. It clutters the thread without adding value to the discussion and spams maintainers with notifications. Use GitHub reactions to upvote features.

4 remaining items
abdoolly commentedon Apr 9, 2018
checkout this package which may help you to make typescript models and ease out models initialization
https://www.npmjs.com/package/ts-sequelize-models
dantaub commentedon Jul 24, 2018
I would request that instead of
--typescriptwe would have--generatedExtension tsIf coupled with registering transformations based on extension, we could support output in coffeescript, livescript, es6, etc
Merge pull request sequelize#328 from exercism/fix-url
mankinchi commentedon Jan 17, 2020
Any updates on this?
mankinchi commentedon Jan 23, 2020
@mrdulin I ended up using this
intellix commentedon Apr 25, 2020
I assume the opinion has changed here since Sequelize 5 exports TypeScript types and could be of some value here. Would love type hints when writing my migrations as it's currently trial and error as the documentation often just says: "object" for options
AnthonyLzq commentedon Jul 23, 2022
It seems that there has been no progress on this requirement, so does anyone knows a reliable way to perform migrations with TS?
CyanoFresh commentedon Aug 3, 2022
would like to know too
mjovanc commentedon Oct 5, 2022
Any news? This seems like a very good proposition.
virgenherrera commentedon Oct 5, 2022
I'd better opt to migrate to Typeorm, since this library looks like this library is continuously ignoring Typescript support.
mjovanc commentedon Oct 5, 2022
@virgenherrera It doesn't make any sense to ignore it (if they seriously are). To work with databases and not to use TypeScript (which enforces types) seems rather ridiculous IMO.
WikiRik commentedon Oct 5, 2022
We're hard at work at improving TypeScript support for the main repo and we'll work on CLI after we've done most of our planned changes. v7 will have much better TypeScript support but we're open to PRs of the community in the meantime
IArnaut2 commentedon Feb 26, 2025
Any updates? It's 2025.
virgenherrera commentedon Feb 27, 2025
Since the last release of this ORM was on Nov 3, 2023, I think that no further updates will come to this project
nbkhope commentedon Apr 27, 2026
Now it's 2026 😉
Have you tried running sequelize cli like this?
That way, instead of using node, it uses tsx to run the migrations written with the .ts extension