Create and publish.
https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html
Do you mean adding definition files for the library itself or for the protocol too?
In the former case it should be quite trivial as the exposed API is fairly small, in the latter I guess we'd need a way to generate it from the JSON during the prepublish phase, no idea about how hard it can be... But even in that case it wouldn't cover the case in which the protocol is fetched at runtime. So I don't think it's feasible. Thoughts?
PS I know approximately nothing about TypeScript.
Just for the library itself.
EDIT (July 2017): please see https://github.com/ChromeDevTools/devtools-protocol/issues/18.
the rest of my comment is mostly outdated.
I don't know of any current and maintained typings for the protocol except for the closure compiler externs that devtools team maintains in the protocol repo: https://github.com/ChromeDevTools/devtools-protocol/tree/master/externs
I'd greatly benefit from this in my high-level project (https://github.com/joelgriffith/navalia). I'd be happy to tackle a Domain or two if manual work is needed.
Seems like a lot could be automated from the typedefs exposed inside of the protocol.
Looks like https://github.com/krisselden/chrome-debugging-client have very extensive ts interfaces for the protocol
@joelgriffith, @Bnaya thanks for the info and willing to help. While there are certainly ways to generate the typing definitions from the JSON I don't think it would suit this module, the protocol.json bundled in this repo is there just for convenience, ideally one would pull it from Chrome directly (which is now possible), in this way one can be sure that the present version is the right one; or even pass in a custom JSON descriptor for whatever reason.
In these cases the generation wouldn't work because (AFAIK) the TypeScript definitions cannot be enforced at runtime. Rather, I think that this feature should be handled at user-level or by a third party (e.g., DefinitelyTyped) and used only when an application target a specific version of Chrome (unlikely) or if just a stable subset of the protocol is needed.
What do you think?
TypeScript definitions are never really enforced during runtime, even with definitions generated directly from a TypeScript source.
TypeScript's compiler strives to essentially provide compile-time safety, so there's no reason to try to have runtime safety. It's not one of TypeScript's goals. Pragmatically, they try to stay as close to "JS with types" as possible. Compilation then essentially verifies the types, and strips all type information.
Could always just bundle a script to generate typings so a user can generate and utilize them for whatever version/configuration they'd like? Instead of maintaining a separate repository.
Could always just bundle a script to generate typings so a user can generate and utilize them for whatever version/configuration they'd like? Instead of maintaining a separate repository.
@simply-jos this could actually make sense.
Found the following which could be relevant for reference.
Canonical upstream issue is this: https://github.com/ChromeDevTools/devtools-protocol/issues/18
@cyrus-and Would this work?
Might be worth a shot using that script. It's better than nothing? Should we try and get it included in the @types namespace since that's where most TS definitions go that aren't part of their respective packages?
Alright so let's try to recap, there are two separate parts of this issue:
The problem with 2 is that it cannot be performed at runtime, meaning that the typings should ideally be re-generated for every release of Chrome. This is IMHO too cumbersome to be useful, but I understand that some people would benefit from that. Apparently something is moving (ChromeDevTools/devtools-protocol#90) so ideally the generation script will be hosted there; @paulirish can you confirm?
About 1, I agree on the [DefinitelyTyped] approach as @joelgriffith suggested. I will not embark on writing and maintaining a TypeScript interface for this module though, so whoever is interested should send a PR there. I'm of course available for any question about this module API.
Yup, We'll be merging that protocol types PR once brendan and joel are
happy.
The generation script will be part of the -protocol repo and the generated
.d.ts will be distributed in the devtools-protocol npm package. (though I'm
fine if someone else wants to ship them into a @types package or w/e)
On Tue, Mar 27, 2018 at 3:54 AM, Andrea Cardaci notifications@github.com
wrote:
Alright so let's try to recap, there are two separate parts of this issue:
- typing info for this module API, hand made;
- typing info for the protocol, generated somehow.
The problem with 2 is that it cannot be performed at runtime, meaning that
the typings should ideally be re-generated for every release of Chrome.
This is IMHO too cumbersome to be useful, but I understand that some people
would benefit from that. Apparently something is moving (
ChromeDevTools/devtools-protocol#90
https://github.com/ChromeDevTools/devtools-protocol/pull/90) so ideally
the generation script will be hosted there; @paulirish
https://github.com/paulirish can you confirm?About 1, I agree on the DefinitelyTyped
https://github.com/DefinitelyTyped/DefinitelyTyped approach as
@joelgriffith https://github.com/joelgriffith suggested. I will not
embark on writing and maintaining a TypeScript interface for this module
though, so whoever is interested should send a PR there. I'm of course
available for any question about this module API.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/cyrus-and/chrome-remote-interface/issues/112#issuecomment-376482554,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AACZF1eUhBtkTdcYkyvmYJbmzDU8OEtlks5tihprgaJpZM4NEjaO
.
Sounds like a plan!
Hey ;)
Is it possible to get it done finally :) ?
@piotrmoszkowicz so:
yah https://github.com/ChromeDevTools/devtools-protocol/tree/master/types probably has most of what you need, though you'll have to apply them a bit yourself.
@cyrus-and @paulirish I'd like to take this up!
I already have rudimentary typings for all of CDP's built-in methods, but to import the protocol definitions, I'd either have to have a cron-like job that pulls in https://github.com/ChromeDevTools/devtools-protocol and adds it in and publishes it, or CDP can include this as a dependency and I can simply reference it.
The former is more tedious and requires an ever-running job, but keeps CDP clean. The latter is far lesser work, but includes an additional (albeit lightweight) dependency that non-TypeScript developers would not need.
Thoughts?
@paambaati i'm open to adding the typings into the devtools-protocol package. wanna make a pull request there? you'll see the protocol-dts-generator.ts that generates the existing ones.
@cyrus-and @paulirish Here's what I've written — https://github.com/paambaati/DefinitelyTyped/blob/chrome-remote-interface/types/chrome-remote-interface/index.d.ts
i'm open to adding the typings into the devtools-protocol package
@paulirish Do you mean adding typings for chrome-remote-interface into devtools-protocol? If yes, would that mean adding devtools-protocol as a dependency for TS users using this library?
@paambaati did you submit the PR to DefinitelyTyped?
@cyrus-and Not yet, I'm still mulling over how to add the Protocol methods, seeing as how they have to be auto-generated every time a new version drops.
@paulirish Bump!
Do you mean adding typings for
chrome-remote-interfaceintodevtools-protocol?
So... there was an attempt (DefinitelyTyped/DefinitelyTyped#31313) but the PR has been closed for inactivity (?); those interested could try to resume that.
I'm closing this as there isn't enough interest to make it happen apparently. Anyone interested can submit a PR to DefinitelyTyped possibly using DefinitelyTyped/DefinitelyTyped#31313 as a base line. (Feel free to link back here if you decide to do so.)
For what concerns the protocol API instead please refer to these files from ChromeDevTools/devtools-protocol.
Cheers.
Most helpful comment
Canonical upstream issue is this: https://github.com/ChromeDevTools/devtools-protocol/issues/18