From f1726e91fba2d34b9f6e640d5e016f997660ccc8 Mon Sep 17 00:00:00 2001 From: AlissonFCampos Date: Thu, 26 May 2022 20:12:55 -0300 Subject: [PATCH 1/2] aprofundamento-typescript --- modulo5/aprofundamento-typescript/package.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 modulo5/aprofundamento-typescript/package.json diff --git a/modulo5/aprofundamento-typescript/package.json b/modulo5/aprofundamento-typescript/package.json new file mode 100644 index 0000000..7410f96 --- /dev/null +++ b/modulo5/aprofundamento-typescript/package.json @@ -0,0 +1,12 @@ +{ + "name": "aprofundamento-typescript", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC" +} From b5063d6d43ba04dd1a00acde7c13083403c99891 Mon Sep 17 00:00:00 2001 From: AlissonFCampos Date: Mon, 30 May 2022 10:01:57 -0300 Subject: [PATCH 2/2] =?UTF-8?q?Altera=C3=A7=C3=B5es=20finais?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modulo5/Lista-Typescript/.gitignore | 1 + modulo5/Lista-Typescript/package.json | 16 ++++++++ modulo5/Lista-Typescript/src/exercicio1.ts | 0 modulo5/Lista-Typescript/tsconfig.json | 0 modulo5/aprofundamento-typescript/.gitignore | 1 + .../package-lock.json | 13 +++++++ .../aprofundamento-typescript/package.json | 16 ++++++-- .../src/exercicio1.ts | 36 ++++++++++++++++++ .../src/exercicio2.ts | 33 +++++++++++++++++ .../src/exercicio3.ts | 37 +++++++++++++++++++ .../src/exercicio4.ts | 26 +++++++++++++ .../src/exercicio5.ts | 3 ++ .../aprofundamento-typescript/tsconfig.json | 11 ++++++ 13 files changed, 189 insertions(+), 4 deletions(-) create mode 100644 modulo5/Lista-Typescript/.gitignore create mode 100644 modulo5/Lista-Typescript/package.json create mode 100644 modulo5/Lista-Typescript/src/exercicio1.ts create mode 100644 modulo5/Lista-Typescript/tsconfig.json create mode 100644 modulo5/aprofundamento-typescript/.gitignore create mode 100644 modulo5/aprofundamento-typescript/package-lock.json create mode 100644 modulo5/aprofundamento-typescript/src/exercicio1.ts create mode 100644 modulo5/aprofundamento-typescript/src/exercicio2.ts create mode 100644 modulo5/aprofundamento-typescript/src/exercicio3.ts create mode 100644 modulo5/aprofundamento-typescript/src/exercicio4.ts create mode 100644 modulo5/aprofundamento-typescript/src/exercicio5.ts create mode 100644 modulo5/aprofundamento-typescript/tsconfig.json diff --git a/modulo5/Lista-Typescript/.gitignore b/modulo5/Lista-Typescript/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/modulo5/Lista-Typescript/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/modulo5/Lista-Typescript/package.json b/modulo5/Lista-Typescript/package.json new file mode 100644 index 0000000..2b6d07d --- /dev/null +++ b/modulo5/Lista-Typescript/package.json @@ -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" +} diff --git a/modulo5/Lista-Typescript/src/exercicio1.ts b/modulo5/Lista-Typescript/src/exercicio1.ts new file mode 100644 index 0000000..e69de29 diff --git a/modulo5/Lista-Typescript/tsconfig.json b/modulo5/Lista-Typescript/tsconfig.json new file mode 100644 index 0000000..e69de29 diff --git a/modulo5/aprofundamento-typescript/.gitignore b/modulo5/aprofundamento-typescript/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/modulo5/aprofundamento-typescript/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/modulo5/aprofundamento-typescript/package-lock.json b/modulo5/aprofundamento-typescript/package-lock.json new file mode 100644 index 0000000..d2c253c --- /dev/null +++ b/modulo5/aprofundamento-typescript/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "aprofundamento-typescript", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "typescript": { + "version": "4.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.2.tgz", + "integrity": "sha512-Mamb1iX2FDUpcTRzltPxgWMKy3fhg0TN378ylbktPGPK/99KbDtMQ4W1hwgsbPAsG3a0xKa1vmw4VKZQbkvz5A==" + } + } +} diff --git a/modulo5/aprofundamento-typescript/package.json b/modulo5/aprofundamento-typescript/package.json index 7410f96..7c1514c 100644 --- a/modulo5/aprofundamento-typescript/package.json +++ b/modulo5/aprofundamento-typescript/package.json @@ -1,12 +1,20 @@ { "name": "aprofundamento-typescript", "version": "1.0.0", - "description": "", - "main": "index.js", + "main": "exercicio1.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "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" + "license": "ISC", + "description": "", + "dependencies": { + "typescript": "^4.7.2" + } } diff --git a/modulo5/aprofundamento-typescript/src/exercicio1.ts b/modulo5/aprofundamento-typescript/src/exercicio1.ts new file mode 100644 index 0000000..87d568b --- /dev/null +++ b/modulo5/aprofundamento-typescript/src/exercicio1.ts @@ -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) diff --git a/modulo5/aprofundamento-typescript/src/exercicio2.ts b/modulo5/aprofundamento-typescript/src/exercicio2.ts new file mode 100644 index 0000000..62fe2e5 --- /dev/null +++ b/modulo5/aprofundamento-typescript/src/exercicio2.ts @@ -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])) \ No newline at end of file diff --git a/modulo5/aprofundamento-typescript/src/exercicio3.ts b/modulo5/aprofundamento-typescript/src/exercicio3.ts new file mode 100644 index 0000000..4c1e8b5 --- /dev/null +++ b/modulo5/aprofundamento-typescript/src/exercicio3.ts @@ -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")) \ No newline at end of file diff --git a/modulo5/aprofundamento-typescript/src/exercicio4.ts b/modulo5/aprofundamento-typescript/src/exercicio4.ts new file mode 100644 index 0000000..9bc5b1a --- /dev/null +++ b/modulo5/aprofundamento-typescript/src/exercicio4.ts @@ -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" \ No newline at end of file diff --git a/modulo5/aprofundamento-typescript/src/exercicio5.ts b/modulo5/aprofundamento-typescript/src/exercicio5.ts new file mode 100644 index 0000000..d085ccd --- /dev/null +++ b/modulo5/aprofundamento-typescript/src/exercicio5.ts @@ -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*/ \ No newline at end of file diff --git a/modulo5/aprofundamento-typescript/tsconfig.json b/modulo5/aprofundamento-typescript/tsconfig.json new file mode 100644 index 0000000..3594826 --- /dev/null +++ b/modulo5/aprofundamento-typescript/tsconfig.json @@ -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. */ + } +} \ No newline at end of file