voltbras / ts-ocpp

:zap: OCPP (Open Charge Point Protocol) implemented in Typescript.
https://voltbras.github.io/ts-ocpp
MIT License
43 stars 25 forks source link

TypeScript compile error #10

Closed securez closed 3 years ago

securez commented 3 years ago

First of all, congratulations for this great library, I'm using it to emulate real CPs, I create a really simple project that creates a ChargePoint and connect to a real Central Server, when I ran it with ts-node it executes without problems, but when I try to compile with tsc i get this errors:

$ npm run build

> nodejs-sandbox@1.0.0 build
> rimraf ./dist && tsc

node_modules/@voltbras/ts-ocpp/dist/messages/index.d.ts:6:93 - error TS2536: Type '"request"' cannot be used to index type 'ReqRes<T, V>'.

6 export declare type Request<T extends ActionName<V>, V extends OCPPVersion = OCPPVersion> = ReqRes<T, V>['request'];
                                                                                              ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@voltbras/ts-ocpp/dist/messages/index.d.ts:7:94 - error TS2536: Type '"response"' cannot be used to index type 'ReqRes<T, V>'.

7 export declare type Response<T extends ActionName<V>, V extends OCPPVersion = OCPPVersion> = ReqRes<T, V>['response'];
                                                                                               ~~~~~~~~~~~~~~~~~~~~~~~~

Found 2 errors.

I want to contribute to the library, I see that have some missing things, CI, lint, other ocpp-j and ocpp-s protocols, npm package, etc. I thing that could be great if this tasks will be created so people that want to help, have some clue on priority things.

eduhenke commented 3 years ago

Hello @securez, thanks, we appreciate that :)

Were you able to compile that? I saw that you posted another issue, so I thought so. If you were able to compile it, could you share us what you did?

Also, yes, all the help we can get, would be super great!

It's my first time creating a public NPM package, so I kinda don't know how to do it properly hahaha. Especially with the CI/NPM Package thingy. I currently have a private token that allows me to publish the package using yarn deploy, but if we could install a CI, it would be great, as well as linting, and supporting other protocols.

I'm gonna create those issues so we can work on them, and please feel free to contribute to whatever you like.

Also sorry for the late response!

securez commented 3 years ago

Hi,

Totally my mistake, I had a project that uses the ts-ocpp as a dependency, my tsconfig.json don't had a skipLibCheck and this error blow up on tsc invocation, despite the output js files generated without problems, In dev mode I ran it via ts-node and this error doesn't blow up, is totally TypeScript config related.

I added this option to my tsconfig.json and the error disappeared, you can close the issue sorry.