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

fixes #27 Add TS types #30

Merged
merged 3 commits into from
Nov 3, 2021
Merged

fixes #27 Add TS types #30

merged 3 commits into from
Nov 3, 2021

Conversation

windupbird144
Copy link
Contributor

  • Overload the build function so there is one signature to create a Transform/split2 and one to create a Duplexify
  • Added tests with tsd and modified the scripts section of package.json

Add index.d.ts as the definition file, add tests that are run with tsd
@windupbird144 windupbird144 marked this pull request as ready for review November 1, 2021 18:30
index.d.ts Outdated
/// <reference types="node" />
/// <reference types="duplexify" />

import { Duplexify } from "duplexify";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is a dependency now for building TS, would be useful to mention installing these types if using ts in readme.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a new commit with instructions to install @types/duplexify and also @types/node for the Stream API


export { OnUnknown };

export default build;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is there no named export for build? there is none in commonjs too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if I'm not mistaken "build" is only a default export in commonjs, not a named export.

const { build } = require('pino-abstract-transport')
console.log(build)
// undefined

Add instructions to install additional type declartions if using
Typescript. Also fixes a few minor typos.
@@ -0,0 +1,19 @@
import build, { OnUnknown } from "../../index";
import { expectType } from "tsd";
import { Duplexify } from "duplexify";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not rely on Duplexify types. Using Duplexify is an implementation detail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the dependency on Duplexify and changed the type to Transform.

@coveralls
Copy link

coveralls commented Nov 2, 2021

Pull Request Test Coverage Report for Build 1409810607

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 1352815647: 0.0%
Covered Lines: 42
Relevant Lines: 42

💛 - Coveralls

Because duplexify is an implementation detail, change return types of
the build function to Transform
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina merged commit cc13a45 into pinojs:main Nov 3, 2021
@@ -5,8 +5,8 @@
"main": "index.js",
"scripts": {
"prepare": "husky install",
"test": "standard | snazzy && tap test/*.test.js",
"test-ci": "standard | snazzy && tap test/*.test.js --coverage-report=lcovonly"
"test": "standard | snazzy && tap test/*.test.js && tsd",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

superfluous space

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants