Seeing something weird with order of imports
See original GitHub issueHaving 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:
- Created 5 years ago
- Comments:9 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Same here, version
3.2.0
Worked for me.
P.S: The url of example has changed. https://github.com/nestjsx/crud/blob/master/integration/crud-typeorm/companies/companies.controller.ts#L32