Skip to content

Commit e8b22e6

Browse files
stepankuzmingithub-actions[bot]
authored andcommitted
Fix some TypeScript suppressions (internal-6322)
GitOrigin-RevId: 0faff52ef1a09b3e45902e77edb1673cc88368b6
1 parent 7380d1a commit e8b22e6

13 files changed

Lines changed: 173 additions & 270 deletions

File tree

3d-style/data/bucket/tiled_3d_model_bucket.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ class Tiled3dModelBucket implements Bucket {
593593
hidden: boolean;
594594
verticalScale: number;
595595
} | null | undefined {
596-
const candidates = [];
596+
const candidates: number[] = [];
597597

598598
const tmpVertex = [0, 0, 0];
599599

@@ -620,7 +620,6 @@ class Tiled3dModelBucket implements Bucket {
620620
const heightValue = mesh.heightmap[heightmapIndex];
621621
if (heightValue < 0 && nodeInfo.node.footprint) {
622622
// unpopulated cell. If it is in the building footprint, return undefined height
623-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
624623
nodeInfo.node.footprint.grid.query(new Point(x, y), new Point(x, y), candidates);
625624
if (candidates.length > 0) {
626625
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
@@ -629,8 +628,7 @@ class Tiled3dModelBucket implements Bucket {
629628
continue;
630629
}
631630
if (nodeInfo.hiddenByReplacement) return; // better luck with the next source
632-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
633-
return {height: heightValue, maxHeight: nodeInfo.feature.properties["height"], hidden: false, verticalScale: nodeInfo.evaluatedScale[2]};
631+
return {height: heightValue, maxHeight: nodeInfo.feature.properties["height"] as number, hidden: false, verticalScale: nodeInfo.evaluatedScale[2]};
634632
}
635633
}
636634
}
@@ -669,7 +667,7 @@ function addPBRVertex(vertexArray: FeatureVertexArray, color: number, colorMix:
669667
const emissionMultiplierValueStart = clamp(heightBasedEmissionMultiplierParams[2], 0, 1);
670668
const emissionMultiplierValueFinish = clamp(heightBasedEmissionMultiplierParams[3], 0, 1);
671669

672-
let a3, b0, b1, b2;
670+
let a3: number, b0: number, b1: number, b2: number;
673671

674672
if (emissionMultiplierStart !== emissionMultiplierFinish && zMax !== zMin &&
675673
emissionMultiplierFinish !== emissionMultiplierStart) {
@@ -687,13 +685,11 @@ function addPBRVertex(vertexArray: FeatureVertexArray, color: number, colorMix:
687685
b2 = 1;
688686
}
689687

690-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
691688
vertexArray.emplaceBack(a0, a1, a2, a3, b0, b1, b2);
692689
if (lightsFeatureArray) {
693690
const size = lightsFeatureArray.length;
694691
lightsFeatureArray.clear();
695692
for (let j = 0; j < size; j++) {
696-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
697693
lightsFeatureArray.emplaceBack(a0, a1, a2, a3, b0, b1, b2);
698694
}
699695
}
@@ -708,11 +704,8 @@ function updateNodeFeatureVertices(nodeInfo: Tiled3dModelFeature, doorLightChang
708704
if (!mesh.featureData) continue;
709705
// initialize featureArray
710706
mesh.featureArray = new FeatureVertexArray();
711-
// @ts-expect-error - TS2339 - Property 'length' does not exist on type 'ArrayBufferView'.
712-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
713707
mesh.featureArray.reserve(mesh.featureData.length);
714708
let pendingDoorLightUpdate = doorLightChanged;
715-
// @ts-expect-error - TS2488 - Type 'ArrayBufferView' must have a '[Symbol.iterator]()' method that returns an iterator.
716709
for (const feature of mesh.featureData) {
717710
// V1 and V2 tiles have a different bit structure
718711
// In V2, meshopt compression forces to use values less than 2^24 to not lose any information

3d-style/data/model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export type Mesh = {
8484
texcoordBuffer: VertexBuffer;
8585
colorArray: StructArray;
8686
colorBuffer: VertexBuffer;
87-
featureData: ArrayBufferView;
87+
featureData: Uint32Array | Float32Array;
8888
featureArray: FeatureVertexArray;
8989
pbrBuffer: VertexBuffer;
9090
material: Material;

3d-style/source/model_loader.ts

Lines changed: 65 additions & 123 deletions
Large diffs are not rendered by default.

3d-style/source/tiled_3d_model_worker_source.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,9 @@ class Tiled3dWorkerTile {
7272
load3DTile(data)
7373
.then(gltf => {
7474
if (!gltf) return callback(new Error('Could not parse tile'));
75-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
76-
const hasMapboxMeshFeatures = (gltf.json.extensionsUsed && gltf.json.extensionsUsed.includes('MAPBOX_mesh_features')) ||
77-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
75+
const hasMapboxMeshFeatures: boolean = (gltf.json.extensionsUsed && gltf.json.extensionsUsed.includes('MAPBOX_mesh_features')) ||
7876
(gltf.json.asset.extras && gltf.json.asset.extras['MAPBOX_mesh_features']);
79-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
77+
8078
const hasMeshoptCompression = gltf.json.extensionsUsed && gltf.json.extensionsUsed.includes('EXT_meshopt_compression');
8179

8280
const parameters = new EvaluationParameters(this.zoom, {brightness: this.brightness, worldview: this.worldview});
@@ -87,7 +85,7 @@ class Tiled3dWorkerTile {
8785
layer.recalculate(parameters, []);
8886
// Nodes are created per layer which allows styling when multiple model layers are referencing the same source
8987
const nodes = process3DTile(gltf, 1.0 / tileToMeter(params.tileID.canonical));
90-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
88+
9189
const bucket = new Tiled3dModelBucket(family as Array<ModelStyleLayer>, nodes, tileID, hasMapboxMeshFeatures, hasMeshoptCompression, this.brightness, featureIndex, this.worldview);
9290
// Upload to GPU without waiting for evaluation if we are in diffuse path
9391
if (!hasMapboxMeshFeatures) bucket.needsUpload = true;
@@ -109,8 +107,7 @@ class Tiled3dWorkerTile {
109107
brightness: null,
110108
});
111109
})
112-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
113-
.catch((err) => callback(new Error(err.message)));
110+
.catch((err: Error) => callback(new Error(err.message)));
114111
}
115112
}
116113

0 commit comments

Comments
 (0)