Cartesian clone type definition is wrong
Open
Nobody has claimed this yet.
category - typescript
type - bug
type - regression
- Dominant language
- JavaScript
- Stars
- 15.8k
- Forks
- 3.9k
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 34
Description
What happened?
After #13168, the generated TypeScript definitions for the static clone methods are incorrect. Methods are extended to accept undefined and return undefined in that case, but TypeScript will throw an error on this with skipLibCheck: false.
TS2322: Type 'undefined' is not assignable to type 'Cartesian3'.
102 | static clone(cartesian, result) {
103 | if (!defined(cartesian)) {
> 104 | return undefined;
| ^^^^^^
105 | }
106 | if (!defined(result)) {
107 | return new Cartesian3(cartesian.x, cartesian.y, cartesian.z);
Reproduction steps
Sandcastle example
No response
Environment
CesiumJS Version: 1.139.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with packages/engine/Source/Core/Cartesian2.js around lines 58-76 and inspect how the static clone methods produce their generated TypeScript definitions. Run the TypeScript check with skipLibCheck set to false and confirm the clone definitions accept undefined and represent an undefined return without TS2322 errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100