score:19

Accepted answer

The error message was actually very misleading, and looks like a typescript bug. It appears that enums can't be exported directly, it seems necessary to use a const to be able to export them correctly.

So I modified my enum declaration like so

declare module 'seeyouftp' {

  // exporting a const instead of 
  export const enum AuthStates {
    success = 'success',
    error = 'error'
  }
}

Everything works now but that error message is very, very bad and time consuming

score:0

You need to create seeyouftp (I assum that seeyouftp is your js module name) folder under /definitions and have types.d.ts inside /definitions/seeyouftp like structure below

|— definitions
 |—seeyouftp
  |— index.d.ts
|— entries
|— fonts
|— less
|— src

And update your tsconfig

"typeRoots": [
  "./assets/definitions",
  "./node_modules/@types"
],

score:0

Because it is a webpack issue, you have to update your webpack config. Webpack needs to be told where to find the module seeyouftp:

// webpack.config.js
const path = require('path');

module.exports = {
  //...
  resolve: {
    // Add an alias
    alias: {
      'seeyouftp': path.resolve(__dirname, 'definitions/types.d.ts')
    }
  }
};

For the path to the file types.d.ts I assumed your webpack configuration is located next to the definitions folder.

Here is the associated webpack documentation.

score:1

Try to export the declarations, and see if that makes a difference:

declare module 'seeyouftp' {
export  interface User {
    admin: boolean;
    roles: string[];
    username: string;
  }

export  enum AuthStates {
    success = 'success',
    error = 'error'
  }

Related Query

More Query from same tag