-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from mr146/master
Substitute value in enums where getter returns constant value
- Loading branch information
Showing
11 changed files
with
128 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...erator.Tests/Files/SimpleGenerator/enum-types-with-const-getter-fixed-strings.expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
export type EnumWithConstGetterContainingRootType = { | ||
defaultEnum: 'A'; | ||
explicitEnum: 'C'; | ||
}; |
5 changes: 5 additions & 0 deletions
5
...erator.Tests/Files/SimpleGenerator/enum-types-with-const-getter-fixed-strings.expected.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
export type EnumWithConstGetterContainingRootType = { | ||
defaultEnum: 'A'; | ||
explicitEnum: 'C'; | ||
}; |
13 changes: 13 additions & 0 deletions
13
...ator.Tests/Files/SimpleGenerator/enum-types-with-const-getter-typescript-enum.expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
export type EnumWithConstGetterContainingRootType = { | ||
defaultEnum: DefaultEnum.A; | ||
explicitEnum: ExplicitEnum.C; | ||
}; | ||
export enum DefaultEnum { | ||
A = 'A', | ||
B = 'B', | ||
} | ||
export enum ExplicitEnum { | ||
C = 'C', | ||
D = 'D', | ||
} |
13 changes: 13 additions & 0 deletions
13
...ator.Tests/Files/SimpleGenerator/enum-types-with-const-getter-typescript-enum.expected.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
export type EnumWithConstGetterContainingRootType = { | ||
defaultEnum: DefaultEnum.A; | ||
explicitEnum: ExplicitEnum.C; | ||
}; | ||
export enum DefaultEnum { | ||
A = 'A', | ||
B = 'B', | ||
} | ||
export enum ExplicitEnum { | ||
C = 'C', | ||
D = 'D', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
TypeScript.ContractGenerator/CodeDom/TypeScriptEnumValueType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace SkbKontur.TypeScript.ContractGenerator.CodeDom | ||
{ | ||
public class TypeScriptEnumValueType : TypeScriptType | ||
{ | ||
public TypeScriptEnumValueType(TypeScriptType enumType, string value) | ||
{ | ||
this.enumType = enumType; | ||
this.value = value; | ||
} | ||
|
||
public override string GenerateCode(ICodeGenerationContext context) | ||
{ | ||
return $"{enumType.GenerateCode(context)}.{value}"; | ||
} | ||
|
||
private readonly TypeScriptType enumType; | ||
private readonly string value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters