Is it possible to type check using `is` without knowing the generic used in C#?

Advertisements In C#, is it possible to check if a variable is of a specific type that uses a generic, without knowing what that generic is? For example, the code using System; using System.Collections.Generic; public static class Program { public static void Main(string[] args) { List<string> list = new List<string>(); if (list is List<object>) Console.WriteLine("Success");… Read More Is it possible to type check using `is` without knowing the generic used in C#?

Is there a way to add a default while still keeping type restrictions in a function in TypeScript?

Advertisements If I have this code as follows, how do I make it so name has to be a string but also has a default of "person", something like what follows: function greet(name = "person": string) { console.log(`Hello ${name}!`); } greet("Bob"); //Should return "Hello Bob!" greet(1) //Should return error about having the wrong type greet()… Read More Is there a way to add a default while still keeping type restrictions in a function in TypeScript?