Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update generation code for the specific case of geojson #463

Merged
merged 7 commits into from
Jan 1, 2024

Conversation

HarelM
Copy link
Collaborator

@HarelM HarelM commented Dec 31, 2023

Launch Checklist

Fixes #393

This add an ugly if to the code generation flow to facilitate the fact that the json definitions are not full enough to represent the data field in the GeoJSONSourceSpecification.
It's a very small fix and I think it adds a lot of value, so I can live with it being dirty I guess...

before:

export type GeoJSONSourceSpecification = {
	"type": "geojson";
	"data": unknown;
	"maxzoom"?: number;
	"attribution"?: string;
	"buffer"?: number;
	"filter"?: unknown;
	"tolerance"?: number;
	"cluster"?: boolean;
	"clusterRadius"?: number;
	"clusterMaxZoom"?: number;
	"clusterMinPoints"?: number;
	"clusterProperties"?: unknown;
	"lineMetrics"?: boolean;
	"generateId"?: boolean;
	"promoteId"?: PromoteIdSpecification;
};

After

export type GeoJSONSourceSpecification = {
	"type": "geojson";
	"data": GeoJSON.GeoJSON | string;
	"maxzoom"?: number;
	"attribution"?: string;
	"buffer"?: number;
	"filter"?: unknown;
	"tolerance"?: number;
	"cluster"?: boolean;
	"clusterRadius"?: number;
	"clusterMaxZoom"?: number;
	"clusterMinPoints"?: number;
	"clusterProperties"?: unknown;
	"lineMetrics"?: boolean;
	"generateId"?: boolean;
	"promoteId"?: PromoteIdSpecification;
};
  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
  • Briefly describe the changes in this PR.
  • Link to related issues.
  • Include before/after visuals or gifs if this PR includes visual changes.
  • Add an entry to CHANGELOG.md under the ## main section.

@codecov-commenter
Copy link

codecov-commenter commented Dec 31, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (fb3eb34) 78.06% compared to head (a57a372) 78.06%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #463   +/-   ##
=======================================
  Coverage   78.06%   78.06%           
=======================================
  Files         101      101           
  Lines        4149     4149           
  Branches     1185     1185           
=======================================
  Hits         3239     3239           
  Misses        910      910           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@HarelM HarelM requested review from louwers and removed request for louwers January 1, 2024 10:09
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@louwers louwers left a comment

Choose a reason for hiding this comment

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

This is great!

General points:

  • Maybe the file needs to be updated to make clear that it is generating TypeScript.
  • I didn't try to run it. Is there any kind of CI in place to validate the output of this script? For example, to ensure that the TypeScript it generates is valid?

Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
@HarelM
Copy link
Collaborator Author

HarelM commented Jan 1, 2024

Yes, this is a pre-build script to generate typescript files from the v8 json spec file, these files are then used to build the package and are checked during the typescript transpilation.

@HarelM
Copy link
Collaborator Author

HarelM commented Jan 1, 2024

Maybe the file needs to be updated to make clear that it is generating TypeScript.

Please propose what you think might help here.
There are two stages that generate typescript, so it might be confusing:

  1. This pre-build script
  2. The dts-bundle-generator which generate the d.ts files (the exported types) to be consumed by the user of this package.

@HarelM HarelM merged commit ca5dd4e into main Jan 1, 2024
6 checks passed
@HarelM HarelM deleted the fix-geojson-types-393 branch January 1, 2024 11:56
@HarelM
Copy link
Collaborator Author

HarelM commented Jan 1, 2024

Ok, one last PR that I need to handle before releasing a new version which is currently stale and I need to rewrite myself.

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.

define type for GeoJSONSourceSpecification data
3 participants