graph TD;
A[ParentComponent]--imports-->B[ChildComponent];
import {readFileSync} from 'fs'; | |
import {execSync} from 'node:child_process'; | |
import {exec} from 'child_process'; | |
import util from 'util'; | |
export const execAsync = util.promisify(exec); | |
execSync('npx nx graph --file=workspace-graph.json').toString('utf-8'); |
type Strict<Contract, Class> = Class extends Contract | |
? { [K in keyof Class]: K extends keyof Contract ? Contract[K] : never } | |
: Contract; | |
interface MyContract { | |
foo: number; | |
bar: boolean; | |
} | |
type MyStrictContract = Strict<MyContract, MyClass>; |
type Repeat<T, Count, Acc extends any[] = []> = Acc['length'] extends Count ? Acc : Repeat<T, Count, [...Acc, T]>; | |
function i18n<Keys extends number[]>([result, ...parts]: TemplateStringsArray, ...keys: Keys) { | |
return (...param: Repeat<string, Keys['length']>) => | |
keys.reduce((acc, key, i) => acc + (param as number[])[key] + parts[i], result); | |
} | |
const introduceEn = i18n`Hi. My name is ${0}. I work as a ${1} at ${2}.`; | |
const introduceTr = i18n`Merhaba. Benim adım ${0}. ${2} şirketinde ${1} olarak çalışıyorum.`; | |
// (param_0: string, param_1: string, param_2: string) => string |
any
: magic, ill-behaved type that acts like a combination ofnever
(the proper [bottom type]) andunknown
(the proper [top type])- Anything except
never
is assignable toany
, andany
is assignable to anything at all. - Identities:
any & AnyTypeExpression = any
,any | AnyTypeExpression = any
- Key TypeScript feature that allows for [gradual typing].
- Anything except
unknown
: proper, well-behaved [top type]- Anything at all is assignable to
unknown
.unknown
is only assignable to itself (unknown
) andany
. - Identities:
unknown & AnyTypeExpression = AnyTypeExpression
,unknown | AnyTypeExpression = unknown
- Anything at all is assignable to
- Prefer over
any
whenever possible. Anywhere in well-typed code you're tempted to useany
, you probably wantunknown
.
This is some sort of answer to recent posts regarding Web Components, where more than a few misconceptions were delivered as fact.
Let's start by defining what we are talking about.
As you can read in the dedicated GitHub page, Web Components is a group of features, where each feature works already by itself, and it doesn't need other features of the group to be already usable, or useful.
lys is a programming language that produces WASM, and its design goal is to be as simple as possible, yet useful to create utilities.
I've been thinking about a subset of JavaScript that could run natively on the browser, similarly to asm.js, but with the ability, through a dedicated parser, to target another language able, on its own, to produce WASM.
The following crazy non sense works already thanks to an agglomerated of modern and deprecated JS features and it might be interesting as experiment to see if a JS to WASM compiler, through the lys indirection, could be possible.
function lys(fn) {
/*! (c) Andrea Giammarchi */
Angular CLI version | Angular version | Node.js version | TypeScript version | RxJS version | |
---|---|---|---|---|---|
~16.0.0 | ~16.0.0 | ^16.13.0 || ^18.10.0 | >=4.9.5 <5.1.0 | ^6.5.5 || ^7.4.0 | |
~15.2.0 | ~15.2.0 | ^14.20.0 || ^16.13.0 || ^18.10.0 | >=4.8.4 <5.0.0 | ^6.5.5 || ^7.4.0 | |
~15.1.0 | ~15.1.0 | ^14.20.0 || ^16.13.0 || ^18.10.0 | >=4.8.4 <5.0.0 | ^6.5.5 || ^7.4.0 | |
~15.0.5 | ~15.0.4 | ^14.20.0 || ^16.13.0 || ^18.10.0 | ~4.8.4 | ^6.5.5 || ^7.4.0 | |
~14.3.0 | ~14.3.0 | ^14.15.0 || ^16.10.0 | >=4.6.4 <4.9.0 | ^6.5.5 || ^7.4.0 | |
~14.2.0 | ~14.2.0 | ^14.15.0 || ^16.10.0 | >=4.6.4 <4.9.0 | ^6.5.5 || ^7.4.0 | |
~14.1.3 | ~14.1.3 | ^14.15.0 || ^16.10.0 | >=4.6.4 <4.8.0 | ^6.5.5 || ^7.4.0 | |
~14.0.7 | ~14.0.7 | ^14.15.0 || ^16.10.0 | >=4.6.4 <4.8.0 | ^6.5.5 || ^7.4.0 | |
~13.3.0 | ~13.3.0 | ^12.20.2 || ^14.15.0 || ^16.10.0 | >=4.4.4 <4.7.0 | ^6.5.5 || ^7.4.0 |
@Component({ | |
selector: 'my-app', | |
template: `<hello></hello>` | |
}) | |
export class AppComponent { | |
name = 'Angular'; | |
} | |
@Component({ | |
selector: 'hello', |
/** | |
* subscriptions data format: | |
* { eventType: { id: callback } } | |
*/ | |
const subscriptions = { } | |
const getNextUniqueId = getIdGenerator() | |
function subscribe(eventType, callback) { | |
const id = getNextUniqueId() |