This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
Compiler, | |
Injector, | |
ModuleWithProviders, | |
NgModuleFactory, | |
NgModuleRef, | |
StaticProvider, | |
Type | |
} from "@angular/core"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// other imports are removed for brevity | |
import { ModuleWithProviders } from "@angular/core"; | |
@NgModule({ | |
imports: [ | |
RouterModule.forChild([ | |
{ | |
path: "", | |
component: FooComponent | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// remove FooModule from imports | |
@NgModule({ | |
imports: [ | |
BrowserModule, | |
RouterModule.forRoot([ | |
{ | |
path: "", | |
loadChildren: () => import('./foo.module').then(m => m.FooModule), | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, NgModule } from "@angular/core"; | |
import { BrowserModule } from "@angular/platform-browser"; | |
import { RouterModule } from "@angular/router"; | |
import { FooModule } from "./foo.module"; | |
@Component({ | |
selector: "app-root", | |
template: "<router-outlet></router-outlet>" | |
}) | |
export class AppComponent {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, Inject, InjectionToken, NgModule } from "@angular/core"; | |
import { RouterModule } from "@angular/router"; | |
export const FOO = new InjectionToken<string>("FOO"); | |
@Component({ | |
selector: "app-foo", | |
template: "{{ foo }} works!" | |
}) | |
export class FooComponent { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rest of your Zsh configuration here | |
demo () { | |
if [ ! "$#" -gt 0 ]; then echo "Missing application name!"; return 1; fi | |
case "$2" in | |
"") | |
mkdir $1; | |
cd $1; | |
npm init -y; | |
;; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http-errors.js | |
export class HttpError extends Error { | |
code; | |
url; | |
constructor(code, url, message) { | |
super(message); | |
this.code = code; | |
this.url = url; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const diacriticsMap = { | |
a: 'a', | |
A: 'A', | |
ₐ: 'a', | |
á: 'a', | |
Á: 'A', | |
à: 'a', | |
À: 'A', | |
ă: 'a', | |
Ă: 'A', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |