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

interface stubbing for anonymous implementations #16755

Closed
mjbvz opened this issue Jun 27, 2017 · 1 comment · Fixed by #44781
Closed

interface stubbing for anonymous implementations #16755

mjbvz opened this issue Jun 27, 2017 · 1 comment · Fixed by #44781
Labels
Domain: Completion Lists The issue relates to showing completion lists in an editor Domain: Quick Fixes Editor-provided fixes, often called code actions. Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue
Milestone

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Jun 27, 2017

From @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

@mjbvz mjbvz self-assigned this Jun 27, 2017
@mjbvz mjbvz removed their assignment Jun 27, 2017
@mjbvz mjbvz added the VS Code Tracked There is a VS Code equivalent to this issue label Jun 27, 2017
@mhegazy mhegazy added Domain: Quick Fixes Editor-provided fixes, often called code actions. Suggestion An idea for TypeScript labels Aug 29, 2017
@RyanCavanaugh RyanCavanaugh added the Experience Enhancement Noncontroversial enhancements label Aug 15, 2018
@RyanCavanaugh RyanCavanaugh added this to the Future milestone Aug 15, 2018
@weswigham weswigham added the In Discussion Not yet reached consensus label Nov 6, 2018
@bigaru
Copy link
Contributor

bigaru commented Nov 8, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Completion Lists The issue relates to showing completion lists in an editor Domain: Quick Fixes Editor-provided fixes, often called code actions. Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
6 participants