Ошибка DeepCopy.ts' cannot be compiled under '--isolatedModules'

Полный текст ошибки: DeepCopy.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module. TS1208 script file. Add an import, export, or an empty 'export {}' statement to make it a module.

Честно, то не пойму в чем проблема, пробовал в tsconfig-e заменять true на false у --isolatedModules, но при сборке он мне автоматом его меняет обратно :)

Код из модуля (весь)

const deepCopy = <T>(target: T): T => {
    if (target === null) {
      return target;
    }
    if (target instanceof Date) {
      return new Date(target.getTime()) as any;
    }
    if (target instanceof Array) {
      const cp = [] as any[];
      (target as any[]).forEach((v) => { cp.push(v); });
      return cp.map((n: any) => deepCopy<any>(n)) as any;
    }
    if (typeof target === 'object' && target !== {}) {
      const cp = { ...(target as { [key: string]: any }) } as { [key: string]: any };
      Object.keys(cp).forEach(k => {
        cp[k] = deepCopy<any>(cp[k]);
      });
      return cp as T;
    }
    return target;
};


export { deepCopy };

Ну и как импортирую import { deepCopy } from "./DeepCopy"


Ответы (1 шт):

Автор решения: steind.VY

я использовал WebShtorm вместо VSCode и все заработало :)

→ Ссылка