Sometimes I get bored at work, and so I mess around with the TypeScript typing engine. And sometimes I use JSON.parse(JSON.stringify(x))
as a quick and dirty deep clone (not performant, mind you). Rather than getting any
, I want to infer the shape of the result.
importModule('./lib/extensions')({ | |
// only need to pass in the types you need extended | |
// for this script | |
Math, | |
Number, | |
Array, | |
}) | |
console.log( | |
Math.getFactors((6).factorial()) |
Constitutional Amendments that would dramatically alter the US government to more closely represent the People
Whether true or not, and I believe it is true, many of us believe the US government is rampant with corrupt politicians, and therefore is corrupt itself.
However, Congress will never propose--much less ratify--an Amendment that would limit their own power. The solution is Constitutional Conventions as laid out by Article V of the Constitution.
The Congress, whenever two thirds of both houses shall deem it necessary, shall propose amendments to this Constitution, or, on the application of the legislatures of two thirds of the several states, shall call a convention for proposing amendments, which, in either case, shall be valid to all intents and purposes, as part of this Constitution, when ratified by t
/** | |
* Creates a readonly object which combines the given `as const` constants. If any of the objects overlap in keys or | |
* values, it evaluates to `never`. Unfortunately this does not work with enums because there is no way to determine if | |
* the *value* `Enum1.foo` is different than that `Enum2.bar`. Typescript treats enum values as distinct types. | |
* | |
* I made this type to prevent flux action types from overlapping. | |
* | |
* Requires Typescript@4.2 or later. | |
*/ | |
type CompositeAsConst< |
// Note to anyone who just happened upon this: I am not proud of this code. | |
Symbol.isProxy = Symbol('@@isProxy'); | |
const _Proxy = Proxy; | |
(typeof global === 'undefined' ? window : global).Proxy = new _Proxy(_Proxy, { | |
construct(target, args, newTarget) { | |
const result = Reflect.construct(target, args, newTarget); | |
return new _Proxy(result, { | |
get(target, prop, receiver) { |
/** | |
* @document Permutations.ts | |
* | |
* I wanted to figure out, just for the challenge of it, whether I could, given an array type `A`, produce a type that | |
* matches any array with every element of `A` exactly once in any order. I *love* abusing the TS typing engine. It | |
* insulted my mother once. | |
*/ | |
/** | |
* Returns an array type that includes every element of `T` exactly once in any order. |
This is a continuation of a Facebook post but a digression from the intent of the post. It is mere postulation of what could happen if the police brutality goes unaddressed by the government.
If left undealt with, to my discernment, one of two things will happen.
1) The People give up. They determine that continued protesting is not worth the risk of the bodily harm and very lives of so many people. They disperse. The putrid status quo is maintained. No justice is served.
2) Things escalate. The People determine a violent overthrow of the government is warranted and obligatory. People take sides. Civil war erupts. Hundreds of thousands die.
I'm an expert JS/ReactJS dev learning AngularJS to work on legacy code. What (or where) is a succinct rundown of high- and mid-level concepts I need to know?
I've been trying to watch a YouTube series called Angularjs Tutorial - Complete (Fundamentals to Advanced.
This series is probably great for people who know nothing about JavaScript frameworks, but it is far too slow/thorough for me. For example, AngularJS: Understanding Scope Inheritance is a half hour video that could have been a single sentence: The $scope
of a nested controller inherits the properties of its parent's $scope
.
It's possible that later videos in the playlist will cover more advanced topics with the assumption that you know what you're doing in JavaScript, b
-
Is this your level?
Yes. That's why I'm clearing it.
-
Can you show us the rest of the level?
No. But here's what it looked like. Preview video.\
import App, { Container } from 'next/app'; | |
import React, { Component } from 'react'; | |
import { ExampleContextProvider, ExampleContextType } from './example-context'; | |
interface Props { | |
pageProps: {}; | |
Component: Component; | |
exampleContext?: ExampleContextType; | |
} |