TS4081

error TS4081: Exported type alias ‘MyReturnType‘ has or is using private name ‘getSdk‘.

Broken Code ❌

index.ts
1
export type MyReturnType = ReturnType<typeof getSdk>;
getSdk.ts
1
function getSdk() {}

Fixed Code ✔️

The getSdk is identified to be private because it is not exported. If we export the getSdk function, we won’t have any more problems:

index.ts
1
2
3
import {getSdk} from './getSdk';

export type MyReturnType = ReturnType<typeof getSdk>;
getSdk.ts
1
export function getSdk() {}