-
-
Notifications
You must be signed in to change notification settings - Fork 760
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
inline types into d.ts #2015
inline types into d.ts #2015
Conversation
Inlining the types by package might be really dumb - it might make sense to add a d.ts file to this project to re-export only the external types that we need; or even to remove external dependencies on |
Point geometry is used by vector tile, this is one of the reasons for keeping it outside this library. |
I still don't quite get it ("used by vector tile" = this type must be kept in sync with X function in Y package). Even if the classes are implemented in external packages, we can still maintain pure Anyway, one of the issues with inlining the types is the real naming collisions. E.g. geojson has a
Here's the dist with the generated types: |
BTW, we also might consider using rollup-plugin-dts or @microsoft/api-extractor to generate the typings instead. I don't know if they handle externally declared types any better. |
Well... It's a long story... Colliding classes definitions is not ideal. |
Also the build is failing, so I'm not sure this solution is an easy fix... :-( |
current implementation = what's in the main branch, not this what's in this PR. Generally speaking, this PR looks in the right direction, or using a different tool might do the work, IDK... |
@rotu where are we on this? |
Blocked by #2054 And I'm not sure how to move forward with the |
If anything, I would consider migrating to the rollup plugin as it is more aligned with how we build this library, I'm not sure how well it will work though. |
I'll give this another look. I admire Rollup but I also feel like it's unwieldy and has led to some iffy choices. I actually feel like we should be reducing the number of rollup plugins (e.g. rollup-plugin-sourcemaps, @rollup/plugin-replace, @rollup/plugin-strip) rather than adding new ones. Here are the extant issues:
|
@rotu do you want to push this forward or close this PR? |
also move all non-runtime dependencies to devDependencies
Updated. All the issues are still present that I mentioned in #2015 (comment) and these prevent further movement of this PR. |
I'm not sure I fully understand what's blocking you, can you please elaborate? |
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## main #2015 +/- ##
=======================================
Coverage 73.83% 73.83%
=======================================
Files 238 238
Lines 18961 18961
Branches 4277 4277
=======================================
Hits 14000 14000
Misses 4961 4961 ☔ View full report in Codecov by Sentry. |
Sorry - I can see how that could be very unclear!
maplibre-gl-js/src/source/geojson_wrapper.ts Lines 8 to 20 in 1cbb496
I'm not sure if the other issues are still true blockers but the Feature type definitely is. |
Well yes... Typescript lacks the concept of namespace so this is expected I guess... |
The bluntness is appreciate! And yes, I agree this is fairly navel-gazy. I do think it’s important to fix the confusion around multiple “Feature” types. Do you have any insight why they all exist? |
Geojson feature, vector tile layer feature, and probably another one... |
I'm closing this for now, feel free to reopen if needed. |
After this PR, the released
maplibre-gl.d.ts
should be self-contained, requiring no additional external libraries to resolve types.d.ts
has a bunch of imports. This means you needed to install those type packages to properly consume the exported types. This should no longer be the case.:Note that there are some conflicts between declarations of types named
Point
andFeature
. I'm not quite sure how to resolve them. These don't break the build but do produce some warnings that will probably show up in the IDE as well: