Skip to content

Turn on type checking for the gltf workspace - #14123

Open
jjhembd wants to merge 1 commit into
gltf-schema-fixesfrom
gltf-types
Open

jjhembd wants to merge 1 commit into
gltf-schema-fixesfrom
gltf-types

Conversation

@jjhembd

@jjhembd jjhembd commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR turns on type checking for every file in packages/gltf/Source, typing the glTF JSON with the generated glTF types.

Code changes

  • packages/gltf/tsconfig.json sets checkJs, so the // @ts-check lines are removed.
  • {object} glTF parameters and returns are now Gltf2, or a nested type such as Gltf2.Accessor, imported with /** @import { Gltf2 } from "../SchemaTypes/index.js"; */.
  • The functions GltfJsonLoader calls before updateVersion handle glTF 1.0 too, so addPipelineExtras, forEachBuffer, and usesExtension take Gltf1 | Gltf2, and addPipelineExtras and parseGlb return it. updateVersion takes Gltf1 | Gltf2 and returns Gltf2.
  • In updateVersion.js, the helpers that upgrade the asset in place work on data that matches no single glTF version, so their gltf parameters are typed {any}. The next PR in the stack replaces them with typed conversions.
  • Two private types are added: PipelineBuffer, a glTF buffer with the extras._pipeline.source that addPipelineExtras, parseGlb, and addBuffer add; and Rgba, a 4-number tuple, which the docs build can't parse in a JSDoc tag.
  • File-scoped functions get JSDoc blocks tagged @private, and getMagic in @cesium/core gets parameter descriptions.

In the generated packages/gltf/index.d.ts, only parameter and return types change. They are @internal, so this PR needs no CHANGES.md entry.

Issue number and link

Part of #13949.

Testing plan

  • npm run tsc -w @cesium/gltf, npm run eslint, and npm run sg-scan should pass.
  • npm run test -w @cesium/gltf and npm run test -- --includeName Scene/Gltf should pass.
  • npx jsdoc --configure Tools/jsdoc/conf.json --pedantic should print no errors.
  • After npm run build-ts, Source/Cesium.d.ts should be unchanged.

Author checklist

  • I have submitted a Contributor License Agreement
  • I have added my name to CONTRIBUTORS.md
  • I have updated CHANGES.md with a short summary of my change
  • I have added or updated unit tests to ensure consistent code coverage
  • I have updated the inline documentation, and included code examples where relevant
  • I have performed a self-review of my code

AI acknowledgment

  • I used AI to generate content in this PR
  • If yes, I have reviewed the AI-generated content before submitting

If yes, I used the following Tools(s) and/or Service(s): GitHub Copilot

If yes, I used the following Model(s): Claude Opus 5.5

@jjhembd
jjhembd added this pull request to stack #14077 November 25, 2026 23:39
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for the pull request, @jjhembd!

✅ We can confirm we have a CLA on file for you.

@jjhembd
jjhembd force-pushed the gltf-types branch 2 times, most recently from d2e7a46 to 86abe90 Compare November 30, 2026 23:28
@jjhembd
jjhembd force-pushed the gltf-types branch 3 times, most recently from 583e605 to 568043c Compare December 1, 2026 15:00
@jjhembd
jjhembd removed this pull request from stack #14077 December 4, 2026 14:56
@jjhembd
jjhembd changed the base branch from gltf-cleanup to gltf-schema-fixes December 4, 2026 14:56
@jjhembd
jjhembd added this pull request to stack #14151 December 4, 2026 14:59
@jjhembd
jjhembd requested a balanced review from Copilot December 4, 2026 15:00
@jjhembd
jjhembd marked this pull request as ready for review December 4, 2026 15:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The review reports no active issues with the glTF type-checking changes.

No open issues 🎉

What changed in this PR

Enables workspace-wide type checking for glTF processing using generated schema types, advancing #13949 while preserving glTF 1.0 support before conversion.

Changes:

  • Enables checkJs and removes redundant per-file directives.
  • Replaces generic object annotations with schema types and adds private buffer and color types.
  • Documents conversion helpers and clarifies getMagic documentation.
File Description
packages/​gltf/​tsconfig.json Enables JavaScript type checking.
packages/​gltf/​Source/​usesExtension.js Types both supported glTF versions.
packages/​gltf/​Source/​updateVersion.js Types conversion boundaries and helpers.
packages/​gltf/​Source/​updateAccessorComponentTypes.js Types accessor conversion helpers.
packages/​gltf/​Source/​Rgba.ts Adds a private color tuple type.
packages/​gltf/​Source/​removePipelineExtras.js Types pipeline extras removal.
packages/​gltf/​Source/​removeExtensionsUsed.js Types the glTF parameter.
packages/​gltf/​Source/​removeExtensionsRequired.js Types the glTF parameter.
packages/​gltf/​Source/​removeExtension.js Types extension removal and traversal.
packages/​gltf/​Source/​readAccessorPacked.js Types accessor data and pipeline buffers.
packages/​gltf/​Source/​PipelineBuffer.ts Defines pipeline buffer extras.
packages/​gltf/​Source/​parseGlb.js Types parsed assets and parsing helpers.
packages/​gltf/​Source/​numberOfComponentsForType.js Removes redundant checking directive.
packages/​gltf/​Source/​getNodeTransform.js Uses the generated node type.
packages/​gltf/​Source/​getComponentReader.js Removes redundant checking directive.
packages/​gltf/​Source/​getAccessorByteStride.js Types accessor stride inputs.
packages/​gltf/​Source/​forEachBuffer.js Types inputs for both glTF versions.
packages/​gltf/​Source/​ForEach.js Removes redundant checking directive.
packages/​gltf/​Source/​findAccessorMinMax.js Types accessor bounds and buffer access.
packages/​gltf/​Source/​constructBoundingVolumeJson.js Types bounding volumes and shape helpers.
packages/​gltf/​Source/​addToArray.js Removes redundant checking directive.
packages/​gltf/​Source/​addPipelineExtras.js Types dual-version inputs and extras initialization.
packages/​gltf/​Source/​addExtensionsUsed.js Types the glTF parameter.
packages/​gltf/​Source/​addDefaults.js Types assets and defaulting helpers.
packages/​gltf/​Source/​addBuffer.js Types the glTF parameter.
packages/​gltf/​index.js Removes redundant checking directive.
packages/​core/​Source/​getMagic.js Clarifies function and parameter documentation.

Review effort: Balanced

@jjhembd
jjhembd force-pushed the gltf-types branch 3 times, most recently from beb33da to e397c1f Compare December 4, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants