module.exports vs export class

Viewed 102

I am writing my first library for npm.

I have a class file:

export class Foo {

  bar: string;

  ...
}

A test file:

import { Foo } from '../models/foo';


test('Foo', () => {
  let s = new Foo('Steve');
  expect(s.bar).toBe('Steve');
});

and an index.ts file:

module.exports = Student;

The issue I am having is that I cannot do a "module.exports" and "export class." If I drop the module.exports, then I can run the jest test no problem; but the resulting "index.js" file (after transpilation) is empty. Does that matter?

If I drop the "export" in "export class" my test cannot find the Foo class.

What is the proper way to handle this?

0 Answers
Related