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

Why don't you raise the version of Typeorm? #17

Open
SuzGori opened this issue Jul 11, 2023 · 20 comments
Open

Why don't you raise the version of Typeorm? #17

SuzGori opened this issue Jul 11, 2023 · 20 comments

Comments

@SuzGori
Copy link

SuzGori commented Jul 11, 2023

I am having trouble with the following error.
The version of Typescript seems to be old.

typeorm/typeorm#9357

@zaro
Copy link
Member

zaro commented Jul 12, 2023

@SuzGori can you provide a bit more information what exactly is your problem ?

The issue linked is really about TypeORM, and there is nothing stopping you from using this library with newer typescript version.

@SuzGori
Copy link
Author

SuzGori commented Jul 12, 2023

@zaro
Thanks for the reply.
I may have mistakenly thought it was a Typescript issue from the Issue.
I got the following error message and arrived at the ↑ link.

Error content

node_modules/@dataui/crud-typeorm/lib/typeorm-crud.service.d.ts:15:32 - error TS2344: Type 'T' does not satisfy the constraint 'ObjectLiteral'.

15     protected repo: Repository<T>;

@zaro
Copy link
Member

zaro commented Jul 12, 2023

@SuzGori what versions or TypeORM and TypeScript are you using ?

If possible it will be very helpful if you can provide with a minimal reproduction example repo.

@SuzGori
Copy link
Author

SuzGori commented Jul 12, 2023

Typescript and TypeORM versions are as follows

├── [email protected]
├── [email protected]

@SuzGori
Copy link
Author

SuzGori commented Jul 13, 2023

@zaro
I edited the following source and it was cured.
Do I need to pull it?

typeorm-crud.service.d.ts

export declare class TypeOrmCrudService<T extends ObjectLiteral> extends CrudService<T, DeepPartial<T>> {

Add extends ObjectLiteral

zaro pushed a commit that referenced this issue Jul 13, 2023
@zaro
Copy link
Member

zaro commented Jul 13, 2023

@SuzGori I just released 5.3.1-alpha.0

It has Typescript, nestjs, etc. updated.

Can you please confirm that the problem is resolved?

@SuzGori
Copy link
Author

SuzGori commented Jul 13, 2023

@zaro
Thanks for the reply.
The errors did not change.

@zaro
Copy link
Member

zaro commented Jul 14, 2023

@SuzGori I updated typescript & typeorm in the alpha because I assumed the older versions were the cause for the error.

Thank you for opening the PR, but I want to first understand how is this error happening ?

Generally the TypeORM models do NOT extend ObjectLiteral , so I am very curious why is this happening in your case .

Can you also provide the model you get this error from ?

@SuzGori
Copy link
Author

SuzGori commented Jul 16, 2023

@zaro
Is that what you mean?
I had assumed that others would have the same symptoms.

Then maybe it is a special case.

I am using Angular Universal to run NestJS this time.
That may have something to do with it.

Model is very simple.

    @PrimaryGeneratedColumn('uuid')
    uuid: string | undefined;

    @Column({ type: 'text', nullable: true })
    name: string | undefined;

    @CreateDateColumn({ type: 'timestamp', nullable: true })
    created_at: Date | undefined;

    @UpdateDateColumn({ type: 'timestamp', nullable: true })
    updated_at: Date | undefined;

@zaro
Copy link
Member

zaro commented Jul 16, 2023

@SuzGori OK I have no idea what angular universal is 😊

I meant the whole model class, the actual columns are irrelevant, but any parent classes will definitely matter. You see, if it was simply typeorm / typescript version this would have shown in the tests. But it doesn't, and I think it somewhat specific to your setup.

The bets thing you can do is create a minimal reproduction example, so that I can debug it myself. Else please at least provide a complete model definition that causes the error and also how exactly do you run it ( angular universal, etc.)

@SuzGori
Copy link
Author

SuzGori commented Jul 18, 2023

@zaro
Thankyou!
A minimal repository was created.
See below.

https://github.com/SuzGori/angular-universal-nest

You can also JIT compile with the following command.

npm ci
npm run dev:ssr

Note: This repository does not contain DB libraries.

@SuzGori
Copy link
Author

SuzGori commented Jul 20, 2023

@zaro
Is there anything I can do to help you?

@zaro
Copy link
Member

zaro commented Jul 20, 2023

@SuzGori I just got time to check your repo and I am trying to figure out what is the issue exactly.

@SuzGori
Copy link
Author

SuzGori commented Jul 20, 2023

@zaro
Oh wow!
Thanks for your excellent reply!
I would be happy to do something for you too!

@zaro
Copy link
Member

zaro commented Jul 20, 2023

@SuzGori please check version 5.3.1-alpha.3 . I did test with your repo and seems fine.

Once you confirm, I am going to publish it as release version.

@SuzGori
Copy link
Author

SuzGori commented Jul 20, 2023

@zaro
Thank you very much!
I will check it out!

@SuzGori
Copy link
Author

SuzGori commented Jul 21, 2023

@zaro

I am having trouble with the following webpack error.

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
   at objKeys (/Users/user/dir/project/dist/app/server/vendor.js:1795:31)

vendor.js:1795:31 is below

/***/ 6844:
/*!********************************************************!*\
  !*** ./node_modules/@dataui/crud-util/lib/obj.util.js ***!
  \********************************************************/
/***/ ((__unused_webpack_module, exports) => {

"use strict";


Object.defineProperty(exports, "__esModule", ({
  value: true
}));
exports.getOwnPropNames = exports.objKeys = void 0;
const objKeys = val => Object.keys(val); //  <--- Error
exports.objKeys = objKeys;
const getOwnPropNames = val => Object.getOwnPropertyNames(val);
exports.getOwnPropNames = getOwnPropNames;

/***/ }),

another

at Object.26414 (/Users/user/dir/project/dist/app/server/vendor.js:230:35)

/***/ 26414:
/*!************************************************************************!*\
  !*** ./node_modules/@dataui/crud-request/lib/request-query.builder.js ***!
  \************************************************************************/
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {

"use strict";


Object.defineProperty(exports, "__esModule", ({
  value: true
}));
exports.RequestQueryBuilder = void 0;
const crud_util_1 = __webpack_require__(/*! @dataui/crud-util */ 80308);
const qs_1 = __webpack_require__(/*! qs */ 29754);
const request_query_validator_1 = __webpack_require__(/*! ./request-query.validator */ 57996); // <-- Error
class RequestQueryBuilder {
  constructor() {

and another

at Object.70722 (/Users/user/dir/project/dist/app/server/vendor.js:3474:24)

/***/ 70722:
/*!********************************************************************************!*\
  !*** ./node_modules/@dataui/crud/lib/interceptors/crud-request.interceptor.js ***!
  \********************************************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {

"use strict";


var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
  var c = arguments.length,
    r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
    d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", ({
  value: true
}));
exports.CrudRequestInterceptor = void 0;
const common_1 = __webpack_require__(/*! @nestjs/common */ 49086);
const crud_request_1 = __webpack_require__(/*! @dataui/crud-request */ 68230); //<---Error

@zaro
Copy link
Member

zaro commented Jul 21, 2023

@SuzGori Now this is most probably because of different TS module settings for your project and the library.

Unfortunately I can't help you with that, but her is what I think about the problem ( take it with a gain of salt, it might be rubbish):

The library is compiled with "commonjs" (https://github.com/gid-oss/dataui-nestjs-crud/blob/master/tsconfig.json#L3) as the module system for most wide compatibility, and andgular universal uses the much newer : https://github.com/SuzGori/angular-universal-nest/blob/main/tsconfig.json#L20

I have no idea how to resolve that currently, usually what helps is using require() instead of import, or you can try a different import syntax like import CRUD from '@dataui/...'.

@SuzGori
Copy link
Author

SuzGori commented Jul 21, 2023

@zaro
Thank you very much.
I will check a little on my end.
The server version of tsconfig for AngularUniversal was commonjs.
https://github.com/SuzGori/angular-universal-nest/blob/829ce5de2790b1e629fc003daf74e20535668dc7/tsconfig.server.json#L5C7-L5C7

@SuzGori
Copy link
Author

SuzGori commented Aug 1, 2023

@zaro
It's still unresolved.
Worst case scenario, I'll clone the repository and continue development, but I hope there's a solution.

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