Notice that line 3 in below code, T extends { message: unknown } message field data type is unknown so returning value from function should be casted to any like obj.message as any
I try to understand eventType field from Event object. But in order to use createEventGridMessage in other TypeScript file, you need to import StartEvent, InfoEvent and EndEvent types. So next example of this case looks better to me 🙂
type NumberOrNot<T> = T extends number ? string : never;
Example 2
type StringOrNot<T> = T extends string ? string : never;
Example 3
type BooleanOrNumberOnly<T> = T extends boolean | number ? T : never;
type NewType = StringOrNumberOnly<string | number | boolean>;
const a1: NewType = true; // boolean
const a2: NewType = 23; // number
$ az --version
azure-cli 2.26.1 *
core 2.26.1 *
telemetry 1.0.6
Python location '/usr/local/Cellar/azure-cli/2.26.1/libexec/bin/python'
Extensions directory '/Users/kenanhancer/.azure/cliextensions'
Python (Darwin) 3.8.11 (default, Jun 29 2021, 03:08:07)
[Clang 12.0.5 (clang-1205.0.22.9)]
Legal docs and information: aka.ms/AzureCliLegal
You have 2 updates available. Consider updating your CLI installation with 'az upgrade'
Please let us know how we are doing: https://aka.ms/azureclihats
and let us know if you're interested in trying out our newest features: https://aka.ms/CLIUXstudy
Upgrading
$ brew update && brew upgrade azure-cli
# OR
$ az upgrade
Uninstalling
$ brew uninstall azure-cli
Sign in with Azure CLI
Sign in interactively
$ az login
Sign in with device code flow interactively
If no web browser is available or the web browser fails to open, you may force device code flow with below command.
$ az login --use-device-code
Azure Functions Core Tools
Installing
$ brew tap azure/functions
$ brew install azure-functions-core-tools@3
# if upgrading on a machine that has 2.x installed
$ brew link --overwrite azure-functions-core-tools@3