diff --git a/TypeScript.ContractGenerator.Tests/Files/CustomGenerator/nullable-types.ts b/TypeScript.ContractGenerator.Tests/Files/CustomGenerator/nullable-types.ts index 5dcf874..56de267 100644 --- a/TypeScript.ContractGenerator.Tests/Files/CustomGenerator/nullable-types.ts +++ b/TypeScript.ContractGenerator.Tests/Files/CustomGenerator/nullable-types.ts @@ -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; diff --git a/TypeScript.ContractGenerator.Tests/Files/CustomGenerator/simple-types.ts b/TypeScript.ContractGenerator.Tests/Files/CustomGenerator/simple-types.ts index a96c587..6777eb3 100644 --- a/TypeScript.ContractGenerator.Tests/Files/CustomGenerator/simple-types.ts +++ b/TypeScript.ContractGenerator.Tests/Files/CustomGenerator/simple-types.ts @@ -1,7 +1,7 @@ export type SimpleRootType = { - long: string; - uLong: string; + long: number; + uLong: number; int: number; uInt: number; short: number; diff --git a/TypeScript.ContractGenerator.Tests/Files/SimpleGenerator/nullable-types.ts b/TypeScript.ContractGenerator.Tests/Files/SimpleGenerator/nullable-types.ts index 410f15b..d3da815 100644 --- a/TypeScript.ContractGenerator.Tests/Files/SimpleGenerator/nullable-types.ts +++ b/TypeScript.ContractGenerator.Tests/Files/SimpleGenerator/nullable-types.ts @@ -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; diff --git a/TypeScript.ContractGenerator.Tests/Files/SimpleGenerator/simple-types.ts b/TypeScript.ContractGenerator.Tests/Files/SimpleGenerator/simple-types.ts index 3adfedb..8cae4e1 100644 --- a/TypeScript.ContractGenerator.Tests/Files/SimpleGenerator/simple-types.ts +++ b/TypeScript.ContractGenerator.Tests/Files/SimpleGenerator/simple-types.ts @@ -1,7 +1,7 @@ export type SimpleRootType = { - long: string; - uLong: string; + long: number; + uLong: number; int: number; uInt: number; short: number; diff --git a/TypeScript.ContractGenerator/TypeBuilders/BuiltinTypeBuildingContext.cs b/TypeScript.ContractGenerator/TypeBuilders/BuiltinTypeBuildingContext.cs index 899fe30..7052377 100644 --- a/TypeScript.ContractGenerator/TypeBuilders/BuiltinTypeBuildingContext.cs +++ b/TypeScript.ContractGenerator/TypeBuilders/BuiltinTypeBuildingContext.cs @@ -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 builtinTypes = new Dictionary @@ -41,8 +41,8 @@ protected override TypeScriptType ReferenceFromInternal(ITypeInfo type, TypeScri {TypeInfo.From(), "(Date | string)"}, {TypeInfo.From(), "(number | string)"}, {TypeInfo.From(), "string"}, - {TypeInfo.From(), "string"}, - {TypeInfo.From(), "string"}, + {TypeInfo.From(), "number"}, + {TypeInfo.From(), "number"}, {TypeInfo.From(), "string"}, {TypeInfo.From(), "string"}, {TypeInfo.From(), "string"}, diff --git a/global.json b/global.json index d58cbe0..b86006c 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,6 @@ { "sdk": { - "version": "5.0.302" + "version": "5.0.302", + "rollForward": "latestFeature" } } \ No newline at end of file