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

Can't build when moduleResolution set to bundler. #63

Closed
dairidong opened this issue Aug 6, 2023 · 4 comments · Fixed by #64
Closed

Can't build when moduleResolution set to bundler. #63

dairidong opened this issue Aug 6, 2023 · 4 comments · Fixed by #64

Comments

@dairidong
Copy link

dairidong commented Aug 6, 2023

my tsconfig.json:

{
    "compilerOptions": {
        "allowJs": true,
        "baseUrl": "./",
        "module": "ESNext",
        "moduleResolution": "bundler",
        "jsx": "react-jsx",
        "strict": true,
        "isolatedModules": true,
        "target": "ESNext",
        "esModuleInterop": true,
        "forceConsistentCasingInFileNames": true,
        "noEmit": true,
        "skipLibCheck": true,
        "paths": {
            "@/*": [
                "./resources/js/*"
            ],
            "@styles/*": [
                "./resources/css/*"
            ]
        }
    },
    "include": [
        "resources/js/**/*.ts",
        "resources/js/**/*.tsx",
        "resources/js/**/*.d.ts"
    ],
    "exclude": [
        "node_modules/*"
    ]
}

tsc error:

yarn run v1.22.19
$ tsc && vite build && vite build --ssr
resources/js/Pages/Articles/Show/index.tsx:5:25 - error TS7016: Could not find a declaration file for module 'rehype-prism-plus'. '/home/dairidong/code/react_blog/node_modules/rehype-prism-plus/dist/rehype-prism-plus.es.js' implicitly has an 'any' type.
  There are types at '/home/dairidong/code/react_blog/node_modules/rehype-prism-plus/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'rehype-prism-plus' library may need to update its package.json or typings.

5 import rehypePrism from "rehype-prism-plus";

it's only can run success if i set "moduleResolution": "node" or "noImplicitAny": false

@timlrx timlrx changed the title Can't build when moduleResolution set to bunlder. Can't build when moduleResolution set to bundler. Aug 6, 2023
@timlrx
Copy link
Owner

timlrx commented Aug 6, 2023

Hmm not too sure about this one. Seems like it is expecting types for rehype-prism-plus.es.js directly as well? I might need to create a sample vite app to figure out what's the issue. Meanwhile, I think you could also workaround it by declaring the module explicitly: https://pjausovec.medium.com/how-to-fix-error-ts7016-could-not-find-a-declaration-file-for-module-xyz-has-an-any-type-ecab588800a8

@dairidong
Copy link
Author

Hmm not too sure about this one. Seems like it is expecting types for rehype-prism-plus.es.js directly as well? I might need to create a sample vite app to figure out what's the issue. Meanwhile, I think you could also workaround it by declaring the module explicitly: https://pjausovec.medium.com/how-to-fix-error-ts7016-could-not-find-a-declaration-file-for-module-xyz-has-an-any-type-ecab588800a8

Thank you, I can set the "noImplicitAny": false temporarily, but I want a right way to solve the problem.

I found some similar problems here microsoft/TypeScript#52363 , hope this can help.

@timlrx
Copy link
Owner

timlrx commented Aug 6, 2023

Thanks, the link helps! Fixed the issue. Let me know if it works for you.

@dairidong
Copy link
Author

It works now, thanks for your help!

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

Successfully merging a pull request may close this issue.

2 participants