Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different results from tsc #54

Closed
JoshWhite opened this issue Feb 16, 2023 · 1 comment
Closed

Different results from tsc #54

JoshWhite opened this issue Feb 16, 2023 · 1 comment

Comments

@JoshWhite
Copy link

Hi, I'm getting different errors when running tsc compared with tsc-files.

I get this when running tsc from root (this is what I expected):

> vite-test@0.0.0 tsc
> tsc

src/routes/Posts.tsx:31:23 - error TS7006: Parameter 'post' implicitly has an 'any' type.

31           {posts.map((post) => (
                         ~~~~


Found 1 error in src/routes/Posts.tsx:31

And this when running tsc-files in a git precommit hook:

✔ Preparing lint-staged...
❯ Running tasks for staged files...
  ❯ package.json — 9 files
    ✔ src/**/*.{js,jsx,ts,tsx,json,css,scss,md} — 4 files
    ❯ src/**/*.{js,jsx,ts,tsx} — 4 files
      ✔ eslint --cache --fix
      ✖ tsc-files --noEmit --pretty [FAILED]
↓ Skipped because of errors from tasks. [SKIPPED]
✔ Reverting to original state because of errors...
✔ Cleaning up temporary files...

✖ tsc-files --noEmit --pretty:
src/components/Page/Page.tsx:2:18 - error TS2307: Cannot find module '../../logo.svg' or its corresponding type declarations.

2 import logo from "../../logo.svg";
                   ~~~~~~~~~~~~~~~~

src/components/Page/Page.tsx:4:20 - error TS2307: Cannot find module './Page.module.css' or its corresponding type declarations.

4 import styles from "./Page.module.css";
                     ~~~~~~~~~~~~~~~~~~~

src/features/counter/Counter.tsx:12:20 - error TS2307: Cannot find module './Counter.module.css' or its corresponding type declarations.

12 import styles from "./Counter.module.css";
                      ~~~~~~~~~~~~~~~~~~~~~~

src/routes/Posts.tsx:31:23 - error TS7006: Parameter 'post' implicitly has an 'any' type.

31           {posts.map((post) => (
                         ~~~~


Found 4 errors in 3 files.

Errors  Files
     2  src/components/Page/Page.tsx:2
     1  src/features/counter/Counter.tsx:12
     1  src/routes/Posts.tsx:31
husky - pre-commit hook exited with code 1 (error)

Any idea why it's throwing the extra errors?

My tsconfig.json looks like this, if it helps:

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": ["src"]
}
@gustavopch
Copy link
Owner

Same as #20. Check the comments for the explanation and workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants