Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modulo5/Lista-Typescript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
16 changes: 16 additions & 0 deletions modulo5/Lista-Typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Lista-Typescript",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"typescript": "^4.7.2"
},
"devDependencies": {},
"scripts": {
"start": "tsc && node ./build/exercicio1.ts"
},
"keywords": [],
"author": "",
"license": "ISC"
}
Empty file.
Empty file.
1 change: 1 addition & 0 deletions modulo5/aprofundamento-typescript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
13 changes: 13 additions & 0 deletions modulo5/aprofundamento-typescript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions modulo5/aprofundamento-typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "aprofundamento-typescript",
"version": "1.0.0",
"main": "exercicio1.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "tsc && node ./build/exercicio1.js",
"start1": "tsc && node ./build/exercicio2.js",
"start2": "tsc && node ./build/exercicio3.js",
"start3": "tsc && node ./build/exercicio4.js",
"start4": "tsc && node ./build/exercicio5.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"typescript": "^4.7.2"
}
}
36 changes: 36 additions & 0 deletions modulo5/aprofundamento-typescript/src/exercicio1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//const minhaString: string = 5 "Não aceita número pois foi definido uma string"
//const meuNumero: number = "tentei" "Não aceita string pois foi definido um tipo number"

type pessoa = {
nome:string,
idade: number,
corFavorita: string
}
enum CorFavorita {
PRETO = "Preto",
AZUL = "Azul",
LILAS = "Lilás",
VERMELHO = "Vermelho"
}
const pessoa: pessoa= {
nome: "Alisson",
idade: 38,
corFavorita: CorFavorita.PRETO
}

const pessoa1:pessoa = {
nome: "Nicollas",
idade: 17,
corFavorita: CorFavorita.AZUL
}
const pessoa2: pessoa= {
nome: "Lucimara",
idade: 38,
corFavorita: CorFavorita.VERMELHO
}
const pessoa3: pessoa= {
nome: "Sophia",
idade: 13,
corFavorita: CorFavorita.LILAS
}
console.table(pessoa3)
33 changes: 33 additions & 0 deletions modulo5/aprofundamento-typescript/src/exercicio2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//A = as entradas são um array de números e saídas também
//B = numerosOrdenados que usa o método sort para ordenar os números do maior para o menor
// a variável soma para dar início ao laço
//e a variável estatísticas que retorna o maior,menor e a média dos números.
//C =
type amostra= {
numeros:number[],
obterEstatisticas:number
}


function obterEstatisticas(numeros: number[]): number {


const numerosOrdenados: number[] = numeros.sort(
(a, b) => a - b
)

let soma = 0

for (let num of numeros) {
soma += num
}

const estatisticas: any = {
maior: numerosOrdenados[numeros.length - 1],
menor: numerosOrdenados[0],
media: soma / numeros.length
}

return estatisticas
}
console.log(obterEstatisticas([25,36,35,888]))
37 changes: 37 additions & 0 deletions modulo5/aprofundamento-typescript/src/exercicio3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@


type postar = {
autor:string,
texto:string
}

const posts : postar[] = [
{
autor: "Alvo Dumbledore",
texto: "Não vale a pena viver sonhando e se esquecer de viver"
},
{
autor: "Severo Snape",
texto: "Menos 10 pontos para Grifinória!"
},
{
autor: "Hermione Granger",
texto: "É levi-ô-sa, não levio-sá!"
},
{
autor: "Dobby",
texto: "Dobby é um elfo livre!"
},
{
autor: "Lord Voldemort",
texto: "Avada Kedavra!"
}
]
function buscarPostsPorAutor(posts:postar[], autorInformado:string) :postar[]{
return posts.filter(
(post) => {
return post.autor === autorInformado
}
)
}
console.log(buscarPostsPorAutor(posts,"Lord Voldemort"))
26 changes: 26 additions & 0 deletions modulo5/aprofundamento-typescript/src/exercicio4.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
type pokemon = {
name: string,
types: string,
healthPoints: number
}

const pokemon1: pokemon = {
name: "Charmander",
types: "Fire",
healthPoints: 28
}

const pokemon2: pokemon = {
name: "Bulbasaur",
types: "Grass/Poison",
healthPoints: 31
}

const pokemon3: pokemon = {
name: "Squirtle",
types: "Water",
healthPoints: 35
}
//B = : "tsc exercicio4.ts"
//C = : "tsc && node ./build/exercicio4.js" indicaria o caminho para chegar ao arquivo pedido
//D = : "É a mesma coisa mudando somente a inclusão de todos os outros arquivos .ts"
3 changes: 3 additions & 0 deletions modulo5/aprofundamento-typescript/src/exercicio5.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//percebi que mudamos a versão do Js para pegar uma versão que tenha menos bug mais comulmente usado nos navegadores
/*observei que mudamos o caminho da outdir e rootdir, como padrão ele vem fora da pasta src, como mudamos para organizar
é necessário alterar*/
11 changes: 11 additions & 0 deletions modulo5/aprofundamento-typescript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"target": "es6", /* Specify ECMAScript target version */
"module": "commonjs", /* Specify module code generation */
"sourceMap": true, /* Generates corresponding '.map' file. */
"outDir": "./build", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. */
"removeComments": true, /* Do not emit comments to output. */
"noImplicitAny": true /* Raise error on declarations with an implied 'any' type. */
}
}