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

Typescript Help: Client is not a constructor #734

Open
stoked10 opened this issue Apr 28, 2022 · 1 comment
Open

Typescript Help: Client is not a constructor #734

stoked10 opened this issue Apr 28, 2022 · 1 comment

Comments

@stoked10
Copy link

I pulled the code directly from the typescript example in the README:

import * as ApiClient from 'kubernetes-client';

const Client = ApiClient.Client1_13;
const client = new Client({ version: '1.13' });

My only difference is loading the kubeconfig from the cluster:

const kubeconfig = new KubeConfig();
kubeconfig.loadFromCluster();
const backend = new Request({ kubeconfig });
return new ApiClient.Client1_13({ backend, version: '1.13' });

When I run this typescript gives me an error:

Error initializing client: TypeError: Client is not a constructor

I tried everything I could think of and searched the googles and couldn't come up with anything, any help would be greatly appreciated!

node: 16.15.0
typescript: 4.6.2

@stoked10
Copy link
Author

I finally figured out a workaround, it's not the greatest though. I basically had to cut the typings out of it:

import pkg from 'kubernetes-client/lib/index';

const kubeconfig = new KubeConfig();
kubeconfig.loadFromCluster();
const backend = new Request({ kubeconfig });

const { Client1_13 } = pkg;
return new Client1_13({ backend, version: '1.13' });

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

1 participant