简体   繁体   中英

using TypeScript and Sails.js is giving issues, TypeError: object is not a function

Converted my Sails.js app to using TypeScript and when I try to hit my previous routes I'm getting errors around "TypeError: object is not a function".

I created a controller using a Class and re-wrote my functions in TypeScript. At the end I instantiated my new controller doing

var controller = new TestController();
export = controller;

I'm not understanding what I did wrong here. I referenced the work done on http://alexclavelle.blogspot.com/2015/03/using-sailsjs-with-typescript.html?showComment=1435617822375

Still nothing...I'm guessing it is something with the es5 code that gets generated.

Based on:

var controller = new TestController();
export = controller;

the runtime cannot do controller() .

Fix:

var controller = () => new TestController();
export = controller;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM