Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

TypeScript guards for the Google Maps JavaScript API.

License

NotificationsYou must be signed in to change notification settings

googlemaps/js-typescript-guards

npmBuildReleasecodecovGitHub contributorssemantic-releaseDiscord

Description

This package providesTypeScript guards for the Google Maps JavaScript API.

A type guard (or type predicate) is an expression that performs a runtime check that guarantees the type in some scope. Type guards are used to narrow the type of a variable or parameter.

Documentation

For the complete API check thereference documentation.

Install

Available via npm as the package@googlemaps/typescript-guards.

npm i @googlemaps/typescript-guards

Example

The following example narrows a union typegoogle.maps.LatLng | google.maps.LatLngLiteral togoogle.maps.LatLngLiteral using theisLatLngLiteral guard.

import{isLatLngLiteral}from"@googlemaps/typescript-guards";constlatLng:google.maps.LatLng|google.maps.LatLngLiteral= ...;if(isLatLngLiteral(latLng)){lat=latLng.lat;lng=latLng.lng;}else{lat=latLng.lat();lng=latLng.lng();}

About

TypeScript guards for the Google Maps JavaScript API.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors7


[8]ページ先頭

©2009-2025 Movatter.jp