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

SNOW-1454180: const enums in TypeScript declaration file means enums cannot be accessed when isolatedModules TS compiler option is set #848

Closed
mtlewis opened this issue May 29, 2024 · 7 comments
Assignees
Labels
bug Something isn't working status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. status-triage_done Initial triage done, will be further handled by the driver team

Comments

@mtlewis
Copy link

mtlewis commented May 29, 2024

Please answer these questions before submitting your issue.
In order to accurately debug the issue this information is required. Thanks!

1. What version of NodeJS driver are you using?

1.11.0

2. What operating system and processor architecture are you using?

macOS / ARM

3. What version of NodeJS are you using?

18.16.0 / 9.5.1

4. What are the component versions in the environment (npm list)?

N/A

5.Server version:* E.g. 1.90.1

N/A (library author)

6. What did you do?

When using the newly-released first-party TypeScript declaration file, it's not possible to access the enums it provides, because they're declared as const enum. It's not recommended to use const enums in library declarations for this reason.

You can see this issue in this TypeScript playground: https://www.typescriptlang.org/play/?isolatedModules=true#code/JYWwDg9gTgLgBAZwHYQO4DMA2BDA1gUwBo4BvOAGQgHNz8A3fTOAXznSghDgHJk0s8+ALQIAJrm4BuAFDSA9HLgAxbMEwI4qABb4kcYAgg4Y+UQFkIogK6Z8Gg4nzwYEODChX8+vTAQBjCCR0YCppPgwcAgA6AKCQqyh8AAoyTGpaBkwALgp0+kYogHUAQQAlADkWAEoZeUVizFRsAE8NVGhcBDCUCMEYwOCqBOTUvMyc7hKK7jhsDUoafKZmGqA

7. What did you expect to see?

No errors produced by this line, even if isolatedModules is turned on in tsconfig.

snowflake.configure({ logLevel: LogLevel.WARN });

8. Can you set logging to DEBUG and collect the logs?

N/A

9. What is your Snowflake account identifier, if any? (Optional)

N/A

@mtlewis mtlewis added the bug Something isn't working label May 29, 2024
@github-actions github-actions bot changed the title const enums in TypeScript declaration file means enums cannot be accessed when isolatedModules TS compiler option is set SNOW-1454180: const enums in TypeScript declaration file means enums cannot be accessed when isolatedModules TS compiler option is set May 29, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this May 29, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka added the status-triage Issue is under initial triage label May 29, 2024
@sfc-gh-dszmolka
Copy link
Collaborator

hi and thank you for reporting this - taking a look. would disabling isolatedModules be a viable option until we sort this out ?

@mtlewis
Copy link
Author

mtlewis commented May 29, 2024

hi and thank you for reporting this - taking a look. would disabling isolatedModules be a viable option until we sort this out ?

Hi David - no problem, and thanks for the quick response. It's recommended for library authors to always set isolatedModules to true to ensure flexibility for consumers of the library. As such, disabling this flag won't be practical for us. The workaround in the playground link above is fine (snowflake.configure({ logLevel: 'WARN' as LogLevel })) for now, though I would note that it won't catch typos in LogLevel strings (i.e. logLevel: 'WRAN' doesn't produce an error.

@sfc-gh-dszmolka
Copy link
Collaborator

okay, got you MT and thank you for the additional clarification. Guess we have no other option than convert these to export enum (which is quite unfortunate because it will require a driver release, which just happened literally couple hours ago, so probably will happen only in the next release cycle, end of June)

@sfc-gh-dszmolka sfc-gh-dszmolka added status-triage_done Initial triage done, will be further handled by the driver team and removed status-triage Issue is under initial triage labels May 29, 2024
@mtlewis
Copy link
Author

mtlewis commented May 29, 2024

Makes sense, thanks very much! We'll use that workaround for now.

@sfc-gh-dszmolka
Copy link
Collaborator

Will be addressed in PR #852

@sfc-gh-dszmolka sfc-gh-dszmolka added status-pr_pending_merge A PR is made and is under review labels Jun 4, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka added status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. and removed status-pr_pending_merge A PR is made and is under review labels Jun 14, 2024
@sfc-gh-dszmolka
Copy link
Collaborator

PR #852 merged and will be part of the next upcoming release (usually happens at the end of the month)

@sfc-gh-dszmolka
Copy link
Collaborator

released with Snowflake Node.JS driver v1.12.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

3 participants