Skip to content

Typescript typings - #627

Merged
jmillan merged 1 commit into
versatica:masterfrom
phwb:typings
Jun 1, 2020
Merged

jmillan merged 1 commit into
versatica:masterfrom
phwb:typings

Conversation

@phwb

@phwb phwb commented May 8, 2020

Copy link
Copy Markdown
Contributor

Hi! I've put together some Typescript typings. Please review. Not all types covered, I will continue work on it.

@jmillan

jmillan commented May 8, 2020

Copy link
Copy Markdown
Member

Looks very nice!

Is all the API covered?

@jmillan

jmillan commented May 8, 2020

Copy link
Copy Markdown
Member

Is all the API covered?

Oh, you already said it's a work in progress. Nice!

@phwb

phwb commented May 8, 2020

Copy link
Copy Markdown
Contributor Author

I covered only main API

image

@jmillan

jmillan commented May 8, 2020

Copy link
Copy Markdown
Member

What about having each type in the corresponding file and have a index.d.ts exporting them all?

So we would have RTCPeerConnection.d.ts, UA.d.ts etc.

@jmillan

jmillan commented May 8, 2020

Copy link
Copy Markdown
Member

I covered only main API

👍

looking good so far.

@phwb

phwb commented May 8, 2020

Copy link
Copy Markdown
Contributor Author

What about having each type in the corresponding file and have a index.d.ts exporting them all?

Honestly, i don't think about it, may be do it in next PR 🙂

@jmillan

jmillan commented May 8, 2020

Copy link
Copy Markdown
Member

Honestly, i don't think about it, may be do it in next PR 🙂

Are you thinking on completing the API in this PR?

@phwb

phwb commented May 8, 2020 •

Copy link
Copy Markdown
Contributor Author

Yes. I already use this types in production

@jmillan

jmillan commented May 8, 2020

Copy link
Copy Markdown
Member

Yes. I already use this types in production

I mean whether you are willing to complete the full public API in this PR. Since you say not all types are covered.

@phwb

phwb commented May 10, 2020 •

Copy link
Copy Markdown
Contributor Author

Hi, I fully covered documented API and split into separate files 🙂

Comment thread .gitignore Resolved
@jmillan

jmillan commented May 11, 2020

Copy link
Copy Markdown
Member

Let us some days to review this.

Looks great BTW.

@phwb
phwb force-pushed the typings branch 2 times, most recently from 53dd4ff to 5862905 Compare May 11, 2020 18:12
@jmillan

jmillan commented May 13, 2020

Copy link
Copy Markdown
Member

@ibc can you please check it? It looks good to me so far.

@ibc

ibc commented May 13, 2020

Copy link
Copy Markdown
Member

While this is a nice work (thanks a lot) I'm afraid this will be hard to maintain. For instance, it misses new API introduced in PR #629. Can you add it please?

I think we should eventually rewrite the whole lib in TypeScript so it would be easier to maintain.

@ibc ibc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just please add the new transportType in sendDTMF() which has been introcuded today.

@phwb

phwb commented May 13, 2020

Copy link
Copy Markdown
Contributor Author

I think we should eventually rewrite the whole lib in TypeScript so it would be easier to maintain.

It will be great. I think, i can help with it.

LGTM. Just please add the new transportType in sendDTMF() which has been introcuded today.

ок

@phwb
phwb force-pushed the typings branch 2 times, most recently from 270b63d to 08c9d50 Compare May 13, 2020 16:22
@phwb

phwb commented May 13, 2020

Copy link
Copy Markdown
Contributor Author

add the new transportType in sendDTMF()

done

Comment thread package.json Resolved
@ibc

ibc commented May 26, 2020

Copy link
Copy Markdown
Member

@jmillan can we discuss this tomorrow?

Comment thread package.json Resolved

@ibc ibc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work!

@jmillan
jmillan merged commit 06c0e8a into versatica:master Jun 1, 2020
@jmillan

jmillan commented Jun 1, 2020

Copy link
Copy Markdown
Member

Merged into master,

Thanks @phwb :-)

@jmillan

jmillan commented Jun 1, 2020 •

Copy link
Copy Markdown
Member

@phwb, we'll announce the TS support in JsSIP and want to reference you if you are OK with it.

Do you have a Twitter account or do you prefer to point to your Github one?

@phwb

phwb commented Jun 1, 2020

Copy link
Copy Markdown
Contributor Author

@phwb, we'll announce the TS support in JsSIP and want to reference you if you are OK with it.
Do you have a Twitter account or do you prefer to point to your Github one?

Yes, it will be nice 🙂 you can use my Github account

@jmillan

jmillan commented Jun 3, 2020

Copy link
Copy Markdown
Member

There you are: https://twitter.com/jomivi/status/1268085538042544133

Thanks!

@arkaev

arkaev commented Jul 8, 2020

Copy link
Copy Markdown

Hello.
Decision to add @types/node is totally wrong. It breaks types for projects that don't use it. Please remove it

@phwb

phwb commented Jul 8, 2020

Copy link
Copy Markdown
Contributor Author

Decision to add @types/node is totally wrong. It breaks types for projects that don't use it. Please remove it

Hi,
Can you show breaking code or repo?

@arkaev

arkaev commented Jul 8, 2020 •

Copy link
Copy Markdown

For example:
"dependencies": {
"jssip": "3.5.2"
},
"devDependencies": {
"@types/events": "^3.0.0"
}

import { Listener } from 'events';
^
Module '"events"' has no exported member 'Listener'

And many issues in TypeScript github about this situation. Official position of this command - fix dependency in library
microsoft/TypeScript#18588
microsoft/TypeScript#17042

@phwb

phwb commented Jul 8, 2020

Copy link
Copy Markdown
Contributor Author

And many issues in TypeScript github about this situation. Official position of this command - fix dependency in library

thanks, i will look at this soon

@jmillan

jmillan commented Jul 8, 2020

Copy link
Copy Markdown
Member

Adding it as devDependency would be the way to go in JsSIP, right?

@arkaev

arkaev commented Jul 8, 2020

Copy link
Copy Markdown

I can't check but looks like devDependency is good move

@phwb

phwb commented Jul 9, 2020

Copy link
Copy Markdown
Contributor Author

@arkaev you can install manually @types/events, it fix you problem.

@arkaev

arkaev commented Jul 9, 2020

Copy link
Copy Markdown

@phwb it's just an example. Problem more complex with many conflicts... And can be solved by typeRoots with manually fixed types. But it's ugly and unmantainable

@phwb
phwb deleted the typings branch July 9, 2020 06:16
@phwb phwb mentioned this pull request Jul 9, 2020
@phwb

phwb commented Jul 9, 2020

Copy link
Copy Markdown
Contributor Author

@arkaev i create PR #645 to fix this problem

@jmillan

jmillan commented Jul 9, 2020

Copy link
Copy Markdown
Member

So basically @types/node is the culprit and should not be used as dependency?

@phwb

phwb commented Jul 9, 2020 •

Copy link
Copy Markdown
Contributor Author

So basically @types/node is the culprit and should not be used as dependency?

Sounds like yes, it should be replaced.

I've done it because tsc does it.
I created empty project, add events and @types/events as dependencies, create .ts file:

import {EventEmitter} from 'events'

compile tsc -d and got the following file:

/// <reference types="node" />
import {EventEmitter} from 'events'

/// <reference path="..." /> directive needs @types/node as deps

@phwb

phwb commented Jul 9, 2020

Copy link
Copy Markdown
Contributor Author

Although... If you want to rewrite all code into typescript, then you got same result

/// <reference types="node" />
import {EventEmitter} from 'events'

and @types/node is correct

@phwb

phwb commented Jul 9, 2020 •

Copy link
Copy Markdown
Contributor Author

@arkaev I think, that replace @types/node to @types/events, doesn't solve you problem. Read my last two comments.

@arkaev

arkaev commented Jul 9, 2020

Copy link
Copy Markdown

devDependencies should solve problem

@phwb

phwb commented Jul 9, 2020

Copy link
Copy Markdown
Contributor Author

devDependencies should solve problem

no, because tsc write /// <reference types="node" /> in .d.ts file, when project migrate to typescript

@arkaev

arkaev commented Jul 9, 2020 •

Copy link
Copy Markdown

Do you use something from node typings? Found regexpp package with @types/node as devDepenency but without reference in typings

@phwb

phwb commented Jul 9, 2020

Copy link
Copy Markdown
Contributor Author

@arkaev my apologies, i mistake. I created an empty project one more time, compile it and tsc doesn't write /// <reference types="node" /> to .d.ts file. I will reopen PR with fix.

@phwb

phwb commented Jul 9, 2020

Copy link
Copy Markdown
Contributor Author

#648

lcl987512 pushed a commit to lcl987512/JsSIP that referenced this pull request Aug 21, 2020
Co-authored-by: Vitaliy Yakovenko <yakovenkovv@yandex-team.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants