I am trying to utilize a specific file from a repository without the need to install its NPM package. This particular file was written in JavaScript and has a separate definition file.
- The JavaScript file contains an export for the
Headers
class. - The TypeScript definition file provides the type definition for the
Headers
class.
In order to combine the JavaScript implementation with the type definition, I came up with this strategy:
import { default as HeadersImplementation } from '../node-fetch/src/headers.js';
import { Headers as HeadersDefinition, HeadersInit } from '../node-fetch/@types/index';
const Headers: {
prototype: HeadersImplementation;
new(init?: HeadersInit): HeadersDefinition;
} = HeadersImplementation;
const test = new Headers();
test.append('Hello', 'World!');
Is there a straightforward way to merge the class implementation with its definition?