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
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
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.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









