Skip to content

interface stubbing for anonymous implementations #16755

Closed

Description

@mjbvz

From Tony Valderrama (@tvald) on June 23, 2017 22:31

Similar to microsoft/vscode#7073, provide a code action to create stubs for an anonymous implementation of a type:

interface Foo {
  field: string,
  func(): void
}

const bar: Foo = {}
// expand above line into...
const bar: Foo = {
  field: 'string',
  func(): void {
    throw new Error('not yet implemented')
  },
}

Ideally, this would also be able to stub in the anonymous implementation of a function argument, but that would require inference of the interface being targeted for implementation:

function example(arg: Foo): void { }

example({})
// expand above line into...
example({
  field: string,
  func(): void {
    throw new Error('not yet implemented')
  },
}

Copied from original issue: microsoft/vscode#29363

Activity

  1. added
    VS Code Tracked
    on Jun 27, 2017
  2. added
    Domain: LS: Quick Fixes
    Suggestion
    on Aug 29, 2017
  3. bigaru commented on Nov 8, 2018

    @bigaru
    Contributor

    I'd like to implement this issue. I estimate that it'll take about 2 weeks, at most 4 weeks.

    Can I use existing error code Type '{}' is not assignable to type 'interfaceName'?
    Or should I rather create a new error code with more appropriate message?
    The last one will probably take more effort because the checker must be adapted accordingly, in order to show the new error message.

  4. added
    Domain: LS: Completion Lists
    on Dec 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: LS: Completion ListsDomain: LS: Quick FixesExperience EnhancementSuggestionVS Code Tracked

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions