Skip to content

Instantly share code, notes, and snippets.

@jaycosaur
Last active August 9, 2020 23:18
Show Gist options
  • Save jaycosaur/2b5de42f0d5e452739d199af0cfe8693 to your computer and use it in GitHub Desktop.
Save jaycosaur/2b5de42f0d5e452739d199af0cfe8693 to your computer and use it in GitHub Desktop.
Strong or Weak [typescript] - Typescript to Python field guide
type Celsius = number;
type Fahrenheit = number;
function convertToCelsius(value: Fahrenheit): Celsius {
return (value * 9) / 5 + 32;
}
function convertToFahrenheit(value: Celsius): Fahrenheit {
return ((value - 32) * 5) / 9;
}
const converted = convertToCelsius(0); // it works!
const fahrenheitValue: Fahrenheit = 32;
convertToFahrenheit(fahrenheitValue); // it works!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment