pnp / pnpjs

Fluent JavaScript API for SharePoint and Microsoft Graph REST APIs
https://pnp.github.io/pnpjs/
Other
753 stars 305 forks source link

Use regular `enum` instead of `const enum` (`verbatimModuleSyntax`) #2962

Closed viceice closed 5 months ago

viceice commented 5 months ago

Target environment

Browser App (Hosted external to Microsoft 365 platform)

Additional environment details

I'm using this library inside an angular app

Enhancement Idea

I like to enable verbatimModuleSyntax^1.

import { FieldTypes, type IFieldInfo } from '@ngx-translate/core';

export function isLookup(field: IFieldInfo): boolean {
  return FieldTypes.Lookup === field.FieldTypeKind; // error: Cannot access ambient const enums when 'verbatimModuleSyntax' is enabled.ts(2748)
}
patrick-rodgers commented 5 months ago

We use const enums to drastically reduce the size of the library, especially for the very large enums. At this point we don't anticipate changing.

To be clear, everything is working you are just unable to use a certain ts setting? Can you skip that line or otherwise ignore enums from imported modules?

viceice commented 5 months ago

disabling the TS setting removes a lot compiler features we like to depend on.

I've not tested if I can use a // @ts-ignore comment to ignore that specific piece.

currently I only have two places where I'm using that enum and I replaced with known numbers as workaround.

patrick-rodgers commented 5 months ago

Closing this issue as answered. If you have additional questions or we did not answer your question, please open a new issue, ref this issue, and provide any additional details available. Thank you!

github-actions[bot] commented 5 months ago

This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.