Skip to content

Commit

Permalink
Improve generated types (#86)
Browse files Browse the repository at this point in the history
* Update index.js type's type

* Update index.js

* Update index.js

* Fix type check
  • Loading branch information
HarelM committed Jul 12, 2024
1 parent a37312e commit 5b19ed0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class VectorTileFeature {
this.properties = {};

this.extent = extent;
/** @type {0 | 1 | 2 | 3} */
this.type = 0;

/** @type {number | undefined} */
Expand Down Expand Up @@ -210,7 +211,7 @@ VectorTileFeature.types = ['Unknown', 'Point', 'LineString', 'Polygon'];
function readFeature(tag, feature, pbf) {
if (tag === 1) feature.id = pbf.readVarint();
else if (tag === 2) readTag(pbf, feature);
else if (tag === 3) feature.type = pbf.readVarint();
else if (tag === 3) feature.type = /** @type {0 | 1 | 2 | 3} */ (pbf.readVarint());
else if (tag === 4) feature._geometry = pbf.pos;
}

Expand Down Expand Up @@ -353,6 +354,7 @@ export class VectorTile {
* @param {number} [end]
*/
constructor(pbf, end) {
/** @type {Record<string, VectorTileLayer>} */
this.layers = pbf.readFields(readTile, {}, end);
}
}
Expand Down

0 comments on commit 5b19ed0

Please sign in to comment.