Shiki Twoslash
20 Jan, 2023
👋 FYI, this note is over 6 months old. Some of the content may be out of date.
// Removes 'readonly' attributes from a type's properties
type CreateMutable<Type> = {
-readonly [Property in keyof Type]: Type[Property]
}
type LockedAccount = {
readonly id: string
readonly name: string
}
type UnlockedAccount = CreateMutable<LockedAccount>
// @module: esnext
// @filename: maths.ts
export function absolute(num: number) {
if (num < 0) return num * -1
return num
}
// @filename: index.ts
import { absolute } from './maths'
const value = absolute(-1)
// @module: esnext
// @filename: maths.ts
export function absolute(num: number) {
if (num < 0) return num * -1
return num
}
// @filename: index.ts
import { absolute } from './maths'
const value = absolute(-1)
// ^?
// @module: esnext
// @filename: maths.ts
export function absolute(num: number) {
if (num < 0) return num * -1
return num
}
// @filename: index.ts
// ---cut---
import { absolute } from './maths'
const value = absolute(-1)
// ^?
function greet(person: string) {
console.log(`Hello ${person},`)
console.log(`How do?`)
}
greet('Maddison')
← Back home