Coder Social home page Coder Social logo

dotupnet / dotup-vscode-interface-generator Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 38.39 MB

vscode extension that generates interface from typescript class

TypeScript 100.00%
vscode vscode-extension typescript typescript-generator interface-builder

dotup-vscode-interface-generator's Introduction

Interface generator for Visual Studio Code

Description

Interface generator is a VSCode Extension which creates an interface definition from a typescript class. Supports import statements, comments, public properties and methods, generics and optional.

Given class:

export class ExtendsOnly<XY, TG extends string> extends ABC implements DEF {
  public NumberProperty: number = 2;
  OptionalStringProperty?: string;
}

Since interfaces can not implement anything, implements DEF is omitted.

Generated interface

export interface IExtendsOnly<XY, TG extends string> extends ABC {
  NumberProperty: number;
  OptionalStringProperty?: string;
}

dotup-vscode-interface-generator Video

Installation

You can browse and install extensions from within VS Code. Press Ctrl+P and narrow down the list commands by typing ext install dotup-vscode-interface-generator.

https://marketplace.visualstudio.com/items?itemName=dotup.dotup-vscode-interface-generator

Usage

1. Open a typescript file with one or more class definitions.

dotup-vscode-interface-generator Screenshot

2. Press Ctrl+Shift+P to see all commands and start typing Generate interface and hit Enter.

dotup-vscode-interface-generator Screenshot

The extension creates a new file in the same folder as the source file. The new file has the name of the source file prefixed with I. Existing files will be overwritten!

dotup-vscode-interface-generator Screenshot

Release Notes

1.0.15

Fixes/Features:

  • Packages not included

Release Notes

1.0.14

Fixes/Features:

  • Explorer context menu "Generate interface"
  • Error handling

1.0.13

Fixes/Features:

  • Update readme :)

1.0.12

Fixes/Features:

1.0.11

Fixes/Features:

  • take over comments ( For classes, methods and properties )

1.0.10

Fixes/Features:

  • Readme: pictures not shown.
  • Readme: Wrong 'Generate interface' example
  • Icon added
  • dependencies missed
  • Wrong target path on Multi-root Workspaces
  • prefix on interface name was missing
  • video added

TODO:

  • take over comments ( For classes, methods and properties )

Enjoy!

dotup-vscode-interface-generator's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

dotup-vscode-interface-generator's Issues

Converts Promise results to any

class myobject {
	public async compare(other: myobject): Promise<boolean> {
		return true;
	}
}

current output:

export interface Imyobject {
    compare(other: Imyobject): any;
}

expected output:

export interface Imyobject {
    compare(other: Imyobject): Promise<boolean>;
}

Fails if a class is using itself as argument in a method

If you have a class that uses itself in a function as argument it´s not adopting the name of that argument:

class myobject {
	public compare(other: myobject): boolean {
		return true;
	}
}

current output:

export interface Imyobject {
    compare(other: myobject): boolean;
}

expected output:

export interface Imyobject {
    compare(other: Imyobject): boolean;
}

Looses multiple result options and transforms only to one

class myobject {
	public compare(other: myobject): number | undefined {
		return 0;
	}
}

Current output:

export interface Imyobject {
    compare(other: myobject): number;
}

expected output:

export interface Imyobject {
    compare(other: myobject): number | undefined;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.