Skip to content

Stripe leaks NodeJS types if imported #2243

@richardsimko

Description

@richardsimko

Describe the bug

Due to weird behavior in TypeScript (Mainly microsoft/TypeScript#37053) the use of /// <reference types="node" /> will leak to any consumers of a type definition file.

This means that if one wants to use some of the Stripe types, for example to define an interface for an API response (Which gets imported in the client) this will leak NodeJS types to all the client side code as well.

To Reproduce

  1. Observe the Cannot find name 'process'. Do you need to install type definitions for node? Try npm i --save-dev @types/node and then add 'node' to the types field in your tsconfig. error as expected
  2. Change the code to import a type from stripe
  3. Observe the error disappearing

Expected behavior

The error regarding process persists

Code snippets

Minimal tsconfig.json:

{
  "include": "test.ts",
  "compilerOptions": {
    "lib": ["ES2022", "DOM", "DOM.Iterable"],
    "types": []
  }
}

test.ts before importing:

// TS error as expected
process.exit()

test.ts after importing:

import type { Stripe } from 'stripe';

const foo: Stripe.Price.Recurring.Interval;

// No error 
process.exit()

OS

macos

Node version

any

Library version

stripe-node 17.4.0

API version

N/A

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions