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

It's not possible to compile the project with a table because of ts errors #4688

Closed
2 tasks done
Travellerme opened this issue Jan 30, 2023 · 6 comments
Closed
2 tasks done

Comments

@Travellerme
Copy link
Contributor

Travellerme commented Jan 30, 2023

Describe the bug

image
The error is happening here:
node_modules/@tanstack/table-core/src/utils/filterRowsUtils.ts:112:19

Your minimal, reproducible example

N/A

Steps to reproduce

Running a build with typescript triggers such errors to be shown

Expected behavior

Is this possible to define rows as follows:
const rows: Row<TData>[] = []
?
It's urgent for us, as we're going to use the table in production
Thank you

How often does this bug happen?

None

Screenshots or Videos

image

Platform

ANY

react-table version

8.7.8

TypeScript version

4.8.4

Additional context

No response

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
@Travellerme
Copy link
Contributor Author

I've created a PR for it #4689

@KevinVandy
Copy link
Member

Why is your TS scanning node_modules?

@Travellerme
Copy link
Contributor Author

It's not I guess.
At least tsc --noEmit --showConfig
returns nothing related to node_modules:


{
    "compilerOptions": {
        "baseUrl": "./src",
        "paths": {
            "components/*": [
                "./components/*"
            ],
            "constants/*": [
                "./constants/*"
            ],
            "config/*": [
                "./config/*"
            ],
            "contexts/*": [
                "./contexts/*"
            ],
            "lib": [
                "./lib"
            ],
            "services": [
                "./services"
            ],
            "ui": [
                "./ui"
            ]
        },
        "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",
        "noImplicitAny": false
    },
    "files": [
        ...  // I've checked and there are no files from node_modules here

    ],
    "include": [
        "src",
        "types"
    ]
}

My assumption is that it checks imports and somehow sees ts errors in dependent packages. But I might be wrong.
Anyway if I may suggest, having a strict type is better than having "never" type

@Travellerme
Copy link
Contributor Author

Most probably I found an explanation for why it fails even if node_modules are not included in TS checking
There is a tool https://www.npmjs.com/package/loose-ts-check that I have to use in order to skip this error in Tanstack/table, and it's said:

Why not exclude in tsconfig.json
The exclude option in tsconfig.json only tells tsc to not start type-checking from those files. If some already type-checked file imports a file listed in the exclude, it will still be type-checked.

Thus, it does not suit this use case.

So most probably my assumption was correct. The file which is using the tanstack table library should be checked by TS. And as it has a dependency on tanstack - it causes a failure

@KevinVandy
Copy link
Member

Most if not all projects (at least that I have ever worked on) include this in their tsconfig

"exclude": [
    "node_modules"
  ]

Different projects and libraries can have very different ts configurations.

Also, this is probably caused by you are importing from src instead of importing directly from @tanstack/react-table. Your own project should only import the transpiled js that way, instead of the source typescript files.

@Travellerme
Copy link
Contributor Author

Travellerme commented Jan 31, 2023

I tried to use exclude option as well but had no luck, unfortunately.
Thx for merging!

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