Home > Mobile >  Are import aliases possible using Typescript
Are import aliases possible using Typescript

Time:02-20

Today I am using import aliasing to change the name of an import in React:

import { Something as SomethingElse } from 'somewhere';

However, after switching this file over to TypeScript, the same thing doesn't seem possible. Only after removing the alias am I able to use the import:

import Something from 'somewhere';

Is it possible to use an import alias in TypeScript?

CodePudding user response:

That's a default export, so you could just name it whatever you want:

import SomethingElse from 'somewhere';

Although... changing the file to TypeScript should not magically cause it to change from named export to default export...

  • Related