medikoo / cli-color

Colors and formatting for the console
ISC License
676 stars 34 forks source link

Mixed Styles results in Unresolved function or method #44

Closed rseiffert closed 8 months ago

rseiffert commented 8 months ago

If styles are mixed like in this example console.log(clc.red.bgWhite("Red text on white background.")); I am seeing a minor warning Unresolved function or method bgWhite()

This happens in a Typescript Project.

node: 21.7.1 cli-color: 2.0.4 @types/cli-color: 2.0.6

medikoo commented 8 months ago

@rseiffert Thanks for opening that, currently TS typings are prepared externally, and I was not involved into their preparation (I'm not even sure of their state).

If issue is specific to TS typings I'll be happy to accept a PR that accomodates proper TS typings in context of this repository (in similar manner as it was done here: https://github.com/medikoo/type/pull/6). However if issue is in plain JS layer (not TS involved) I'll be grateful for some reproduction case.

rseiffert commented 8 months ago

@medikoo I'm afraid that this is not really a Typescript problem, as I suspected. I just tried it in a pure JavaScript based Node project.

Here is a really complicated example code ;-)

const clc = require("cli-color");
console.info(clc.bgGreen.yellow('Warming up..............................'));
console.info(clc.red('Warming up..............................'));

Unfortunately, I now also see warnings for not-mixed usages

Unresolved variable bgGreen
Unresolved function or method yellow()
Unresolved function or method red()
2024-03-17_13-58-04

IDE is IntelliJ IDEA 2023.3.5

medikoo commented 8 months ago

@rseiffert neither JavaScript engine (V8) nor Node.js produces such messages.

It's definitely related to some extra tooling which probably tries to rely on TS typings.

See how it works in Node.js v20:

Screenshot 2024-03-17 at 15 56 04
rseiffert commented 8 months ago

First of all: Thank you for your quick answers!

I think it has something to do with the config of my intelliJ IDE. The warnings are not visible if i run the code, but the warnings show up in the IDE in the so called Problems view.

So feel free to close my issue