iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
600 stars 210 forks source link

ViewState.createFromProps is misleading #6089

Open a-gagnon opened 11 months ago

a-gagnon commented 11 months ago

I tried using ViewState.createFromProps by passing ViewStateProps that I previously obtained by calling ViewState.toProps(). I kept wondering why it always returned undefined until I looked at the implementation which always returns undefined... It might be a good idea to put a note to use convertViewStatePropsToViewState instead and eventually remove this entirely?


⚠ Do not edit this section. It is required for imodeljs.github.io ➟ GitHub issue linking

pmconne commented 11 months ago

Yeah, that's weird. It is overridden (statically) in classes like SpatialViewState. I suspect the author wanted to mark it abstract, but TypeScript doesn't support abstract static methods.

The base implementation should probably check the BIS class of the supplied ViewStateProps and invoke the corresponding subclass (e.g., SpatialViewState.createFromProps).