-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[request] generic Property type #8930
Comments
Thanks @rot1024 I've been trying to carve out the time to write up this issue myself. We definitely want Property to be a generic and to be able to express this through the documentation. We started experimenting with generics for Event in #8903 (tsd-jsdoc can express them with |
Matt, if I made Property generic with a default the same way I did with Event, would there be any reason to hold back on it? Should it be a separate PR or would it make sense to just pile it in to #8903 ? |
I put together this branch to just kind of see what it would look like. I stumbled in a couple of places that I did not expect:
The docs don't currently do anything with the |
I think this comment goes here in this thread? I am leading a large project to move an old C++ 3D app to a Cesium based one. We are trying use/learn typescript but we want it to be as close to vanilla JS as possible so we can switch when we want for quick prototyping purposes. Just a few days ago I got TS working but there was an uneasy amount of redness that filled my VSCode editor concerning Cesium. This is of particular concern: What is the proper way to address this and how far does the method to get rid of these red squiggles diverge from plain JS? |
I believe you can wrap the call to The workaround for now is to wrap it yourself before passing it, which will make TypeScript happy (only a Property is allowed) and it's totally vanilla JS. In the long run, I'd like to see the type data for |
Thomas, I don't want to be the Github Police but this is getting into help/support rather than discussion about the feature request. You should stop by the community site when you have more questions. If you stick with Typescript, you'll get used to the "is not assignable to" errors. It's worded that way because TS uses duck typing, so it can't just say "expected Property, got Boolean", it's all based on whether the r-value meets the constraints of the l-value. As for types of When I was getting started, I found the Sandcastle demo collection to be of great value -- that's where I discovered e.g. |
I suggest that adding a type parameter to Property class type in
Cesium.d.ts
:Why:
Currently Property's value is any, so it is loose. We can use the types to more tightly constrain the content of a Property.
Notes:
any
is good idea because it will prevent to compromise compatibility.The text was updated successfully, but these errors were encountered: