jquery-param | equivalent function to jQuery.param | Plugin library
kandi X-RAY | jquery-param Summary
kandi X-RAY | jquery-param Summary
equivalent function to jQuery.param
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of jquery-param
jquery-param Key Features
jquery-param Examples and Code Snippets
Community Discussions
Trending Discussions on jquery-param
QUESTION
The jquery-param npm package has the functionality I need in my Angular9 project. I noticed it doesn't have typings for typescript so I also added @types/jquery-param as dependency. I've tried importing in different ways to no avail. I've also read various answers about DefinitelyTyped and typings but can't manage to find the solution. Made a StackBlitz with intended usage if someone is willing to take a look.
Update:
TL;DR: I managed to import and use it. Now the project compiles and works great, but the VSCode's checker marks an error in the import statement. After closing and reopening VSCode it no longer shows error in the import. It seems it only load changes to tsconfig.json on app start.
In StackBlitz works great with just the typings and importing with import param from 'jquery-param';
.
Went ahead and installed both packages in my real project. Then had trouble importing as the compiler complained:
ERROR in src/app/shared/services/http.service.ts:4:24 - error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'allowSyntheticDefaultImports' flag and referencing its default export.
This is because of how the typings are exported, as @wtho mentioned and as stated by:
index.d.ts(8, 1): This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.
Tried importing with import * as params from 'jquery-params'
and other ways using curly braces, didn't work.
So I added
...ANSWER
Answered 2020-Jul-03 at 12:14Before ES modules were introduced, packages often exported a single function as default export. You can import these using the ES modules syntax import param from 'jquery-param'
and just setting "esModuleInterop": true
in your base tsconfig.json
.
If VSCode still complains, make sure you do not have some outdated TypeScript extensions active.
Here is a working stackblitz demo.
It also worked for me locally with Angular v10.0.2
and TypeScript v3.9.5
.
Note that url query parameters are not designed to transport complex object. If possible, switching to a HTTP POST request might be the better solution.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install jquery-param
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page