Skip to content

Improve TypeScript IDE ability to hint as to expected Input spec shape #375

@pbelbin

Description

@pbelbin

Currently, at the time the spec uses Input as a parameter eg: const spec: CommandSpec =.... the Input interface is expected to conform to a particular shape (that of CommandInput), but, the IDE does not seem to manage to back-track that to the point where we are defining the Input interface, and provide hints to the user as to the allowed shape.

For example, if thing.spec.ts exists in an application using Waterfall CLI, and it has:

import { project } from '@sparksuite/core';
import { CommandSpec } from 'waterfall-cli';
import path from 'path';

export interface Input {
	flags: {
		verbose?: boolean;
		'no-push'?: boolean;
	};
	data?: string;
}
.
.
.

there is no hinting provided by VSCode IDE regarding data being supported as either a string | number | string[] | number[], nor that data is an accepted key.

Later, we have a usage of Input where it is declared to be extending another interface.

eg: export type CommandSpec<Input extends CommandInput = EmptyCommandInput> = .....

I'm kind of expecting this is due to the use of a 'roots to leaves' kind of approach, and not being able to infer within the definition of the Input interface that it's meant to extend CommandInput's shape, and therefore be able to use CommandInput's shape as a basis for hints.

But, is there another way to do it, so that we do get hints?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions