@fable-org/fable-library-ts 2.0.0-beta.4 → 2.0.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/Array.ts +253 -247
  2. package/Async.ts +13 -12
  3. package/AsyncBuilder.ts +10 -11
  4. package/BigInt.ts +6 -6
  5. package/BitConverter.ts +3 -3
  6. package/Boolean.ts +3 -2
  7. package/CHANGELOG.md +14 -0
  8. package/Char.ts +38 -35
  9. package/Choice.ts +36 -12
  10. package/CollectionUtil.ts +4 -4
  11. package/Date.ts +67 -62
  12. package/DateOffset.ts +47 -56
  13. package/DateOnly.ts +8 -8
  14. package/Decimal.ts +9 -9
  15. package/Double.ts +3 -2
  16. package/Encoding.ts +1 -1
  17. package/Event.ts +3 -3
  18. package/FSharp.Collections.ts +31 -13
  19. package/FSharp.Core.CompilerServices.ts +4 -4
  20. package/FSharp.Core.ts +34 -34
  21. package/Global.ts +44 -2
  22. package/Guid.ts +7 -6
  23. package/Int32.ts +20 -17
  24. package/List.ts +57 -56
  25. package/Long.ts +6 -5
  26. package/MailboxProcessor.ts +8 -7
  27. package/Map.ts +67 -65
  28. package/MapUtil.ts +5 -5
  29. package/MutableMap.ts +32 -20
  30. package/MutableSet.ts +12 -12
  31. package/Native.ts +3 -3
  32. package/Numeric.ts +1 -1
  33. package/Observable.ts +3 -3
  34. package/Option.ts +3 -3
  35. package/Random.ts +34 -34
  36. package/Range.ts +7 -7
  37. package/Reflection.ts +73 -40
  38. package/RegExp.ts +5 -3
  39. package/Result.ts +31 -27
  40. package/Seq.ts +56 -54
  41. package/Seq2.ts +14 -14
  42. package/Set.ts +81 -80
  43. package/String.ts +41 -38
  44. package/System.Collections.Generic.ts +45 -25
  45. package/System.Text.ts +12 -12
  46. package/System.ts +366 -0
  47. package/TimeOnly.ts +10 -10
  48. package/TimeSpan.ts +11 -11
  49. package/Timer.ts +2 -2
  50. package/Types.ts +1 -19
  51. package/Uri.ts +13 -10
  52. package/Util.ts +74 -26
  53. package/package.json +1 -1
  54. package/tsconfig.json +18 -5
  55. package/SystemException.ts +0 -7
package/Async.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { OperationCanceledError, Trampoline } from "./AsyncBuilder.js";
2
- import { Continuation, Continuations } from "./AsyncBuilder.js";
3
- import { Async, IAsyncContext, CancellationToken } from "./AsyncBuilder.js";
4
- import { protectedCont, protectedBind, protectedReturn } from "./AsyncBuilder.js";
5
- import { FSharpChoice$2_$union, Choice_makeChoice1Of2, Choice_makeChoice2Of2 } from "./Choice.js";
6
- import { TimeoutException } from "./SystemException.js";
1
+ import { OperationCanceledException, Trampoline } from "./AsyncBuilder.ts";
2
+ import { Continuation, Continuations } from "./AsyncBuilder.ts";
3
+ import { Async, IAsyncContext, CancellationToken } from "./AsyncBuilder.ts";
4
+ import { protectedCont, protectedBind, protectedReturn } from "./AsyncBuilder.ts";
5
+ import { FSharpChoice$2_$union, Choice_makeChoice1Of2, Choice_makeChoice2Of2 } from "./Choice.ts";
6
+ import { TimeoutException_$ctor } from "./System.ts";
7
+ import { Exception } from "./Util.ts";
7
8
 
8
9
  function emptyContinuation<T>(_x: T) {
9
10
  // NOP
@@ -53,7 +54,7 @@ export function isCancellationRequested(token: CancellationToken) {
53
54
 
54
55
  export function throwIfCancellationRequested(token: CancellationToken) {
55
56
  if (token != null && token.isCancelled) {
56
- throw new Error("Operation is cancelled");
57
+ throw new Exception("Operation is cancelled");
57
58
  }
58
59
  }
59
60
 
@@ -62,11 +63,11 @@ function throwAfter(millisecondsDueTime: number): Async<void> {
62
63
  let tokenId: number;
63
64
  const timeoutId = setTimeout(() => {
64
65
  ctx.cancelToken.removeListener(tokenId);
65
- ctx.onError(new TimeoutException() as Error);
66
+ ctx.onError(TimeoutException_$ctor());
66
67
  }, millisecondsDueTime);
67
68
  tokenId = ctx.cancelToken.addListener(() => {
68
69
  clearTimeout(timeoutId);
69
- ctx.onCancel(new OperationCanceledError());
70
+ ctx.onCancel(new OperationCanceledException());
70
71
  });
71
72
  });
72
73
  }
@@ -93,7 +94,7 @@ export function startChild<T>(computation: Async<T>, ms?: number): Async<Async<T
93
94
  export function awaitPromise<T>(p: Promise<T>) {
94
95
  return fromContinuations((conts: Continuations<T>) =>
95
96
  p.then(conts[0]).catch((err) =>
96
- (err instanceof OperationCanceledError
97
+ (err instanceof OperationCanceledException
97
98
  ? conts[2] : conts[1])(err)));
98
99
  }
99
100
 
@@ -104,7 +105,7 @@ export function cancellationToken() {
104
105
  export const defaultCancellationToken = new CancellationToken();
105
106
 
106
107
  export function catchAsync<T>(work: Async<T>) {
107
- return protectedCont((ctx: IAsyncContext<FSharpChoice$2_$union<T, Error>>) => {
108
+ return protectedCont((ctx: IAsyncContext<FSharpChoice$2_$union<T, Exception>>) => {
108
109
  work({
109
110
  onSuccess: (x) => ctx.onSuccess(Choice_makeChoice1Of2(x)),
110
111
  onError: (ex) => ctx.onSuccess(Choice_makeChoice2Of2(ex)),
@@ -154,7 +155,7 @@ export function sleep(millisecondsDueTime: number) {
154
155
  }, millisecondsDueTime);
155
156
  tokenId = ctx.cancelToken.addListener(() => {
156
157
  clearTimeout(timeoutId);
157
- ctx.onCancel(new OperationCanceledError());
158
+ ctx.onCancel(new OperationCanceledException());
158
159
  });
159
160
  });
160
161
  }
package/AsyncBuilder.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { ensureErrorOrException } from './Types.js';
2
- import { IDisposable } from "./Util.js";
1
+ import { Exception, ensureErrorOrException, IDisposable } from "./Util.ts";
3
2
 
4
3
  export interface AsyncReplyChannel<Reply> {
5
4
  reply(value: Reply): void
@@ -9,8 +8,8 @@ export type Continuation<T> = (x: T) => void;
9
8
 
10
9
  export type Continuations<T> = [
11
10
  Continuation<T>,
12
- Continuation<Error>,
13
- Continuation<OperationCanceledError>
11
+ Continuation<Exception>,
12
+ Continuation<OperationCanceledException>
14
13
  ];
15
14
 
16
15
  export class CancellationToken implements IDisposable {
@@ -53,10 +52,10 @@ export class CancellationToken implements IDisposable {
53
52
  }
54
53
  }
55
54
 
56
- export class OperationCanceledError extends Error {
57
- constructor() {
58
- super("The operation was canceled");
59
- Object.setPrototypeOf(this, OperationCanceledError.prototype);
55
+ export class OperationCanceledException extends Exception {
56
+ constructor(msg?: string) {
57
+ super(msg ?? "The operation was canceled");
58
+ // Object.setPrototypeOf(this, OperationCanceledException.prototype);
60
59
  }
61
60
  }
62
61
 
@@ -79,8 +78,8 @@ export class Trampoline {
79
78
 
80
79
  export interface IAsyncContext<T> {
81
80
  onSuccess: Continuation<T>;
82
- onError: Continuation<Error>;
83
- onCancel: Continuation<OperationCanceledError>;
81
+ onError: Continuation<Exception>;
82
+ onCancel: Continuation<OperationCanceledException>;
84
83
 
85
84
  cancelToken: CancellationToken;
86
85
  trampoline: Trampoline;
@@ -91,7 +90,7 @@ export type Async<T> = (x: IAsyncContext<T>) => void;
91
90
  export function protectedCont<T>(f: Async<T>) {
92
91
  return (ctx: IAsyncContext<T>) => {
93
92
  if (ctx.cancelToken.isCancelled) {
94
- ctx.onCancel(new OperationCanceledError());
93
+ ctx.onCancel(new OperationCanceledException());
95
94
  } else if (ctx.trampoline.incrementAndCheck()) {
96
95
  ctx.trampoline.hijack(() => {
97
96
  try {
package/BigInt.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { FSharpRef } from "./Types.js";
2
- import { int8, uint8, int16, uint16, int32, uint32, float16, float32, float64 } from "./Int32.js";
3
- import { decimal, fromParts, truncate } from "./Decimal.js";
4
- import { bigintHash } from "./Util.js";
1
+ import { FSharpRef } from "./Types.ts";
2
+ import { int8, uint8, int16, uint16, int32, uint32, float16, float32, float64 } from "./Int32.ts";
3
+ import { decimal, fromParts, truncate } from "./Decimal.ts";
4
+ import { Exception, bigintHash } from "./Util.ts";
5
5
 
6
6
  const isBigEndian = false;
7
7
 
@@ -138,7 +138,7 @@ export function toIntN(bits: number, x: bigint, signed: boolean): bigint {
138
138
  let higher_bits = abs(x) >> BigInt(bits);
139
139
  if (higher_bits !== 0n) {
140
140
  const s = signed ? "a signed" : "an unsigned";
141
- throw new Error(`Value was either too large or too small for ${s} ${bits}-bit integer.`);
141
+ throw new Exception(`Value was either too large or too small for ${s} ${bits}-bit integer.`);
142
142
  }
143
143
  return signed ? BigInt.asIntN(bits, x) : BigInt.asUintN(bits, x);
144
144
  }
@@ -338,7 +338,7 @@ function toSignedBytes(x: bigint, isBigEndian: boolean): Uint8Array {
338
338
 
339
339
  function fromSignedBytes(bytes: ArrayLike<uint8>, isBigEndian: boolean) {
340
340
  if (bytes == null) {
341
- throw new Error("bytes is null");
341
+ throw new Exception("bytes is null");
342
342
  }
343
343
  const len = bytes.length;
344
344
  const first = isBigEndian ? 0 : len - 1;
package/BitConverter.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { uint8, int16, uint16, int32, uint32, float32, float64 } from "./Int32.js";
2
- import { int64, uint64 } from "./BigInt.js";
3
- import { char } from "./Char.js";
1
+ import { uint8, int16, uint16, int32, uint32, float32, float64 } from "./Int32.ts";
2
+ import { int64, uint64 } from "./BigInt.ts";
3
+ import { char } from "./Char.ts";
4
4
 
5
5
  const littleEndian = true;
6
6
 
package/Boolean.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { FSharpRef } from "./Types.js"
1
+ import { FSharpRef } from "./Types.ts";
2
+ import { Exception } from "./Util.ts";
2
3
 
3
4
  export function tryParse(str: string, defValue: FSharpRef<boolean>): boolean {
4
5
  if (str != null && str.match(/^\s*true\s*$/i)) {
@@ -17,6 +18,6 @@ export function parse(str: string): boolean {
17
18
  if (tryParse(str, defValue)) {
18
19
  return defValue.contents;
19
20
  } else {
20
- throw new Error(`String '${str}' was not recognized as a valid Boolean.`)
21
+ throw new Exception(`String '${str}' was not recognized as a valid Boolean.`)
21
22
  }
22
23
  }
package/CHANGELOG.md CHANGED
@@ -7,8 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 2.0.0-beta.6 - 2025-12-26
11
+
12
+ ### Fixed
13
+
14
+ * [JS/TS] Fix #4305 `DateTimeOffset.Now` returns wrong time (by @ncave)
15
+
16
+ ## 2.0.0-beta.5 - 2025-11-19
17
+
18
+ ### Changed
19
+
20
+ * [JS/TS] Replace the deprecated `substr` method with `slice` (by @Thorium)
21
+
10
22
  ## 2.0.0-beta.4 - 2025-07-25
11
23
 
24
+ ### Added
25
+
12
26
  * [JS/TS] Initial support for Nullable Reference Types (by @ncave)
13
27
 
14
28
  ## 2.0.0-beta.3 - 2025-03-14
package/Char.ts CHANGED
@@ -1,4 +1,5 @@
1
- import * as Unicode from "./Unicode.13.0.0.js";
1
+ import * as Unicode from "./Unicode.13.0.0.ts";
2
+ import { Exception } from "./Util.ts";
2
3
 
3
4
  export type char = string;
4
5
 
@@ -32,38 +33,40 @@ function getCategoryFunc() {
32
33
  };
33
34
  }
34
35
 
35
- export const enum UnicodeCategory {
36
- UppercaseLetter,
37
- LowercaseLetter,
38
- TitlecaseLetter,
39
- ModifierLetter,
40
- OtherLetter,
41
- NonSpacingMark,
42
- SpacingCombiningMark,
43
- EnclosingMark,
44
- DecimalDigitNumber,
45
- LetterNumber,
46
- OtherNumber,
47
- SpaceSeparator,
48
- LineSeparator,
49
- ParagraphSeparator,
50
- Control,
51
- Format,
52
- Surrogate,
53
- PrivateUse,
54
- ConnectorPunctuation,
55
- DashPunctuation,
56
- OpenPunctuation,
57
- ClosePunctuation,
58
- InitialQuotePunctuation,
59
- FinalQuotePunctuation,
60
- OtherPunctuation,
61
- MathSymbol,
62
- CurrencySymbol,
63
- ModifierSymbol,
64
- OtherSymbol,
65
- OtherNotAssigned,
66
- }
36
+ export const UnicodeCategory = {
37
+ UppercaseLetter: 0,
38
+ LowercaseLetter: 1,
39
+ TitlecaseLetter: 2,
40
+ ModifierLetter: 3,
41
+ OtherLetter: 4,
42
+ NonSpacingMark: 5,
43
+ SpacingCombiningMark: 6,
44
+ EnclosingMark: 7,
45
+ DecimalDigitNumber: 8,
46
+ LetterNumber: 9,
47
+ OtherNumber: 10,
48
+ SpaceSeparator: 11,
49
+ LineSeparator: 12,
50
+ ParagraphSeparator: 13,
51
+ Control: 14,
52
+ Format: 15,
53
+ Surrogate: 16,
54
+ PrivateUse: 17,
55
+ ConnectorPunctuation: 18,
56
+ DashPunctuation: 19,
57
+ OpenPunctuation: 20,
58
+ ClosePunctuation: 21,
59
+ InitialQuotePunctuation: 22,
60
+ FinalQuotePunctuation: 23,
61
+ OtherPunctuation: 24,
62
+ MathSymbol: 25,
63
+ CurrencySymbol: 26,
64
+ ModifierSymbol: 27,
65
+ OtherSymbol: 28,
66
+ OtherNotAssigned: 29,
67
+ } as const;
68
+
69
+ export type UnicodeCategory = typeof UnicodeCategory[keyof typeof UnicodeCategory];
67
70
 
68
71
  const isControlMask = 1 << UnicodeCategory.Control;
69
72
  const isDigitMask = 1 << UnicodeCategory.DecimalDigitNumber;
@@ -108,7 +111,7 @@ function charCodeAt(s: string, index: number) {
108
111
  if (index >= 0 && index < s.length) {
109
112
  return s.charCodeAt(index);
110
113
  } else {
111
- throw new Error("Index out of range.");
114
+ throw new Exception("Index out of range.");
112
115
  }
113
116
  }
114
117
 
@@ -217,6 +220,6 @@ export function parse(input: string) {
217
220
  if (input.length === 1) {
218
221
  return input[0];
219
222
  } else {
220
- throw new Error("String must be exactly one character long.");
223
+ throw new Exception("String must be exactly one character long.");
221
224
  }
222
225
  }
package/Choice.ts CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
- import { Union } from "./Types.js";
3
- import { union_type, TypeInfo } from "./Reflection.js";
4
- import { int32 } from "./Int32.js";
5
- import { Option, some } from "./Option.js";
2
+ import { Union } from "./Types.ts";
3
+ import { union_type, TypeInfo } from "./Reflection.ts";
4
+ import { int32 } from "./Int32.ts";
5
+ import { Option, some } from "./Option.ts";
6
6
 
7
7
  export type FSharpChoice$2_$union<T1, T2> =
8
8
  | FSharpChoice$2<T1, T2, 0>
@@ -22,9 +22,13 @@ export function FSharpChoice$2_Choice2Of2<T1, T2>(Item: T2) {
22
22
  }
23
23
 
24
24
  export class FSharpChoice$2<T1, T2, Tag extends keyof FSharpChoice$2_$cases<T1, T2>> extends Union<Tag, FSharpChoice$2_$cases<T1, T2>[Tag][0]> {
25
- constructor(readonly tag: Tag, readonly fields: FSharpChoice$2_$cases<T1, T2>[Tag][1]) {
25
+ constructor(tag: Tag, fields: FSharpChoice$2_$cases<T1, T2>[Tag][1]) {
26
26
  super();
27
+ this.tag = tag;
28
+ this.fields = fields;
27
29
  }
30
+ readonly tag: Tag;
31
+ readonly fields: FSharpChoice$2_$cases<T1, T2>[Tag][1];
28
32
  cases() {
29
33
  return ["Choice1Of2", "Choice2Of2"];
30
34
  }
@@ -58,9 +62,13 @@ export function FSharpChoice$3_Choice3Of3<T1, T2, T3>(Item: T3) {
58
62
  }
59
63
 
60
64
  export class FSharpChoice$3<T1, T2, T3, Tag extends keyof FSharpChoice$3_$cases<T1, T2, T3>> extends Union<Tag, FSharpChoice$3_$cases<T1, T2, T3>[Tag][0]> {
61
- constructor(readonly tag: Tag, readonly fields: FSharpChoice$3_$cases<T1, T2, T3>[Tag][1]) {
65
+ constructor(tag: Tag, fields: FSharpChoice$3_$cases<T1, T2, T3>[Tag][1]) {
62
66
  super();
67
+ this.tag = tag;
68
+ this.fields = fields;
63
69
  }
70
+ readonly tag: Tag;
71
+ readonly fields: FSharpChoice$3_$cases<T1, T2, T3>[Tag][1];
64
72
  cases() {
65
73
  return ["Choice1Of3", "Choice2Of3", "Choice3Of3"];
66
74
  }
@@ -100,9 +108,13 @@ export function FSharpChoice$4_Choice4Of4<T1, T2, T3, T4>(Item: T4) {
100
108
  }
101
109
 
102
110
  export class FSharpChoice$4<T1, T2, T3, T4, Tag extends keyof FSharpChoice$4_$cases<T1, T2, T3, T4>> extends Union<Tag, FSharpChoice$4_$cases<T1, T2, T3, T4>[Tag][0]> {
103
- constructor(readonly tag: Tag, readonly fields: FSharpChoice$4_$cases<T1, T2, T3, T4>[Tag][1]) {
111
+ constructor(tag: Tag, fields: FSharpChoice$4_$cases<T1, T2, T3, T4>[Tag][1]) {
104
112
  super();
113
+ this.tag = tag;
114
+ this.fields = fields;
105
115
  }
116
+ readonly tag: Tag;
117
+ readonly fields: FSharpChoice$4_$cases<T1, T2, T3, T4>[Tag][1];
106
118
  cases() {
107
119
  return ["Choice1Of4", "Choice2Of4", "Choice3Of4", "Choice4Of4"];
108
120
  }
@@ -148,9 +160,13 @@ export function FSharpChoice$5_Choice5Of5<T1, T2, T3, T4, T5>(Item: T5) {
148
160
  }
149
161
 
150
162
  export class FSharpChoice$5<T1, T2, T3, T4, T5, Tag extends keyof FSharpChoice$5_$cases<T1, T2, T3, T4, T5>> extends Union<Tag, FSharpChoice$5_$cases<T1, T2, T3, T4, T5>[Tag][0]> {
151
- constructor(readonly tag: Tag, readonly fields: FSharpChoice$5_$cases<T1, T2, T3, T4, T5>[Tag][1]) {
163
+ constructor(tag: Tag, fields: FSharpChoice$5_$cases<T1, T2, T3, T4, T5>[Tag][1]) {
152
164
  super();
165
+ this.tag = tag;
166
+ this.fields = fields;
153
167
  }
168
+ readonly tag: Tag;
169
+ readonly fields: FSharpChoice$5_$cases<T1, T2, T3, T4, T5>[Tag][1];
154
170
  cases() {
155
171
  return ["Choice1Of5", "Choice2Of5", "Choice3Of5", "Choice4Of5", "Choice5Of5"];
156
172
  }
@@ -202,9 +218,13 @@ export function FSharpChoice$6_Choice6Of6<T1, T2, T3, T4, T5, T6>(Item: T6) {
202
218
  }
203
219
 
204
220
  export class FSharpChoice$6<T1, T2, T3, T4, T5, T6, Tag extends keyof FSharpChoice$6_$cases<T1, T2, T3, T4, T5, T6>> extends Union<Tag, FSharpChoice$6_$cases<T1, T2, T3, T4, T5, T6>[Tag][0]> {
205
- constructor(readonly tag: Tag, readonly fields: FSharpChoice$6_$cases<T1, T2, T3, T4, T5, T6>[Tag][1]) {
221
+ constructor(tag: Tag, fields: FSharpChoice$6_$cases<T1, T2, T3, T4, T5, T6>[Tag][1]) {
206
222
  super();
223
+ this.tag = tag;
224
+ this.fields = fields;
207
225
  }
226
+ readonly tag: Tag;
227
+ readonly fields: FSharpChoice$6_$cases<T1, T2, T3, T4, T5, T6>[Tag][1];
208
228
  cases() {
209
229
  return ["Choice1Of6", "Choice2Of6", "Choice3Of6", "Choice4Of6", "Choice5Of6", "Choice6Of6"];
210
230
  }
@@ -262,9 +282,13 @@ export function FSharpChoice$7_Choice7Of7<T1, T2, T3, T4, T5, T6, T7>(Item: T7)
262
282
  }
263
283
 
264
284
  export class FSharpChoice$7<T1, T2, T3, T4, T5, T6, T7, Tag extends keyof FSharpChoice$7_$cases<T1, T2, T3, T4, T5, T6, T7>> extends Union<Tag, FSharpChoice$7_$cases<T1, T2, T3, T4, T5, T6, T7>[Tag][0]> {
265
- constructor(readonly tag: Tag, readonly fields: FSharpChoice$7_$cases<T1, T2, T3, T4, T5, T6, T7>[Tag][1]) {
285
+ constructor(tag: Tag, fields: FSharpChoice$7_$cases<T1, T2, T3, T4, T5, T6, T7>[Tag][1]) {
266
286
  super();
287
+ this.tag = tag;
288
+ this.fields = fields;
267
289
  }
290
+ readonly tag: Tag;
291
+ readonly fields: FSharpChoice$7_$cases<T1, T2, T3, T4, T5, T6, T7>[Tag][1];
268
292
  cases() {
269
293
  return ["Choice1Of7", "Choice2Of7", "Choice3Of7", "Choice4Of7", "Choice5Of7", "Choice6Of7", "Choice7Of7"];
270
294
  }
@@ -284,7 +308,7 @@ export function Choice_makeChoice2Of2<T2, a>(x: T2): FSharpChoice$2_$union<a, T2
284
308
 
285
309
  export function Choice_tryValueIfChoice1Of2<T1, T2>(x: FSharpChoice$2_$union<T1, T2>): Option<T1> {
286
310
  if ((x.tag as int32) === /* Choice1Of2 */ 0) {
287
- return some(x.fields[0] as any);
311
+ return some(x.fields[0] as T1);
288
312
  }
289
313
  else {
290
314
  return undefined;
@@ -293,7 +317,7 @@ export function Choice_tryValueIfChoice1Of2<T1, T2>(x: FSharpChoice$2_$union<T1,
293
317
 
294
318
  export function Choice_tryValueIfChoice2Of2<T1, T2>(x: FSharpChoice$2_$union<T1, T2>): Option<T2> {
295
319
  if ((x.tag as int32) === /* Choice2Of2 */ 1) {
296
- return some(x.fields[0] as any);
320
+ return some(x.fields[0] as T2);
297
321
  }
298
322
  else {
299
323
  return undefined;
package/CollectionUtil.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { equals, isArrayLike } from "./Util.js";
1
+ import { Exception, MutableArray, equals, isArrayLike } from "./Util.ts";
2
2
 
3
3
  export function count<T>(col: Iterable<T>): number {
4
4
  if (typeof (col as any)["System.Collections.Generic.ICollection`1.get_Count"] === "function") {
@@ -29,7 +29,7 @@ export function isReadOnly<T>(col: Iterable<T>): boolean {
29
29
  return (col as any)["System.Collections.Generic.ICollection`1.get_IsReadOnly"](); // collection
30
30
  } else {
31
31
  if (isArrayLike(col)) {
32
- return ArrayBuffer.isView(col); // true for typed arrays, false for other arrays
32
+ return false; // array, resize array
33
33
  } else {
34
34
  if (typeof (col as any).size === "number") {
35
35
  return false; // map, set
@@ -41,7 +41,7 @@ export function isReadOnly<T>(col: Iterable<T>): boolean {
41
41
  }
42
42
  }
43
43
 
44
- export function copyTo<T>(col: Iterable<T>, array: T[], arrayIndex: number) {
44
+ export function copyTo<T>(col: Iterable<T>, array: MutableArray<T>, arrayIndex: number) {
45
45
  if (typeof (col as any)["System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"] === "function") {
46
46
  (col as any)["System.Collections.Generic.ICollection`1.CopyToZ3B4C077E"](array, arrayIndex); // collection
47
47
  } else {
@@ -94,7 +94,7 @@ export function add<T>(col: Iterable<T>, item: T): void {
94
94
  if ((col as any).has(item[0]) === false) {
95
95
  (col as any).set(item[0], item[1]); // map
96
96
  } else {
97
- throw new Error("An item with the same key has already been added. Key: " + item[0]);
97
+ throw new Exception("An item with the same key has already been added. Key: " + item[0]);
98
98
  }
99
99
  } else {
100
100
  // TODO: throw for other collections?