custom-electron-titlebar icon indicating copy to clipboard operation
custom-electron-titlebar copied to clipboard

bug/question: wrong TypeScript declarations?

Open Znerole opened this issue 2 years ago • 1 comments

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):

  • TypeScript version: 4.4.4
  • custom-electron-titlebar version: 4.1.0

Znerole avatar Mar 03 '22 07:03 Znerole

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?

TheBentoBox avatar May 27 '22 18:05 TheBentoBox

#188 duplicated

AlexTorresDev avatar Nov 05 '22 09:11 AlexTorresDev