Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
YouTube Security VideosfreeCodeCamp.org: TimescaleDB Course – PostgreSQL for Time-Series Data(23.09.2026 um 12:30 Uhr)
•
Windows Tipps & SecurityAndroid 17: Rollout auf Samsung-Galaxy-Smartphones verzögert sich(23.09.2026 um 11:42 Uhr)
••
Unix & Linux ServerUSN-8733-2: Gzip vulnerabilities(22.09.2026 um 18:04 Uhr)
••
Sichere ProgrammierungHow to Build Custom PowerPoint Add-Ins for Enterprise Teams(23.09.2026 um 11:25 Uhr)
••
Sichere ProgrammierungSearch Google Jobs in Real-Time with Go and SerpApi 🚀(23.09.2026 um 12:13 Uhr)
•
Sichere ProgrammierungA Psychological State is a Coefficient Vector(23.09.2026 um 12:16 Uhr)
••
YouTube Security VideosfreeCodeCamp.org: TimescaleDB Course – PostgreSQL for Time-Series Data(23.09.2026 um 12:30 Uhr)
•
Windows Tipps & SecurityAndroid 17: Rollout auf Samsung-Galaxy-Smartphones verzögert sich(23.09.2026 um 11:42 Uhr)
••
Unix & Linux ServerUSN-8733-2: Gzip vulnerabilities(22.09.2026 um 18:04 Uhr)
••
Sichere ProgrammierungHow to Build Custom PowerPoint Add-Ins for Enterprise Teams(23.09.2026 um 11:25 Uhr)
••
Sichere ProgrammierungSearch Google Jobs in Real-Time with Go and SerpApi 🚀(23.09.2026 um 12:13 Uhr)
•
Sichere ProgrammierungA Psychological State is a Coefficient Vector(23.09.2026 um 12:16 Uhr)
••
Intelligence View
⚡ tsecurity.de Intelligence

The Typo Typescript Hid From Me

Here’s a draft: The Typo That TypeScript Hid From Me I spent a good chunk of time debugging a silent failure in a React Native app. I was integrating the Google Routes API v2 to draw polylines and compute distance/duration between two c…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Here’s a draft:



The Typo That TypeScript Hid From Me



I spent a good chunk of time debugging a silent failure in a React Native app. I was integrating the Google Routes API v2 to draw polylines and compute distance/duration between two coordinates. The API kept returning an empty object {} despite a 200 OK response.



After ruling out field mask issues, API key restrictions, and billing problems — all the usual suspects — I added granular logs directly inside the fetch function:



console.log("START COORDS:", JSON.stringify(start));

console.log("END COORDS:", JSON.stringify(end));



The output:



START COORDS: {"latitude":6.450904}

END COORDS: {"latitude":6.4696}



No longitude. The Routes API received an incomplete request body and returned {} silently.



But when I logged the raw data from the parent component:



console.log(schedule?.pickup_coord);

// {"latitude": 6.450904, "longitide": 3.390147}



There it was — longitide instead of longitude. A missing u.



Here’s where it gets interesting.



My custom hook accepted coordinates typed as LatLng:



type LatLng = {

latitude: number;

longitude: number;

};



When the object { latitude: 6.450904, longitide: 3.390147 } was cast with as LatLng, TypeScript didn’t complain. The cast silenced any structural mismatch. At runtime, accessing .longitude on that object returned undefined — and undefined serialized into the request body as a missing field entirely.



The Routes API received:



{

"origin": {

"location": {

"latLng": {

"latitude": 6.450904,

"longitude": undefined

}

}

}

}



Which JSON.stringify quietly drops, producing:



{

"origin": {

"location": {

"latLng": {

"latitude": 6.450904

}

}

}

}



A perfectly valid JSON object. No error thrown. No warning logged. Just a silent wrong request — and a silent empty response.



The real lesson here isn’t just “check your typos.”



It’s that as SomeType in TypeScript is an assertion, not a validation. You’re telling the compiler “trust me, this is the right shape” — and it does. Completely. If the runtime data doesn’t match, TypeScript has no way to know.



The safer pattern is a runtime validator or a mapping function that explicitly pulls the fields you need:



const toLatLng = (coord: any): LatLng => ({

latitude: coord?.latitude,

longitude: coord?.longitude,

});



This way, even if the upstream data has a typo, the mapping makes the missing field explicit — and you catch a { latitude: 6.450904, longitude: undefined } object before it ever reaches your API call, rather than getting a silent {} response from a server later.



Two layers failed here: a typo in the data source, and an unchecked as cast that let it through undetected.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten The Typo Typescript Hid From Me

Thematisch verwandte Begriffe: Typo, Typescript, From · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-96258 | A vulnerability has been found in onSite internet GmbH Auktion NG Auktio…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel • Rechts: nächster Artikel • unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger • Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick