It would be very nice if this package supplies its types on its own for a better and complete typescript support.
The types provided by DefinitelyTyped with the package @types/simple-peer are very poor and useless
Thanks
Struggling from last 6 hours for creating SimplePeer object. Requesting you to please help us with proper typings.
npm i @types/simple-peer
import * as SimplePeer from 'simple-peer';
private peer: SimplePeer.Instance;
seems to be working for me
@giacomodeliberali, Thanks for your help, it is working now. I am not really understanding syntax
can you please tell me how to instantiate the private peer: SimplePeer.Instance;
Just this.peer = new SimplePeer()
@giacomodeliberali Thanks for your response.
Still I am getting an error. Requesting you to check error and component blocks in below snippet.
(alias) namespace SimplePeer
(alias) const SimplePeer: {
default: SimplePeer.SimplePeer;
WEBRTC_SUPPORT: boolean;
}
import SimplePeer
This expression is not constructable.
Type '{ default: SimplePeer; WEBRTC_SUPPORT: boolean; }' has no construct signatures.ts(2351)
call-dash.component.ts(2, 1): Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead.
import { Component, OnInit } from '@angular/core';
import * as SimplePeer from 'simple-peer';
@Component({
selector: 'app-call-dash',
templateUrl: './call-dash.component.html',
styleUrls: ['./call-dash.component.css']
})
export class CallDashComponent implements OnInit {
private peer: SimplePeer.Instance;
constructor() { }
ngOnInit(): void {
this.peer = new SimplePeer()
}
}
Try changing
import * as SimplePeer from 'simple-peer';
to
import SimplePeer from "simple-peer";
Are anyone working on this at the moment? If not, I would be happy to pick it up!
If you are going to add typescript support, please make it OPTIONAL and not convert everything and force end users to use it.
I personally have no interest in typescript and think it's existence is pretty pointless and tries to solve a problem that never existed. It makes me feel dumb to have to learn a new "version" of JavaScript while I've been
developing Javascript since the 90's when it was first invented.
Forcing end users to use something is almost as bad when websites/programs "update" their websites with totally different GUIs and force people to use it, so PLEASE don't do that, just make another optional branch or something if you choose to add support for it.
@gittyup2018 trend says something different about typescript.

Having typescript as native support in an npm library instead of relying as a separate install is normal these days. You don't have to use typescript if library supports typescript i.e 100% es5 module/syntaxt will still work with any library which is what you want. Having said that, you can 100% use pure javascript with no typescript and that is valid typescript, but typescript does help in so many ways that javascript may create problem for many developers, things like type checking, refactoring etc. This is the same reason Google, Facebook and Microsoft are using typescript on so many projects.
Anyway, lets not get into a long debate and consider suggestion in this issue will work for typescript and non-typescript developers :)
@halvardssm If you want to PR typescript into this package, I'll merge it. But I don't use typescript, nor I do plan to convert this project to it so you (or someone) needs to help keep the typings up to date. If they get out-of-date and no one steps up to update them, I'll have to remove them.
If you are going to add typescript support, please make it OPTIONAL and not convert everything and force end users to use it.
I personally have no interest in typescript and think it's existence is pretty pointless and tries to solve a problem that never existed. It makes me feel dumb to have to learn a new "version" of JavaScript while I've been
developing Javascript since the 90's when it was first invented.Forcing end users to use something is almost as bad when websites/programs "update" their websites with totally different GUIs and force people to use it, so PLEASE don't do that, just make another optional branch or something if you choose to add support for it.
typescript is always optional, all typescript libraries produce a .js file that any javascript project can use
No one has stepped up to submit typings and I don't have any plans to work on this so I'm going to close it. If you would like to see it implemented, please send a pull request.
Most helpful comment
@gittyup2018 trend says something different about typescript.
Having typescript as native support in an npm library instead of relying as a separate install is normal these days. You don't have to use typescript if library supports typescript i.e 100% es5 module/syntaxt will still work with any library which is what you want. Having said that, you can 100% use pure javascript with no typescript and that is valid typescript, but typescript does help in so many ways that javascript may create problem for many developers, things like type checking, refactoring etc. This is the same reason Google, Facebook and Microsoft are using typescript on so many projects.
Anyway, lets not get into a long debate and consider suggestion in this issue will work for typescript and non-typescript developers :)