andrewf
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.
Trending in Questions
Other Trending Topics
Latest Phoenix Threads
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
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #elixirconf-us
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 3- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
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.
andrewf
Ha, well, part of the problem is that I’m not experienced enough to know if the problem is really with the type definitions or some kind of user error.
But if DefinitelyTyped really is the canonical source, I guess the options are user error or pull request.
andrewf
For posterity: it was user error. I guess you’re not supposed to directly assign to
channel.paramsanymore, but pass a closure to the Channel constructor that returns up-to-date params when called.Anyway, the definitions in
@types/phoenixare correct AFAICT.