coral-xyz / anchor

⚓ Solana Sealevel Framework
https://anchor-lang.com
Apache License 2.0
3.58k stars 1.32k forks source link

Typescript error when isolatedModules is set to true #1395

Open epicfaace opened 2 years ago

epicfaace commented 2 years ago

When isolatedModules is set to true in my tsconfig, I get the following error when trying to import something:

import { Program } from "@project-serum/anchor";
import * as anchor from "@project-serum/anchor";
import * as anchor_types from "@project-serum/anchor/src/program/namespace/types";
 Can't import from anchor or we get this error when compiling from the frontend:
 /.../node_modules/@project-serum/anchor/src/index.ts
TypeScript error in /.../node_modules/@project-serum/anchor/src/index.ts(15,10):
Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.  TS1205

    13 | 
    14 | export * from "./error.js";
  > 15 | export { Instruction } from "./coder/instruction.js";
       |          ^
    16 | export { Idl } from "./idl.js";
    17 | 
    18 | export * as utils from "./utils/index.js";
mschneider commented 2 years ago

have the same issue the generated modules can not be compiled with isolatedModules which is forced true in the recent versions of nextjs