TS2686

error TS2686: ‘ko’ refers to a UMD global, but the current file is a module. Consider adding an import instead.

Broken Code ❌

1
const downloadProgress = ko.observable();

Fixed Code ✔️

1
2
3
import ko from 'knockout';

const downloadProgress = ko.observable();

TS2686: ‘sinon’ refers to a UMD global, but the current file is a module. Consider adding an import instead.

Broken Code ❌

1
2
import { SinonFakeServer } from 'sinon';
let server: SinonFakeServer;

Fixed Code ✔️

1
2
import * as sinon from 'sinon';
let server: sinon.SinonFakeServer;

TS2686: ‘React’ refers to a UMD global, but the current file is a module. Consider adding an import instead.

Broken Code ❌

1
2
3
4
5
import {FC} from 'react';

const App: FC = (): JSX.Element => {
return <></>;
};

Fixed Code ✔️

Use default import for React:

1
2
3
4
5
import React from 'react';

const App: React.FC = (): JSX.Element => {
return <></>;
};