Skip to content

Documentation tips for TypeScript #141

Open
@shadowspawn

Description

@shadowspawn

To get the most out of the typings, the input conjuration needs to be static or const in Typescript. We should add a tip in the documentation here and in utils to reduce potential confusion.

// accurate
const results1 = parseArgs({ options: { foo: { type: 'string' }}});

// accurate
const config2 = { options: { foo: { type: 'string' }}} as const;
const results2 = parseArgs(config2);

// error because `type` is typed as string and not `'type'` so TypeScript can not check used correctly
const config3 = { options: { foo: { type: 'string' }}};
const results3 = parseArgs(config3); // error

Related comment:

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