import { CaseStyle } from "./Casing/CaseStyle" ; import { Language } from "./Language" ; import { GeneralProperties } from "./Properties/GeneralProperties" ; import { ProjectProperties } from "./Properties/ProjectProperties" ; import { ArrayNewSizedSyntax } from "./Properties/Syntax/ArrayNewSizedSyntax" ; import { ArraySyntax } from "./Properties/Syntax/ArraySyntax" ; import { BooleanSyntax } from "./Properties/Syntax/BooleanSyntax" ; import { ClassGenericSyntax } from "./Properties/Syntax/ClassGenericSyntax" ; import { ClassMemberFunctionSyntax } from "./Properties/Syntax/ClassMemberFunctionSyntax" ; import { ClassMemberVariableSyntax } from "./Properties/Syntax/ClassMemberVariableSyntax" ; import { ClassStaticFunctionSyntax } from "./Properties/Syntax/ClassStaticFunctionSyntax" ; import { ClassStaticVariableSyntax } from "./Properties/Syntax/ClassStaticVariableSyntax" ; import { ClassSyntax } from "./Properties/Syntax/ClassSyntax" ; import { CommentSyntax } from "./Properties/Syntax/CommentSyntax" ; import { ConditionalSyntax } from "./Properties/Syntax/ConditionalSyntax" ; import { DictionarySyntax } from "./Properties/Syntax/DictionarySyntax" ; import { EnumSyntax } from "./Properties/Syntax/EnumSyntax" ; import { ExceptionSyntax } from "./Properties/Syntax/ExceptionSyntax" ; import { ExportSyntax } from "./Properties/Syntax/ExportSyntax" ; import { FileSyntax } from "./Properties/Syntax/FileSyntax" ; import { FunctionSyntax } from "./Properties/Syntax/FunctionSyntax" ; import { ImportSyntax } from "./Properties/Syntax/ImportSyntax" ; import { InterfaceSyntax } from "./Properties/Syntax/InterfaceSyntax" ; import { LambdaSyntax } from "./Properties/Syntax/LambdaSyntax" ; import { LambdaTypeInlineSyntax } from "./Properties/Syntax/LambdaTypeInlineSyntax" ; import { ListNewItemsSyntax } from "./Properties/Syntax/ListNewItemsSyntax" ; import { ListNewSizedSyntax } from "./Properties/Syntax/ListNewSizedSyntax" ; import { ListSliceSupport , ListSliceSyntax } from "./Properties/Syntax/ListSliceSyntax" ; import { ListSortMembersSyntax , ListSortMemberType } from "./Properties/Syntax/ListSortMembersSyntax" ; import { ListSyntax } from "./Properties/Syntax/ListSyntax" ; import { LoopSyntax } from "./Properties/Syntax/LoopSyntax" ; import { MainSyntax } from "./Properties/Syntax/MainSyntax" ; import { MathSyntax } from "./Properties/Syntax/MathSyntax" ; import { NativeCallScope , NativeCallSyntax , NativeCallType } from "./Properties/Syntax/NativeCallSyntax" ; import { NewInstantiationSyntaxKind , NewSyntax } from "./Properties/Syntax/NewSyntax" ; import { OperatorSyntax } from "./Properties/Syntax/OperatorSyntax" ; import { ParameterSyntax } from "./Properties/Syntax/ParameterSyntax" ; import { PrintingSyntax } from "./Properties/Syntax/PrintingSyntax" ; import { SetSyntax } from "./Properties/Syntax/SetSyntax" ; import { StandaloneFunctionSyntax } from "./Properties/Syntax/StandaloneFunctionSyntax" ; import { StringFormatSyntax } from "./Properties/Syntax/StringFormatSyntax" ; import { StringSubstringSupport , StringSubstringSyntax } from "./Properties/Syntax/StringSubstringSyntax" ; import { StringSyntax } from "./Properties/Syntax/StringSyntax" ; import { StringToNumberStartConversionType , StringToNumberSyntax } from "./Properties/Syntax/StringToNumberSyntax" ; import { StyleSyntax } from "./Properties/Syntax/StyleSyntax" ; import { UnsupportedSyntax } from "./Properties/Syntax/UnsupportedSyntax" ; import { VariableSyntax } from "./Properties/Syntax/VariableSyntax" ; /**
 * A summary of information for the TypeScript language.
 */ export class TypeScript extends Language { param general protected generateGeneralProperties ( general ) { general . directoryCase = CaseStyle . PascalCase ; general . extension = ".ts" ; general . fileCase = CaseStyle . PascalCase ; general . name = "TypeScript" ; } param projects protected generateProjectProperties ( projects ) { projects . mainFile = "index.ts" ; projects . metadataFiles = { "package.json" : [ `{` , `    "name": "{name}",` , `    "author": {` , `        "name": "{author.name}",` , `        "email": "{author.email}"` , `    },` , `    "bugs": {` , `        "url": "{repository.url}/issues"` , `    },` , `    "description": "{description}",` , `    "license": "{license}",` , `    "repository": {` , `        "type": "{repository.type}",` , `        "url": "{repository.url}"` , `    },` , `    "main": "{main}.js",` , `    "typings": "{typings}.d.ts",` , `    "version": "{version}"` , `}` , ] , "src/index.ts" : [ `{{#exports}}` , `export \\{ {name} \\} from "{file}";` , `{{/exports}}` ] , } ; projects . nameFormat = CaseStyle . DashLowerCase ; } param members protected generateClassGenericSyntax ( generics ) { generics . left = "<" ; generics . middle = ", " ; generics . right = ">" ; } param arrays protected generateArraySyntax ( arrays ) { arrays . className = "Array" ; arrays . length = new NativeCallSyntax ( "length" , NativeCallScope . Member , NativeCallType . Property ) ; arrays . newGenericCastRequired = false ; arrays . requiredImports = [ ] ; } param arrays protected generateArrayNewSizedSyntax ( newSized ) { newSized . includeType = true ; newSized . left = "new Array<" ; newSized . middle = ">(" ; newSized . right = ")" ; } param booleans protected generateBooleanSyntax ( booleans ) { booleans . className = "boolean" ; } param functions protected generateClassMemberFunctionSyntax ( functions ) { functions . privatePrefix = "" ; functions . protectedPrefix = "" ; functions . publicPrefix = "" ; functions . abstractDeclaration = "abstract " ; functions . includeThisReference = false ; functions . private = "private " ; functions . privateCase = CaseStyle . CamelCase ; functions . protected = "protected " ; functions . protectedCase = CaseStyle . CamelCase ; functions . public = "public " ; functions . publicCase = CaseStyle . CamelCase ; } param members protected generateClassMemberVariableSyntax ( variables ) { variables . privateCase = CaseStyle . CamelCase ; variables . privatePrefix = "" ; variables . protectedPrefix = "" ; variables . publicPrefix = "" ; variables . private = "private " ; variables . protected = "protected " ; variables . protectedCase = CaseStyle . CamelCase ; variables . public = "public " ; variables . publicCase = CaseStyle . CamelCase ; } param classes protected generateClassSyntax ( classes ) { classes . declareEnd = "}" ; classes . declareExtendsRight = "" ; classes . declareStartLeft = "class " ; classes . newStart = "new " ; classes . statics . labelBeforePublicity = false ; classes . this = "this" ; classes . abstractDeclaration = "abstract " ; classes . abstractsSupported = true ; classes . aliases = { char : "string" , double : "number" , float : "number" , int : "number" , } ; classes . constructors . baseConstructor = "super" ; classes . constructors . private = "private " ; classes . constructors . protected = "protected " ; classes . constructors . public = "public " ; classes . constructors . keyword = "constructor" ; classes . constructors . useKeyword = true ; classes . declareExtendsLeft = " extends " ; classes . declareImplementsLeft = " implements " ; classes . declareStartRight = " {" ; classes . instanceOf = new NativeCallSyntax ( " instanceof " , NativeCallScope . Operator , NativeCallType . FloatingRight ) ; classes . generics . used = true ; } param functions protected generateClassStaticFunctionSyntax ( functions ) { functions . label = "static " ; functions . privatePrefix = "" ; functions . protectedPrefix = "" ; functions . publicPrefix = "" ; functions . private = "private " ; functions . privateCase = CaseStyle . CamelCase ; functions . protected = "protected " ; functions . protectedCase = CaseStyle . CamelCase ; functions . public = "public " ; functions . publicCase = CaseStyle . CamelCase ; } param members protected generateClassStaticVariableSyntax ( variables ) { variables . label = "static " ; variables . privateCase = CaseStyle . CamelCase ; variables . privatePrefix = "" ; variables . protectedPrefix = "" ; variables . publicPrefix = "" ; variables . private = "private " ; variables . privateCase = CaseStyle . CamelCase ; variables . protected = "protected " ; variables . protectedCase = CaseStyle . CamelCase ; variables . public = "public " ; variables . publicCase = CaseStyle . CamelCase ; } param comments protected generateCommentSyntax ( comments ) { comments . blockEnd = "*/" ; comments . blockLineLeft = "" ; comments . blockLineRight = "" ; comments . blockStart = "/*" ; comments . lineLeft = "// " ; comments . lineRight = "" ; comments . docEnd = " */" ; comments . docLineEnd = "" ; comments . docLineStart = " * " ; comments . docTagAliases = { note : "remarks" , parameter : "param" , returns : "returns" , summary : "" , todo : "todo" , } ; comments . docTagsWithParameters = { parameter : "" , summary : "\0" , } ; comments . docTagEnd = " " ; comments . docTagSpaceAfter = "  " ; comments . docTagStart = "@" ; comments . docStart = "/**" ; } param conditionals protected generateConditionalSyntax ( conditionals ) { conditionals . elif = "else if" ; conditionals . else = "else" ; conditionals . end = "}" ; conditionals . if = "if" ; conditionals . startLeft = " (" ; conditionals . continueLeft = "} " ; conditionals . continueRight = " {" ; conditionals . startRight = ") {" ; } param dictionaries protected generateDictionarySyntax ( dictionaries ) { dictionaries . className = "Object" ; dictionaries . containsKey = new NativeCallSyntax ( "{}.hasOwnProperty.call" , NativeCallScope . Static , NativeCallType . Function ) ; dictionaries . getLeft = "[" ; dictionaries . getRight = "]" ; dictionaries . keys = new NativeCallSyntax ( "Object.keys" , NativeCallScope . Static , NativeCallType . Function ) ; dictionaries . initializeAsLiteral = "{}" ; dictionaries . initializeEnd = "}" ; dictionaries . initializePairComma = "," ; dictionaries . initializePairLeft = "" ; dictionaries . initializePairMiddle = ": " ; dictionaries . initializePairRight = "" ; dictionaries . initializeStart = "{" ; dictionaries . requiredImports = [ ] ; dictionaries . setLeft = "[" ; dictionaries . setMiddle = "] = " ; dictionaries . setRight = "" ; dictionaries . typeLeft = "{ [i: " ; dictionaries . typeMiddle = "]: " ; dictionaries . typeRight = " }" ; } param enums protected generateEnumSyntax ( enums ) { enums . declareCommaRight = "," ; enums . declareLastRight = "" ; enums . declareExternal = "export enum {0} {" ; enums . declareInternal = "enum {0} {" ; enums . declareValueLeft = " = " ; enums . declareValueRight = "" ; enums . declareValues = true ; enums . isObject = false ; enums . requiredImports = [ ] ; enums . valueLeft = "" ; enums . valueMiddle = "." ; enums . valueRight = "" ; } param exceptions protected generateExceptionSyntax ( exceptions ) { exceptions . blockEnd = "} " ; exceptions . catch = "catch" ; exceptions . catchStartLink = " " ; exceptions . catchStartMiddle = " (" ; exceptions . catchStartRight = ") {" ; exceptions . finally = "finally" ; exceptions . finallyStartRight = " {" ; exceptions . throw = "throw new" ; exceptions . throwMiddle = "(" ; exceptions . throwRight = ")" ; exceptions . try = "try" ; exceptions . tryStartRight = " {" ; exceptions . variablePrefix = "" ; exceptions . className = "Error" ; exceptions . requiredImports = [ ] ; exceptions . requiresExceptionType = false ; } param members protected generateExportSyntax ( exports ) { exports . exportedLeft = "export " ; exports . internal = "" ; } param files protected generateFileSyntax ( files ) { files . endLines = [ ] ; files . indentation = 0 ; files . startCase = CaseStyle . FileSystemLowerCase ; files . startLines = [ ] ; } param functions protected generateFunctionSyntax ( functions ) { functions . case = CaseStyle . CamelCase ; functions . defineEnd = "}" ; functions . defineStartLeft = "function " ; functions . defineStartRight = " {" ; functions . explicitNewStaticGenericType = true ; functions . explicitReturns = true ; functions . requiresExceptions = false ; functions . returnTypeAfterName = true ; functions . returnTypeMarker = ": " ; } param imports protected generateImportSyntax ( imports ) { imports . case = CaseStyle . DirectoryUpperCase ; imports . explicitItems = true ; imports . itemsBeforePackage = true ; imports . leftAbsolute = "import { " ; imports . leftLocal = "import { " ; imports . middle = ' } from "' ; imports . right = '";' ; imports . useLocalRelativeImports = true ; imports . useLocalRelativePaths = true ; } param interfaces protected generateInterfaceSyntax ( interfaces ) { interfaces . declareStartLeft = "interface " ; interfaces . declareStartRight = " {" ; interfaces . declareExtendsLeft = " extends " ; interfaces . declareExtendsRight = ", " ; interfaces . declareEnd = "}" ; interfaces . declareMethodLeft = "" ; interfaces . declareMethodMiddle = "(" ; interfaces . declareMethodRight = ")" ; interfaces . declareImplementsExplicit = true ; interfaces . methodTypeAfter = true ; interfaces . supported = true ; } param lambdas protected generateLambdaSyntax ( lambdas ) { lambdas . callLeft = "(" ; lambdas . callRight = ")" ; lambdas . functionLeft = "(" ; lambdas . functionMiddle = ") => " ; lambdas . functionRight = "" ; lambdas . parameterTypeRequired = false ; lambdas . returnTypeRequired = false ; } param typeInline protected generateLambdaTypeInlineSyntax ( typeInline ) { typeInline . includeParameterNames = true ; typeInline . leftByParameterCount = [ "(" , "(" , "(" ] ; typeInline . middleWithoutParameters = ") => " ; typeInline . middleWithParameters = ") => " ; typeInline . requiredImports = [ ] ; typeInline . right = "" ; } param lists protected generateListSyntax ( lists ) { lists . addList = new NativeCallSyntax ( "concat" , NativeCallScope . Member , NativeCallType . Function ) ; lists . asArray = true ; lists . getLeft = "[" ; lists . getRight = "]" ; lists . insert = new NativeCallSyntax ( "splice" , NativeCallScope . Member , NativeCallType . Function ) . withSeparator ( ", 0, " ) ; lists . length = new NativeCallSyntax ( "length" , NativeCallScope . Member , NativeCallType . Property ) ; lists . pop = new NativeCallSyntax ( "pop" , NativeCallScope . Member , NativeCallType . Function ) ; lists . popFront = new NativeCallSyntax ( "shift" , NativeCallScope . Member , NativeCallType . Function ) ; lists . push = new NativeCallSyntax ( "push" , NativeCallScope . Member , NativeCallType . Function ) ; lists . requiredImports = [ ] ; lists . setLeft = "[" ; lists . setMiddle = "] = " ; lists . setRight = "" ; lists . sortNumbers = new NativeCallSyntax ( "sort" , NativeCallScope . Member , NativeCallType . Function ) . withArguments ( [ "(a: number, b: number): number => a - b" , ] ) ; lists . sortStrings = new NativeCallSyntax ( "sort" , NativeCallScope . Member , NativeCallType . Function ) ; } /**
     * Fills out metadata on list creation with items.
     */ protected generateListNewItemsSyntax ( newItems ) { } param arrays protected generateListNewSizedSyntax ( newSized ) { newSized . includeType = true ; newSized . left = "new Array<" ; newSized . middle = ">(" ; newSized . right = ")" ; } /**
     * Fills out metadata on list slicing.
     */ protected generateListSliceSyntax ( slices ) { slices . before = "" ; slices . left = ".slice(" ; slices . middle = ", " ; slices . right = ")" ; slices . support = ListSliceSupport . Index ; slices . untilEndDefaultStart = "" ; slices . untilEndLeft = ".slice(" ; slices . untilEndMiddle = "" ; slices . untilEndRightFromIndex = ")" ; slices . untilEndRightFromStart = ")" ; } /**
     * Fills out metadata on list sorting by keyed member numbers.
     */ protected generateListSortMemberNumbersSyntax ( sortMembers ) { sortMembers . lambdaLeft = ".sort((" ; sortMembers . lambdaMiddleLeft = ") => " ; sortMembers . lambdaMiddleRight = " < " ; sortMembers . lambdaRight = " ? -1 : 1)" ; sortMembers . requiredImports = [ ] ; sortMembers . type = ListSortMemberType . KeyComparator ; } /**
     * Fills out metadata on list sorting by keyed member strings.
     */ protected generateListSortMemberStringsSyntax ( sortMembers ) { sortMembers . lambdaLeft = ".sort((" ; sortMembers . lambdaMiddleLeft = ") => " ; sortMembers . lambdaMiddleRight = " < " ; sortMembers . lambdaRight = " ? -1 : 1)" ; sortMembers . requiredImports = [ ] ; sortMembers . type = ListSortMemberType . KeyComparator ; } param loops protected generateLoopSyntax ( loops ) { loops . break = "break" ; loops . continue = "continue" ; loops . for = "for" ; loops . forEachEnd = "}" ; loops . forEachKeyEnd = "}" ; loops . forEachPairEnd = "}" ; loops . forNumbersEnd = "}" ; loops . whileStartLeft = "while" ; loops . whileStartMiddle = " (" ; loops . whileStartRight = ") {" ; loops . foreach = "for" ; loops . forEachGetKeys = "" ; loops . forEachGetPairs = "" ; loops . forEachMiddle = " in " ; loops . forEachPairsAsKeys = true ; loops . forEachRight = "" ; loops . forEachStartLeft = "for" ; loops . forEachStartIteration = " (" ; loops . forEachStartSeparator = " of " ; loops . forEachStartRight = ") {" ; } param main protected generateMainSyntax ( main ) { main . contextEndLines = [ ] ; main . contextIndentation = 0 ; main . contextStartLines = [ ] ; main . group = "" ; main . mainEndLines = [ ] ; main . mainIndentation = 0 ; main . mainStartLines = [ ] ; } param math protected generateMathSyntax ( math ) { math . absolute = new NativeCallSyntax ( "Math.abs" , NativeCallScope . Static , NativeCallType . Function ) ; math . asInt = new NativeCallSyntax ( "Math.floor" , NativeCallScope . Static , NativeCallType . Function ) ; math . ceiling = new NativeCallSyntax ( "Math.ceil" , NativeCallScope . Static , NativeCallType . Function ) ; math . floor = new NativeCallSyntax ( "Math.floor" , NativeCallScope . Static , NativeCallType . Function ) ; math . max = new NativeCallSyntax ( "Math.max" , NativeCallScope . Static , NativeCallType . Function ) ; math . min = new NativeCallSyntax ( "Math.min" , NativeCallScope . Static , NativeCallType . Function ) ; math . power = new NativeCallSyntax ( "Math.pow" , NativeCallScope . Static , NativeCallType . Function ) ; math . mathName = "Math" ; } param newProp protected generateNewSyntax ( newProp ) { newProp . instantiationKind = NewInstantiationSyntaxKind . Prefix ; newProp . keyword = "new" ; } param operators protected generateOperatorSyntax ( operators ) { operators . and = "&&" ; operators . decreaseBy = "-=" ; operators . divide = "/" ; operators . divideBy = "/=" ; operators . equals = "=" ; operators . greaterThan = ">" ; operators . greaterThanOrEqualTo = ">=" ; operators . increaseBy = "+=" ; operators . lessThan = "<" ; operators . lessThanOrEqualTo = "<=" ; operators . minus = "-" ; operators . mod = "%" ; operators . multiplyBy = "*=" ; operators . not = "!" ; operators . or = "||" ; operators . plus = "+" ; operators . times = "*" ; operators . equalTo = "===" ; operators . notEqualTo = "!==" ; } param parameters protected generateParameterSyntax ( parameters ) { parameters . restDeclarationAfter = true ; parameters . restDeclarationType = true ; parameters . restKeywordLeft = "..." ; parameters . restKeywordMiddle = ": " ; parameters . restKeywordRight = "[]" ; } param parameters protected generatePrintingSyntax ( printing ) { printing . end = ")" ; printing . requiredImports = [ ] ; printing . start = "console.log(" ; } param parameters protected generateSetSyntax ( sets ) { sets . add = new NativeCallSyntax ( "add" , NativeCallScope . Member , NativeCallType . Function ) ; sets . className = "Set" ; sets . contains = new NativeCallSyntax ( "has" , NativeCallScope . Member , NativeCallType . Function ) ; sets . initializeAsNew = true ; sets . initializeStart = "" ; sets . requiredImports = [ ] ; sets . startItemsLeft = "([" ; sets . startItemsRight = "])" ; sets . startNoItems = "()" ; sets . toArray = new NativeCallSyntax ( "Array.from" , NativeCallScope . Static , NativeCallType . Function ) ; sets . toList = sets . toArray ; sets . typeLeft = "<" ; sets . typeRight = ">" ; } param parameters protected generateStandaloneFunctionSyntax ( standaloneFunctions ) { standaloneFunctions . withinStaticClass = false ; } param formatting protected generateStringFormatSyntax ( formatting ) { formatting . formatLeft = "`" ; formatting . formatRight = "`" ; formatting . formatInputLeft = "${" ; formatting . formatInputRight = "}" ; formatting . includeIndexInFormatting = false ; formatting . inputTypes = false ; formatting . useInterpolation = true ; } param strings protected generateStringSyntax ( strings ) { strings . caseLower = new NativeCallSyntax ( "toLowerCase" , NativeCallScope . Member , NativeCallType . Function ) ; strings . caseUpper = new NativeCallSyntax ( "toUpperCase" , NativeCallScope . Member , NativeCallType . Function ) ; strings . className = "String" ; strings . concatenate = " + " ; strings . indexLeft = "[" ; strings . indexOf = new NativeCallSyntax ( "indexOf" , NativeCallScope . Member , NativeCallType . Function ) ; strings . indexOfNotFound = "-1" ; strings . indexRight = "]" ; strings . length = new NativeCallSyntax ( "length" , NativeCallScope . Member , NativeCallType . Property ) ; strings . trim = new NativeCallSyntax ( "trim" , NativeCallScope . Member , NativeCallType . Function ) ; } param strings protected generateStringSubstringSyntax ( substrings ) { substrings . defaultEnd = "" ; substrings . leftIndex = ".substring(" ; substrings . leftLength = ".substr(" ; substrings . middle = ", " ; substrings . right = ")" ; substrings . support = StringSubstringSupport . Both ; } param toDouble protected generateStringToDoubleSyntax ( toDouble ) { toDouble . conversionType = StringToNumberStartConversionType . ConvertAndValidate ; toDouble . perVariableConversionStartLeft = "let " ; toDouble . perVariableConversionStartMiddle = ": number = parseFloat(" ; toDouble . perVariableConversionStartRight = ");\n" ; toDouble . validationBlockComparison = "!isNaN({1})" ; toDouble . validationBlockLeft = "\nif (" ; toDouble . validationBlockMiddle = " && " ; toDouble . validationBlockRight = ") {" ; } param toInt protected generateStringToIntSyntax ( toInt ) { toInt . conversionType = StringToNumberStartConversionType . ConvertAndValidate ; toInt . perVariableConversionStartLeft = "let " ; toInt . perVariableConversionStartMiddle = ": number = parseInt(" ; toInt . perVariableConversionStartRight = ");\n" ; toInt . validationBlockComparison = "!isNaN({1})" ; toInt . validationBlockLeft = "\nif (" ; toInt . validationBlockMiddle = " && " ; toInt . validationBlockRight = ") {" ; } param style protected generateStyleSyntax ( style ) { style . semicolon = ";" ; } param style protected generateUnsupportedSyntax ( unsupported ) { unsupported . complaintEnd = "*/" ; unsupported . complaintStart = "/*" ; } param variables protected generateVariableSyntax ( variables ) { variables . declarationRequired = true ; variables . aliases = { infinity : "Infinity" , } ; variables . castLeft = "<" ; variables . castRight = ">" ; variables . declaration = "let " ; variables . explicitTypes = true ; variables . null = "undefined" ; variables . typesAfterName = true ; variables . typeLeft = ": " ; variables . isNullLeft = "" ; variables . isNotNullLeft = "" ; variables . isNotNullMiddle = " !== " ; variables . isNullMiddle = " === " ; variables . nullRight = "undefined" ; } }