Skip to content

Commit

Permalink
Merge pull request #50 from skbkontur/a.dobrynin/long-as-number
Browse files Browse the repository at this point in the history
treat long type as number in typescript
  • Loading branch information
fakefeik authored Oct 28, 2021
2 parents afc7249 + 07b72ec commit 8de07d3
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

export type SimpleNullableRootType = {
long?: null | string;
uLong?: null | string;
long?: null | number;
uLong?: null | number;
int?: null | number;
uInt?: null | number;
short?: null | number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

export type SimpleRootType = {
long: string;
uLong: string;
long: number;
uLong: number;
int: number;
uInt: number;
short: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

export type SimpleNullableRootType = {
long?: null | string;
uLong?: null | string;
long?: null | number;
uLong?: null | number;
int?: null | number;
uInt?: null | number;
short?: null | number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

export type SimpleRootType = {
long: string;
uLong: string;
long: number;
uLong: number;
int: number;
uInt: number;
short: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public static bool Accept(ITypeInfo type)

protected override TypeScriptType ReferenceFromInternal(ITypeInfo type, TypeScriptUnit targetUnit, ITypeGenerator typeGenerator)
{
if (builtinTypes.ContainsKey(type))
return new TypeScriptBuildInType(builtinTypes[type]);
throw new ArgumentOutOfRangeException();
if (builtinTypes.TryGetValue(type, out var typeScriptType))
return new TypeScriptBuildInType(typeScriptType);
throw new ArgumentOutOfRangeException(nameof(type), $"Type '{type}' is not found");
}

private static readonly Dictionary<ITypeInfo, string> builtinTypes = new Dictionary<ITypeInfo, string>
Expand All @@ -41,8 +41,8 @@ protected override TypeScriptType ReferenceFromInternal(ITypeInfo type, TypeScri
{TypeInfo.From<DateTime>(), "(Date | string)"},
{TypeInfo.From<TimeSpan>(), "(number | string)"},
{TypeInfo.From<string>(), "string"},
{TypeInfo.From<long>(), "string"},
{TypeInfo.From<ulong>(), "string"},
{TypeInfo.From<long>(), "number"},
{TypeInfo.From<ulong>(), "number"},
{TypeInfo.From<byte[]>(), "string"},
{TypeInfo.From<Guid>(), "string"},
{TypeInfo.From<char>(), "string"},
Expand Down
3 changes: 2 additions & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"sdk": {
"version": "5.0.302"
"version": "5.0.302",
"rollForward": "latestFeature"
}
}

0 comments on commit 8de07d3

Please sign in to comment.