Skip to content

allow type parameters on type arguments #5959

Description

interfaceMap<a>{[key: string]: a;}// IMPORTANT: here my intention is that the `read` and `run` methods are agreed on using the same type parameterinterfaceCommand<Options>{read(args: string[]): Options;run(options: Options): void;};interfaceCopyCommandOptions{from: string;to: string;}interfaceCleanCommandOptions{directory: string;pattern: string;}// currently in TypeScript there are 2 options to to declare `knownCommands` below:// - Map<Command<any>> which contaminates my code with `any`// - Map<Command<CopyCommandOptions | CleanCommandOptions>> which has different semantics// ideally I wish I could declare it like this:letknownCommands : Map<<a>Command<a>>={// <-- hypothetical syntax'copy': <Command<CopyCommandOptions>>undefined,'clean': <Command<CleanCommandOptions>>undefined};// so that later I could the following do in a type safe manner:letcommand=knownCommands[name];command.run(command.read(args));

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions