I want to use a specific file from a repository without installing its NPM package, but it was coded in JavaScript and has a separate definition file.
- The code file in JavaScript exports a
Headersclass () - The TypeScript definition file exports the
Headersclass definition
I want to merge the JavaScript implementation with the type definition, so I ended with this approach:
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 teste = new Headers();
teste.append('Hello', 'World!');
Is there an easy way to merge the class implementation with its definition?