- modules
- Exporting a declaration
- Export statements
- Re - exports
- Import a single export from a module
- Default exports
- Default exports of classes and functions
- Default exports can also be just values:
- export = and import = require()
- Code Generation for Modules
- Simple Example
- Optional Module Loading
- Ambient Modules
- Shorthand ambient modules
- Wildcard module declarations
- UMD modules
- Export as close to top-level as possible
- Re -export to extend
- variables
- function
- class
- interfaces
- Simple interface
- Reference to interface
- Optional properties
- Optional properties 2
- Readonly properties
- Readonly vs const
- Call signature
- Index signature
- Index signature 2
- Index signature 3
- Readonly index signature 3
- Class Types
- static and instance sides of classes - fails
- static and instance sides of classes - succeds
- Extending Interfaces 1
- Extending Interfaces 2
- Hybrid Types
- Class with private property
- Interface extending class
- Derived class extending interface
- Derived class
- Class extending interface
- generics
- Identity function with any
- Identity function with type variable
- Type argument
- Length property fails
- Length property succeds 1
- Length property succeds 2
- Generic function
- Call signature object literal type
- Generic interface
- Generic Classes
- Generic Constraints - fails
- Generic Constraints - succeds
- Type Parameters in Generic Constraints
- Class Types in Generics
- Prototype property
- advanced
- Intersection Types
- Union Types - fail at run time
- Union Types - succeds at run time
- Union Types - common members
- Type Guards and Differentiating Types
- User - Defined Type Guards
- Instanceof type guards
- Nullable types
- Type guards and type assertions
- Type Aliases
- Interfaces vs.Type Aliases
- String Literal Types
- Numeric Literal Types
- Enum Member Types
- Exhaustiveness checking
- Polymorphic this types
- Index types
- Mapped types
- Mapped types 2
- Inference from mapped types
- Conditional Types
- Distributive conditional types
- Conditional types combined with mapped types:
- Type inference in conditional types
- Predefined conditional types
Exporting a declaration
1 + 2 # 3 # Validation.ts 4 export 5 :interface StringValidator 6 :m isAcceptable 7 :boolean 8 param s 9 :string 10 # 11 # ZipCodeValidator.ts 12 export 13 const numberRegexp = /^[0-9]+$/ 14 export 15 class ZipCodeValidator 16 :implements StringValidator 17 m isAcceptable 18 param s 19 :string 20 return s.length === 5 && numberRegexp.test(s)
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
//
export interface StringValidator {
isAcceptable(s: string): boolean;
}
//
export const numberRegexp = /^[0-9]+$/;
export class ZipCodeValidator implements StringValidator {
isAcceptable(s: string) {
return s.length === 5 && numberRegexp.test(s);
}
}
Export statements
1 + 2 class ZipCodeValidator 3 :implements StringValidator 4 m isAcceptable 5 param s 6 :string 7 return s.length === 5 && numberRegexp.test(s) 8 export 9 @ ZipCodeValidator 10 export 11 @ ZipCodeValidator 12 as mainValidator
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
class ZipCodeValidator implements StringValidator {
isAcceptable(s: string) {
return s.length === 5 && numberRegexp.test(s);
}
}
export {ZipCodeValidator};
export {ZipCodeValidator as mainValidator};
Re - exports
1 + 2 # 3 # ParseIntBasedZipCodeValidator.ts 4 export 5 class ParseIntBasedZipCodeValidator 6 m isAcceptable 7 param s 8 :string 9 return s.length === 5 && parseInt(s).toString() === s 10 export 11 @ ZipCodeValidator 12 as RegExpBasedZipCodeValidator 13 from "./ZipCodeValidator" 14 # 15 # AllValidators.ts 16 export * 17 from "./StringValidator" 18 export * 19 from "./LettersOnlyValidator" 20 export * 21 from "./ZipCodeValidator"
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
//
export class ParseIntBasedZipCodeValidator {
isAcceptable(s: string) {
return s.length === 5 && parseInt(s).toString() === s;
}
}
export {ZipCodeValidator as RegExpBasedZipCodeValidator} from "./ZipCodeValidator";
//
export * from "./StringValidator";
export * from "./LettersOnlyValidator";
export * from "./ZipCodeValidator";
Import a single export from a module
1 + 2 import 3 @ ZipCodeValidator 4 from "./ZipCodeValidator" 5 let myValidator = new ZipCodeValidator() 6 # 7 # imports can also be renamed 8 import 9 @ ZipCodeValidator 10 as ZCV 11 from "./ZipCodeValidator" 12 let myValidator = new ZCV() 13 # 14 # Import the entire module into a single variable, and use it to access the module exports 15 import 16 as validator 17 from "./ZipCodeValidator" 18 let myValidator = new validator.ZipCodeValidator() 19 # 20 # Import a module for side- effects only 21 import "./my-module.js"
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
import {ZipCodeValidator} from "./ZipCodeValidator";
let myValidator = new ZipCodeValidator();
//
import {ZipCodeValidator as ZCV} from "./ZipCodeValidator";
let myValidator = new ZCV();
//
import * as validator from "./ZipCodeValidator";
let myValidator = new validator.ZipCodeValidator();
//
import "./my-module.js";
Default exports
1 + 2 # 3 # JQuery.d.ts 4 :declare 5 let 6 :ref JQuery 7 export-default 8 # 9 # App.ts 10 import $ from "JQuery" 11 _ $("button.continue").html("Next Step...")
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
//
declare let $: JQuery;
export default $;
//
import $ from "JQuery";
$("button.continue").html("Next Step...");
Default exports of classes and functions
1 + 2 # 3 # ZipCodeValidator.ts 4 export-default 5 class ZipCodeValidator 6 p numberRegexp 7 static 8 := /^[0-9]+$/ 9 m isAcceptable 10 param s 11 :string 12 return s.length === 5 && ZipCodeValidator.numberRegexp.test(s) 13 # 14 # Test.ts 15 import validator from "./ZipCodeValidator" 16 let myValidator = new validator() 17 # 18 # or 19 # StaticZipCodeValidator.ts 20 const numberRegexp = /^[0-9]+$/ 21 export-default 22 function 23 param s 24 :string 25 return s.length === 5 && numberRegexp.test(s) 26 # 27 # Test.ts 28 import validate from "./StaticZipCodeValidator" 29 let strings 30 [ 31 @ "Hello" 32 @ "98052" 33 @ "101" 34 _ strings.forEach 35 => 36 param s 37 _ console.log 38 `lit 39 + " 40 @ s 41 + " 42 iif validate(s) 43 then " matches" 44 else " does not match" 45 +
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
//
export default class ZipCodeValidator {
static numberRegexp = /^[0-9]+$/;
isAcceptable(s: string) {
return s.length === 5 && ZipCodeValidator.numberRegexp.test(s);
}
}
//
import validator from "./ZipCodeValidator";
let myValidator = new validator();
//
const numberRegexp = /^[0-9]+$/;
export default function(s: string) {
return s.length === 5 && numberRegexp.test(s);
}
//
import validate from "./StaticZipCodeValidator";
let strings = [
"Hello",
"98052",
"101"
];
strings.forEach(s =>
console.log(`"${s}"${
validate(s)
? " matches"
: " does not match"}
`)
)
Default exports can also be just values:
1 + 2 # 3 # OneTwoThree.ts 4 export-default "123" 5 # 6 # Log.ts 7 import num from "./OneTwoThree" 8 _ console.log(num)
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
//
export default "123";
//
import num from "./OneTwoThree";
console.log(num);
export = and import = require()
1 + 2 # 3 # ZipCodeValidator.ts 4 let numberRegexp = /^[0-9]+$/ 5 class ZipCodeValidator 6 m isAcceptable 7 param s 8 :string 9 return s.length === 5 && numberRegexp.test(s) 10 :export ZipCodeValidator 11 # 12 # Test.ts 13 :import zip 14 :require "./ZipCodeValidator" 15 let strings 16 [ 17 @ "Hello" 18 @ "98052" 19 @ "101" 20 let validator = new zip() 21 _ strings.forEach 22 => 23 param s 24 _ console.log 25 `lit 26 + " 27 @ s 28 + " - 29 iif validator.isAcceptable(s) 30 then "matches" 31 else "does not match" 32 +
{
"name": "WizziModelLoadError",
"message": "Error: Tag not recognized: :import, wzElement: undefined, wzName:, row:14, col:9, source:json:/index.ts.ittf\nIn ts Factory, calling loadFromNode.\nLoading ittf document json:/index.ts.ittf (@wizzi/factory.0.8.46)",
"inner": {
"message": "Tag not recognized: :import, wzElement: undefined, wzName:, row:14, col:9, source:json:/index.ts.ittf",
"errorLines": [
"0011 :export ZipCodeValidator",
"0012 # ",
"0013 # Test.ts",
"0014 :import zip",
" ^ Tag not recognized: :import <--- --- --- --- --- ERROR",
"0015 :require \"./ZipCodeValidator\"",
"0016 let strings",
"0017 [ ",
"0018 @ \"Hello\""
],
"stack": "Error\n at new tsModelException (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:6727:23)\n at /app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:936:23\n at Array.forEach (<anonymous>)\n at statement.loadFromNode (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:932:23)\n at tsBase.wzLoadToChildColl (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:114:18)\n at statement.loadChild (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:198:25)\n at xmodule.loadChild (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:999:48)\n at /app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:1005:31\n at Array.forEach (<anonymous>)\n at xmodule.loadFromNode (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:1003:23)"
},
"stack": "Error\n at new tsModelException (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:6727:23)\n at /app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:936:23\n at Array.forEach (<anonymous>)\n at statement.loadFromNode (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:932:23)\n at tsBase.wzLoadToChildColl (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:114:18)\n at statement.loadChild (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:198:25)\n at xmodule.loadChild (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:999:48)\n at /app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:1005:31\n at Array.forEach (<anonymous>)\n at xmodule.loadFromNode (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:1003:23)"
}
Code Generation for Modules
1 + 2 :import m 3 :require "mod" 4 export 5 let t = m.something + 1 6 # 7 # AMD / RequireJS SimpleModule.js 8 _ define 9 [ 10 @ "require" 11 @ "exports" 12 @ "./mod" 13 function 14 param require 15 param exports 16 param mod_1 17 set exports.t = mod_1.something + 1 18 # 19 # CommonJS / Node SimpleModule.js 20 var mod_1 = require("./mod") 21 set exports.t = mod_1.something + 1 22 # 23 # UMD SimpleModule.js 24 iife 25 param factory 26 if typeof module === "object" && typeof module.exports === "object" 27 var v = factory(require, exports) 28 if v !== undefined 29 set module.exports = v 30 else 31 if typeof define === "function" && define.amd 32 _ define 33 [ 34 @ "require" 35 @ "exports" 36 @ "./mod" 37 @ factory 38 () 39 function 40 param require 41 param exports 42 var mod_1 = require("./mod") 43 set exports.t = mod_1.something + 1 44 # 45 # System SimpleModule.js 46 _ System.register 47 [ 48 @ "./mod" 49 function 50 param exports_1 51 var mod_1 52 var t 53 return 54 { 55 [ setters 56 function 57 param mod_1_1 58 set mod_1 = mod_1_1 59 @ execute 60 function 61 _ exports_1 62 @ "t" 63 set t = mod_1.something + 1 64 # 65 # Native ECMAScript 2015 modules SimpleModule.js 66 import 67 @ something 68 from "./mod" 69 export 70 var t = something + 1
{
"name": "WizziModelLoadError",
"message": "Error: Tag not recognized: :import, wzElement: undefined, wzName:, row:3, col:9, source:json:/index.ts.ittf\nIn ts Factory, calling loadFromNode.\nLoading ittf document json:/index.ts.ittf (@wizzi/factory.0.8.46)",
"inner": {
"message": "Tag not recognized: :import, wzElement: undefined, wzName:, row:3, col:9, source:json:/index.ts.ittf",
"errorLines": [
"0001 module ",
"0002 + ",
"0003 :import m",
" ^ Tag not recognized: :import <--- --- --- --- --- ERROR",
"0004 :require \"mod\"",
"0005 export ",
"0006 let t = m.something + 1",
"0007 # "
],
"stack": "Error\n at new tsModelException (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:6727:23)\n at /app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:936:23\n at Array.forEach (<anonymous>)\n at statement.loadFromNode (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:932:23)\n at tsBase.wzLoadToChildColl (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:114:18)\n at statement.loadChild (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:198:25)\n at xmodule.loadChild (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:999:48)\n at /app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:1005:31\n at Array.forEach (<anonymous>)\n at xmodule.loadFromNode (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:1003:23)"
},
"stack": "Error\n at new tsModelException (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:6727:23)\n at /app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:936:23\n at Array.forEach (<anonymous>)\n at statement.loadFromNode (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:932:23)\n at tsBase.wzLoadToChildColl (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:114:18)\n at statement.loadChild (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:198:25)\n at xmodule.loadChild (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:999:48)\n at /app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:1005:31\n at Array.forEach (<anonymous>)\n at xmodule.loadFromNode (/app/node_modules/@wizzi/plugin.ts/lib/wizzi/models/ts-model.g.js:1003:23)"
}
Simple Example
1 + 2 # 3 # Validation.ts 4 export 5 :interface StringValidator 6 :m isAcceptable 7 :boolean 8 param s 9 :string 10 # 11 # LettersOnlyValidator.ts 12 import 13 @ StringValidator 14 from "./Validation" 15 const lettersRegexp = /^[A-Za-z]+$/ 16 export 17 class LettersOnlyValidator 18 :implements StringValidator 19 m isAcceptable 20 param s 21 :string 22 return lettersRegexp.test(s) 23 # 24 # ZipCodeValidator.ts 25 import 26 @ StringValidator 27 from "./Validation" 28 const numberRegexp = /^[0-9]+$/ 29 export 30 class ZipCodeValidator 31 :implements StringValidator 32 m isAcceptable 33 param s 34 :string 35 return s.length === 5 && numberRegexp.test(s) 36 # 37 # Test.ts 38 import 39 @ StringValidator 40 from "./Validation" 41 import 42 @ ZipCodeValidator 43 from "./ZipCodeValidator" 44 import 45 @ LettersOnlyValidator 46 from "./LettersOnlyValidator" 47 let strings 48 [ 49 @ "Hello" 50 @ "98052" 51 @ "101" 52 let validators 53 :{ 54 :index 55 :ref StringValidator 56 param s 57 :string 58 { 59 set validators["ZIP code"] = new ZipCodeValidator() 60 set validators["Letters only"] = new LettersOnlyValidator() 61 _ strings.forEach 62 => 63 param s 64 for let name in validators 65 _ console.log 66 `lit 67 + " 68 @ s 69 + " - 70 iif validators[name].isAcceptable(s) 71 then "matches" 72 else "does not match" 73 + 74 @ name 75 +
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
//
export interface StringValidator {
isAcceptable(s: string): boolean;
}
//
import {StringValidator} from "./Validation";
const lettersRegexp = /^[A-Za-z]+$/;
export class LettersOnlyValidator implements StringValidator {
isAcceptable(s: string) {
return lettersRegexp.test(s);
}
}
//
import {StringValidator} from "./Validation";
const numberRegexp = /^[0-9]+$/;
export class ZipCodeValidator implements StringValidator {
isAcceptable(s: string) {
return s.length === 5 && numberRegexp.test(s);
}
}
//
import {StringValidator} from "./Validation";
import {ZipCodeValidator} from "./ZipCodeValidator";
import {LettersOnlyValidator} from "./LettersOnlyValidator";
let strings = [
"Hello",
"98052",
"101"
];
let validators: {
[s: string]: StringValidator;
} = {};
validators["ZIP code"] = new ZipCodeValidator();
validators["Letters only"] = new LettersOnlyValidator();
strings.forEach((s) => {
for (let name in validators) {
console.log(`"${s}" -${
validators[name].isAcceptable(s)
? "matches"
: "does not match"}
${name}`)
}
}
)
Optional Module Loading
1 + 2 # 3 # Dynamic Module Loading in Node.js 4 :declare 5 :function require 6 param moduleName 7 :string 8 :return 9 :any 10 import 11 @ ZipCodeValidator 12 as Zip 13 from "./ZipCodeValidator" 14 if needZipValidation 15 let ZipCodeValidator 16 :typeof Zip 17 _ require("./ZipCodeValidator") 18 let validator = new ZipCodeValidator() 19 if validator.isAcceptable("...") 20 # 21 # Sample: Dynamic Module Loading in require.js 22 :declare 23 :function require 24 param moduleNames 25 :[ 26 :string 27 param onLoad 28 :=> 29 :void 30 param ...args 31 :[ 32 :any 33 :return 34 :void 35 import 36 as Zip 37 from "./ZipCodeValidator" 38 if needZipValidation 39 _ require 40 [ 41 @ "./ZipCodeValidator" 42 => 43 param ZipCodeValidator 44 :typeof Zip 45 let validator = new ZipCodeValidator.ZipCodeValidator() 46 if validator.isAcceptable("...") 47 # 48 # Sample: Dynamic Module Loading in System.js 49 :declare 50 const System 51 :any 52 import 53 @ ZipCodeValidator 54 as Zip 55 from "./ZipCodeValidator" 56 if needZipValidation 57 _ System.import("./ZipCodeValidator").then 58 => 59 param ZipCodeValidator 60 :typeof Zip 61 var x = new ZipCodeValidator() 62 if x.isAcceptable("...")
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
//
declare function require(moduleName: string): any;
import {ZipCodeValidator as Zip} from "./ZipCodeValidator";
if (needZipValidation) {
let ZipCodeValidator: typeof Zip = require("./ZipCodeValidator");
let validator = new ZipCodeValidator();
if (validator.isAcceptable("...")) {
}
}
//
declare function require(moduleNames: string[], onLoad: (...args: any[]) => void): void;
import * as Zip from "./ZipCodeValidator";
if (needZipValidation) {
require([
"./ZipCodeValidator"
], (ZipCodeValidator: typeof Zip) => {
let validator = new ZipCodeValidator.ZipCodeValidator();
if (validator.isAcceptable("...")) {
}
}
)
}
//
declare const System: any;
import {ZipCodeValidator as Zip} from "./ZipCodeValidator";
if (needZipValidation) {
System.import("./ZipCodeValidator").then((ZipCodeValidator: typeof Zip) => {
var x = new ZipCodeValidator();
if (x.isAcceptable("...")) {
}
}
)
}
Ambient Modules
1 + 2 # 3 # node.d.ts(simplified excerpt) 4 :declare 5 :module "url" 6 export 7 :interface Url 8 :p protocol 9 :optional 10 :string 11 :p hostname 12 :optional 13 :string 14 :p pathname 15 :optional 16 :string 17 export 18 :function parse 19 param urlStr 20 :string 21 param parseQueryString 22 :optional 23 param slashesDenoteHost 24 :optional 25 :return 26 :ref Url 27 :module "path" 28 export 29 :function normalize 30 param p 31 :string 32 :return 33 :string 34 export 35 :function join 36 param ...paths 37 :[ 38 :any 39 :return 40 :string 41 export 42 var sep 43 :string 44 # 45 # Now we can /// <reference> node.d.ts and then load the modules using import url = require("url"); or import * as URL from "url". 46 import 47 as URL 48 from "url" 49 let myUrl = URL.parse("http://www.typescriptlang.org")
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
//
declare module "url" {
export interface Url {
protocol?: string;
hostname?: string;
pathname?: string;
}
export function parse(urlStr: string, parseQueryString?, slashesDenoteHost?): Url;
}
declare module "path" {
export function normalize(p: string): string;
export function join(...paths: any[]): string;
export var sep: string;
}
//
import * as URL from "url";
let myUrl = URL.parse("http://www.typescriptlang.org");
Shorthand ambient modules
1 + 2 # 3 # declarations.d.ts 4 :declare 5 :module "hot-new-module" 6 # 7 # All imports from a shorthand module will have the any type. 8 import x 9 @ y 10 from "hot-new-module" 11 _ x(y)
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
//
declare module "hot-new-module" {
}
//
import x, {y} from "hot-new-module";
x(y);
Wildcard module declarations
1 + 2 :declare 3 :module "*!text" 4 const content 5 :string 6 export-default content 7 :module "json!*" 8 const value 9 :any 10 export-default value 11 # 12 # Now you can import things that match "*!text" or "json!*". 13 import fileContent from "./xyz.txt!text" 14 import data from "json!http://example.com/data.json" 15 _ console.log(data, fileContent)
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
declare module "*!text" {
const content: string;
export default content;
}
declare module "json!*" {
const value: any;
export default value;
}
//
import fileContent from "./xyz.txt!text";
import data from "json!http://example.com/data.json";
console.log(data, fileContent);
UMD modules
1 + 2 # 3 # math-lib.d.ts 4 export 5 :function isPrime 6 param x 7 :number 8 :return 9 :boolean 10 :export-ns mathLib 11 # 12 # The library can then be used as an import within modules: 13 import 14 @ isPrime 15 from "math-lib" 16 _ isPrime(2) 17 _ mathLib.isPrime(2) 18 # 19 # It can also be used as a global variable, but only inside of a script. (A script is a file with no imports or exports.) 20 _ mathLib.isPrime(2)
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
//
export function isPrime(x: number): boolean;
export as namespace
;
//
import {isPrime} from "math-lib";
isPrime(2);
mathLib.isPrime(2);
//
mathLib.isPrime(2);
Export as close to top-level as possible
1 + 2 export-default 3 class SomeType 4 ctor 5 # 6 # MyFunc.ts 7 export-default 8 function getThing 9 return "thing" 10 # 11 # Consumer.ts 12 import t from "./MyClass" 13 import f from "./MyFunc" 14 let x = new t() 15 _ console.log(f()) 16 # 17 # This is optimal for consumers. 18 # They can name your type whatever they want (t in this case) and don’t have to do any excessive dotting to find your objects. 19 # If you’re exporting multiple objects, put them all at top- level 20 # MyThings.ts 21 export 22 class SomeType 23 export 24 function someFunc 25 # 26 # Conversely when importing: 27 # Explicitly list imported names 28 # Consumer.ts 29 import 30 @ SomeType 31 @ someFunc 32 from "./MyThings" 33 let x = new SomeType() 34 let y = someFunc() 35 # 36 # Use the namespace import pattern if you’re importing a large number of things 37 # MyLargeModule.ts 38 export 39 class Dog 40 export 41 class Cat 42 export 43 class Tree 44 export 45 class Flower 46 # 47 # Consumer.ts 48 import 49 as myLargeModule 50 from "./MyLargeModule.ts" 51 let x = new myLargeModule.Dog()
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
export default class SomeType {
constructor() {
}
}
//
export default function getThing() {
return "thing";
}
//
import t from "./MyClass";
import f from "./MyFunc";
let x = new t();
console.log(f());
//
export class SomeType {
}
export function someFunc() {
}
//
import {SomeType, someFunc} from "./MyThings";
let x = new SomeType();
let y = someFunc();
//
export class Dog {
}
export class Cat {
}
export class Tree {
}
export class Flower {
}
//
import * as myLargeModule from "./MyLargeModule.ts";
let x = new myLargeModule.Dog();
Re -export to extend
1 + 2 export 3 class Calculator 4 p current 5 :private 6 := 0 7 p memory 8 :private 9 := 0 10 p operator 11 :private 12 :string 13 m processDigit 14 :protected 15 param digit 16 :string 17 param currentValue 18 :number 19 if digit >= "0" && digit <= "9" 20 return currentValue * 10 + (digit.charCodeAt(0) - "0".charCodeAt(0)) 21 m processOperator 22 :protected 23 param operator 24 :string 25 if 26 test 27 >= 28 [ 29 @ "+" 30 @ "-" 31 @ "*" 32 @ "/" 33 ._ indexOf 34 @ operator 35 + 0 36 return operator 37 m evaluateOperator 38 :protected 39 param operator 40 :string 41 param left 42 :number 43 param right 44 :number 45 :return 46 :number 47 switch this.operator 48 case "+" 49 return left + right 50 case "-" 51 return left - right 52 case "*" 53 return left * right 54 case "/" 55 return left / right 56 m evaluate 57 :private 58 if this.operator 59 set this.memory = this.evaluateOperator(this.operator, this.memory, this.current) 60 else 61 set this.memory = this.current 62 set this.current = 0 63 m handleChar 64 :public 65 param char 66 :string 67 if char === "=" 68 _ this.evaluate 69 return 70 else 71 let value = this.processDigit(char, this.current) 72 if value !== undefined 73 set this.current = value 74 return 75 else 76 let value = this.processOperator(char) 77 if value !== undefined 78 _ this.evaluate 79 set this.operator = value 80 return 81 throw 82 new Error 83 `lit 84 + Unsupported input: ' 85 @ char 86 + ' 87 m getResult 88 :public 89 return this.memory 90 export 91 function test 92 param c 93 :ref Calculator 94 param input 95 :string 96 for let i = 0; i < input.length; i++ 97 _ c.handleChar(input[i]) 98 _ console.log 99 `lit 100 + result of ' 101 @ input 102 + ' is ' 103 _ c.getResult 104 + ' 105 # 106 # Here is a simple test for the calculator using the exposed test function. 107 # 108 # TestCalculator.ts 109 import 110 @ Calculator 111 @ test 112 from "./Calculator" 113 let c = new Calculator() 114 _ test(c, "1+2*33/11=") 115 # 116 # Now to extend this to add support for input with numbers in bases other than 10, let’s create ProgrammerCalculator.ts 117 # ProgrammerCalculator.ts 118 import 119 @ Calculator 120 from "./Calculator" 121 class ProgrammerCalculator 122 super Calculator 123 p digits 124 static 125 [ 126 @ "0" 127 @ "1" 128 @ "2" 129 @ "3" 130 @ "4" 131 @ "5" 132 @ "6" 133 @ "7" 134 @ "8" 135 @ "9" 136 @ "A" 137 @ "B" 138 @ "C" 139 @ "D" 140 @ "E" 141 @ "F" 142 ctor 143 param base 144 :public 145 :number 146 _ super 147 const maxBase = ProgrammerCalculator.digits.length 148 if base <= 0 || base > maxBase 149 throw 150 new Error 151 `lit 152 + base has to be within 0 to 153 @ maxBase 154 + inclusive. 155 m processDigit 156 :protected 157 param digit 158 :string 159 param currentValue 160 :number 161 if ProgrammerCalculator.digits.indexOf(digit) >= 0 162 return currentValue * this.base + ProgrammerCalculator.digits.indexOf(digit) 163 export 164 @ ProgrammerCalculator 165 as Calculator 166 export 167 @ test 168 from "./Calculator" 169 # 170 # The new module ProgrammerCalculator exports an API shape similar to that of the original Calculator module, 171 # but does not augment any objects in the original module. Here is a test for our ProgrammerCalculator class: 172 # TestProgrammerCalculator.ts 173 import 174 @ Calculator 175 @ test 176 from "./ProgrammerCalculator" 177 let c = new Calculator(2) 178 _ test(c, "001+010=")
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
export class Calculator {
private current = 0;
private memory = 0;
private operator: string;
protected processDigit(digit: string, currentValue: number) {
if (digit >= "0" && digit <= "9") {
return currentValue * 10 + (digit.charCodeAt(0) - "0".charCodeAt(0));
}
}
protected processOperator(operator: string) {
if (([
"+",
"-",
"*",
"/"
].indexOf(operator)) >= 0) {
return operator;
}
}
protected evaluateOperator(operator: string, left: number, right: number): number {
switch (this.operator) {
case "+": {
return left + right;
}
case "-": {
return left - right;
}
case "*": {
return left * right;
}
case "/": {
return left / right;
}
}
}
private evaluate() {
if (this.operator) {
this.memory = this.evaluateOperator(this.operator, this.memory, this.current);
}
else {
this.memory = this.current;
}
this.current = 0;
}
public handleChar(char: string) {
if (char === "=") {
this.evaluate();
return ;
}
else {
let value = this.processDigit(char, this.current);
if (value !== undefined) {
this.current = value;
return ;
}
else {
let value = this.processOperator(char);
if (value !== undefined) {
this.evaluate();
this.operator = value;
return ;
}
}
}
throw new Error(`Unsupported input: '${char}'`);
}
public getResult() {
return this.memory;
}
}
export function test(c: Calculator, input: string) {
for (let i = 0; i < input.length; i++) {
c.handleChar(input[i]);
}
console.log(`result of '${input}' is '${c.getResult()}'`)
}
//
//
import {Calculator, test} from "./Calculator";
let c = new Calculator();
test(c, "1+2*33/11=");
//
import {Calculator} from "./Calculator";
class ProgrammerCalculator extends Calculator {
constructor(public base: number) {
super();
const maxBase = ProgrammerCalculator.digits.length;
if (base <= 0 || base > maxBase) {
throw new Error(`base has to be within 0 to${maxBase}inclusive.`);
}
}
static digits = [
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"A",
"B",
"C",
"D",
"E",
"F"
];
protected processDigit(digit: string, currentValue: number) {
if (ProgrammerCalculator.digits.indexOf(digit) >= 0) {
return currentValue * this.base + ProgrammerCalculator.digits.indexOf(digit);
}
}
}
export {ProgrammerCalculator as Calculator};
export {test} from "./Calculator";
//
import {Calculator, test} from "./ProgrammerCalculator";
let c = new Calculator(2);
test(c, "001+010=");
Boolean
1 let isDone 2 :boolean 3 := false
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
let isDone: boolean = false;
Number
1 let decimal 2 :number 3 := 6
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
let decimal: number = 6;
String
1 let color 2 :string 3 := "blue"
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
let color: string = "blue";
String literal 1
1 let fullName 2 :string 3 `lit 4 + Bob Bobbington
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
let fullName: string = `Bob Bobbington`;
String literal 2
1 let sentence 2 :string 3 `lit 4 + Hello, my name is 5 @ fullName 6 +
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
let sentence: string = `Hello, my name is${fullName}`;
String literal 3
1 let sentence 2 :string 3 set "Hello, my name is " + fullName + ".\n\n" + "I'll be " + (age + 1) + " years old next month."
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
let sentence: string = "Hello, my name is " + fullName + ".\n\n" + "I'll be " + (age + 1) + " years old next month.";
Array 1
1 let list 2 :[ 3 :number 4 [ 5 @ 1 6 @ 2 7 @ 3
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
let list: number[] = [
1,
2,
3
];
Array 2
1 let list 2 :ref Array 3 :param number 4 [ 5 @ 1 6 @ 2 7 @ 3
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
let list: Array<number> = [
1,
2,
3
];
Tuple
1 let x 2 :tuple 3 :string 4 :number
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
let x = [string , number];
Enum
1 + 2 :enum Color 3 @ Red 4 @ Green 5 @ Blue 6 let c 7 :ref Color 8 := Color.Green 9 :enum Color 10 @ Red 1 11 @ Green 12 @ Blue 13 let c 14 :ref Color 15 := Color.Green 16 :enum Color 17 @ Red 1 18 @ Green 2 19 @ Blue 4 20 let c 21 :ref Color 22 := Color.Green 23 :enum Color 24 @ Red 1 25 @ Green 26 @ Blue 27 let colorName 28 :string 29 := Color[2]
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
enum Color {
Red ,
Green ,
Blue
}
let c: Color = Color.Green;
enum Color {
Red = 1 ,
Green ,
Blue
}
let c: Color = Color.Green;
enum Color {
Red = 1 ,
Green = 2 ,
Blue = 4
}
let c: Color = Color.Green;
enum Color {
Red = 1 ,
Green ,
Blue
}
let colorName: string = Color[2];
Any, Void, Null, Undefined
1 + 2 let notSure 3 :any 4 := 4 5 set notSure = "maybe a string instead" 6 set notSure = false 7 let notSure 8 :any 9 := 4 10 _ notSure.ifItExists 11 _ notSure.toFixed 12 let prettySure 13 :ref Object 14 := 4 15 _ prettySure.toFixed 16 let list 17 :[ 18 :any 19 [ 20 @ 1 21 @ true 22 @ "free" 23 set list[1] = 100 24 function warnUser 25 :return 26 :void 27 _ console.log("This is my warning message") 28 let unusable 29 :void 30 := undefined 31 let u 32 :void 33 := undefined 34 let n 35 :null 36 := null
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
let notSure: any = 4;
notSure = "maybe a string instead";
notSure = false;
let notSure: any = 4;
notSure.ifItExists();
notSure.toFixed();
let prettySure: Object = 4;
prettySure.toFixed();
let list: any[] = [
1,
true,
"free"
];
list[1] = 100;
function warnUser(): void {
console.log("This is my warning message");
}
let unusable: void = undefined;
let u: void = undefined;
let n: null = null;
Never
1 + 2 function error 3 param message 4 :string 5 :return 6 :never 7 throw new Error(message) 8 function fail 9 return error("Something failed") 10 function infiniteLoop 11 :return 12 :never 13 while true
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function error(message: string): never {
throw new Error(message);
}
function fail() {
return error("Something failed");
}
function infiniteLoop(): never {
while (true) {
}
}
Object
1 + 2 :function create 3 param o 4 :union 5 :object 6 :null 7 :return 8 :void 9 let strLength 10 :number 11 := 12 () 13 @id someValue 14 :as 15 :string 16 . length
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function create(o: object | null): void;
let strLength: number = (someValue as string).length;
Typed functions 1
1 + 2 function add 3 param x 4 :number 5 param y 6 :number 7 :return 8 :number 9 return x + y 10 let myAdd 11 function 12 param x 13 :number 14 param y 15 :number 16 :return 17 :number 18 return x + y
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function add(x: number, y: number): number {
return x + y;
}
let myAdd = function(x: number, y: number): number {
return x + y;
};
Typed functions 2
1 let myAdd 2 :=> 3 :number 4 param x 5 :number 6 param y 7 :number 8 function 9 param x 10 :number 11 param y 12 :number 13 :return 14 :number 15 return x + y
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
let myAdd: (x: number, y: number) => number = function(x: number, y: number): number {
return x + y;
};
Optional parameters
1 + 2 function buildName 3 param firstName 4 :string 5 param lastName 6 :string 7 :optional 8 if lastName 9 return firstName + " " + lastName 10 else 11 return firstName 12 # error, too few parameters 13 let result1 = buildName("Bob") 14 # error, too many parameters 15 let result2 = buildName("Bob", "Adams", "Sr.") 16 # ah, just right 17 let result3 = buildName("Bob", "Adams")
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function buildName(firstName: string, lastName?: string) {
if (lastName) {
return firstName + " " + lastName;
}
else {
return firstName;
}
}
// error, too few parameters
let result1 = buildName("Bob");
// error, too many parameters
let result2 = buildName("Bob", "Adams", "Sr.");
// ah, just right
let result3 = buildName("Bob", "Adams");
Rest parameters
1 + 2 function buildName 3 param firstName 4 :string 5 param ...restOfName 6 :[ 7 :string 8 return firstName + " " + restOfName.join(" ") 9 let buildNameFun 10 :=> 11 :string 12 param fname 13 :string 14 param ...rest 15 :[ 16 :string 17 := buildName
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function buildName(firstName: string, ...restOfName: string[]) {
return firstName + " " + restOfName.join(" ");
}
let buildNameFun: (fname: string, ...rest: string[]) => string = buildName;
This and arrow functions
1 let deck 2 { 3 [ suits 4 @ "hearts" 5 @ "spades" 6 @ "clubs" 7 @ "diamonds" 8 @ cards Array(52) 9 @ createCardPicker 10 function 11 # NOTE: the line below is now an arrow function, allowing us to capture 'this' right here 12 return 13 => 14 let pickedCard = Math.floor(Math.random() * 52) 15 let pickedSuit = Math.floor(pickedCard / 13) 16 return 17 { 18 @ suit this.suits[pickedSuit] 19 @ card pickedCard % 13
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
let deck = {
suits: [
"hearts",
"spades",
"clubs",
"diamonds"
],
cards: Array(52),
createCardPicker: // NOTE: the line below is now an arrow function, allowing us to capture 'this' right here
function() {
return () => {
let pickedCard = Math.floor(Math.random() * 52);
let pickedSuit = Math.floor(pickedCard / 13);
return {
suit: this.suits[pickedSuit],
card: pickedCard % 13
};
}
;
}
};
This parameters in callbacks
1 + 2 :interface UIElement 3 :m addClickListener 4 :void 5 param onclick 6 :=> 7 :void 8 param this 9 :void 10 param e 11 :ref Event 12 class Handler 13 p info 14 :string 15 m onClickBad 16 param this 17 :ref Handler 18 param e 19 :ref Event 20 set this.info = e.message
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface UIElement {
addClickListener(onclick: (this: void, e: Event) => void): void;
}
class Handler {
info: string;
onClickBad(this: Handler, e: Event) {
this.info = e.message;
}
}
Overloads 1
1 + 2 let suits 3 [ 4 @ "hearts" 5 @ "spades" 6 @ "clubs" 7 @ "diamonds" 8 function pickCard 9 param x 10 :return 11 :any 12 if typeof x == "object" 13 let pickedCard = Math.floor(Math.random() * x.length) 14 return pickedCard 15 else 16 # Otherwise just let them pick the card 17 if typeof x == "number" 18 let pickedSuit = Math.floor(x / 13) 19 return 20 { 21 @ suit suits[pickedSuit] 22 @ card x % 13
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
let suits = [
"hearts",
"spades",
"clubs",
"diamonds"
];
function pickCard(x): any {
if (typeof x == "object") {
let pickedCard = Math.floor(Math.random() * x.length);
return pickedCard;
}
// Otherwise just let them pick the card
else {
if (typeof x == "number") {
let pickedSuit = Math.floor(x / 13);
return {
suit: suits[pickedSuit],
card: x % 13
};
}
}
}
Overloads 2
1 + 2 let suits 3 [ 4 @ "hearts" 5 @ "spades" 6 @ "clubs" 7 @ "diamonds" 8 :function pickCard 9 param x 10 :[ 11 :{ 12 :p suit 13 :string 14 :p card 15 :number 16 :return 17 :number 18 :function pickCard 19 param x 20 :number 21 :return 22 :{ 23 :p suit 24 :string 25 :p card 26 :number 27 function pickCard 28 param x 29 :return 30 :any 31 # if so, they gave us the deck and we'll pick the card 32 if typeof x == "object" 33 let pickedCard = Math.floor(Math.random() * x.length) 34 return pickedCard 35 else 36 # Otherwise just let them pick the card 37 if typeof x == "number" 38 let pickedSuit = Math.floor(x / 13) 39 return 40 { 41 @ suit suits[pickedSuit] 42 @ card x % 13
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
let suits = [
"hearts",
"spades",
"clubs",
"diamonds"
];
function pickCard(x: {
suit: string;
card: number;
}[]): number;
function pickCard(x: number): {
suit: string;
card: number;
};
// if so, they gave us the deck and we'll pick the card
function pickCard(x): any {
if (typeof x == "object") {
let pickedCard = Math.floor(Math.random() * x.length);
return pickedCard;
}
// Otherwise just let them pick the card
else {
if (typeof x == "number") {
let pickedSuit = Math.floor(x / 13);
return {
suit: suits[pickedSuit],
card: x % 13
};
}
}
}
Simple class
1 class Greeter 2 p greeting 3 :string 4 ctor 5 param message 6 :string 7 set this.greeting = message 8 m greet 9 return "Hello, " + this.greeting
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
class Greeter {
constructor(message: string) {
this.greeting = message;
}
greeting: string;
greet() {
return "Hello, " + this.greeting;
}
}
let greeter = new Greeter("world");
Class extension
1 class Animal 2 m move 3 param distanceInMeters 4 :number 5 := 0 6 _ console.log 7 `lit 8 + Animal moved 9 @ distanceInMeters 10 + m.
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
class Animal {
move(distanceInMeters: number = 0) {
console.log(`Animal moved${distanceInMeters}m.`)
}
}
class Dog extends Animal {
bark() {
console.log('Woof! Woof!');
}
}
Complex class example
1 + 2 class Animal 3 p name 4 :string 5 ctor 6 param theName 7 :string 8 set this.name = theName 9 m move 10 param distanceInMeters 11 :number 12 := 0 13 _ console.log 14 `lit 15 + 16 @ this.name 17 + moved 18 @ distanceInMeters 19 + m. 20 class Snake 21 super Animal 22 ctor 23 param name 24 :string 25 _ super(name) 26 m move 27 param distanceInMeters = 5 28 _ console.log("Slithering...") 29 _ super.move(distanceInMeters) 30 class Horse 31 super Animal 32 ctor 33 param name 34 :string 35 _ super(name) 36 m move 37 param distanceInMeters = 45 38 _ console.log("Galloping...") 39 _ super.move(distanceInMeters)
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
class Animal {
constructor(theName: string) {
this.name = theName;
}
name: string;
move(distanceInMeters: number = 0) {
console.log(`${this.name}moved${distanceInMeters}m.`)
}
}
class Snake extends Animal {
constructor(name: string) {
super(name);
}
move(distanceInMeters = 5) {
console.log("Slithering...");
super.move(distanceInMeters);
}
}
class Horse extends Animal {
constructor(name: string) {
super(name);
}
move(distanceInMeters = 45) {
console.log("Galloping...");
super.move(distanceInMeters);
}
}
Class accessors
1 + 2 class Animal 3 p name 4 :private 5 :string 6 ctor 7 param theName 8 :string 9 set this.name = theName 10 class Rhino 11 super Animal 12 ctor 13 _ super("Rhino") 14 class Employee 15 p name 16 :private 17 :string 18 ctor 19 param theName 20 :string 21 set this.name = theName 22 let animal = new Animal("Goat") 23 let rhino = new Rhino() 24 let employee = new Employee("Bob") 25 set animal = rhino 26 set animal = employee
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
class Animal {
constructor(theName: string) {
this.name = theName;
}
private name: string;
}
class Rhino extends Animal {
constructor() {
super("Rhino");
}
}
class Employee {
constructor(theName: string) {
this.name = theName;
}
private name: string;
}
let animal = new Animal("Goat");
let rhino = new Rhino();
let employee = new Employee("Bob");
animal = rhino;
animal = employee;
Class accessors
1 + 2 class Person 3 p name 4 :protected 5 :string 6 ctor 7 param name 8 :string 9 set this.name = name 10 class Employee 11 super Person 12 p department 13 :private 14 :string 15 ctor 16 param name 17 :string 18 param department 19 :string 20 _ super(name) 21 set this.department = department 22 m getElevatorPitch 23 :public 24 return 25 `lit 26 + Hello, my name is 27 @ this.name 28 + and I work in 29 @ this.department 30 + .
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
class Person {
constructor(name: string) {
this.name = name;
}
protected name: string;
}
class Employee extends Person {
constructor(name: string, department: string) {
super(name);
this.department = department;
}
private department: string;
public getElevatorPitch() {
return `Hello, my name is${this.name}and I work in${this.department}.`;
}
}
Readonly modifier
1 + 2 class Octopus 3 p name 4 :readonly 5 :string 6 p numberOfLegs 7 :readonly 8 :number 9 := 8 10 ctor 11 param theName 12 :string 13 set this.name = theName 14 let dad = new Octopus("Man with the 8 strong legs") 15 set dad.name = "Man with the 3-piece suit"
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
class Octopus {
constructor(theName: string) {
this.name = theName;
}
readonly name: string;
readonly numberOfLegs: number = 8;
}
let dad = new Octopus("Man with the 8 strong legs");
dad.name = "Man with the 3-piece suit";
Parameter properties
1 + 2 class Octopus 3 p numberOfLegs 4 :readonly 5 :number 6 := 8 7 ctor 8 param 9 :readonly 10 :string
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
class Octopus {
constructor(readonly : string) {
}
readonly numberOfLegs: number = 8;
}
Static members
1 class Grid 2 p origin 3 static 4 { 5 @ x 0 6 @ y 0 7 m calculateDistanceFromOrigin 8 param point 9 :{ 10 :p x 11 :number 12 :p y 13 :number 14 let xDist = (point.x - Grid.origin.x) 15 let yDist = (point.y - Grid.origin.y) 16 return Math.sqrt(xDist * xDist + yDist * yDist) / this.scale 17 ctor 18 param scale 19 :public 20 :number
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
class Grid {
constructor(public scale: number) {
}
static origin = {
x: 0,
y: 0
}
;
calculateDistanceFromOrigin(point: {
x: number;
y: number;
}) {
let xDist = (point.x - Grid.origin.x);
let yDist = (point.y - Grid.origin.y);
return Math.sqrt(xDist * xDist + yDist * yDist) / this.scale;
}
}
Abstract classes 1
1 + 2 class Animal 3 :abstract 4 :m makeSound 5 :abstract 6 :return 7 :void 8 m move 9 :return 10 :void 11 _ console.log("roaming the earth...")
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
abstract class Animal {
abstract makeSound(): void {
}
move(): void {
console.log("roaming the earth...");
}
}
Abstract classes 2
1 + 2 class Department 3 :abstract 4 ctor 5 param name 6 :public 7 :string 8 m printName 9 :return 10 :void 11 _ console.log("Department name: " + this.name) 12 :m printMeeting 13 :abstract 14 :return 15 :void 16 class AccountingDepartment 17 super Department 18 ctor 19 _ super("Accounting and Auditing") 20 m printMeeting 21 :return 22 :void 23 _ console.log("The Accounting Department meets each Monday at 10am.") 24 m generateReports 25 :return 26 :void 27 _ console.log("Generating accounting reports...") 28 let department 29 :ref Department 30 set department = new Department() 31 set department = new AccountingDepartment() 32 _ department.printName 33 _ department.printMeeting 34 _ department.generateReports 35 # error: method doesn't exist on declared abstract type
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
abstract class Department {
constructor(public name: string) {
}
printName(): void {
console.log("Department name: " + this.name);
}
abstract printMeeting(): void {
}
}
class AccountingDepartment extends Department {
constructor() {
super("Accounting and Auditing");
}
printMeeting(): void {
console.log("The Accounting Department meets each Monday at 10am.");
}
generateReports(): void {
console.log("Generating accounting reports...");
}
}
let department: Department;
department = new Department();
department = new AccountingDepartment();
department.printName();
department.printMeeting();
department.generateReports();
// error: method doesn't exist on declared abstract type
Static members
1 + 2 class Greeter 3 p standardGreeting 4 static 5 := "Hello, there" 6 p greeting 7 :string 8 m greet 9 if this.greeting 10 return "Hello, " + this.greeting 11 else 12 return Greeter.standardGreeting
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
class Greeter {
static standardGreeting = "Hello, there";
greeting: string;
greet() {
if (this.greeting) {
return "Hello, " + this.greeting;
}
else {
return Greeter.standardGreeting;
}
}
}
Class extended by interface
1 + 2 class Point 3 p x 4 :number 5 p y 6 :number 7 :interface Point3d 8 :extends Point 9 :p z 10 :number 11 let point3d 12 :ref Point3d 13 { 14 @ x 1 15 @ y 2 16 @ z 3
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
class Point {
x: number;
y: number;
}
interface Point3d extends Point {
z: number;
}
let point3d: Point3d = {
x: 1,
y: 2,
z: 3
};
Simple interface
1 :interface LabelledValue 2 :p label 3 :string
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface LabelledValue {
label: string;
}
Reference to interface
1 + 2 function printLabel 3 param labelledObj 4 :ref LabelledValue 5 _ console.log(labelledObj.label) 6 let myObj 7 { 8 @ size 10 9 @ label "Size 10 Object" 10 _ printLabel(myObj)
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function printLabel(labelledObj: LabelledValue) {
console.log(labelledObj.label);
}
let myObj = {
size: 10,
label: "Size 10 Object"
};
printLabel(myObj);
Optional properties
1 :interface SquareConfig 2 :p color 3 :optional 4 :string 5 :p width 6 :optional 7 :number
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface SquareConfig {
color?: string;
width?: number;
}
Optional properties 2
1 + 2 :interface SquareConfig 3 :p color 4 :optional 5 :string 6 :p width 7 :optional 8 :number 9 function createSquare 10 param config 11 :ref SquareConfig 12 :return 13 :{ 14 :p color 15 :string 16 :p area 17 :number 18 let newSquare 19 { 20 @ color "white" 21 @ area 100 22 if config.clor 23 # Error: Property 'clor' does not exist on type 'SquareConfig' 24 set newSquare.color = config.clor 25 if config.width 26 set newSquare.area = config.width * config.width 27 return newSquare 28 let mySquare 29 _ createSquare 30 { 31 @ color "black"
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface SquareConfig {
color?: string;
width?: number;
}
function createSquare(config: SquareConfig): {
color: string;
area: number;
} {
let newSquare = {
color: "white",
area: 100
};
// Error: Property 'clor' does not exist on type 'SquareConfig'
if (config.clor) {
newSquare.color = config.clor;
}
if (config.width) {
newSquare.area = config.width * config.width;
}
return newSquare;
}
let mySquare = createSquare({
color: "black"
});
Readonly properties
1 + 2 :interface Point 3 :p x 4 :number 5 :p y 6 :number 7 # You can construct a Point by assigning an object literal.After the assignment, x and y can’t be changed. 8 let p1 9 :ref Point 10 { 11 @ x 10 12 @ y 20 13 # error! 14 set p1.x = 5
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface Point {
x: number;
y: number;
}
// You can construct a Point by assigning an object literal.After the assignment, x and y can’t be changed.
let p1: Point = {
x: 10,
y: 20
};
// error!
p1.x = 5;
Readonly vs const
1 + 2 :interface SquareConfig 3 :p color 4 :optional 5 :string 6 :p width 7 :optional 8 :number 9 function createSquare 10 param config 11 :ref SquareConfig 12 :return 13 :{ 14 :p color 15 :string 16 :p area 17 :number 18 let mySquare 19 _ createSquare 20 { 21 @ colour "red" 22 @ width 100
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface SquareConfig {
color?: string;
width?: number;
}
function createSquare(config: SquareConfig): {
color: string;
area: number;
} {
}
let mySquare = createSquare({
colour: "red",
width: 100
});
Call signature
1 + 2 :interface SearchFunc 3 :call 4 :boolean 5 param source 6 :string 7 param subString 8 :string 9 let mySearch 10 :ref SearchFunc 11 set mySearch = 12 function 13 param source 14 :string 15 param subString 16 :string 17 let result = source.search(subString) 18 return result > -1
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface SearchFunc {
(source: string, subString: string): boolean;
}
let mySearch: SearchFunc;
mySearch = function(source: string, subString: string) {
let result = source.search(subString);
return result > -1;
}
;
Index signature
1 + 2 :interface StringArray 3 :index 4 :string 5 param index 6 :number 7 let myArray 8 :ref StringArray 9 set myArray = 10 [ 11 @ "Bob" 12 @ "Fred" 13 let myStr 14 :string 15 := myArray[0]
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface StringArray {
[index: number]: string;
}
let myArray: StringArray;
myArray = [
"Bob",
"Fred"
];
let myStr: string = myArray[0];
Index signature 2
1 + 2 class Animal 3 p name 4 :string 5 class Dog 6 super Animal 7 p breed 8 :string 9 :interface NotOkay 10 :index 11 :ref Animal 12 param x 13 :number 14 :index 15 :ref Dog 16 param x 17 :string
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
class Animal {
name: string;
}
class Dog extends Animal {
breed: string;
}
interface NotOkay {
[x: number]: Animal;
[x: string]: Dog;
}
Index signature 3
1 :interface NumberDictionary 2 :index 3 :number 4 param index 5 :string 6 :p length 7 :number 8 :p name 9 :string
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface NumberDictionary {
[index: string]: number;
length: number;
name: string;
}
Readonly index signature 3
1 + 2 :interface ReadonlyStringArray 3 :index 4 :string 5 :readonly 6 param index 7 :number 8 let myArray 9 :ref ReadonlyStringArray 10 [ 11 @ "Alice" 12 @ "Bob" 13 set myArray[2] = "Mallory"
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface ReadonlyStringArray {
readonly [index: number]: string;
}
let myArray: ReadonlyStringArray = [
"Alice",
"Bob"
];
myArray[2] = "Mallory";
Class Types
1 + 2 :interface ClockInterface 3 :p currentTime 4 :ref Date 5 class Clock 6 :implements ClockInterface 7 p currentTime 8 :ref Date 9 ctor 10 param h 11 :number 12 param m 13 :number 14 :interface ClockInterface 15 :p currentTime 16 :ref Date 17 :m setTime 18 param d 19 :ref Date 20 class Clock 21 :extends ClockInterface 22 p currentTime 23 :ref Date 24 m setTime 25 param d 26 :ref Date 27 set this.currentTime = d 28 ctor 29 param h 30 :number 31 param m 32 :number
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface ClockInterface {
currentTime: Date;
}
class Clock implements ClockInterface {
constructor(h: number, m: number) {
}
currentTime: Date;
}
interface ClockInterface {
currentTime: Date;
setTime(d: Date);
}
class Clock extends ClockInterface {
constructor(h: number, m: number) {
}
currentTime: Date;
setTime(d: Date) {
this.currentTime = d;
}
}
static and instance sides of classes - fails
1 + 2 :interface ClockConstructor 3 :new 4 param hour 5 :number 6 param minute 7 :number 8 class Clock 9 :implements ClockConstructor 10 p currentTime 11 :ref Date 12 ctor 13 param h 14 :number 15 param m 16 :number
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface ClockConstructor {
(hour: number, minute: number);
}
class Clock implements ClockConstructor {
constructor(h: number, m: number) {
}
currentTime: Date;
}
static and instance sides of classes - succeds
1 + 2 :interface ClockConstructor 3 :new 4 :ref ClockInterface 5 param hour 6 :number 7 param minute 8 :number 9 :interface ClockInterface 10 :m tick 11 function createClock 12 param ctor 13 :ref ClockConstructor 14 param hour 15 :number 16 param minute 17 :number 18 :return 19 :ref ClockInterface 20 return new ctor(hour, minute) 21 class DigitalClock 22 :implements ClockInterface 23 ctor 24 param h 25 :number 26 param m 27 :number 28 m tick 29 _ console.log("beep beep") 30 class AnalogClock 31 :implements ClockInterface 32 ctor 33 param h 34 :number 35 param m 36 :number 37 m tick 38 _ console.log("tick tock") 39 let digital = createClock(DigitalClock, 12, 17) 40 let analog = createClock(AnalogClock, 7, 32)
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface ClockConstructor {
(hour: number, minute: number): ClockInterface;
}
interface ClockInterface {
tick();
}
function createClock(ctor: ClockConstructor, hour: number, minute: number): ClockInterface {
return new ctor(hour, minute);
}
class DigitalClock implements ClockInterface {
constructor(h: number, m: number) {
}
tick() {
console.log("beep beep");
}
}
class AnalogClock implements ClockInterface {
constructor(h: number, m: number) {
}
tick() {
console.log("tick tock");
}
}
let digital = createClock(DigitalClock, 12, 17);
let analog = createClock(AnalogClock, 7, 32);
Extending Interfaces 1
1 + 2 :interface Shape 3 :p color 4 :string 5 :interface Square 6 :extends Shape 7 :p sideLength 8 :number 9 let square 10 { 11 :as 12 :ref Square 13 set square.color = "blue" 14 set square.sideLength = 10
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface Shape {
color: string;
}
interface Square extends Shape {
sideLength: number;
}
let square = {} as Square;
square.color = "blue";
square.sideLength = 10;
Extending Interfaces 2
1 + 2 :interface Shape 3 :p color 4 :string 5 :interface PenStroke 6 :p penWidth 7 :number 8 :interface Square 9 :extends Shape 10 :extends PenStroke 11 :p sideLength 12 :number 13 let square 14 { 15 :as 16 :ref Square 17 set square.color = "blue" 18 set square.sideLength = 10 19 set square.penWidth = 5
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface Shape {
color: string;
}
interface PenStroke {
penWidth: number;
}
interface Square extends Shape, PenStroke {
sideLength: number;
}
let square = {} as Square;
square.color = "blue";
square.sideLength = 10;
square.penWidth = 5;
Hybrid Types
1 + 2 :interface Counter 3 :call 4 :string 5 param start 6 :number 7 :p interval 8 :number 9 :m reset 10 :void 11 function getCounter 12 :return 13 :ref Counter 14 let counter 15 :as 16 :ref Counter 17 function 18 param start 19 :number 20 set counter.interval = 123 21 set counter.reset = 22 function 23 return counter 24 let c = getCounter() 25 _ c(10) 26 _ c.reset 27 set c.interval = 5
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface Counter {
(start: number): string;
interval: number;
reset(): void;
}
function getCounter(): Counter {
let counter = as Counterfunction(start: number) {
};
counter.interval = 123;
counter.reset = function() {
}
;
return counter;
}
let c = getCounter();
c(10);
c.reset();
c.interval = 5;
Class with private property
1 class Control 2 p state 3 :private 4 :any
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
class Control {
private state: any;
}
Interface extending class
interface SelectableControl extends Control {
select(): void;
}
1 :interface SelectableControl 2 :extends Control 3 :m select 4 :void
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface SelectableControl extends Control {
select(): void;
}
Derived class extending interface
class Button extends Control implements SelectableControl {
select() {}
}
1 class Button 2 super Control 3 :implements SelectableControl 4 m select
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
class Button extends Control implements SelectableControl {
select() {
}
}
Derived class
class TextBox extends Control {
select() {}
}
1 class TextBox 2 super Control 3 m select
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
class TextBox extends Control {
select() {
}
}
Class extending interface
// Error: Property 'state' is missing in type 'Image'.
class Image implements SelectableControl {
select() {}
}
1 class Image 2 :implements SelectableControl 3 m select
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
class Image implements SelectableControl {
select() {
}
}
Identity function with any
1 function identity 2 param arg 3 :any 4 :return 5 :any 6 return arg
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function identity(arg: any): any {
return arg;
}
Identity function with type variable
1 function identity 2 :< T 3 param arg 4 :ref T 5 :return 6 :ref T 7 return arg
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function identity<T>(arg: T): T {
return arg;
}
Type argument
1 let output 2 _ identity 3 :< string 4 @ "myString"
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
let output = identity(string, "myString");
Length property fails
1 function loggingIdentity 2 :< T 3 param arg 4 :ref T 5 :return 6 :ref T 7 _ console.log(arg.length) 8 return arg
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function loggingIdentity<T>(arg: T): T {
console.log(arg.length);
return arg;
}
Length property succeds 1
1 + 2 function loggingIdentity 3 :< T 4 param arg 5 :[ 6 :ref T 7 :return 8 :[ 9 :ref T 10 _ console.log(arg.length) 11 return arg
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function loggingIdentity<T>(arg: T[]): T[] {
console.log(arg.length);
return arg;
}
Length property succeds 2
1 function loggingIdentity 2 :< T 3 param arg 4 :ref Array 5 :ref T 6 :return 7 :ref Array 8 :ref T 9 _ console.log(arg.length) 10 return arg
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function loggingIdentity<T>(arg: <Array>T): <Array>T {
console.log(arg.length);
return arg;
}
Generic function
1 + 2 function identity 3 :< T 4 param arg 5 :ref T 6 :return 7 :ref T 8 return arg 9 let myIdentity 10 :=> 11 :ref T 12 param arg 13 :ref T 14 := identity
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function identity<T>(arg: T): T {
return arg;
}
let myIdentity: (arg: T) => T = identity;
Call signature object literal type
1 + 2 function identity 3 :< T 4 param arg 5 :ref T 6 :return 7 :ref T 8 return arg 9 let myIdentity 10 :{ 11 :call 12 :< T 13 :ref T 14 param arg 15 :ref T 16 := identity
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function identity<T>(arg: T): T {
return arg;
}
let myIdentity: {
T(arg: T): T;
} = identity;
Generic interface
1 + 2 :interface GenericIdentityFn 3 :< T 4 :call 5 :ref T 6 param arg 7 :ref T 8 function identity 9 :< T 10 param arg 11 :ref T 12 :return 13 :ref T 14 return arg 15 let myIdentity 16 :ref GenericIdentityFn 17 :param number 18 := identity
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface GenericIdentityFn<T> {
(arg: T): T;
}
function identity<T>(arg: T): T {
return arg;
}
let myIdentity: GenericIdentityFn<number> = identity;
Generic Classes
1 class GenericNumber 2 :< T 3 p zeroValue 4 :ref T 5 p add 6 :=> 7 :ref T 8 param x 9 :ref T 10 param y 11 :ref T
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
class GenericNumber<T> {
zeroValue: T;
add: (x: T, y: T) => T;
}
Generic Constraints - fails
1 function loggingIdentity 2 :< T 3 param arg 4 :ref T 5 :return 6 :ref T 7 _ console.log(arg.length) 8 return arg
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function loggingIdentity<T>(arg: T): T {
console.log(arg.length);
return arg;
}
Generic Constraints - succeds
1 + 2 :interface Lengthwise 3 :p length 4 :number 5 function loggingIdentity 6 :< T 7 :ref Lengthwise 8 param arg 9 :ref T 10 :return 11 :ref T 12 _ console.log(arg.length) 13 return arg
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface Lengthwise {
length: number;
}
function loggingIdentity<T extends Lengthwise>(arg: T): T {
console.log(arg.length);
return arg;
}
Type Parameters in Generic Constraints
1 + 2 function getProperty 3 :< T 4 :< K 5 :keyof 6 :ref T 7 param obj 8 :ref T 9 param key 10 :ref K 11 return obj[key] 12 let x 13 { 14 @ a 1 15 @ b 2 16 @ c 3 17 @ d 4 18 _ getProperty(x, "a") 19 _ getProperty(x, "m")
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function getProperty<T, K extends keyof T>(obj: T, key: K) {
return obj[key];
}
let x = {
a: 1,
b: 2,
c: 3,
d: 4
};
getProperty(x, "a");
getProperty(x, "m");
Class Types in Generics
1 function create 2 :< T 3 param c 4 :{ 5 :new 6 :ref T 7 :return 8 :ref T 9 return new c()
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function create<T>(c: {
(): T;
}): T {
return new c();
}
Prototype property
1 + 2 class BeeKeeper 3 p hasMask 4 :boolean 5 class ZooKeeper 6 p nametag 7 :string 8 class Animal 9 p numLegs 10 :number 11 class Bee 12 super Animal 13 p keeper 14 :ref BeeKeeper 15 class Lion 16 super Animal 17 p keeper 18 :ref ZooKeeper 19 function createInstance 20 :< A 21 :ref Animal 22 param c 23 :ctor 24 :ref A 25 :return 26 :ref A 27 return new c() 28 var x = createInstance(Lion).keeper.nametag 29 var y = createInstance(Bee).keeper.hasMask
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
class BeeKeeper {
hasMask: boolean;
}
class ZooKeeper {
nametag: string;
}
class Animal {
numLegs: number;
}
class Bee extends Animal {
keeper: BeeKeeper;
}
class Lion extends Animal {
keeper: ZooKeeper;
}
function createInstance<A extends Animal>(c = *** :ctor ;
): A {
return new c();
}
var x = createInstance(Lion).keeper.nametag;
var y = createInstance(Bee).keeper.hasMask;
Intersection Types
1 + 2 function extend 3 :< T 4 :< U 5 param first 6 :ref T 7 param second 8 :ref U 9 :return 10 :intersect 11 :ref T 12 :ref U 13 let result 14 :as 15 :intersect 16 :ref T 17 :ref U 18 { {} 19 for let id in first 20 set = 21 @expr 22 () 23 @id result 24 :as 25 :any 26 .[ id 27 @expr 28 () 29 @id first 30 :as 31 :any 32 .[ id 33 for let id in second 34 if !result.hasOwnProperty(id) 35 set = 36 @expr 37 () 38 @id result 39 :as 40 :any 41 .[ id 42 @expr 43 () 44 @id second 45 :as 46 :any 47 .[ id 48 return result 49 class Person 50 ctor 51 param name 52 :string 53 :interface Loggable 54 :m log 55 :void 56 class ConsoleLogger 57 :extends Loggable 58 m log 59 var jim = extend(new Person("Jim"), new ConsoleLogger()) 60 var n = jim.name 61 _ jim.log
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function extend<T, U>(first: T, second: U): T & U {
let result = as T & U;
for (let id in first) {
(result as any)[id] = (first as any)[id];
}
for (let id in second) {
if (!result.hasOwnProperty(id)) {
(result as any)[id] = (second as any)[id];
}
}
return result;
}
class Person {
constructor(name: string) {
}
}
interface Loggable {
log(): void;
}
class ConsoleLogger extends Loggable {
log() {
}
}
var jim = extend(new Person("Jim"), new ConsoleLogger());
var n = jim.name;
jim.log();
Union Types - fail at run time
1 + 2 function padLeft 3 param value 4 :string 5 param padding 6 :any 7 if typeof padding === "number" 8 return Array(padding + 1).join(" ") + value 9 if typeof padding === "string" 10 return padding + value 11 throw 12 new Error 13 `lit 14 + Expected string or number, got ' 15 @ padding 16 + '. 17 _ padLeft("Hello world", 4) 18 let indentedString = padLeft("Hello world", true)
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function padLeft(value: string, padding: any) {
if (typeof padding === "number") {
return Array(padding + 1).join(" ") + value;
}
if (typeof padding === "string") {
return padding + value;
}
throw new Error(`Expected string or number, got '${padding}'.`);
}
padLeft("Hello world", 4);
let indentedString = padLeft("Hello world", true);
Union Types - succeds at run time
1 + 2 function padLeft 3 param value 4 :string 5 param padding 6 :union 7 :string 8 :number 9 let indentedString = padLeft("Hello world", true)
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function padLeft(value: string, padding: string | number) {
}
let indentedString = padLeft("Hello world", true);
Union Types - common members
1 + 2 :interface Bird 3 :m fly 4 :m layEggs 5 :interface Fish 6 :m swim 7 :m layEggs 8 function getSmallPet 9 :return 10 :union 11 :ref Fish 12 :ref Bird 13 let pet = getSmallPet() 14 _ pet.layEggs 15 _ pet.swim
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface Bird {
fly();
layEggs();
}
interface Fish {
swim();
layEggs();
}
function getSmallPet(): Fish | Bird {
}
let pet = getSmallPet();
pet.layEggs();
pet.swim();
Type Guards and Differentiating Types
1 + 2 let pet = getSmallPet() 3 if 4 test 5 @expr 6 () 7 @id pet 8 :as 9 :ref Fish 10 . swim 11 _ 12 () 13 @id pet 14 :as 15 :ref Fish 16 ._ swim 17 else 18 _ 19 () 20 @id pet 21 :as 22 :ref Bird 23 ._ fly
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
let pet = getSmallPet();
if ((pet as Fish).swim) {
(pet as Fish).swim()
}
else {
(pet as Bird).fly()
}
User - Defined Type Guards
1 + 2 function isFish 3 param pet 4 :union 5 :ref Fish 6 :ref Bird 7 :return 8 :predicate pet 9 :ref Fish 10 return 11 !== 12 @expr 13 () 14 @id pet 15 :as 16 :ref Fish 17 . swim 18 + undefined 19 function isNumber 20 param x 21 :any 22 :return 23 :predicate x 24 :number 25 return typeof x === "number" 26 function isString 27 param x 28 :any 29 :return 30 :predicate x 31 :string 32 return typeof x === "string" 33 function padLeft 34 param value 35 :string 36 param padding 37 :union 38 :string 39 :number 40 if isNumber(padding) 41 return Array(padding + 1).join(" ") + value 42 if isString(padding) 43 return padding + value 44 throw 45 new Error 46 `lit 47 + Expected string or number, got ' 48 @ padding 49 + '.
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function isFish(pet: Fish | Bird): pet is Fish {
return ((pet as Fish).swim) !== undefined;
}
function isNumber(x: any): x is number {
return typeof x === "number";
}
function isString(x: any): x is string {
return typeof x === "string";
}
function padLeft(value: string, padding: string | number) {
if (isNumber(padding)) {
return Array(padding + 1).join(" ") + value;
}
if (isString(padding)) {
return padding + value;
}
throw new Error(`Expected string or number, got '${padding}'.`);
}
Instanceof type guards
1 + 2 :interface Padder 3 :m getPaddingString 4 :string 5 class SpaceRepeatingPadder 6 :extends Padder 7 ctor 8 param numSpaces 9 :private 10 :number 11 m getPaddingString 12 return Array(this.numSpaces + 1).join(" ") 13 class StringPadder 14 :extends Padder 15 ctor 16 param value 17 :private 18 :string 19 m getPaddingString 20 return this.value 21 function getRandomPadder 22 return 23 iif Math.random() < 0.5 24 then new SpaceRepeatingPadder(4) 25 else new StringPadder(" ") 26 # Type is 'SpaceRepeatingPadder | StringPadder' 27 let padder 28 :ref Padder 29 _ getRandomPadder 30 if padder instanceof SpaceRepeatingPadder 31 var x = padder 32 # type narrowed to 'SpaceRepeatingPadder' 33 if padder instanceof StringPadder 34 var x = padder 35 # type narrowed to 'StringPadder'
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
interface Padder {
getPaddingString(): string;
}
class SpaceRepeatingPadder extends Padder {
constructor(private numSpaces: number) {
}
getPaddingString() {
return Array(this.numSpaces + 1).join(" ");
}
}
class StringPadder extends Padder {
constructor(private value: string) {
}
getPaddingString() {
return this.value;
}
}
function getRandomPadder() {
return Math.random() < 0.5 ? new SpaceRepeatingPadder(4) : new StringPadder(" ");
}
// Type is 'SpaceRepeatingPadder | StringPadder'
let padder: Padder = getRandomPadder();
// type narrowed to 'SpaceRepeatingPadder'
if (padder instanceof SpaceRepeatingPadder) {
var x = padder;
}
// type narrowed to 'StringPadder'
if (padder instanceof StringPadder) {
var x = padder;
}
Nullable types
1 + 2 let s = "foo" 3 set s = null 4 let sn 5 :union 6 :string 7 :null 8 := "bar" 9 set sn = null 10 set sn = undefined 11 function f 12 param x 13 :number 14 param 15 :number 16 :optional 17 return x + y || 0 18 _ f(1, 2) 19 _ f(1) 20 _ f(1, undefined) 21 _ f(1, null) 22 class C 23 p a 24 :number 25 p b 26 :number 27 let c = new C() 28 set c.a = 12 29 set c.a = undefined 30 set c.b = 13 31 set c.b = undefined 32 set c.b = null
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
let s = "foo";
s = null;
let sn: string | null = "bar";
sn = null;
sn = undefined;
function f(x: number, ?: number) {
return x + y || 0;
}
f(1, 2);
f(1);
f(1, undefined);
f(1, null);
class C {
a: number;
b: number;
}
let c = new C();
c.a = 12;
c.a = undefined;
c.b = 13;
c.b = undefined;
c.b = null;
Type guards and type assertions
1 + 2 function f 3 param sn 4 :union 5 :string 6 :null 7 :return 8 :string 9 if sn == null 10 return "default" 11 else 12 return sn 13 function f 14 param sn 15 :union 16 :string 17 :null 18 :return 19 :string 20 return sn || "default" 21 function broken 22 param name 23 :union 24 :string 25 :null 26 :return 27 :string 28 function postfix 29 param epithet 30 :string 31 return name.charAt(0) + '. the ' + epithet 32 set name = name || "Bob" 33 return postfix("great") 34 function fixed 35 param name 36 :union 37 :string 38 :null 39 :return 40 :string 41 function postfix 42 param epithet 43 :string 44 return 45 op+ 46 op+ 47 _ 48 ._ charAt 49 @ 0 50 + '. the ' 51 + epithet 52 set name = name || "Bob" 53 return postfix("great")
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
function f(sn: string | null): string {
if (sn == null) {
return "default";
}
else {
return sn;
}
}
function f(sn: string | null): string {
return sn || "default";
}
function broken(name: string | null): string {
function postfix(epithet: string) {
return name.charAt(0) + '. the ' + epithet;
}
name = name || "Bob";
return postfix("great");
}
function fixed(name: string | null): string {
function postfix(epithet: string) {
return ((.charAt(0)
) + '. the ') + epithet;
}
name = name || "Bob";
return postfix("great");
}
Type Aliases
1 + 2 :type Name 3 :string 4 :type NameResolver 5 :=> 6 :string 7 :type NameOrResolver 8 :union 9 :ref Name 10 :ref NameResolver 11 function getName 12 param n 13 :ref NameOrResolver 14 :return 15 :ref Name 16 if typeof n === "string" 17 return n 18 else 19 return n() 20 :type Container 21 :< T 22 :{ 23 :p value 24 :ref T 25 :type Tree 26 :< T 27 :{ 28 :p value 29 :ref T 30 :p left 31 :ref Tree 32 :ref T 33 :p right 34 :ref Tree 35 :ref T 36 :type LinkedList 37 :< T 38 :intersect 39 :ref T 40 :{ 41 :p next 42 :ref LinkedList 43 :ref T 44 :interface Person 45 :p name 46 :string 47 var people 48 :ref LinkedList 49 :ref Person 50 var s = people.name 51 var s = people.next.name 52 var s = people.next.next.name 53 var s = people.next.next.next.name 54 :type Yikes 55 :ref Array 56 :ref Yikes
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
type Name = string;
type NameResolver = () => string;
type NameOrResolver = Name | NameResolver;
function getName(n: NameOrResolver): Name {
if (typeof n === "string") {
return n;
}
else {
return n();
}
}
type Container<T> = {
value: T;
};
type Tree<T> = {
value: T;
left: <Tree>T;
right: <Tree>T;
};
type LinkedList<T> = T & {
next: <LinkedList>T;
};
interface Person {
name: string;
}
var people: <LinkedList>Person;
var s = people.name;
var s = people.next.name;
var s = people.next.next.name;
var s = people.next.next.next.name;
type Yikes = <Array>Yikes;
Interfaces vs.Type Aliases
1 + 2 :type Alias 3 :{ 4 :p num 5 :number 6 :interface Interface 7 :p num 8 :number 9 :function aliased 10 param arg 11 :ref Alias 12 :return 13 :ref Alias 14 :function interfaced 15 param arg 16 :ref Interface 17 :return 18 :ref Interface
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
type Alias = {
num: number;
};
interface Interface {
num: number;
}
function aliased(arg: Alias): Alias;
function interfaced(arg: Interface): Interface;
String Literal Types
1 + 2 :type Easing 3 :union 4 :literal "ease-in" 5 :literal "ease-out" 6 :literal "ease-in-out" 7 class UIElement 8 m animate 9 param dx 10 :number 11 param dy 12 :number 13 param easing 14 :ref Easing 15 if easing === "ease-in" 16 else 17 if easing === "ease-out" 18 else 19 if easing === "ease-in-out" 20 else 21 let button = new UIElement() 22 _ button.animate(0, 0, "ease-in") 23 _ button.animate(0, 0, "uneasy") 24 :function createElement 25 param tagName 26 :literal "img" 27 :return 28 :ref HTMLImageElement 29 :function createElement 30 param tagName 31 :literal "input" 32 :return 33 :ref HTMLInputElement 34 function createElement 35 param tagName 36 :string 37 :return 38 :ref Element
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:31 GMT
*/
type Easing = "ease-in" | "ease-out" | "ease-in-out";
class UIElement {
animate(dx: number, dy: number, easing: Easing) {
if (easing === "ease-in") {
}
else {
if (easing === "ease-out") {
}
else {
if (easing === "ease-in-out") {
}
else {
}
}
}
}
}
let button = new UIElement();
button.animate(0, 0, "ease-in");
button.animate(0, 0, "uneasy");
function createElement(tagName: "img"): HTMLImageElement;
function createElement(tagName: "input"): HTMLInputElement;
function createElement(tagName: string): Element {
}
Numeric Literal Types
1 + 2 function rollDie 3 :return 4 :union 5 :literal 1 6 :literal 2 7 :literal 3 8 :literal 4 9 :literal 5 10 :literal 6 11 function foo 12 param x 13 :number 14 if x !== 1 || x !== 2
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:32 GMT
*/
function rollDie(): 1 | 2 | 3 | 4 | 5 | 6 {
}
function foo(x: number) {
if (x !== 1 || x !== 2) {
}
}
Enum Member Types
1 + 2 :interface Square 3 :p kind 4 :literal "square" 5 :p size 6 :number 7 :interface Rectangle 8 :p kind 9 :literal "rectangle" 10 :p width 11 :number 12 :p height 13 :number 14 :interface Circle 15 :p kind 16 :literal "circle" 17 :p radius 18 :number 19 :type Shape 20 :union 21 :ref Square 22 :ref Rectangle 23 :ref Circle 24 function area 25 param s 26 :ref Shape 27 switch s.kind 28 case "square" 29 return s.size * s.size 30 case "rectangle" 31 return s.height * s.width 32 case "circle" 33 return Math.PI * s.radius ** 2
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:32 GMT
*/
interface Square {
kind: "square";
size: number;
}
interface Rectangle {
kind: "rectangle";
width: number;
height: number;
}
interface Circle {
kind: "circle";
radius: number;
}
type Shape = Square | Rectangle | Circle;
function area(s: Shape) {
switch (s.kind) {
case "square": {
return s.size * s.size;
}
case "rectangle": {
return s.height * s.width;
}
case "circle": {
return Math.PI * s.radius ** 2;
}
}
}
Exhaustiveness checking
1 + 2 :type Shape 3 :union 4 :ref Square 5 :ref Rectangle 6 :ref Circle 7 :ref Triangle 8 function area 9 param s 10 :ref Shape 11 switch s.kind 12 case "square" 13 return s.size * s.size 14 case "rectangle" 15 return s.height * s.width 16 case "circle" 17 return Math.PI * s.radius ** 2 18 function area 19 param s 20 :ref Shape 21 :return 22 :number 23 switch s.kind 24 case "square" 25 return s.size * s.size 26 case "rectangle" 27 return s.height * s.width 28 case "circle" 29 return Math.PI * s.radius ** 2 30 function assertNever 31 param x 32 :never 33 :return 34 :never 35 throw new Error("Unexpected object: " + x) 36 function area 37 param s 38 :ref Shape 39 switch s.kind 40 case "square" 41 return s.size * s.size 42 case "rectangle" 43 return s.height * s.width 44 case "circle" 45 return Math.PI * s.radius ** 2 46 default 47 return assertNever(s)
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:32 GMT
*/
type Shape = Square | Rectangle | Circle | Triangle;
function area(s: Shape) {
switch (s.kind) {
case "square": {
return s.size * s.size;
}
case "rectangle": {
return s.height * s.width;
}
case "circle": {
return Math.PI * s.radius ** 2;
}
}
}
function area(s: Shape): number {
switch (s.kind) {
case "square": {
return s.size * s.size;
}
case "rectangle": {
return s.height * s.width;
}
case "circle": {
return Math.PI * s.radius ** 2;
}
}
}
function assertNever(x = never): never {
throw new Error("Unexpected object: " + x);
}
function area(s: Shape) {
switch (s.kind) {
case "square": {
return s.size * s.size;
}
case "rectangle": {
return s.height * s.width;
}
case "circle": {
return Math.PI * s.radius ** 2;
}
default: {
return assertNever(s);
}
}
}
Polymorphic this types
1 + 2 class BasicCalculator 3 ctor 4 :public 5 param value 6 :number 7 := 0 8 m currentValue 9 :public 10 return this.value 11 m add 12 :public 13 param operand 14 :number 15 set this.value += operand 16 return this 17 m multiply 18 :public 19 param operand 20 :number 21 set this.value *= operand 22 return this 23 let v = new BasicCalculator(2).multiply(5).add(1).currentValue() 24 class ScientificCalculator 25 super BasicCalculator 26 ctor 27 :public 28 param value = 0 29 _ super(value) 30 m sin 31 :public 32 set this.value = Math.sin(this.value) 33 return this 34 let v = new ScientificCalculator(2).multiply(5).sin().add(1).currentValue()
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:32 GMT
*/
class BasicCalculator {
public constructor(value: number = 0) {
}
public currentValue() {
return this.value;
}
public add(operand: number) {
this.value += operand;
return this;
}
public multiply(operand: number) {
this.value *= operand;
return this;
}
}
let v = new BasicCalculator(2).multiply(5).add(1).currentValue();
class ScientificCalculator extends BasicCalculator {
public constructor(value = 0) {
super(value);
}
public sin() {
this.value = Math.sin(this.value);
return this;
}
}
let v = new ScientificCalculator(2).multiply(5).sin().add(1).currentValue();
Index types
1 + 2 function pluck 3 param o 4 param names 5 return 6 _ names.map 7 => 8 param n 9 + o[n] 10 function pluck 11 :< T 12 :< K 13 :keyof 14 :ref T 15 param o 16 :ref T 17 param names 18 :[ 19 :ref K 20 :return 21 :[ 22 :[] 23 :ref T 24 :ref K 25 return 26 _ names.map 27 => 28 param n 29 + o[n] 30 :interface Person 31 :p name 32 :string 33 :p age 34 :number 35 let person 36 :ref Person 37 { 38 @ name 'Jarid' 39 @ age 35 40 let strings 41 :[ 42 :string 43 _ pluck 44 @ person 45 [ 46 @ 'name' 47 let personProps 48 :keyof 49 :ref Person 50 _ pluck 51 @ person 52 [ 53 @ 'age' 54 @ 'unknown' 55 function getProperty 56 :< T 57 :< K 58 :keyof 59 :ref T 60 param o 61 :ref T 62 param name 63 :ref K 64 :return 65 :[] 66 :ref T 67 :ref K 68 return o[name] 69 let name 70 :string 71 _ getProperty(person, 'name') 72 let age 73 :number 74 _ getProperty(person, 'age') 75 let unknown = getProperty(person, 'unknown') 76 :interface Map 77 :< T 78 :index 79 :ref T 80 param key 81 :string 82 let keys 83 :keyof 84 :ref Map 85 :number 86 let value 87 :[] 88 :ref Map 89 :number 90 :literal 'foo'
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:32 GMT
*/
function pluck(o, names) {
return names.map(n =>
o[n]
);
}
function pluck<T, K extends keyof T>(o: T, names: K[]): T[K][] {
return names.map(n =>
o[n]
);
}
interface Person {
name: string;
age: number;
}
let person: Person = {
name: 'Jarid',
age: 35
};
let strings: string[] = pluck(person, [
'name'
]);
let personProps: keyof Person;
pluck(person, [
'age',
'unknown'
])
function getProperty<T, K extends keyof T>(o: T, name: K): T[K] {
return o[name];
}
let name: string = getProperty(person, 'name');
let age: number = getProperty(person, 'age');
let unknown = getProperty(person, 'unknown');
interface Map<T> {
[key: string]: T;
}
let keys: keyof <Map>number;
let value = <Map>number['foo'];
Mapped types
1 + 2 :interface PersonPartial 3 :p name 4 :optional 5 :string 6 :p age 7 :optional 8 :number 9 :interface PersonReadonly 10 :p name 11 :string 12 :p age 13 :number 14 :type Readonly 15 :< T 16 :mapped 17 :< P 18 :keyof 19 :ref T 20 :[] 21 :ref T 22 :ref P 23 :type Partial 24 :< T 25 :mapped 26 :optional 27 :< P 28 :keyof 29 :ref T 30 :[] 31 :ref T 32 :ref P 33 :type PersonPartial 34 :ref Partial 35 :ref Person 36 :type ReadonlyPerson 37 :ref Readonly 38 :ref Person 39 :type Keys 40 :union 41 :literal 'option1' 42 :literal 'option2' 43 :type Flags 44 :mapped 45 :< K 46 :ref Keys 47 :boolean
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:32 GMT
*/
interface PersonPartial {
name?: string;
age?: number;
}
interface PersonReadonly {
name: string;
age: number;
}
type Readonly<T> = [P in keyof T] : T[P];
type Partial<T> = [P in keyof T] : T[P];
type PersonPartial = <Partial>Person;
type ReadonlyPerson = <Readonly>Person;
type Keys = 'option1' | 'option2';
type Flags = [K in Keys] : boolean;
Mapped types 2
1 + 2 :type Flags 3 :{ 4 :p option1 5 :boolean 6 :p option2 7 :boolean 8 :type NullablePerson 9 :mapped 10 :< P 11 :keyof 12 :ref Person 13 :union 14 :[] 15 :ref Person 16 :ref P 17 :null 18 :type PartialPerson 19 :mapped 20 :optional 21 :< P 22 :keyof 23 :ref Person 24 :[] 25 :ref Person 26 :ref P 27 :type Nullable 28 :< T 29 :mapped 30 :< P 31 :keyof 32 :ref T 33 :union 34 :[] 35 :ref T 36 :ref P 37 :null 38 :type Partial 39 :< T 40 :mapped 41 :optional 42 :< P 43 :keyof 44 :ref T 45 :[] 46 :ref T 47 :ref P 48 :type Proxy 49 :< T 50 :{ 51 :m get 52 :ref T 53 :m set 54 :void 55 param value 56 :ref T 57 :type Proxify 58 :< T 59 :mapped 60 :< P 61 :keyof 62 :ref T 63 :ref Proxy 64 :[] 65 :ref T 66 :ref P 67 function proxify 68 :< T 69 param o 70 :ref T 71 :return 72 :ref Proxify 73 :ref T 74 let proxyProps = proxify(props) 75 :type Pick 76 :< T 77 :< K 78 :keyof 79 :ref T 80 :mapped 81 :< P 82 :ref K 83 :[] 84 :ref T 85 :ref P 86 :type Record 87 :< K 88 :string 89 :< T 90 :mapped 91 :< P 92 :ref K 93 :ref T 94 :type ThreeStringProps 95 :ref Record 96 :union 97 :literal 'prop1' 98 :literal 'prop2' 99 :literal 'prop3' 100 :string
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:32 GMT
*/
type Flags = {
option1: boolean;
option2: boolean;
};
type NullablePerson = [P in keyof Person] : Person[P] | null;
type PartialPerson = [P in keyof Person] : Person[P];
type Nullable<T> = [P in keyof T] : T[P] | null;
type Partial<T> = [P in keyof T] : T[P];
type Proxy<T> = {
get(): T;
set(value: T): void;
};
type Proxify<T> = [P in keyof T] : <Proxy>T[P];
function proxify<T>(o: T): <Proxify>T {
}
let proxyProps = proxify(props);
type Pick<T, K extends keyof T> = [P in K] : T[P];
type Record<K extends string, T> = [P in K] : T;
type ThreeStringProps = Record;
Inference from mapped types
1 + 2 function unproxify 3 :< T 4 param t 5 :ref Proxify 6 :param 7 :ref T 8 :return 9 :ref T 10 let result = {} 11 for const k in t 12 set result[k] = t[k].get() 13 return result 14 let originalProps = unproxify(proxyProps)
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:32 GMT
*/
function unproxify<T>(t: Proxify<T>): T {
let result = {};
for (const k in t) {
result[k] = t[k].get();
}
return result;
}
let originalProps = unproxify(proxyProps);
Conditional Types
1 + 2 :function f 3 :< T 4 :boolean 5 param x 6 :ref T 7 :return 8 :iif 9 :check 10 :ref T 11 :extends 12 :literal true 13 :then 14 :string 15 :else 16 :number 17 # Type is 'string | number 18 let x = f(Math.random() < 0.5) 19 # Another example would be the TypeName type alias, which uses nested conditional types: 20 :type TypeName 21 :< T 22 :iif 23 :check 24 :ref T 25 :extends 26 :string 27 :then 28 :literal "string" 29 :else 30 :iif 31 :check 32 :ref T 33 :extends 34 :number 35 :then 36 :literal "number" 37 :else 38 :iif 39 :check 40 :ref T 41 :extends 42 :boolean 43 :then 44 :literal "boolean" 45 :else 46 :iif 47 :check 48 :ref T 49 :extends 50 :void 51 :then 52 :literal "undefined" 53 :else 54 :iif 55 :check 56 :ref T 57 :extends 58 :ref Function 59 :then 60 :literal "function" 61 :else 62 :literal "object" 63 :type T0 64 :ref TypeName 65 :param string 66 # "string" 67 :type T1 68 :ref TypeName 69 :param 70 :literal "a" 71 # "string" 72 :type T2 73 :ref TypeName 74 :param 75 :literal true 76 # "boolean" 77 :type T3 78 :ref TypeName 79 :param 80 :=> 81 :void 82 # "function" 83 :type T4 84 :ref TypeName 85 :param 86 :[ 87 :string 88 # "object" 89 # But as an example of a place where conditonal types are deferred - where they stick around instead of picking a branch - would be in the following: 90 :interface Foo 91 :p propA 92 :boolean 93 :p propB 94 :boolean 95 :function f 96 :< T 97 param x 98 :ref T 99 :return 100 :iif 101 :check 102 :ref T 103 :extends 104 :ref Foo 105 :then 106 :string 107 :else 108 :number 109 function foo 110 :< U 111 param x 112 :ref U 113 # Has type 'U extends Foo ? string : number' 114 let a = f(x) 115 # This assignment is allowed though! 116 let b 117 :union 118 :string 119 :number 120 := a
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:32 GMT
*/
function f<T extends boolean>(x: T): T extends true ? string : number;
// Type is 'string | number
let x = f(Math.random() < 0.5);
// Another example would be the TypeName type alias, which uses nested conditional types:
type TypeName<T> = T extends string ? "string" : T extends number ? "number" : T extends boolean ? "boolean" : T extends void ? "undefined" : T extends Function ? "function" : "object";
type T0 = TypeName<string>;
// "string"
type T1 = TypeName<"a">;
// "string"
type T2 = TypeName<true>;
// "boolean"
type T3 = TypeName<() => void>;
// "function"
type T4 = TypeName<string[]>;
// "object"
// But as an example of a place where conditonal types are deferred - where they stick around instead of picking a branch - would be in the following:
interface Foo {
propA: boolean;
propB: boolean;
}
function f<T>(x: T): T extends Foo ? string : number;
// Has type 'U extends Foo ? string : number'
// This assignment is allowed though!
function foo<U>(x: U) {
let a = f(x);
let b: string | number = a;
}
Distributive conditional types
1 + 2 :type T10 3 :ref TypeName 4 :param 5 :union 6 :string 7 :paren 8 :=> 9 :void 10 :type T12 11 :ref TypeName 12 :param 13 :union 14 :string 15 :[ 16 :string 17 :void 18 :type T11 19 :ref TypeName 20 :param 21 :union 22 :[ 23 :string 24 :[ 25 :number 26 # 27 # In instantiations of a distributive conditional type T extends U ? X : Y, references to T within the conditional type are resolved 28 # to individual constituents of the union type (i.e. T refers to the individual constituents after the conditional type is distributed 29 # over the union type). Furthermore, references to T within X have an additional type parameter constraint U (i.e. T is considered 30 # assignable to U within X). 31 :type BoxedValue 32 :< T 33 :{ 34 :p value 35 :ref T 36 :type BoxedArray 37 :< T 38 :{ 39 :p array 40 :[ 41 :ref T 42 :type Boxed 43 :< T 44 :iif 45 :check 46 :ref T 47 :extends 48 :[ 49 :any 50 :then 51 :ref BoxedArray 52 :param 53 :[] 54 :ref T 55 :number 56 :else 57 :ref BoxedValue 58 :param 59 :ref T 60 :type T20 61 :ref Boxed 62 :param string 63 :type T21 64 :ref Boxed 65 :param 66 :[ 67 :number 68 :type T22 69 :ref Boxed 70 :param 71 :union 72 :string 73 :[ 74 :number 75 :type Diff 76 :< T 77 :< U 78 :iif 79 :check 80 :ref T 81 :extends 82 :ref U 83 :then 84 :never 85 :else 86 :ref T 87 :type Filter 88 :< T 89 :< U 90 :iif 91 :check 92 :ref T 93 :extends 94 :ref U 95 :then 96 :ref T 97 :else 98 :never 99 :type T30 100 :ref Diff 101 :param 102 :union 103 :literal "a" 104 :literal "b" 105 :literal "c" 106 :literal "d" 107 :param 108 :union 109 :literal "a" 110 :literal "c" 111 :literal "f" 112 :type T31 113 :ref Filter 114 :param 115 :union 116 :literal "a" 117 :literal "b" 118 :literal "c" 119 :literal "d" 120 :param 121 :union 122 :literal "a" 123 :literal "c" 124 :literal "f" 125 :type T32 126 :ref Diff 127 :param 128 :union 129 :string 130 :number 131 :paren 132 :=> 133 :void 134 :param 135 :ref Function 136 :type T33 137 :ref Filter 138 :param 139 :union 140 :string 141 :number 142 :paren 143 :=> 144 :void 145 :param 146 :ref Function 147 :type NonNullable 148 :< T 149 :ref Diff 150 :param 151 :ref T 152 :param 153 :union 154 :null 155 :void 156 :type T34 157 :ref NonNullable 158 :param 159 :union 160 :string 161 :number 162 :void 163 :type T35 164 :ref NonNullable 165 :param 166 :union 167 :string 168 :[ 169 :string 170 :null 171 :void 172 function f1 173 :< T 174 param x 175 :ref T 176 param y 177 :ref NonNullable 178 :param 179 :ref T 180 set x = y 181 set y = x 182 function f2 183 :< T 184 :union 185 :string 186 :void 187 param x 188 :ref T 189 param y 190 :ref NonNullable 191 :param 192 :ref T 193 set x = y 194 set y = x 195 let s1 196 :string 197 := x 198 let s2 199 :string 200 := y
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:32 GMT
*/
type T10 = TypeName<string | (() => void)>;
type T12 = TypeName<string | string[] | void>;
type T11 = TypeName<string[] | number[]>;
//
type BoxedValue<T> = {
value: T;
};
type BoxedArray<T> = {
array: T[];
};
type Boxed<T> = T extends any[] ? BoxedArray<T[number]> : BoxedValue<T>;
type T20 = Boxed<string>;
type T21 = Boxed<number[]>;
type T22 = Boxed<string | number[]>;
type Diff<T, U> = T extends U ? never : T;
type Filter<T, U> = T extends U ? T : never;
type T30 = Diff<"a" | "b" | "c" | "d", "a" | "c" | "f">;
type T31 = Filter<"a" | "b" | "c" | "d", "a" | "c" | "f">;
type T32 = Diff<string | number | (() => void), Function>;
type T33 = Filter<string | number | (() => void), Function>;
type NonNullable<T> = Diff<T, null | void>;
type T34 = NonNullable<string | number | void>;
type T35 = NonNullable<string | string[] | null | void>;
function f1<T>(x: T, y: NonNullable<T>) {
x = y;
y = x;
}
function f2<T extends string | void>(x: T, y: NonNullable<T>) {
x = y;
y = x;
let s1: string = x;
let s2: string = y;
}
Conditional types combined with mapped types:
1 + 2 :type FunctionPropertyNames 3 :< T 4 :[] 5 :mapped 6 :< K 7 :keyof 8 :ref T 9 :iif 10 :check 11 :[] 12 :ref T 13 :ref K 14 :extends 15 :ref Function 16 :then 17 :ref K 18 :else 19 :never 20 :keyof 21 :ref T 22 :type FunctionProperties 23 :< T 24 :ref Pick 25 :param 26 :ref T 27 :param 28 :ref FunctionPropertyNames 29 :param 30 :ref T 31 :type NonFunctionPropertyNames 32 :< T 33 :[] 34 :mapped 35 :< K 36 :keyof 37 :ref T 38 :iif 39 :check 40 :[] 41 :ref T 42 :ref K 43 :extends 44 :ref Function 45 :then 46 :never 47 :else 48 :ref K 49 :keyof 50 :ref T 51 :type NonFunctionProperties 52 :< T 53 :ref Pick 54 :param 55 :ref T 56 :param 57 :ref NonFunctionPropertyNames 58 :param 59 :ref T 60 :interface Part 61 :p id 62 :number 63 :p name 64 :string 65 :p subparts 66 :[ 67 :ref Part 68 :m updatePart 69 :void 70 param newName 71 :string 72 :type T40 73 :ref FunctionPropertyNames 74 :param 75 :ref Part 76 :type T41 77 :ref NonFunctionPropertyNames 78 :param 79 :ref Part 80 :type T42 81 :ref FunctionProperties 82 :param 83 :ref Part 84 :type T43 85 :ref NonFunctionProperties 86 :param 87 :ref Part 88 :type ElementType 89 :< T 90 :iif 91 :check 92 :ref T 93 :extends 94 :[ 95 :any 96 :then 97 :ref ElementType 98 :param 99 :[] 100 :ref T 101 :number 102 :else 103 :ref T
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:32 GMT
*/
type FunctionPropertyNames<T> = {[K in keyof T] : T[K] extends Function ? K : never}[ keyof T];
type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>;
type NonFunctionPropertyNames<T> = {[K in keyof T] : T[K] extends Function ? never : K}[ keyof T];
type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>;
interface Part {
id: number;
name: string;
subparts: Part[];
updatePart(newName: string): void;
}
type T40 = FunctionPropertyNames<Part>;
type T41 = NonFunctionPropertyNames<Part>;
type T42 = FunctionProperties<Part>;
type T43 = NonFunctionProperties<Part>;
type ElementType<T> = T extends any[] ? ElementType<T[number]> : T;
Type inference in conditional types
1 + 2 :type ReturnType 3 :< T 4 :iif 5 :check 6 :ref T 7 :extends 8 :=> 9 :infer 10 :< R 11 param ...args 12 :[ 13 :any 14 :then 15 :ref R 16 :else 17 :any 18 :type Unpacked 19 :< T 20 :iif 21 :check 22 :ref T 23 :extends 24 :[ 25 :paren 26 :infer 27 :< U 28 :then 29 :ref U 30 :else 31 :iif 32 :check 33 :ref T 34 :extends 35 :=> 36 :infer 37 :< U 38 param ...args 39 :[ 40 :any 41 :then 42 :ref U 43 :else 44 :iif 45 :check 46 :ref T 47 :extends 48 :ref Promise 49 :param 50 :infer 51 :< U 52 :then 53 :ref U 54 :else 55 :ref T 56 :type T0 57 :ref Unpacked 58 :param string 59 :type T1 60 :ref Unpacked 61 :param 62 :[ 63 :string 64 :type T2 65 :ref Unpacked 66 :param 67 :=> 68 :string 69 :type T3 70 :ref Unpacked 71 :param 72 :ref Promise 73 :param string 74 :type T4 75 :ref Unpacked 76 :param 77 :[ 78 :ref Promise 79 :param string 80 :type T5 81 :ref Unpacked 82 :param 83 :ref Unpacked 84 :param 85 :[ 86 :ref Promise 87 :param string 88 :type Foo 89 :< T 90 :iif 91 :check 92 :ref T 93 :extends 94 :{ 95 :p a 96 :infer 97 :< U 98 :p b 99 :infer 100 :< U 101 :then 102 :ref U 103 :else 104 :never 105 :type T10 106 :ref Foo 107 :param 108 :{ 109 :p a 110 :string 111 :p b 112 :string 113 :type T11 114 :ref Foo 115 :param 116 :{ 117 :p a 118 :string 119 :p b 120 :number 121 :type Bar 122 :< T 123 :iif 124 :check 125 :ref T 126 :extends 127 :{ 128 :p a 129 :=> 130 :void 131 param x 132 :infer 133 :< U 134 :p b 135 :=> 136 :void 137 param x 138 :infer 139 :< U 140 :then 141 :ref U 142 :else 143 :never 144 :type T20 145 :ref Bar 146 :param 147 :{ 148 :p a 149 :=> 150 :void 151 param x 152 :string 153 :p b 154 :=> 155 :void 156 param x 157 :string 158 :type T21 159 :ref Bar 160 :param 161 :{ 162 :p a 163 :=> 164 :void 165 param x 166 :string 167 :p b 168 :=> 169 :void 170 param x 171 :number 172 :function foo 173 param x 174 :string 175 :return 176 :number 177 :function foo 178 param x 179 :number 180 :return 181 :string 182 :function foo 183 param x 184 :union 185 :string 186 :number 187 :return 188 :union 189 :string 190 :number 191 :type T30 192 :ref ReturnType 193 :param 194 :typeof foo 195 :type ReturnType 196 :< T 197 :=> 198 :infer 199 :< R 200 param ...args 201 :[ 202 :any 203 :ref R 204 :type AnyFunction 205 :=> 206 :any 207 param ...args 208 :[ 209 :any 210 :type ReturnType 211 :< T 212 :ref AnyFunction 213 :iif 214 :check 215 :ref T 216 :extends 217 :=> 218 :infer 219 :< R 220 param ...args 221 :[ 222 :any 223 :then 224 :ref R 225 :else 226 :any
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:32 GMT
*/
type ReturnType<T> = T extends (...args: any[]) => infer R ? R : any;
type Unpacked<T> = T extends ( infer U)[] ? U : T extends (...args: any[]) => infer U ? U : T extends Promise< infer U> ? U : T;
type T0 = Unpacked<string>;
type T1 = Unpacked<string[]>;
type T2 = Unpacked<() => string>;
type T3 = Unpacked<Promise<string>>;
type T4 = Unpacked<Promise<string>[]>;
type T5 = Unpacked<Unpacked<Promise<string>[]>>;
type Foo<T> = T extends {
a: infer U;
b: infer U;
} ? U : never;
type T10 = Foo<{
a: string;
b: string;
}>;
type T11 = Foo<{
a: string;
b: number;
}>;
type Bar<T> = T extends {
a: (x = infer U) => void;
b: (x = infer U) => void;
} ? U : never;
type T20 = Bar<{
a: (x: string) => void;
b: (x: string) => void;
}>;
type T21 = Bar<{
a: (x: string) => void;
b: (x: number) => void;
}>;
function foo(x: string): number;
function foo(x: number): string;
function foo(x: string | number): string | number;
type T30 = ReturnType<typeof foo>;
type ReturnType<T extends (...args: any[]) => infer R> = R;
type AnyFunction = (...args: any[]) => any;
type ReturnType<T extends AnyFunction> = T extends (...args: any[]) => infer R ? R : any;
Predefined conditional types
1 + 2 :type T00 3 :ref Exclude 4 :param 5 :union 6 :literal "a" 7 :literal "b" 8 :literal "c" 9 :literal "d" 10 :param 11 :union 12 :literal "a" 13 :literal "c" 14 :literal "f" 15 :type T01 16 :ref Extract 17 :param 18 :union 19 :literal "a" 20 :literal "b" 21 :literal "c" 22 :literal "d" 23 :param 24 :union 25 :literal "a" 26 :literal "c" 27 :literal "f" 28 :type T02 29 :ref Exclude 30 :param 31 :union 32 :string 33 :number 34 :paren 35 :=> 36 :void 37 :param 38 :ref Function 39 :type T03 40 :ref Extract 41 :param 42 :union 43 :string 44 :number 45 :paren 46 :=> 47 :void 48 :param 49 :ref Function 50 :type T04 51 :ref NonNullable 52 :param 53 :union 54 :string 55 :number 56 :void 57 :type T05 58 :ref NonNullable 59 :param 60 :union 61 :paren 62 :=> 63 :string 64 :[ 65 :string 66 :null 67 :void 68 function f1 69 param s 70 :string 71 return 72 { 73 @ a 1 74 @ b s 75 class C 76 p x 77 := 0 78 p y 79 := 0 80 :type T10 81 :ref ReturnType 82 :param 83 :=> 84 :string 85 :type T11 86 :ref ReturnType 87 :param 88 :=> 89 :void 90 param s 91 :string 92 :type T12 93 :ref ReturnType 94 :param 95 :paren 96 :=> 97 :< T 98 :ref T 99 :type T13 100 :ref ReturnType 101 :param 102 :paren 103 :=> 104 :< T 105 :ref U 106 :< U 107 :[ 108 :number 109 :ref T 110 :type T14 111 :ref ReturnType 112 :param 113 :typeof f1 114 :type T15 115 :ref ReturnType 116 :param any 117 :type T16 118 :ref ReturnType 119 :param never 120 :type T17 121 :ref ReturnType 122 :param string 123 :type T18 124 :ref ReturnType 125 :param 126 :ref Function 127 :type T20 128 :ref InstanceType 129 :param 130 :typeof C 131 :type T21 132 :ref InstanceType 133 :param any 134 :type T22 135 :ref InstanceType 136 :param never 137 :type T23 138 :ref InstanceType 139 :param string 140 :type T24 141 :ref InstanceType 142 :param 143 :ref Function 144 # Error
/*
artifact generator: /app/node_modules/@wizzi/plugin.ts/lib/artifacts/ts/module/gen/main.js
package: wizzi.plugin.ts@
primary source IttfDocument: json:/index.ts.ittf
utc time: Tue, 16 Dec 2025 18:37:32 GMT
*/
type T00 = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">;
type T01 = Extract<"a" | "b" | "c" | "d", "a" | "c" | "f">;
type T02 = Exclude<string | number | (() => void), Function>;
type T03 = Extract<string | number | (() => void), Function>;
type T04 = NonNullable<string | number | void>;
type T05 = NonNullable<(() => string) | string[] | null | void>;
function f1(s: string) {
return {
a: 1,
b: s
};
}
class C {
x = 0;
y = 0;
}
type T10 = ReturnType<() => string>;
type T11 = ReturnType<(s: string) => void>;
type T12 = ReturnType<(<T>() => T)>;
type T13 = ReturnType<(<T extends U, U extends number[]>() => T)>;
type T14 = ReturnType<typeof f1>;
type T15 = ReturnType<any>;
type T16 = ReturnType<never>;
type T17 = ReturnType<string>;
type T18 = ReturnType<Function>;
type T20 = InstanceType<typeof C>;
type T21 = InstanceType<any>;
type T22 = InstanceType<never>;
type T23 = InstanceType<string>;
type T24 = InstanceType<Function>;
// Error