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

FAQ: diffence of import and require #334

Open
malleus35 opened this issue Apr 14, 2020 · 0 comments
Open

FAQ: diffence of import and require #334

malleus35 opened this issue Apr 14, 2020 · 0 comments

Comments

@malleus35
Copy link

Hello, I want to use seneca with Typescript.
So, I import seneca node package to use import statement.
I run tutorial code to have little change. Like this.

import Seneca from "seneca";
const seneca = Seneca();

seneca.add({ role: "math", cmd: "sum" }, function (
  msg: any,
  respond: Function
) {
  var sum = msg.left + msg.right;
  respond(null, { answer: sum });
});

seneca.add({ role: "math", cmd: "product" }, function (
  msg: any,
  respond: Function
) {
  var product = msg.left * msg.right;
  respond(null, { answer: product });
});

seneca
  .act({ role: "math", cmd: "sum", left: 1, right: 2 }, console.log)
  .act({ role: "math", cmd: "product", left: 3, right: 4 }, console.log); // This line has Error
/*
*  Property 'act' does not exist on type 'void'.ts(2339)
*/

Could you tell me how can i use ES6 module system?
If this problem can't solve without CommonJS module system, then i use require statement.
Thanks

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