1
resposta

Compilador não funciona

Baixei a pasta do projeto com as alterações feitas pelo professor. Dei o comando 'npm install" e, em seguida, digitei o comando 'npm start" e o servidor local foi gerado, abrindo a página. Todavia, quando eu adiciono modificações nos arquivos Typescript, elas não são compiladas para os arquivos Javascript. Além disso, percebi que, ao digitar o comando 'npm run watch' os erros abaixo são apresentados (coisa que o projeto anterior não apresentava). Tentei todas as soluções que achei na internet para instalar este módulo babel, mas nenhuma funcionou.

../../../../node_modules/@types/babel__core/index.d.ts:12:31 - error TS2792: Cannot find module '@babel/parser'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?

12 import { ParserOptions } from '@babel/parser';
                                 ~~~~~~~~~~~~~~~

../../../../node_modules/@types/babel__core/index.d.ts:15:20 - error TS2792: Cannot find module '@babel/types'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?

15 import * as t from '@babel/types';
                      ~~~~~~~~~~~~~~

../../../../node_modules/@types/babel__generator/index.d.ts:11:20 - error TS2792: Cannot find module '@babel/types'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?

11 import * as t from '@babel/types';
                      ~~~~~~~~~~~~~~

../../../../node_modules/@types/babel__template/index.d.ts:9:31 - error TS2792: Cannot find module '@babel/parser'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?

9 import { ParserOptions } from '@babel/parser';
                                ~~~~~~~~~~~~~~~

../../../../node_modules/@types/babel__template/index.d.ts:10:48 - error TS2792: Cannot find module '@babel/types'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?

10 import { Expression, Program, Statement } from '@babel/types';
                                                  ~~~~~~~~~~~~~~

../../../../node_modules/@types/babel__traverse/index.d.ts:13:20 - error TS2792: Cannot find module '@babel/types'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?

13 import * as t from '@babel/types';
                      ~~~~~~~~~~~~~~

../../../../node_modules/@types/babel__traverse/index.d.ts:63:18 - error TS2411: Property 'blacklist' of type 'any[] | undefined' is not assignable to string index type '(VisitNode<S, any> & VisitNode<S, any>) | undefined'.

63 export interface TraverseOptions<S = Node> extends Visitor<S> {
                    ~~~~~~~~~~~~~~~

../../../../node_modules/@types/babel__traverse/index.d.ts:63:18 - error TS2411: Property 'denylist' of type 'any[] | undefined' is not assignable to string index type '(VisitNode<S, any> & VisitNode<S, any>) | undefined'.

63 export interface TraverseOptions<S = Node> extends Visitor<S> {
                    ~~~~~~~~~~~~~~~

../../../../node_modules/@types/babel__traverse/index.d.ts:64:5 - error TS2411: Property 'scope' of type 'Scope | undefined' is not assignable to string index type '(VisitNode<S, any> & VisitNode<S, any>) | undefined'.

64     scope?: Scope | undefined;
       ~~~~~

../../../../node_modules/@types/babel__traverse/index.d.ts:65:5 - error TS2411: Property 'noScope' of type 'boolean | undefined' is not assignable to string index type '(VisitNode<S, any> & VisitNode<S, any>) | undefined'.

65     noScope?: boolean | undefined;
       ~~~~~~~

../../../../node_modules/@types/babel__traverse/index.d.ts:248:69 - error TS2536: Type '"type"' cannot be used to index type 'T'.

248     type: T extends null | undefined ? undefined : T extends Node ? T['type'] : string | undefined;
                                                                        ~~~~~~~~~

../../../../node_modules/@types/jest/index.d.ts:477:51 - error TS2792: Cannot find module 'jest-diff'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?

477             diff(a: any, b: any, options?: import("jest-diff").DiffOptions): string | null;
                                                      ~~~~~~~~~~~

[17:38:35] Found 12 errors. Watching for file changes.
1 resposta

Oii, Dev! Como vai?

Agradeço por aguardar o nosso retorno.

Percebi que você concluiu o curso "TypeScript parte 3: mais técnicas e boas práticas" e gostaria inicialmente de saber se você ainda está enfrentando esse desafio com relação à compilação e também ao erro apresentado apósnpm run watch. Caso ainda esteja com esse problema, peço que me informe, por gentileza, qual módulo e aula você baixou o código, para que eu possa simular o problema e te ajudar de forma mais assertiva.

Fico no aguardo.

Bons estudos!