givo / lib-kurento

A typescript library for simplifying the use of Kurento in Node.js
24 stars 5 forks source link

Nice. Thanks for sharing #1

Closed neilyoung closed 5 years ago

neilyoung commented 5 years ago

However, can't use your lib in my node ts app. What might go wrong?

import * as libKurento from 'lib-kurento';

src/index.ts(2,29): error TS2307: Cannot find module 'lib-kurento'.

neilyoung commented 5 years ago

OK, got it. But while using gulp on your lib i had some errors:

~/Documents/Kurento/lib-kurento $ gulp
[10:36:09] Using gulpfile ~/Documents/Kurento/lib-kurento/gulpfile.js
[10:36:09] Starting 'scripts'...
[10:36:09] Finished 'scripts' after 17 ms
[10:36:09] Starting 'watch'...
[10:36:09] Finished 'watch' after 12 ms
[10:36:09] Starting 'default'...
gulp out
[10:36:09] Finished 'default' after 66 μs
src/endpoints/recorder/recorder-endpoint.interface.ts(3,18): error TS2430: Interface 'IRecorderEndpointWrapper' incorrectly extends interface 'IEndpointWrapper'.
  Types of property 'on' are incompatible.
    Type '{ (event: "RecordingStarted", listener: (event: any) => void): this; (event: "RecordingStopped", listener: (event: any) => void): this; }' is not assignable to type '{ (event: "MediaFlowingIn", listener: (event: any) => void): this; (event: "MediaStoppedFlowingIn", listener: (event: any) => void): this; (event: "MediaFlowingOut", listener: (event: any) => void): this; (event: "MediaStoppedFlowingOut", listener: (event: any) => void): this; }'.
      Types of parameters 'event' and 'event' are incompatible.
        Type '"MediaFlowingIn"' is not assignable to type '"RecordingStarted"'.
src/endpoints/webrtc/webrtc-endpoint.interface.ts(3,18): error TS2430: Interface 'IWebRTCEndpointWrapper' incorrectly extends interface 'IEndpointWrapper'.
  Types of property 'on' are incompatible.
    Type '(event: "ServerIceCandidate", listener: (candidate: any) => void) => this' is not assignable to type '{ (event: "MediaFlowingIn", listener: (event: any) => void): this; (event: "MediaStoppedFlowingIn", listener: (event: any) => void): this; (event: "MediaFlowingOut", listener: (event: any) => void): this; (event: "MediaStoppedFlowingOut", listener: (event: any) => void): this; }'.
      Types of parameters 'event' and 'event' are incompatible.
        Type '"MediaFlowingIn"' is not assignable to type '"ServerIceCandidate"'.
[10:36:11] TypeScript: 2 semantic errors
[10:36:11] TypeScript: emit succeeded (with errors)
^C
~
givo commented 5 years ago

Hi!

I am aware of those errors, but don't worry, they are only semantic ones.

I am using function overloading and for some reason the compiler doesn't like that.

You shouldn't have any problems running the code, try to ignore them until I solve the problem.

neilyoung commented 5 years ago

@givo Thanks. I still had problems, but since it was of the "cannot find li-kurento" as result of my import, it is most likely my fault :) Thanks

givo commented 5 years ago

Great!

I am closing the issue, if you have any problems just let me know :)

SongLin123 commented 5 years ago

@givo I have the same problem as you!

givo commented 5 years ago

@SongLin123

For some reason Typescript compiler doesn't allow function overloading when having an interface that inherits from another interface:

export interface IWebRTCEndpointWrapper extends IEndpointWrapper{
    on(event: "ServerIceCandidate", listener: (candidate: any) => void): this;
}

But, overloading on(event, handler) inside the same interface does work:

export interface IEndpointWrapper {
    on(event: "MediaFlowingIn", listener: (event: any) => void): this;

    on(event: "MediaStoppedFlowingIn", listener: (event: any) => void): this;

    on(event: "MediaFlowingOut", listener: (event: any) => void): this;

    on(event: "MediaStoppedFlowingOut", listener: (event: any) => void): this;

    ...

If you have a solution, I'll be happy to hear.

SongLin123 commented 5 years ago

@givo Sorry I have no idea of this problem. But,maybe change package.json main:"./dist/index.ts" =>main:"./dist/index.js can solve your Cannot find module 'lib-kurento'. problem:)

givo commented 5 years ago

@SongLin123

Fixed in v0.0.2