mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-23 06:10:02 +08:00
14 lines
507 B
TypeScript
14 lines
507 B
TypeScript
// Imported generic functions monomorphize at the importer's call sites;
|
|
// instantiations are shared program-wide (whole-program compilation).
|
|
import { identity, lastOf, localUse } from "./util.ts";
|
|
|
|
console.log("main", localUse);
|
|
console.log(identity(10), identity("ten"), identity(true));
|
|
console.log(lastOf([1, 2, 3]), lastOf(["a", "z"]));
|
|
|
|
// Cross-module generic call inside a local generic function.
|
|
function wrap<T>(x: T): string {
|
|
return `[${identity(x)}]`;
|
|
}
|
|
console.log(wrap(5), wrap("five"));
|