$ npm i prettier prettier-plugin-css-order prettier-plugin-organize-attributes css-declaration-sorter -D
Create .prettierrc
file:
{
"printWidth": 120,
"tabWidth": 2,
import { Platform } from '@angular/cdk/platform'; | |
import { Injectable } from '@angular/core'; | |
import { MemoryStorage } from './memory-storage'; | |
@Injectable({ | |
providedIn: 'root', | |
}) | |
export class LocalStorage implements Storage { | |
private readonly storage: Storage; |
$ npm i prettier prettier-plugin-css-order prettier-plugin-organize-attributes css-declaration-sorter -D
Create .prettierrc
file:
{
"printWidth": 120,
"tabWidth": 2,
Official documentation: https://www.typescriptlang.org/docs/handbook/utility-types.html
Make all properties in T
optional.
type t = Partial<{a: string; b: number}>;
import { existsSync, mkdirSync } from 'fs'; | |
import { resolve } from 'path'; | |
import { config } from '../config'; | |
export async function processTextToSpeech(ssml: string, filename: string) { | |
// Check media dir | |
const dirPath = resolve(config.main.storePath); | |
if (!existsSync(dirPath)) { | |
mkdirSync(dirPath); | |
} |
by Wassim Chegham (@manekinekko)
From this awesome animation, originally from this tweet
getData( a => {
getMoreData(a, b => {
import {Pipe, PipeTransform} from '@angular/core'; | |
@Pipe({ | |
name: 'nl2br', | |
standalone: true, | |
}) | |
export class Nl2brPipe implements PipeTransform { | |
transform(text: string): string { | |
return Nl2brPipe.replace(text); | |
} |
Angular has CanDeactivate
guard, but you have to declare it to each path in the routes configuration.
Valid until angular/angular#11836 will be done.
You can use CanActivateChild
guard to prevent leaving from any component with single declaration.