Repository navigation
Conversation
…esolve api key Change-Id: I27b82bf399830383104708b67e310661b8a17f8f
…time Change-Id: I74deb5c82f84ba7afa5d0c1181018332ecc3363f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes two critical issues with the
weather-api-current-compactsample that were preventing the map and markers from loading correctly.1. Fixed API Key Resolution (Vite Config)
The sample was previously bypassing the centralized Vite configuration by hardcoding its
startscript tovite --port 5173. Because it bypassed the config, theGOOGLE_MAPS_API_KEYplaceholder string was never substituted for the local.envkey, resulting in anInvalidKeyMapError.package.jsonto properly pipe through the workspacevite.config.jsand strict TS compilation.2. Fixed Invisible Markers (TypeScript Elision Bug)
Once strict TypeScript compilation was enabled, it revealed a hidden type error:
SimpleWeatherWidgetwas being imported but was never exported from its definition file.When fixing this type error by updating the import to a named import (
import { SimpleWeatherWidget } from './simple-weather-widget'), a side-effect was triggered: because the class was only used for type annotations inindex.ts, the TypeScript compiler optimized the code by completely eliding (erasing) the import statement from the compiled JS.Because the import was erased,
simple-weather-widget.jswas never executed at runtime, the custom element was never registered with the browser, and the Maps API attached invisible, unstyled elements to the Advanced Markers.SimpleWeatherWidgetand explicitly split the imports inindex.tsto guarantee runtime registration:Testing
npm startsuccessfully loads the map.