Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pbelbin opened this issue Jul 6, 2021 · 1 comment
Open

Comments

@pbelbin
Copy link
Collaborator

pbelbin commented Jul 6, 2021

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?

@WesCossick
Copy link
Member

WesCossick commented Aug 2, 2021

@pbelbin Can you add appropriate label(s) to this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants