Skip to content
This repository has been archived by the owner on Oct 15, 2018. It is now read-only.

Commit

Permalink
#135 - setTypeExpression - This requires the next version of typescri…
Browse files Browse the repository at this point in the history
…pt to compile
  • Loading branch information
dsherret committed May 3, 2016
1 parent a6028c4 commit 4ccb4b1
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/definitions/base/BaseParameterDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export abstract class BaseParameterDefinition extends BaseDefinition implements
name: string;
// TypeExpressionedDefinition
typeExpression: TypeExpressionDefinition;
setTypeExpression: (text: string) => this;
// DefaultExpressionedDefinition
defaultExpression: ExpressionDefinition;
}
Expand Down
1 change: 1 addition & 0 deletions src/definitions/base/BasePropertyDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export abstract class BasePropertyDefinition extends BaseDefinition implements N
name: string;
// TypeExpressionedDefinition
typeExpression: TypeExpressionDefinition;
setTypeExpression: (text: string) => this;
}

applyMixins(BasePropertyDefinition, BaseDefinition, [NamedDefinition, TypeExpressionedDefinition]);
6 changes: 6 additions & 0 deletions src/definitions/base/TypeExpressionedDefinition.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import {StructureFactory} from "./../../factories";
import {TypeExpressionDefinition} from "./../expression";

export abstract class TypeExpressionedDefinition {
typeExpression: TypeExpressionDefinition;

setTypeExpression(text: string) {
this.typeExpression = new StructureFactory().getTypeExpressionFromText(text);
return this;
}
}
1 change: 1 addition & 0 deletions src/definitions/general/TypeAliasDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class TypeAliasDefinition extends BaseDefinition
isDefaultExportOfFile: boolean;
// TypeExpressionedDefinition
typeExpression: TypeExpressionDefinition;
setTypeExpression: (text: string) => this;
// TypeParameteredDefinition
typeParameters: TypeParameterDefinition[];
addTypeParameters: (...typeParameters: TypeParameterStructure[]) => this;
Expand Down
1 change: 1 addition & 0 deletions src/definitions/variable/VariableDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class VariableDefinition extends BaseDefinition
isDefaultExportOfFile: boolean;
// TypeExpressionedDefinition
typeExpression: TypeExpressionDefinition;
setTypeExpression: (text: string) => this;
// DefaultExpressionedDefinition
defaultExpression: ExpressionDefinition;
// AmbientableDefinition
Expand Down
11 changes: 11 additions & 0 deletions src/tests/definitions/base/typeExpressionTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {VariableDefinition} from "./../../../definitions";
import {runTypeExpressionedDefinitionTests} from "./../../testHelpers";

describe("TypeExpressionedDefinition", () => {
describe("setTypeExpression", () => {
const v = new VariableDefinition();
v.setTypeExpression("string");

runTypeExpressionedDefinitionTests(v, { typeExpression: { text: "string" } });
});
});

0 comments on commit 4ccb4b1

Please sign in to comment.