Platform-specific TypeScript declarations for NativeScript for accessing native objects
84
Build a temperature storage system for a NativeScript Android application that properly handles native type conversions.
Create a temperature storage utility that interacts with Android's SharedPreferences system. The utility should:
Important: Android's SharedPreferences methods require specific Java primitive types. JavaScript numbers must be properly converted to Android's native float and long types when calling SharedPreferences methods like putFloat(), getFloat(), putLong(), and getLong().
@generates
/**
* Converts Celsius temperature to Fahrenheit
* @param celsius Temperature in Celsius
* @returns Temperature in Fahrenheit
*/
export function celsiusToFahrenheit(celsius: number): number;
/**
* Saves a temperature reading with timestamp to Android SharedPreferences
* @param context Android context
* @param temperature Temperature value to save
* @param timestamp Timestamp in milliseconds
*/
export function saveTemperature(context: any, temperature: number, timestamp: number): void;
/**
* Retrieves the last saved temperature from Android SharedPreferences
* @param context Android context
* @returns The last saved temperature or null if none exists
*/
export function getLastTemperature(context: any): number | null;
/**
* Retrieves the timestamp of the last saved temperature
* @param context Android context
* @returns The timestamp in milliseconds or null if none exists
*/
export function getLastTimestamp(context: any): number | null;Provides TypeScript declarations for accessing Android native APIs, including primitive type conversion utilities.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-tns-platform-declarationsevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10