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

21.1.0 has broken typings #452

Closed
glani opened this issue Aug 3, 2022 · 6 comments · Fixed by #454 or #455
Closed

21.1.0 has broken typings #452

glani opened this issue Aug 3, 2022 · 6 comments · Fixed by #454 or #455

Comments

@glani
Copy link

glani commented Aug 3, 2022

node_modules/@types/yargs/index.d.ts(27,10): error TS2305: Module '"yargs-parser"' has no exported member 'DetailedArguments'.
node_modules/@types/yargs/index.d.ts(27,29): error TS2305: Module '"yargs-parser"' has no exported member 'Configuration'.

Version posted 30 minutes ago does not work

@patolit
Copy link

patolit commented Aug 4, 2022

Happen to me using ts-jest that has yargs-parser : ^21.0.0 as dependency

09:36:32 node_modules/@types/yargs/index.d.ts(28,10): error TS2305: Module '"yargs-parser"' has no exported member 'DetailedArguments'. 09:36:32 node_modules/@types/yargs/index.d.ts(28,29): error TS2305: Module '"yargs-parser"' has no exported member 'Configuration'.

@ericmorand
Copy link

It looks like the published package now exposes its own type definitions, which are used in priority by TypeScript instead of the perfectly functioning ones provided by @types/yargs-parser:

index.d.cts

**
 * @license
 * Copyright (c) 2016, Contributors
 * SPDX-License-Identifier: ISC
 */
/**
 * An object whose all properties have the same type, where each key is a string.
 */
interface Dictionary<T> {
    [key: string]: T;
}
type ArgsInput = string | any[];
type ArgsOutput = (string | number)[];
interface Arguments {
    /** Non-option arguments */
    _: ArgsOutput;
    /** Arguments after the end-of-options flag `--` */
    "--"?: ArgsOutput;
    /** All remaining options */
    [argName: string]: any;
}
interface DetailedArguments {
    /** An object representing the parsed value of `args` */
    argv: Arguments;
    /** Populated with an error object if an exception occurred during parsing. */
    error: Error | null;
    /** The inferred list of aliases built by combining lists in opts.alias. */
    aliases: Dictionary<string[]>;
    /** Any new aliases added via camel-case expansion. */
    newAliases: Dictionary<boolean>;
    /** Any new argument created by opts.default, no aliases included. */
    defaulted: Dictionary<boolean>;
    /** The configuration loaded from the yargs stanza in package.json. */
    configuration: Configuration;
}
interface Configuration {
    /** Should variables prefixed with --no be treated as negations? Default is `true` */
    "boolean-negation": boolean;
    /** Should hyphenated arguments be expanded into camel-case aliases? Default is `true` */
    "camel-case-expansion": boolean;
    /** Should arrays be combined when provided by both command line arguments and a configuration file? Default is `false`  */
    "combine-arrays": boolean;
    /** Should keys that contain `.` be treated as objects? Default is `true` */
    "dot-notation": boolean;
    /** Should arguments be coerced into an array when duplicated? Default is `true` */
    "duplicate-arguments-array": boolean;
    /** Should array arguments be coerced into a single array when duplicated? Default is `true` */
    "flatten-duplicate-arrays": boolean;
    /** Should arrays consume more than one positional argument following their flag? Default is `true` */
    "greedy-arrays": boolean;
    /** Should parsing stop at the first text argument? This is similar to how e.g. ssh parses its command line. Default is `false` */
    "halt-at-non-option": boolean;
    /** Should nargs consume dash options as well as positional arguments? Default is `false` */
    "nargs-eats-options": boolean;
    /** The prefix to use for negated boolean variables. Default is `'no-'` */
    "negation-prefix": string;
    /** Should positional values that look like numbers be parsed? Default is `true` */
    "parse-positional-numbers": boolean;
    /** Should keys that look like numbers be treated as such? Default is `true` */
    "parse-numbers": boolean;
    /** Should unparsed flags be stored in -- or _? Default is `false` */
    "populate--": boolean;
    /** Should a placeholder be added for keys not set via the corresponding CLI argument? Default is `false` */
    "set-placeholder-key": boolean;
    /** Should a group of short-options be treated as boolean flags? Default is `true` */
    "short-option-groups": boolean;
    /** Should aliases be removed before returning results? Default is `false` */
    "strip-aliased": boolean;
    /** Should dashed keys be removed before returning results? This option has no effect if camel-case-expansion is disabled. Default is `false` */
    "strip-dashed": boolean;
    /** Should unknown options be treated like regular arguments? An unknown option is one that is not configured in opts. Default is `false` */
    "unknown-options-as-args": boolean;
}
type ArrayOption = string | {
    key: string;
    boolean?: boolean;
    string?: boolean;
    number?: boolean;
    integer?: boolean;
};
type CoerceCallback = (arg: any) => any;
type ConfigCallback = (configPath: string) => {
    [key: string]: any;
} | Error;
interface Options {
    /** An object representing the set of aliases for a key: `{ alias: { foo: ['f']} }`. */
    alias: Dictionary<string | string[]>;
    /**
     * Indicate that keys should be parsed as an array: `{ array: ['foo', 'bar'] }`.
     * Indicate that keys should be parsed as an array and coerced to booleans / numbers:
     * { array: [ { key: 'foo', boolean: true }, {key: 'bar', number: true} ] }`.
     */
    array: ArrayOption | ArrayOption[];
    /** Arguments should be parsed as booleans: `{ boolean: ['x', 'y'] }`. */
    boolean: string | string[];
    /** Indicate a key that represents a path to a configuration file (this file will be loaded and parsed). */
    config: string | string[] | Dictionary<boolean | ConfigCallback>;
    /** configuration objects to parse, their properties will be set as arguments */
    configObjects: Dictionary<any>[];
    /** Provide configuration options to the yargs-parser. */
    configuration: Partial<Configuration>;
    /**
     * Provide a custom synchronous function that returns a coerced value from the argument provided (or throws an error), e.g.
     * `{ coerce: { foo: function (arg) { return modifiedArg } } }`.
     */
    coerce: Dictionary<CoerceCallback>;
    /** Indicate a key that should be used as a counter, e.g., `-vvv = {v: 3}`. */
    count: string | string[];
    /** Provide default values for keys: `{ default: { x: 33, y: 'hello world!' } }`. */
    default: Dictionary<any>;
    /** Environment variables (`process.env`) with the prefix provided should be parsed. */
    envPrefix?: string;
    /** Specify that a key requires n arguments: `{ narg: {x: 2} }`. */
    narg: Dictionary<number>;
    /** `path.normalize()` will be applied to values set to this key. */
    normalize: string | string[];
    /** Keys should be treated as strings (even if they resemble a number `-x 33`). */
    string: string | string[];
    /** Keys should be treated as numbers. */
    number: string | string[];
    /** i18n handler, defaults to util.format */
    __: (format: any, ...param: any[]) => string;
    /** alias lookup table defaults */
    key: Dictionary<any>;
}
interface Parser {
    (args: ArgsInput, opts?: Partial<Options>): Arguments;
    detailed(args: ArgsInput, opts?: Partial<Options>): DetailedArguments;
    camelCase(str: string): string;
    decamelize(str: string, joinString?: string): string;
    looksLikeNumber(x: null | undefined | number | string): boolean;
}
declare const yargsParser: Parser;
export = yargsParser;

gnunicorn added a commit to gnunicorn/matrix-rust-sdk that referenced this issue Aug 4, 2022
We are effected by yargs/yargs-parser#452
through the transient dependency of jest on yargs
gnunicorn added a commit to matrix-org/matrix-rust-sdk that referenced this issue Aug 4, 2022
We are effected by yargs/yargs-parser#452
through the transient dependency of jest on yargs
ansgarm added a commit to hashicorp/terraform-cdk that referenced this issue Aug 4, 2022
Related to yargs/yargs-parser#452 which caused synth to fail. After this change TypeScript will only check types that are actually used in user code but not whether all types in dependencies are correct. We opted for this instead of pinning a version of yargs-parser without this big, because disabling this kind of checking will also help with future bugs that might occur and won't require an update of the TypeScript template. Thus this change also helps with #1991
ansgarm added a commit to hashicorp/terraform-cdk that referenced this issue Aug 4, 2022
Related to yargs/yargs-parser#452 which caused synth to fail. After this change TypeScript will only check types that are actually used in user code but not whether all types in dependencies are correct. We opted for this instead of pinning a version of yargs-parser without this bug because disabling this kind of checking will also help with future bugs that might occur and won't require an update of the TypeScript template. Thus this change also helps with #1991
@heydev
Copy link

heydev commented Aug 4, 2022

Happen to me using ts-jest that has yargs-parser : ^21.0.0 as dependency

09:36:32 node_modules/@types/yargs/index.d.ts(28,10): error TS2305: Module '"yargs-parser"' has no exported member 'DetailedArguments'. 09:36:32 node_modules/@types/yargs/index.d.ts(28,29): error TS2305: Module '"yargs-parser"' has no exported member 'Configuration'.

Same here.

@glasser
Copy link

glasser commented Aug 4, 2022

This is presumably the bad PR: #442
Due to presumably this giant change: wessberg/rollup-plugin-ts@aae4588

The bad package has a build/index.d.ts file; the previous packages do not.

@bcoe
Copy link
Member

bcoe commented Aug 4, 2022

we intentionally weren't publishing index.d.ts, the new rollup instead added index.d.cts

trevor-scheer added a commit to apollographql/apollo-server that referenced this issue Aug 4, 2022
@glasser
Copy link

glasser commented Aug 4, 2022

oops typo in my comment, yep. thanks for fixing!

jplatte pushed a commit to matrix-org/matrix-rust-sdk-crypto-nodejs that referenced this issue Jul 12, 2023
We are effected by yargs/yargs-parser#452
through the transient dependency of jest on yargs
jplatte pushed a commit to matrix-org/matrix-rust-sdk-crypto-wasm that referenced this issue Jul 13, 2023
We are effected by yargs/yargs-parser#452
through the transient dependency of jest on yargs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants