question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Seeing something weird with order of imports

See original GitHub issue

Having a few issues starting with the example code outlined in the base readme. It seems that when I import Crud before my entity in my controller I get a stack trace

TypeError: typeorm_1.Entity is not a function
    at Object.<anonymous> (\src\app\posts\post.entity.ts:3:2)
import { Crud } from '@nestjsx/crud';
import { Post } from './post.entity';

However, when I import Post entity before Crud it seems to work. Additionally, when I try to POST { “content”: “blah” } it returns with a 500 with stack trace

TypeError: Cannot read property 'createOne' of undefined
    at PostsController.createOneBase (\src\decorators\crud.decorator.ts:207:25)

Code: Entity:

import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';

@Entity()
export class Post {
    @PrimaryGeneratedColumn()
    id: number;

    @Column({ length: 500 })
    content: string;
}

Controller

import { Post } from './post.entity';
import { Crud } from '@nestjsx/crud';
import { Controller } from '@nestjs/common';
import { PostsService } from './posts.service';

@Crud(Post)
@Controller('posts')
export class PostsController {
    constructor(private readonly postService: PostsService) {}
}

Am I missing something obvious? Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
avatsaevcommented, Apr 1, 2019

Same here, version 3.2.0

1reaction
ymoreiratiticommented, Jan 10, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Wrong order in import when using sort imports in vscode #14254
Just try to sort imports as I explained above and it should happen. Logs. Here are the logs from vscode. > ~/Development/virtual_env/bin/python ...
Read more >
What's the correct way to sort Python `import x` and `from x ...
Imports are generally sorted alphabetically and described in various places besides PEP 8. Alphabetically sorted modules are quicker to read ...
Read more >
Python import: Advanced Techniques and Tips
In particular, it'll look in a module cache to see if something has ... Order imports alphabetically within each group. ... Something weird...
Read more >
194358 – [import rewrite] Organize Imports produces wrong ...
Group sort order remains set by the current preferences, ... Import rewriter is not called very often, so anything up to 1 second...
Read more >
6 Common CSV Import Errors and How to Fix Them - Flatfile
Discover the top 6 most common CSV import errors that companies ... are in the wrong order or required fields – columns –...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found