I have several APIs where we pass in descriptions as part of the payload. I use OpenAPI to generate a Typescript Client and compile targeting esnext
.
export interface V1alphaExample {
/**
* Description of the rule for backoffice use only.
* @type {string}
* @memberof V1alphaExample
*/
description?: string;
}
export function V1alphaExampleFromJSONTyped(json: any, ignoreDiscriminator: boolean): V1alphaExample {
if ((json === undefined) || (json === null)) {
return json;
}
return {
'description': !exists(json, 'description') ? undefined : json['description'],
};
}
export function V1alphaExampleToJSON(value?: V1alphaExample | null): any {
if (value === undefined) {
return undefined;
}
if (value === null) {
return null;
}
return {
'description': value.description,
};
}
compiled to JS:
export function V1alphaExampleFromJSONTyped(json, ignoreDiscriminator) {
if ((json === undefined) || (json === null)) {
return json;
}
return {
'description': !exists(json, 'description') ? undefined : json['description'],
};
}
export function V1alphaExampleToJSON(value) {
if (value === undefined) {
return undefined;
}
if (value === null) {
return null;
}
return {
'description': value.description,
};
}
During the compilation of my application (using babel + typescript), things work fine. However, when using Jest to test my application, I am getting a bunch of errors such as:
Cannot find module 'core-js/modules/es.symbol.description' from 'V1alphaExample.js'
I believe the value.description
in the compiled JS is triggering Jest + Babel to think I'm using the Symbol.prototype.description
feature when I'm not.
Is there a way to disable this when using Jest? Should description
be considered a reserved keyword going forward and discouraged from use as object properties?