electricessence / TypeScript.NET

A JavaScript-Friendly .NET Based TypeScript Library (Moved)
https://github.com/electricessence/TypeScript.NET-Core
Other
251 stars 36 forks source link

TimeSpan issue: compareTo is not a function (TypeError) #71

Closed netsrotr closed 5 years ago

netsrotr commented 5 years ago

Hi, we use the TimeSpan datatype within our typescript project (typescript-dotnet-commonjs: ^4.11.1).

  1. Now if I use one timespan variable and try to compare to another instance using .compareTo() I get an error xxx.compareTo is not a function (TypeError). Sample: if (this.time.compareTo(TimeSpan.zero) === 1) ... where time is of type TimeSpan too.

  2. Another issue I have: I Cannot use code like this: if (this.time.compareTo(TimeSpan.zero) === CompareResult.Greater) ... because I get webpack require error about CompareResult type not loadable. Further we cannot include the library in our separate library webpack module package because of the missing index file. What are we doing wrong here?

Update to issue 1) I work with a JSON object instance of the TimeSpan, so that seems to cause the error(s) about missing functions. Resolved, sorry.

electricessence commented 5 years ago

AH ok. :) If you were curious, TimeSpan inherits from TimeQuanity and you can compare against any TimeQuantity: https://github.com/electricessence/TypeScript.NET/blob/master/source/System/Time/TimeQuantity.ts#L51-L59

electricessence commented 5 years ago

@netsrotr I'm glad to see someone using this and doing so in an elegant way as intended. Any thoughts, comments? I'm working on another if not potentially final version of TS .NET as we are moving into a WebAssembly world where this might all become obsolete. 😏