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

Add export of FakeResponseType and PerftoolComponent #471

Closed
saranchonkau opened this issue Apr 5, 2024 · 1 comment
Closed

Add export of FakeResponseType and PerftoolComponent #471

saranchonkau opened this issue Apr 5, 2024 · 1 comment

Comments

@saranchonkau
Copy link

saranchonkau commented Apr 5, 2024

Is your feature request related to a problem? Please describe.
I'm trying to write perf test but TS throws error

import { intercept } from '@salutejs/perftool';
// long non-standard import
import type { PerftoolComponent } from '@salutejs/perftool/dist/client/measurement/runner'; 

export const Default: PerftoolComponent = () => {
  return <div></div>;
};

Default.beforeTest = async () => {
  await intercept({
    method: 'GET',
    responseType: 'file', // TS2322: Type "file" is not assignable to type FakeResponseType | undefined
    source: '**/some.client.js',
    response: 'public/js/some.client.js',
  });
};

I tried to use FakeResponseType directly, but its value is not exported from the package...
I can write something like this, but it looks like workaround but not as intended.

import type { FakeResponseType } from '@salutejs/perftool/dist/api/intercept';
...
await intercept({
    method: 'GET',
    responseType: 'file' as FakeResponseType.File,
    source: '**/some.client.js',
    response: 'public/js/some.client.js',
});

Describe the solution you'd like
Would be great if you add export of FakeResponseType object and type PerftoolComponent, so I will be able to just import them as usual:

import { PerftoolComponent, FakeResponseType } from '@salutejs/perftool';

Describe alternatives you've considered
Or you may allow to pass common strings 'file' | 'json' | 'abort' instead of const enum

@akhdrv
Copy link
Collaborator

akhdrv commented Apr 8, 2024

Const enums were a bad idea, it's a known issue. Now string literals will be used instead

@akhdrv akhdrv closed this as completed Apr 8, 2024
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