This file contains 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
class KeyValuePair<KeyType, ValueType> { | |
key: KeyType; | |
value: ValueType; | |
constructor(key: KeyType, value: ValueType) { | |
this.key = key; | |
this.value = value; | |
} | |
} |
This file contains 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
function sum(a: number, b: number): number; | |
function sum(a: string, b: string): string; | |
function sum(a: number | string, b: number | string): number | string { | |
if (typeof a === "number" && typeof b === "number") { | |
return a + b; | |
} else { | |
return `${parseInt(`${a}`, 10) + parseInt(`${b}`, 10)}`; | |
} | |
} |
This file contains 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
Playlist: https://www.youtube.com/playlist?list=PLCbdBdyNHZXLX9p_F8WCPwXHn67QlstZ9 | |
Video in Playlist: https://www.youtube.com/watch?v=qZN0Lo-f3iE&list=PLCbdBdyNHZXLX9p_F8WCPwXHn67QlstZ9 | |
Video: https://www.youtube.com/watch?v=qZN0Lo-f3iE |
This file contains 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
function getRandom<T>(array: T[]): T { | |
const diceRoll = Math.floor(Math.random() * array.length); | |
return array[diceRoll]; | |
} | |
const names = [ | |
'Amelia', 'Ava', 'Benjamin', 'Charlotte', 'Elijah', 'Emma', | |
'Evelyn', 'Harper', 'Henry', 'Isabella', 'James', 'Liam', 'Lucas', 'Mia', | |
'Noah', 'Oliver', 'Olivia', 'Sophia', 'Theodore', 'William' | |
]; |
This file contains 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
function sum(a: number, b: number): number; | |
function sum(a: string, b: string): string; | |
function sum(a: number | string, b: number | string): number | string { | |
if (typeof a === "number" && typeof b === "number") { | |
return a + b; | |
} else { | |
return `${parseInt(`${a}`, 10) + parseInt(`${b}`, 10)}`; | |
} | |
} |
This file contains 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
interface Dog { | |
age: number; | |
name: string; | |
bark: () => void; | |
type: "dog"; | |
} | |
interface Person { | |
age: number; | |
name: string; |
This file contains 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 {Person, printAddress, MissingAddressError} from './printAddress'; | |
describe('printAddress', () => { | |
it('throws an error when person does not have an address', () => { | |
const benny = { | |
age: 34, | |
} as Person; | |
expect(() => { | |
printAddress(benny); | |
}).toThrowError(MissingAddressError); |
This file contains 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
Show hidden characters
{ | |
"compilerOptions": { | |
"allowJs": true, | |
"allowSyntheticDefaultImports": true, | |
"alwaysStrict": true, | |
"declaration": false, | |
"downlevelIteration": true, | |
"emitDecoratorMetadata": true, | |
"esModuleInterop": true, | |
"experimentalDecorators": true, |
This file contains 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
name: 'Merge Dependencies' | |
# https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/ | |
on: [pull_request_target] | |
permissions: | |
pull-requests: write | |
contents: write | |
jobs: |
This file contains 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
typeof process === 'object' |