tenry92 / orm-js

Database abstraction layer using decorators.
4 stars 0 forks source link

Compilation errors of default code example #3

Open chiarelli opened 7 years ago

chiarelli commented 7 years ago

I was running the example: README.md, however the following errors occurred:

1. I was trying to connect to a database and it was this error that launched:

file:///home/raphael/wokspace-VSCode/test_ormtypescript/dist/node_modules/orm-js-sqlite/node_modules/sqlite/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/set-blocking/index.js

index.js:3Uncaught TypeError: Cannot read property '_handle' of undefined(anonymous function) 
@ index.js:3t.exports 
@ index.js:2(anonymous function) 
@ log.js:11r.52._process 
@ log.js:302u 
@ _prelude.js:1(anonymous function) 
@ node-pre-gyp.js:15r.46.../package 
@ node-pre-gyp.js:191u 
@ _prelude.js:1(anonymous function) 
@ sqlite3.js:1r.44../trace 
@ sqlite3.js:189u 
@ _prelude.js:1(anonymous function) 
@ main.js:5r.43.fs 
@ main.js:646u 
@ _prelude.js:1r.41.orm-js/abstract-database 
@ index.js:11u @ _prelude.js:1r.133.../entities/pessoa 
@ connection.js:40u
@ _prelude.js:1r.132../persistence/connection 
@ main.js:2u 
@ _prelude.js:1e 
@ _prelude.js:1(anonymous function)
@ _prelude.js:1

2. My compiler complained about this snippet of code:

...
var connection = new SqliteDatabase("database.db");
orm.setDatabase(connection);
...

source/persistence/connection.ts(7,17): error TS2345: Argument of type 'SqliteDatabase' is not assignable to parameter of type 'AbstractDatabase'. Types of property 'schema' are incompatible. Type 'Schema' is not assignable to type 'Schema'. Property 'hasTable' is missing in type 'Schema'.

tenry92 commented 7 years ago

I can reproduce the second error. I'm investigating into this to fix the bug.

In the meantime, you can use orm-js@0.1.6 (current version is orm-js@0.2.1), that should work for now.

$ npm install orm-js@0.1.6
chiarelli commented 7 years ago

The strange thing about error 1. is that instances of "SqliteDatabase" is an "AbstractDatabase" type, but even then, a compiler error occurs (Could the error be in the "tsconfig.json" configuration?)

I'm going to downgrade and I'll report back to you later.

Regarding the code of yours is written in es6 my compiler is presenting the following error:

/home/raphael/wokspace-VSCode/test_ormtypescript/node_modules/orm-js/orm.js:10 const changeCase = require('change-case'); ^^^^^ SyntaxError: Use of const in strict mode. at Module._compile (module.js:439:25) at Module._extensions..js (module.js:474:10) at Object.require.extensions.(anonymous function) [as .js] (/home/raphael/wokspace-VSCode/test_ormtypescript/node_modules/babel-cli/node_modules/babel-register/lib/node.js:152:7) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at Object. (/home/raphael/wokspace-VSCode/test_ormtypescript/source/persistence/connection.js:38:11) at Module._compile (module.js:456:26) at loader (/home/raphael/wokspace-VSCode/test_ormtypescript/node_modules/babel-cli/node_modules/babel-register/lib/node.js:144:5) [nodemon] app crashed - waiting for file changes before starting...

I believe this error is on my side, but would you have any solution for me to run javascript-es6 on my nodejs?

I've already used babel to do the transpilation for es5, but it only solves for my code. If there was a js-ES6 code in the dependencies (node_modules) the error persists (or am I not setting babel to run correctly?)

chiarelli commented 7 years ago

I downgraded to orm-js@0.1.6 version, but received the following error:

[16:07:36] Using gulpfile ~/wokspace-VSCode/test_ormtypescript/gulpfile.js [16:07:36] Starting 'default'... [16:07:36] Starting 'lint'... [16:07:37] Finished 'lint' after 440 ms [16:07:37] Starting 'build'... [16:07:37] Starting 'build-app'... [16:07:37] Starting 'build-test'... [16:07:39] Finished 'build-test' after 2.5 s source/entities/pessoa.ts(6,10): error TS2339: Property 'field' does not exist on type 'typeof "/home/raphael/wokspace-VSCode/test_ormtypescript/node_modules/orm-js/decorators"'.

tenry92 commented 7 years ago

It's strange. SqliteDatabase is a subclass of AbstractDatabase, I'm unsure why this is occurring now. I've checked an older project of mine, that uses orm-js@0.1.6 and orm-js-sqlite@0.1.2.

I'll do further investigations tomorrow. Thank you for trying out my unstable module and giving me feedback :-)