Typescript error on latest version when `--isolatedModules` is set to true.
cmillar-titan opened this issue · comments
We're on version "@contentful/node-apps-toolkit": "^2.0.2",
.
Our Typescript config has "isolatedModules": true /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */,
We see the following error locally and on CI:
node_modules/@contentful/node-apps-toolkit/lib/requests/typings.d.ts:43:6 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.
43 [ContentfulContextHeader.AppId]: string;
~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@contentful/node-apps-toolkit/lib/requests/typings.d.ts:49:6 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.
49 [ContentfulContextHeader.UserId]: string;
~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@contentful/node-apps-toolkit/lib/requests/typings.d.ts:56:6 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.
56 [ContentfulContextHeader.SpaceId]: string;
~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@contentful/node-apps-toolkit/lib/requests/typings.d.ts:57:6 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.
57 [ContentfulContextHeader.EnvironmentId]: string;
Typescript is offended by the following lines in typings.d.ts
:
export declare type AppContextSignedHeaders = {
[ContentfulContextHeader.AppId]: string;
};
export declare type SubjectHeadersUser = {
userId: string;
};
export declare type UserContextSignedHeaders = {
[ContentfulContextHeader.UserId]: string;
};
export declare type Context<SubjectContext> = {
spaceId: string;
envId: string;
} & SubjectContext;
declare type SignedHeadersWithoutSubject = {
[ContentfulContextHeader.SpaceId]: string;
[ContentfulContextHeader.EnvironmentId]: string;
};
In particular, ContentfulContextHeader
.
I believe it is complaining that ContentfulContextHeader
might not be accessible.
I found an article that seems to sum up the issue: https://ncjamieson.com/dont-export-const-enums/
Would Contentful be able to fix this ASAP? This is a blocker for development.
Thank you!
-Carmelle Millar
Hey @cmillar-titan thanks for the report!
You can find here the changes required to fix the issue. It should be out soon, but if you're blocked feel free to clone and build the branch.
Hope this helps.
Have a great day,
Manuel
Thank you for the prompt response! Greatly appreciated.