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
interface DefaultResponse<T> { | |
code: number; | |
content: T; | |
timestamp: string; | |
valid: boolean; | |
} | |
interface Driver { | |
id: number; | |
name: string; |
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
interface DriverF1 { | |
firstName: string; | |
lastName: string; | |
} | |
const newDriverF1 = <T extends DriverF1>(obj: T) => { | |
return { | |
...obj, | |
fullName: `${obj.firstName} ${obj.lastName}` | |
} |
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
interface DriverF1 { | |
firstName: string; | |
lastName: string; | |
} | |
const newDriverF1 = (obj: DriverF1) => { | |
return { | |
...obj, | |
fullName: `${obj.firstName} ${obj.lastName}` | |
} |
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 createArray = <A, B = number>(a: A, b: B) => { | |
return [a, b]; | |
} | |
let otherArray = createArray<string | null>("Junho", 6); |
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
let showArrayWithNumberNBoolean = createArray<string, boolean | null>('Brasil', 2020); | |
//Argument of type '2020' is not assignable to parameter of type 'boolean' |
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 createArray = <A, B>(a: A, b: B) => { | |
return [a, b]; | |
} | |
let showArray = createArray('Brasil', 2020); |
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
function returnLastOne<T>(param: Array<T>): T { | |
return param.pop(); | |
} | |
//ou | |
function returnLastOne<T>(param: T[]) { //implícito retorna tipo T | |
return param.pop(); | |
} | |
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
function returnTheSameArguments<T>(param: T): T { | |
return param; | |
} | |
let showMessage = returnTheSameArguments("Qual conhecimento você compartilhou hoje?"); |
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
function returnTheSameArguments(arg: number): number { | |
return arg; | |
} |
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
function ruleOfThree (had, got, have) { | |
return have * got / had; | |
} |
NewerOlder