AlexTorresDev / custom-electron-titlebar

Custom electon title bar inpire on VS Code title bar
MIT License
866 stars 148 forks source link

bug/question: wrong TypeScript declarations? #180

Closed Znerole closed 2 years ago

Znerole commented 2 years ago

Describe the bug The current TypeScript declarations appear to be wrong to me. Importing Titlebar and Color doesn't allow proper type usage:

import { Titlebar } from "custom-electron-titlebar"

const titleBar: Titlebar = new Titlebar()

The second statement produces the following error:

'Titlebar' refers to a value, but is being used as a type here. Did you mean 'typeof Titlebar'?

Contents of index.d.ts are:

import Titlebar from './titlebar';
import { Color } from './common/color';
declare const _default: {
    Titlebar: typeof Titlebar;
    Color: typeof Color;
};
export = _default;

This issue is new in 4.x.

To Reproduce Steps to reproduce the behavior:

  1. Create a new TypeScript project
  2. Add custom-electron-titlebar to the project
  3. Import Titlebar as shown before

Expected behavior Types should be used "normally".

Desktop (please complete the following information):

TheBentoBox commented 2 years ago

Same issue here. To be blunt the typings in this project are not the greatest in general right now.

Another issue is that there's no proper way to import anything other than Titlebar and Color if you're targeting ECMAScript modules:

These two fail to compile:

image image

While a direct import fails on build since it's not exported by the package: image image

Is there a reason the main index file doesn't export the entirety of the package's API?

AlexTorresDev commented 2 years ago

188 duplicated