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

JSON objects named config break type definition #67

Open
tmus opened this issue Dec 3, 2020 · 0 comments
Open

JSON objects named config break type definition #67

tmus opened this issue Dec 3, 2020 · 0 comments
Labels

Comments

@tmus
Copy link

tmus commented Dec 3, 2020

Describe the bug:
In default.json, creating an object with a key of config breaks the type definitions for the config as a whole.

Steps To Reproduce:

For example:

// default.json

{
  "config": {
    "some": "value"
  },

  "someother": "value"
}

Results in:

// Config.d.ts

/* tslint:disable */
/* eslint-disable */
declare module "node-config-ts" {
  interface IConfig {
    config: Config
    someother: string
  }
  interface Config {
    some: string
  }
  export const config: Config
  export type Config = IConfig
}

Typehinting now doesn't find the someother property on the config, only some, as part of the defined config object.

Expected behavior:

Any of:

  • Document that config is a keyword and should not be used in config
  • Change the name of the exported type to something more specific, to prevent a clash
  • Throw an error when attempting to run node-config-ts if a config key exists.

Typescript Version: 4.0.5

node-config-ts version: 3.1.0

@tusharmath tusharmath added the bug label Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants