File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { cliui, UIOptions } from './index.js'
33const stringWidth = require ( 'string-width' )
44const stripAnsi = require ( 'strip-ansi' )
55const wrap = require ( 'wrap-ansi' )
6- export default function ui ( opts : UIOptions ) {
6+ export default function ui ( opts ? : UIOptions ) {
77 return cliui ( opts , {
88 stringWidth,
99 stripAnsi,
Original file line number Diff line number Diff line change @@ -11,11 +11,14 @@ const bottom = 2
1111const left = 3
1212
1313export interface UIOptions {
14- width : number ;
14+ width ? : number ;
1515 wrap ?: boolean ;
1616 rows ?: string [ ] ;
1717}
1818
19+ // The width should be worked out by the time we are constructing the actual class.
20+ type UIConstructorOptions = UIOptions & { width :number } ;
21+
1922interface Column {
2023 text : string ;
2124 width ?: number ;
@@ -45,7 +48,7 @@ export class UI {
4548 wrap : boolean ;
4649 rows : ColumnArray [ ] ;
4750
48- constructor ( opts : UIOptions ) {
51+ constructor ( opts : UIConstructorOptions ) {
4952 this . width = opts . width
5053 this . wrap = opts . wrap ?? true
5154 this . rows = [ ]
@@ -380,7 +383,7 @@ function alignCenter (str: string, width: number): string {
380383}
381384
382385let mixin : Mixin
383- export function cliui ( opts : Partial < UIOptions > , _mixin : Mixin ) {
386+ export function cliui ( opts : UIOptions | undefined , _mixin : Mixin ) {
384387 mixin = _mixin
385388 return new UI ( {
386389 width : opts ?. width || getWindowWidth ( ) ,
You can’t perform that action at this time.
0 commit comments