Skip to content

Add ts enums #15

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

Merged
merged 30 commits into from
Sep 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't check this in, I don't use this setup.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This setup doesn't use anything environment-specific. It's generalizable so long as we use mocha, so if someone writes TS in vscode, this run configuration can save them the work of figuring out how to debug tests. I think it adds value, but obviously it's your project so I'll remove it if you still think I should.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean. Also I realized that .vscode/settings is already checked in - let's keep this guy here :)

"version": "0.2.5",
"configurations": [
{
// Name of configuration; appears in the launch configuration drop down menu.
"name": "Run mocha",
// Type of configuration. Possible values: "node", "mono".
"type": "node",
// Workspace relative or absolute path to the program.
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
// Automatically stop program after launch.
"stopOnEntry": false,
// Command line arguments passed to the program.
"args": ["out/test/test.js"],
// Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
"cwd": "${workspaceRoot}",
// Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
"runtimeExecutable": null,
// Environment variables passed to the program.
"env": { "NODE_ENV": "production"}
}
]
}
59 changes: 38 additions & 21 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Generated by dts-bundle v0.5.0

export function compile(schema: JSONSchema.Schema, settings?: TsType.TsTypeSettings): string;
export function compile(schema: JSONSchema.Schema, path: string, settings?: TsType.TsTypeSettings): string;
export function compileFromFile(inputFilename: string): Promise<string | Error>;

export namespace JSONSchema {
Expand Down Expand Up @@ -42,6 +42,7 @@ export namespace JSONSchema {
[k: string]: HttpJsonSchemaOrgDraft04Schema | string[];
};
enum?: any[];
tsEnumNames?: string[];
type?: SimpleTypes | SimpleTypes[];
allOf?: HttpJsonSchemaOrgDraft04Schema[];
anyOf?: HttpJsonSchemaOrgDraft04Schema[];
Expand All @@ -56,17 +57,18 @@ export namespace JSONSchema {

export namespace TsType {
interface TsTypeSettings {
declareSimpleType?: boolean;
declarationDescription?: boolean;
declareReferenced?: boolean;
useFullReferencePathAsName?: boolean;
useInterfaceDeclaration?: boolean;
endTypeWithSemicolon?: boolean;
declareSimpleType?: boolean;
endPropertyWithSemicolon?: boolean;
declarationDescription?: boolean;
endTypeWithSemicolon?: boolean;
propertyDescription?: boolean;
useConstEnums?: boolean;
useFullReferencePathAsName?: boolean;
useInterfaceDeclaration?: boolean;
}
var DEFAULT_SETTINGS: TsTypeSettings;
abstract class TsType {
abstract class TsTypeBase {
id?: string;
description?: string;
protected safeId(): string | undefined;
Expand All @@ -82,37 +84,52 @@ export namespace TsType {
interface TsProp {
name: string;
required: boolean;
type: TsType;
type: TsTypeBase;
}
class Any extends TsType {
class Any extends TsTypeBase {
_type(): string;
}
class String extends TsType {
class String extends TsTypeBase {
_type(): string;
}
class Boolean extends TsType {
class Boolean extends TsTypeBase {
_type(): string;
}
class Number extends TsType {
class Number extends TsTypeBase {
_type(): string;
}
class Object extends TsType {
class Object extends TsTypeBase {
_type(): string;
}
class Void extends TsType {
class Void extends TsTypeBase {
_type(): string;
}
class Literal extends TsType {
class Literal extends TsTypeBase {
constructor(value: any);
_type(): any;
}
class Array extends TsType {
constructor(type?: TsType);
class EnumValue {
identifier: string;
value: string;
constructor(enumValues: string[]);
toDeclaration(): string;
toString(): string;
}
class Enum extends TsTypeBase {
enumValues: EnumValue[];
constructor(enumValues: EnumValue[]);
isSimpleType(): boolean;
_type(settings: TsTypeSettings): string;
toSafeType(settings: TsTypeSettings): string;
toDeclaration(settings: TsTypeSettings): string;
}
class Array extends TsTypeBase {
constructor(type?: TsTypeBase);
_type(settings: TsTypeSettings): string;
}
class Intersection extends TsType {
protected data: TsType[];
constructor(data: TsType[]);
class Intersection extends TsTypeBase {
protected data: TsTypeBase[];
constructor(data: TsTypeBase[]);
isSimpleType(): boolean;
_type(settings: TsTypeSettings): string;
toSafeType(settings: TsTypeSettings): string;
Expand All @@ -121,7 +138,7 @@ export namespace TsType {
isSimpleType(): boolean;
_type(settings: TsTypeSettings): string;
}
class Interface extends TsType {
class Interface extends TsTypeBase {
constructor(props: TsProp[]);
static reference(id: string): Interface;
protected _type(settings: TsTypeSettings, declaration?: boolean): string;
Expand Down
Loading