1. What is a generic function in TS

    1. way to write code that is Type flexible without using “any”
    function genericFunction<T>(arg: T) {
    		return "string" as T
    }
    
  2. what is “as const” in TS and diff bw this and normal “const”

    1. allows us to write objects that are sealed in a way that you cannot modify any part of the object, ex. DB config
    2. TS is a developer tool → everything applies during build time
    3. JS Object.freeze applies at runtime and only at first level → does not apply to nested data
    const config = { 
    		host: "123",
    		port: 45
    }
    // can be modified
    config.host = "456"
    
    const config = { 
    		host: "123",
    		port: 45,
    		auth: {
    				client: "abc"
    		}
    } as const; // nested fields and objects are immutable now
    
  3. what does the private access modifier do when added to a class

    1. private → cannot be accessed outside of class → interface segregation
  4. TS decorator, what is it and what is the use case

    1. way to reuse code following decorator pattern
    2. class inheritance → violates liskov substitution → creates messy chain
    // apply code to multiple classes
    function Injectable(){}
    
    @Injectable
    class Service {...}
    
  5. difference bw type vs. interface

    1. at build time interfaces are merged
    2. types have to be unique → duplicate types will give type error
    3. request type - interface - extend - props/auxiliary
    4. type - define domain entities
  6. type guard

    1. constraints added to filter types
  7. structural vs nominal typing

    1. TS → structural typing - if 2 objects have the same properties then they are the same - interchangeable - gives flexibility to combine and interchange objects if they satisfy the same properties
    2. Java/C# → nominal typing - objects must match same signature to be the same, have to be instances of the same class