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

[Feature]TypeScript support #12

Open
shinriyo opened this issue Jul 17, 2020 · 13 comments
Open

[Feature]TypeScript support #12

shinriyo opened this issue Jul 17, 2020 · 13 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@shinriyo
Copy link

It can't install.
npm install @types/addsearch-js-client

I hope type definitions.

@anttiai anttiai added enhancement New feature or request help wanted Extra attention is needed labels Jul 20, 2020
@shinriyo
Copy link
Author

I just pull-requested for only class.
DefinitelyTyped/DefinitelyTyped#46203

I hope someone adds for it.

@shinriyo
Copy link
Author

@nexiuhm
Copy link

nexiuhm commented Mar 23, 2022

Any updates on Typescript support ? Thanks : )

@abhinayts
Copy link

Is there a package which can be used in Typescript project? Badly in need of it.

@jkytomaki
Copy link
Contributor

@abhinayts we have worked towards bringing Typescript support to the project. Could you take a look at the branch provide-type-support-for-library and see if this works for you?

@abhinayts
Copy link

@jkytomaki I tried to install 0.8.2 but I don't see types installed in module. I am using npm install --save-dev addsearch-js-client@0.8.2. Am I missing anything? Also repo is not building getting error while running npm run build.

addsearch-js-client@0.8.2 build **\Repos\js-client-library-provide-type-support-for-library\js-client-library-provide-type-support-for-library
npm run test && ./node_modules/webpack-cli/bin/cli.js

addsearch-js-client@0.8.2 test **\Repos\js-client-library-provide-type-support-for-library\js-client-library-provide-type-support-for-library
./node_modules/mocha/bin/mocha.js --recursive --require @babel/register -r esm

'.' is not recognized as an internal or external command,

@haoAddsearch
Copy link
Collaborator

@abhinayts the feature branch is not published to npmjs, so to use it you need to clone the repo to your machine then install it from there.
npm install /path/to/project/folder/js-client-library

Regarding error with npm run build, you could try removing ./ at the beginning of "test" and "build" script in package.json.

@abhinayts
Copy link

removing ./ not helping.

@haoAddsearch
Copy link
Collaborator

In case you are using Windows machine, try editing package.json's scripts with this

"test": "node node_modules/mocha/bin/mocha.js --recursive --require @babel/register -r esm"

"build": "npm run test && node node_modules/webpack-cli/bin/cli.js"

@abhinayts
Copy link

abhinayts commented May 16, 2023

@haoAddsearch so after using it the code in my application I am getting error. My application is TS application.
Unhandled Runtime Error
TypeError: Cannot read properties of undefined (reading 'prototype')

.next\static\chunks\webpack.js (25:0) @ webpack_require

23 | webpack_require.i.forEach(function(handler) { handler(execOptions); });
24 | module = execOptions.module;

25 | execOptions.factory.call(module.exports, module, module.exports, execOptions.require);
26 | threw = false;
27 | } finally {
28 | if(threw) delete webpack_module_cache[moduleId];

@haoAddsearch
Copy link
Collaborator

@abhinayts we will need to create a bug ticket and look into this. Could you tell which frontend/backend framework your application is using?

@abhinayts
Copy link

@haoAddsearch I am trying to use it in react application using typescript.

@kanarupan-addsearch
Copy link
Contributor

@abhinayts

(1) We have successfully tried the below settings
Typescript support feature branch: https://github.com/AddSearch/js-client-library/tree/provide-type-support-for-library
Windows Platform: amazon/Windows_Server-2022-English-Full-Base-2023.05.10
nvm: 1.1.11
node: 10.17.6
npm: 6.14.15
typescript: 5.0.4
react + typescript sample public project: https://github.com/Lemoncode/react-typescript-samples/tree/master/hooks/01_HelloReact

(2) High-level steps

a) js-client-library:

  1. in the Windows platform perform the suggested modification in package.json
    [Feature]TypeScript support #12 (comment)

  2. run npm install

  3. run npm run build

b) the sample project 01_HelloReact:

  1. replace hello.tsc with the below content
import * as React from "react";
import AddSearchClient from 'addsearch-js-client';

export const HelloComponent = () => {

  let client: any = new AddSearchClient( `<adddsearch customer public key>`);

  client.search('keyword', (response: any) => {
    console.log(response);
  });

  return <h2>Hello component !</h2>;
};

  1. run npm install
  2. run npm install <local directory path to the root of js-client-library>
  3. npm run start
  4. check localhost:8080 with the network tab for the request with the <adddsearch customer public key>.

(3) If the above isn't helpful to resolve your particular issue, then,

  1. kindly list the relevant technology versions as in section (1) above. Provide other information that you deem useful to replicate your specific environment.
  2. or to speed up the process it's better to contact our support [1] and pass this Issue thread [2], so we could work out 1. interactively.

[1] https://www.addsearch.com/support/contact-support/
{2] #12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants