Skip to content

Commit

Permalink
nodeJs: fix signature for List.make in sys.d.ts
Browse files Browse the repository at this point in the history
For historical reasons the List.make(Type of, Int capacity) has always
been implemented in the JS as List.mamke(Type, Int|List) where the
2nd parameter is typically the initial values instead of the capacity.

Way too much native js code depends on this anomaly to change that
behavior, so we need to manually write the signature for List.make
to reflect that.
  • Loading branch information
Matthew Giannini authored and Matthew Giannini committed Dec 5, 2024
1 parent e0769f5 commit 6112308
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/nodeJs/fan/ts/GenTsDecl.fan
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,13 @@ class GenTsDecl
// Write methods
if (isList)
{
// make list iterable
out.print(" /** List Iterator */\n")
out.print(" [Symbol.iterator](): Iterator<V>\n")
// make list iterable and write custom make constructor
out.print(
""" /** List Iterator */
[Symbol.iterator](): Iterator<V>;
/** Constructor for of[] with optional initial values */
static make(of\$: Type, ...args: unknown[]): List;
""")
}
type.methods.each |method|
{
Expand Down Expand Up @@ -207,6 +211,10 @@ class GenTsDecl
// skip @NoDoc
if (isNoDoc(slot)) return false

// we write the List.make() method explicitly because the
// javascript impl doesn't adhere to the type signature for Fantom.
if (slot.qname == "sys::List.make") return false

// public only
return slot.isPublic
}
Expand Down

0 comments on commit 6112308

Please sign in to comment.