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

Could not find a declaration file for module 'qs' #794

Open
dac-humi opened this issue Nov 27, 2024 · 2 comments
Open

Could not find a declaration file for module 'qs' #794

dac-humi opened this issue Nov 27, 2024 · 2 comments
Assignees

Comments

@dac-humi
Copy link

Ziggy version

2.4.1

Laravel version

10.48.24

Description

In a Laravel/React/Inertia.js project, we go with the recommendation to get TypeScript types directly from the composer packages, see:

Today, after upgrading to latest and doing yarn install; yarn build, we get this in CI/CD

vendor/tightenco/ziggy/src/js/index.d.ts:1:26 - error TS7016: Could not find a declaration file for module 'qs'. '/var/www/hr/node_modules/qs/lib/index.js' implicitly has an 'any' type. Try `npm i --save-dev @types/qs` if it exists or add a new declaration (.d.ts) file containing `declare module 'qs';`

Or this in local:

vendor/tightenco/ziggy/src/js/index.d.ts:1:26 - error TS7016: Could not find a declaration file for module 'qs'. '/Users/dac.chartrand/code/github/Humi-HR/humility/applications/hr/node_modules/qs/lib/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/qs` if it exists or add a new declaration (.d.ts) file containing `declare module 'qs';`

1 import { ParsedQs } from 'qs';
                           ~~~~


Found 1 error in vendor/tightenco/ziggy/src/js/index.d.ts:1

Ziggy call and context

yarn build

Ziggy configuration

// tsconfig.json
{
    "compilerOptions": {
        "allowJs": true,
        "module": "ESNext",
        "moduleResolution": "bundler",
        "jsx": "react-jsx",
        "strict": true,
        "isolatedModules": true,
        "target": "ESNext",
        "esModuleInterop": true,
        "forceConsistentCasingInFileNames": true,
        "noEmit": true,
        "paths": {
            "@/*": ["./resources/js/*"],
            "@images/*": ["./resources/images/*"],
            "ziggy-js": ["./vendor/tightenco/ziggy"]
        }
    },
    "include": ["resources/js/**/*.ts", "resources/js/**/*.tsx", "resources/js/**/*.d.ts"]
}

Route definition

n/a
@dac-humi
Copy link
Author

(We want to avoid adding @types/qs to our own package.json. It's not very maintainable if we have to play catch up.)

@bakerkretzmar bakerkretzmar self-assigned this Nov 27, 2024
@bakerkretzmar
Copy link
Collaborator

Ugh, sorry about this. Probably best for us to just manually copy in the ParsedQs type. I'll work on it.

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