-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
fix: typescript issues #9019
fix: typescript issues #9019
Conversation
Thanks for the pull request @jony89!
Reviewers, don't forget to make sure that:
|
@mramato please review |
@jony89 I appreciate the PR but we can't take any of these changes except for the As I mentioned to you in my comment here, #8898 (comment), TypeScript doesn't support getters/setters of differing types. For example, this PR breaks the below code: const entity = new Entity();
entity.position = new Cartesian3(1,2,3);
const currentPosition = entity.position.getValue(JulianDate.now()); Because TypeScript thinks that If there's something we're missing that would allow us to take a |
@mramato Then how should one set the position property? or the material property with Color? both inline or using the entity constructor,
|
@jony89 if your position isn't changing with time, use |
What if it does? what about PolygonHierarchy ? @mramato Anyway I changed the PR and kept the viewer change only |
The documentation and type definition tell you which base type of property you need to use, e.g.
@mramato as an aside, I wonder if we're thinking about this wrong. Users of CesiumJS are much more likely to set entity properties than they are to get them. So maybe we should change the type definitions to correctly express that you're allowed to set with a simple primitive type. That means it will (incorrectly) think that that the getter might give you back a primitive type, which is not true, but in this less common and more advanced use-case, it's easy to work around that annoyance with a type assertion (cast). I'm not sure if I'm convinced on this, just throwing it out for consideration. |
@jony89 Just came across the "position" issue in my code and Google brought me here. There is hacky work-around where you can cast the position property as an "any". It's real ugly though... I'm going to try and isolate that bit in my code in case of future changes :)
|
Changes I've had to made in order to get typescript working. all changes are tested and working. I always working with the examples in sandcastle and the documentation.
reviews, and changes requests are welcome.