Typescript modules in k6

Hi,
I am a little confused regarding the use of Typescript with k6.
I have custom ts modules that help me with data generation and I would like to import these within the k6 test. However, when doing so I get Syntax errors with the .ts files.

WARN[0001] A url was resolved but it didn't have scheme. This will be deprecated in the future and all remote modules will need to explicitly use `https` as scheme  url=//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.0/underscore-min.js
ERRO[0001] SyntaxError: file:///Users/vaishnavi/k6-typescript-framework/modules/server/models/sg/sgModel.ts: Unexpected token, expected , (19:53)

I need help in understanding whether this is related to the lack of support for typescript in k6.

I tried making use of GitHub - go-automate/k6-typescript-framework: A starter framework for k6 load tests written in TypeScript, but on bundling with webpack and running my test I again see numerous errors.

Hi @Vaishnavi,

Given that k6 does not support TypeScript, if you import it you will get a SyntaxError … unless it is basically not typescript but pure JavaScript :wink: So yes … the second line is because of the lack of typescript support in k6.

You can try this GitHub - grafana/k6-template-typescript: Template to use TypeScript with k6 project made by @simme as well and please provide us with what you do and … how it breaks, otherwise, we can’t help you

Good luck :wink:

Thanks for the reply @mstoykov.
We decided to keep all the setup outside of the load and just use k6 to make our requests. This is working out perfectly fine!