#Import standard library stuff as something else?

10 messages · Page 1 of 1 (latest)

gritty crypt
#

I am working with a library that makes extensive use of an interface called Record. The problem is that I also want to use typescript's Record<T, U>. I would like to have Record refer to my library's interface, not the typescript one. is there any way to do

import { Record as TSRecord } from '???'
livid axle
#

@gritty crypt I don't think there's any way to do that via import syntax.

#

You could make your own file that exports it, like:

// ts-utils.ts
export type TSRecord<K extends string, V> = Record<K, V>;
import { TSRecord } from "./ts-utils"
#

... but personally, I'd suggest going the other way.

gritty crypt
#

oh interesting

livid axle
#

I would do something like:

import * as lib from "lib";

type Whatever = lib.Record
gritty crypt
#

idk its hard, Record is such a widely used thing that I dont want to confuse me/others about whether it refers to our lib or typescript

gritty crypt
livid axle
gritty crypt
#

got it, thanks for the advice!