andrewf

andrewf

Recommended Typescript definitions for Phoenix Javascript library

Hi, I’m relatively new to Phoenix and Typescript, and ran into a problem. The type definitions installed in the “@types/phoenix” npm package (GitHub - DefinitelyTyped/DefinitelyTyped: The repository for high quality TypeScript type definitions. · GitHub) don’t include the “params” property on the Channel object. I kind of need that property, but when I use it Typescript throws a bunch of errors.

What’s the recommended approach for using Phoenix’s JS library from Typescript? Is there a different type definition package I should use, or do most people just copy type definitions from somewhere else into their own code? Is there another approach I don’t see?

Thanks! As I said, I’m new to this ecosystem, so if I missed some documentation go ahead and just link it.

Marked As Solved

John-Goff

John-Goff

If the types in this package are wrong, please submit a PR! I’ve done so myself in the past and it’s not terribly hard to do, and it’ll get accepted pretty fast.

To answer your question though, no I am not aware of any other typescript types for Phoenix.

Last Post!

andrewf

andrewf

For posterity: it was user error. I guess you’re not supposed to directly assign to channel.params anymore, but pass a closure to the Channel constructor that returns up-to-date params when called.

Anyway, the definitions in @types/phoenix are correct AFAICT.

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement