Chalk.js how to fill in TODOs
See original GitHub issueI tried running ts2fable against chalk using the declarations included with the library. (not from definitelytyped). I got the following error message about 40 or so times while running ts2fable.
unsupported printType This
unsupported printType This
unsupported printType This
unsupported printType This
unsupported printType This
unsupported printType This
unsupported printType This
unsupported printType This
unsupported printType This
unsupported printType This
The output looks like this:
module rec chalk
open System
open Fable.Core
open Fable.Import.JS
type [<AllowNullLiteral>] IExports =
abstract ChalkConstructor: ChalkConstructorStatic with get, set
type [<RequireQualifiedAccess>] Level =
| None = 0
| Basic = 1
| Ansi256 = 2
| TrueColor = 3
type [<AllowNullLiteral>] ChalkOptions =
abstract enabled: bool option with get, set
abstract level: Level option with get, set
type [<AllowNullLiteral>] ChalkConstructor =
[<Emit "$0($1...)">] abstract Invoke: ?options: ChalkOptions -> Chalk
type [<AllowNullLiteral>] ChalkConstructorStatic =
[<Emit "new $0($1...)">] abstract Create: ?options: ChalkOptions -> ChalkConstructor
type [<AllowNullLiteral>] ColorSupport =
abstract level: Level with get, set
abstract hasBasic: bool with get, set
abstract has256: bool with get, set
abstract has16m: bool with get, set
type [<AllowNullLiteral>] Chalk =
[<Emit "$0($1...)">] abstract Invoke: [<ParamArray>] text: string -> string
[<Emit "$0($1...)">] abstract Invoke: text: TemplateStringsArray * [<ParamArray>] placeholders: string -> string
abstract ``constructor``: ChalkConstructor with get, set
abstract enabled: bool with get, set
abstract level: Level with get, set
abstract rgb: r: float * g: float * b: float -> Chalk
abstract hsl: h: float * s: float * l: float -> Chalk
abstract hsv: h: float * s: float * v: float -> Chalk
abstract hwb: h: float * w: float * b: float -> Chalk
abstract bgHex: color: string -> Chalk
abstract bgKeyword: color: string -> Chalk
abstract bgRgb: r: float * g: float * b: float -> Chalk
abstract bgHsl: h: float * s: float * l: float -> Chalk
abstract bgHsv: h: float * s: float * v: float -> Chalk
abstract bgHwb: h: float * w: float * b: float -> Chalk
abstract hex: color: string -> Chalk
abstract keyword: color: string -> Chalk
abstract reset: TODO with get, set
abstract bold: TODO with get, set
abstract dim: TODO with get, set
abstract italic: TODO with get, set
abstract underline: TODO with get, set
abstract inverse: TODO with get, set
abstract hidden: TODO with get, set
abstract strikethrough: TODO with get, set
abstract visible: TODO with get, set
abstract black: TODO with get, set
abstract red: TODO with get, set
abstract green: TODO with get, set
abstract yellow: TODO with get, set
abstract blue: TODO with get, set
abstract magenta: TODO with get, set
abstract cyan: TODO with get, set
abstract white: TODO with get, set
abstract gray: TODO with get, set
abstract grey: TODO with get, set
abstract blackBright: TODO with get, set
abstract redBright: TODO with get, set
abstract greenBright: TODO with get, set
abstract yellowBright: TODO with get, set
abstract blueBright: TODO with get, set
abstract magentaBright: TODO with get, set
abstract cyanBright: TODO with get, set
abstract whiteBright: TODO with get, set
abstract bgBlack: TODO with get, set
abstract bgRed: TODO with get, set
abstract bgGreen: TODO with get, set
abstract bgYellow: TODO with get, set
abstract bgBlue: TODO with get, set
abstract bgMagenta: TODO with get, set
abstract bgCyan: TODO with get, set
abstract bgWhite: TODO with get, set
abstract bgBlackBright: TODO with get, set
abstract bgRedBright: TODO with get, set
abstract bgGreenBright: TODO with get, set
abstract bgYellowBright: TODO with get, set
abstract bgBlueBright: TODO with get, set
abstract bgMagentaBright: TODO with get, set
abstract bgCyanBright: TODO with get, set
abstract bgWhiteBright: TODO with get, set
let [<Global>] chalk: obj = jsNative
Notice all the “TODO” entries. I am not sure what to replace these with. This is a fluent API to be used like this from JavaScript:
// Combine styled and normal strings
log(chalk.blue('Hello') + 'World' + chalk.red('!'));
// Compose multiple styles using the chainable API
log(chalk.blue.bgRed.bold('Hello world!'));
// Pass in multiple arguments
log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'));
What do I need to do to get this working and how would I consume from fable/f#?
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Dumping objects outputs [object Object] #118 - chalk/chalk
Chalk outputting contents of objects is opinionated - meaning it breaks the basic JavaScript contract of .toString() showing us the string equivalent of...
Read more >How to use the chalk.greenBright function in chalk
To help you get started, we've selected a few chalk. ... root => f => { // TODO: Add logic for modifications, new,...
Read more >Colorize your console output with Chalk! - Node.js ... - YouTube
Chalk NPM package link: https://www.npmjs.com/package/ chalk In this video I'll be demonstrating how you can use the hugely popular NPM ...
Read more >How to Highlight A Terminal Output with Node.JS using Chalk
In this video, we are going to explore another popular NPM package called Chalk. Simply put, Chalk allows us to do Terminal styling...
Read more >Getting started with oclif by creating a todo cli app
The oclif generator creates a CLI project in either JavaScript or TypeScript to get you started quickly. It requires very few runtime ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
To try it out:
yarn global add ts2fable@next
. It is quite a fun library.Ok, this is working:
Note the biggest change is to function of string -> string for most of the methods and allows syntax like.
I was surprised that I had to add the importDefault to the code, I expected
open Chalk
to import the dependency so I could just use it. Could be my misunderstanding though.