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

Autocomplete not working in Vscode #250

Open
macario1983 opened this issue Sep 18, 2023 · 2 comments
Open

Autocomplete not working in Vscode #250

macario1983 opened this issue Sep 18, 2023 · 2 comments

Comments

@macario1983
Copy link

I created new project using the commands linke

npm init -y

And generate new binary

xk6 build --with github.com/mostafa/xk6-kafka@latest

The program is running ok, but I tried to follow the step 9 in the documentation but not working.

My folder structure is

image

And my code is:

/// <reference path="..//api-docs//index.d.ts" />

import {
    Writer,
    Connection,
    SchemaRegistry,
    SCHEMA_TYPE_STRING
} from "k6/x/kafka";

const writer = new Writer({
    brokers: ["localhost:19092"],
    topic: "my-topic",
    autoCreateTopic: true,
});

const connection = new Connection({
    address: "localhost:19092",
});

const schemaRegistry = new SchemaRegistry();

export default function () {

    writer.produce({
        messages: [
            {
                key: schemaRegistry.serialize({
                    data: "test-key-string",
                    schemaType: SCHEMA_TYPE_STRING,
                }),
                value: schemaRegistry.serialize({
                    data: "test-value-string",
                    schemaType: SCHEMA_TYPE_STRING,
                }),
                headers: {
                    mykey: "myvalue",
                },
                partition: 0,
                time: new Date(),
            }
        ],
    });
}

export function teardown(data) {
    writer.close();
    connection.close();
}
@mostafa
Copy link
Owner

mostafa commented Sep 19, 2023

Hey @macario1983,

You probably don't need the entire source code of xk6-kafka to work with it and write scripts, and you can use the binaries distributed here. Also, I recommend copying the index.d.ts file next to your JavaScript code, and referencing it from the current working directory.

@macario1983
Copy link
Author

@mostafa thanks for your reply, before to post, I also tryed to put the index.d.ts in the same level of the mas test file, but not worked.

I think if you could publish one example in github will help to know whats wrong.

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