Skip to content

Instantly share code, notes, and snippets.

View amcdnl's full-sized avatar

Austin amcdnl

View GitHub Profile

Why I hate TypeScript

Warning: These views are highly oppinated and might have some slightly incorrect facts. My experience with typescript was about 2 weeks in Node and a week in angular2.

Not Standard

TypeScript is implementing their own take on JavaScript. Some of the things they are writing will likely never make it in an official ES* spec either.

Technologies that have competing spec / community driven development have a history of failing; take: Flash, SilverLight, CoffeeScript, the list goes on. If you have a large code base, picking TypeScript is something your going to be living with for a long time. I can take a bet in 3 years JavaScript will still be around without a doubt.

Its also worth noting that they have built some things like module system and as soon as the spec came out they ditched it and started using that. Have fun updating!

Angular Interview Questions

Some basic questions going from easy to difficult. A more exhaustive list of more questions from the community can be found here.

Easy

  • Whats the difference between components and directives? [ANSWER]: Components are widgets while directives more like decorators for elements and/or components.
  • How do you get a reference to a child component? [ANSWER]: ViewChild/ViewChildren or ContentChild/ContentChildren
  • What is the difference between ViewChild and ContentChild?
  • Whats the difference between NgModules and ES2015 Modules?
  • How do you lazy load components and why is lazy loading important?
  • Explain Observables and why they are useful.
import React, { FC, useMemo, useRef } from 'react';
import { a, useSpring } from '@react-spring/three';
import { TextureLoader, LinearFilter, DoubleSide, Color, MathUtils } from 'three';
import { animationConfig } from '../utils';
import { useLoader } from '@react-three/fiber';
import { SVGLoader } from 'three/examples/jsm/loaders/SVGLoader';
export interface IconProps {
image: string;
opacity?: number;
import { animate } from "framer-motion";
import React, { useEffect, useRef } from "react";
function Counter({ from, to }) {
const ref = useRef();
from https://stackoverflow.com/questions/65013742/how-to-animate-number-with-framer-motion
useEffect(() => {
const controls = animate(from, to, {
define(['angular'], function (angular, $) {
// Use to style checkboxes, bind checkboxes to arrays, and run validators on checkboxes
// Modified from: https://github.com/bkuhl/angular-form-ui/tree/master/src/directives/checkBox
var module = angular.module('components.checkbox', []);
/**
* <check-box ng-model="isChecked()"></check-box>
* Required attribute: ng-model="[expression]"
* Optional attribute: value="[expression]"

Example Structure

/
    /scripts
    /src
        /assets
            /css
            /font
            /img

General

Dev

VSCode

import { useRef, useEffect, useCallback } from 'react';
export type noop = (...args: any[]) => any;
/**
* Stable callback
*
* References:
* - https://github.com/facebook/react/issues/14099
* - https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback
@amcdnl
amcdnl / readme.md
Last active January 31, 2021 17:05

Info

Goals

  • Modern TS
  • Little boilerplate
  • Better types

Features

  • Selectors
  • Easy Testing
import { Directive, Input, TemplateRef, ViewContainerRef, OnInit } from '@angular/core';
import { CONFIG } from 'environments/config';
@Directive({
selector: '[featureToggle]'
})
export class FeatureToggleDirective implements OnInit {
@Input() featureToggle: string;
constructor(