timothyclifford timothyclifford - 7 months ago 84
TypeScript Question

TypeScript import syntax

I'm using node-fetch with TypeScript.

I want to access the fetch function and also the Resource interface which are defined in the type definition as:

export default function fetch(url: string | Request, init?: RequestInit): Promise<Response>;


export class Response extends Body {
// ...

In my TypeScript file I'm importing these separately using:

import fetch from 'node-fetch';
import { Response } from 'node-fetch';

Is there a nicer, single line way to do this?


This syntax?

import fetch, { Response } from 'node-fetch';