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

Docs don't mention minimum ES target version #26

Closed
dxptqhtlutehvlyxcmtg opened this issue Feb 24, 2025 · 1 comment · Fixed by #27
Closed

Docs don't mention minimum ES target version #26

dxptqhtlutehvlyxcmtg opened this issue Feb 24, 2025 · 1 comment · Fixed by #27
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@dxptqhtlutehvlyxcmtg
Copy link

Thanks for this package. It's proving to be very useful.

Is the document missing? Please describe.

I can't remember why now, but my tsconfig.json target happened to be set to ES2021 and while this library did run, it reported every field in my AppConfig class was missing, even though I verified they weren't.

Simply changed the target to ES2022 and the library works as expected. Perhaps it has something to do with the class property features introduced then.

It took me by surprise because a different library that seemingly operates similarly does not have a problem under ES2021.

So, if there is indeed a minimum ES version, it would save users some trouble if the docs made mention of it.

@dxptqhtlutehvlyxcmtg dxptqhtlutehvlyxcmtg added the documentation Improvements or additions to documentation label Feb 24, 2025
@Val-istar-Guo
Copy link
Contributor

Val-istar-Guo commented Feb 24, 2025

The compatibility has not been tested before, which caused you trouble.
And this is a really interesting issue!!! This is also the first time I have seen someone do something similar to me.

The problem was that I was using Object.getOwnPropertyNames to avoid adding decorators(like @Value in @itgorillaz/configify) to all properties:

for (const key of Object.getOwnPropertyNames(instance)) {
const configName = Reflect.getMetadata(CONFIG_NAME_METADATA_KEY, ConfigProviderClass, key)
if (configName) {
const value = objectPath.get(config, configName)
if (value !== undefined) instance[key] = value
}
const value = subConfig && subConfig[toCamelCase(key)]
if (value !== undefined) instance[key] = value
}

However, this leads to the loss of these properties, in target=es2021.

I will try to solve this problem.

@Val-istar-Guo Val-istar-Guo added the bug Something isn't working label Feb 24, 2025
@Val-istar-Guo Val-istar-Guo pinned this issue Feb 24, 2025
@Val-istar-Guo Val-istar-Guo unpinned this issue Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants