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

fix extension typing error #131

Merged

Conversation

ChibiBlasphem
Copy link
Contributor

When creating extraAccessors there's a typing problem:

I'm not fluent in english so i'll illustrate with an example:

const env = from(process.env, {
  asEnv: (value: string): 'development' | 'production' | 'test' => {
    if (value !== 'production' && value !== 'production' && value !== 'test') {
      throw new Error('must be "production", "development", "test"')
    }
    return value
  },
})

When using it I have an error:

const nodeEnv = env.get('NODE_ENV').default('production').asEnv();

Typescript complains about "value" argument not being specified

I read the typings and even if I use required

const nodeEnv = env.get('NODE_ENV').default('production').required().asEnv();

TS does not complain anymore, but the type of params is not correctly infered from the extraAccessor definition

@coveralls
Copy link

coveralls commented Jun 11, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling d87d8e9 on ChibiBlasphem:fix-extension-typing-error into 57fcded on evanshortiss:6.x.

@evanshortiss evanshortiss changed the base branch from master to 6.x June 11, 2020 13:10
@evanshortiss
Copy link
Owner

Great find @ChibiBlasphem.

It's strange that the example included in the repo doesn't have this issue - I haven't investigated why.

I've changed your PR to target the 6.x branch so it can be included in the 6.2.0 release. There's some conflicts, could you take a look?

@evanshortiss evanshortiss merged commit 8494446 into evanshortiss:6.x Jun 11, 2020
@evanshortiss
Copy link
Owner

Thanks @ChibiBlasphem

@ChibiBlasphem ChibiBlasphem deleted the fix-extension-typing-error branch June 11, 2020 13:51
evanshortiss added a commit that referenced this pull request Jun 12, 2020
* docs: add note about asUrlString() pathname behaviour

* chore: include Node.js v14 in target CI versions

* feat: add internal accessors to the public API

* docs: update CHANGELOG with 6.2.0 notes

* chore: bump package version

* docs: update CHANGELOG with Node.js v14 note

* feat: add logging and logger support

* docs: update CHANGELOG with logger support notes

* 6.2.0-alpha.0

* docs: remove extra period

Co-authored-by: Evan <evan.it.sg@gmail.com>

* docs: correct position stated in above/below for accessors

Co-authored-by: Evan <evan.it.sg@gmail.com>

* docs: correct position stated in above/below for accessors

Co-authored-by: Evan <evan.it.sg@gmail.com>

* docs: add DigiPie to contributors list

* fix: prevent accidental leakage of environment values

* Contribute to 6.2.0 (#129)

* docs: correct typos

* chore: update .editorconfig to use single quotes

* docs: custom-accessor.js

* docs: update README with custom-accessor example

* docs: update custom-accessor.js

* chore: prep CHANGELOG and package for 6.2.0 release

* Add @DigiPie as a contributor

* fix: extension typing error (#131)

* fix: type definitions of .asUrlObject() and comments of .asUrlString() (#132)

* docs: update contrubutors list

* chore: commit formatting changes for example

* docs: CHANGELOG updates for release

Co-authored-by: Evan <evan.it.sg@gmail.com>
Co-authored-by: Debove Christopher <chibiblasphem@gmail.com>
Co-authored-by: Ari Autio <ari.autio@iki.fi>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants