Skip to content

Unable to get 'export default' to work #1

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

Open
dougreed opened this issue Mar 4, 2018 · 2 comments
Open

Unable to get 'export default' to work #1

dougreed opened this issue Mar 4, 2018 · 2 comments

Comments

@dougreed
Copy link

dougreed commented Mar 4, 2018

I have an issue with sequelize-typescript. I cannot duplicate the success in this example.

I create a table definition i.e.:

@table({tableName: "security.security_user"})
export default class User extends Model {
...

Then the 'default' doesn't really do anything, and it cannot resolve even the functions in the defined class at 'tsc' compile time. If I don't define 'default' I get the same thing. Your example does not use default and it works fine.

If I define:

@table({tableName: "security.security_user"})
export class User extends Model {
...

and don't set a default there, but define something like 'export default this.Model('User', User)' after I close the definition, then compile works, but at run time, it fails because 'this.Model' is nonsense.

Your example imports using import {Movie} from '../models/Movie', but My routes complain that I have no exported members. I can only import using import User from '../models/User', .. i.e. no braces.

I would appreciate any advice you can give.

@RobinBuschmann
Copy link
Owner

Hey @dougreed, I don't fully understand your issue.

When using default exports like export default class User extends Model<User> {} you need to import them with import User from './path/to/user' or import {default as User} from './path/to/user'

For named exports like export class User extends Model<User> {} use import {User} from './path/to/user'

If this doesn't solve your problem, can you provide an example repo, so that I can have a look at it?

@dougreed
Copy link
Author

dougreed commented Mar 5, 2018 via email

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

2 participants