├── .gitignore ├── .vscode └── launch.json ├── LICENSE.md ├── README.md ├── docs ├── Examples.md ├── GenerateOptions.md ├── Installing.md ├── Mapping.md ├── Mapping │ ├── BasicTypes.md │ ├── Generics.md │ └── RestParameters.md ├── UnitTests.md └── Usage.md ├── package-lock.json ├── package.json ├── src ├── CSharpEmitter.ts ├── CommandLineParser.ts ├── Context.ts ├── DataStructures.ts ├── Diagnostics.ts ├── GenerateOptions.ts ├── GeneratorHelpers.ts ├── TsToCSharp.ts ├── TsToCSharpGenerator.ts └── TsToCSharpTests.ts ├── test ├── cases │ ├── classes │ │ ├── InterfaceDeclaration.cs │ │ ├── InterfaceDeclaration1.cs │ │ ├── InterfaceDeclaration2.cs │ │ ├── InterfaceDeclaration4.cs │ │ ├── InterfaceDeclaration5.cs │ │ ├── InterfaceDeclarationNoEmitComments.cs │ │ ├── InterfaceDeclarationPropertyIndexer.cs │ │ ├── InterfaceDeclarationWithComments.cs │ │ ├── InterfaceDeclarationWithConstructorArgs.cs │ │ ├── InterfaceDeclarationWithEventHandlers.cs │ │ ├── InterfaceDeclarationWithInheritedMethods.cs │ │ ├── InterfaceDeclarationWithInheritedProperties.cs │ │ ├── InterfaceDeclarationWithMethods.cs │ │ ├── InterfaceDeclarationWithProperties.cs │ │ └── InterfaceDeclarationWithTypeQuery.cs │ └── interfaces │ │ ├── ArrayProperty.cs │ │ ├── ArrayProperty2.cs │ │ ├── BooleanArrayOrNullProperty.cs │ │ ├── BooleanArrayProperty.cs │ │ ├── BooleanOrNullProperty.cs │ │ ├── BooleanProperty.cs │ │ ├── Comments.cs │ │ ├── Comments2.cs │ │ ├── EventHandlers.cs │ │ ├── Extends.cs │ │ ├── Extends2.cs │ │ ├── Extends3.cs │ │ ├── Extends4.cs │ │ ├── ExtendsGeneric.cs │ │ ├── GenericInterfaceWithConstraint.cs │ │ ├── GenericInterfaceWithConstraint2.cs │ │ ├── GenericInterfaceWithTypeDefault.cs │ │ ├── IndexerProperty.cs │ │ ├── IndexerPropertyComments.cs │ │ ├── Interface.cs │ │ ├── Interface2.cs │ │ ├── MethodComments.cs │ │ ├── MethodReturnAny.cs │ │ ├── MethodReturnAnyArray.cs │ │ ├── MethodReturnAnyArrayOrNull.cs │ │ ├── MethodReturnAnyOrNull.cs │ │ ├── MethodReturnBool.cs │ │ ├── MethodReturnBoolOrNull.cs │ │ ├── MethodReturnNever.cs │ │ ├── MethodReturnNumber.cs │ │ ├── MethodReturnNumberArray.cs │ │ ├── MethodReturnNumberArrayOrNull.cs │ │ ├── MethodReturnNumberOrNull.cs │ │ ├── MethodReturnRefType1.cs │ │ ├── MethodReturnRefType2.cs │ │ ├── MethodReturnRefTypeArray.cs │ │ ├── MethodReturnRefTypeArrayOrNull.cs │ │ ├── MethodReturnRefTypeOrNull.cs │ │ ├── MethodReturnString.cs │ │ ├── MethodReturnStringArray.cs │ │ ├── MethodReturnStringArrayOrNull.cs │ │ ├── MethodReturnStringOrNull.cs │ │ ├── MethodReturnVoid.cs │ │ ├── MethodWithBooleanArrayOrNullParms.cs │ │ ├── MethodWithBooleanArrayParms.cs │ │ ├── MethodWithBooleanOrNullParms.cs │ │ ├── MethodWithBooleanParms.cs │ │ ├── MethodWithDOMEventHandlerParms.cs │ │ ├── MethodWithLiteralTypeParm.cs │ │ ├── MethodWithNumberArrayOrNullParms.cs │ │ ├── MethodWithNumberArrayParms.cs │ │ ├── MethodWithNumberOrNullParms.cs │ │ ├── MethodWithNumberParms.cs │ │ ├── MethodWithRestAnyParms.cs │ │ ├── MethodWithRestStringParms.cs │ │ ├── MethodWithRestTypeRefParms.cs │ │ ├── MethodWithStringArrayOrNullParms.cs │ │ ├── MethodWithStringArrayParms.cs │ │ ├── MethodWithStringOrNullParms.cs │ │ ├── MethodWithStringParmReturnBool.cs │ │ ├── MethodWithStringParms.cs │ │ ├── MethodWithTypeRefArrayOrNullParms.cs │ │ ├── MethodWithTypeRefArrayParms.cs │ │ ├── MethodWithTypeRefOrNullParms.cs │ │ ├── NumberArrayOrNullProperty.cs │ │ ├── NumberArrayProperty.cs │ │ ├── NumberOrNullProperty.cs │ │ ├── NumberProperty.cs │ │ ├── ObjOrNullProperty.cs │ │ ├── ReadOnlyIndexerProperty.cs │ │ ├── ReadOnlyObjectProperty.cs │ │ ├── StringArrayOrNullProperty.cs │ │ ├── StringArrayProperty.cs │ │ ├── StringIndexerProperty.cs │ │ ├── StringOrNullProperty.cs │ │ ├── StringProperty.cs │ │ ├── TypeQueryProperty.cs │ │ ├── TypeRefArrayOrNullProperty.cs │ │ └── TypeRefArrayProperty.cs └── definitions │ ├── classes │ ├── InterfaceDeclaration.d.ts │ ├── InterfaceDeclaration1.d.ts │ ├── InterfaceDeclaration2.d.ts │ ├── InterfaceDeclaration3.d.ts │ ├── InterfaceDeclaration4.d.ts │ ├── InterfaceDeclaration5.d.ts │ ├── InterfaceDeclarationNoEmitComments.d.ts │ ├── InterfaceDeclarationPropertyIndexer.d.ts │ ├── InterfaceDeclarationWithComments.d.ts │ ├── InterfaceDeclarationWithConstructorArgs.d.ts │ ├── InterfaceDeclarationWithEventHandlers.d.ts │ ├── InterfaceDeclarationWithInheritedMethods.d.ts │ ├── InterfaceDeclarationWithInheritedProperties.d.ts │ ├── InterfaceDeclarationWithMethods.d.ts │ ├── InterfaceDeclarationWithProperties.d.ts │ └── InterfaceDeclarationWithTypeQuery.d.ts │ ├── diagnostics │ ├── DeclarationOfNonInterface.d.ts │ └── GenericInterfaceWithTypeDefault.d.ts │ └── interfaces │ ├── ArrayProperty.d.ts │ ├── ArrayProperty2.d.ts │ ├── BooleanArrayOrNullProperty.d.ts │ ├── BooleanArrayProperty.d.ts │ ├── BooleanOrNullProperty.d.ts │ ├── BooleanProperty.d.ts │ ├── Comments.d.ts │ ├── Comments2.d.ts │ ├── EventHandlers.d.ts │ ├── Extends.d.ts │ ├── Extends2.d.ts │ ├── Extends3.d.ts │ ├── Extends4.d.ts │ ├── ExtendsGeneric.d.ts │ ├── GenericInterfaceWithConstraint.d.ts │ ├── GenericInterfaceWithConstraint2.d.ts │ ├── GenericInterfaceWithTypeDefault.d.ts │ ├── IndexerProperty.d.ts │ ├── IndexerPropertyComments.d.ts │ ├── Interface.d.ts │ ├── Interface2.d.ts │ ├── MethodComments.d.ts │ ├── MethodReturnAny.d.ts │ ├── MethodReturnAnyArray.d.ts │ ├── MethodReturnAnyArrayOrNull.d.ts │ ├── MethodReturnAnyOrNull.d.ts │ ├── MethodReturnBool.d.ts │ ├── MethodReturnBoolOrNull.d.ts │ ├── MethodReturnNever.d.ts │ ├── MethodReturnNumber.d.ts │ ├── MethodReturnNumberArray.d.ts │ ├── MethodReturnNumberArrayOrNull.d.ts │ ├── MethodReturnNumberOrNull.d.ts │ ├── MethodReturnRefType1.d.ts │ ├── MethodReturnRefType2.d.ts │ ├── MethodReturnRefTypeArray.d.ts │ ├── MethodReturnRefTypeArrayOrNull.d.ts │ ├── MethodReturnRefTypeOrNull.d.ts │ ├── MethodReturnString.d.ts │ ├── MethodReturnStringArray.d.ts │ ├── MethodReturnStringArrayOrNull.d.ts │ ├── MethodReturnStringOrNull.d.ts │ ├── MethodReturnVoid.d.ts │ ├── MethodWithBooleanArrayOrNullParms.d.ts │ ├── MethodWithBooleanArrayParms.d.ts │ ├── MethodWithBooleanOrNullParms.d.ts │ ├── MethodWithBooleanParms.d.ts │ ├── MethodWithDOMEventHandlerParms.d.ts │ ├── MethodWithLiteralTypeParm.d.ts │ ├── MethodWithNumberArrayOrNullParms.d.ts │ ├── MethodWithNumberArrayParms.d.ts │ ├── MethodWithNumberOrNullParms.d.ts │ ├── MethodWithNumberParms.d.ts │ ├── MethodWithRestAnyParms.d.ts │ ├── MethodWithRestStringParms.d.ts │ ├── MethodWithRestTypeRefParms.d.ts │ ├── MethodWithStringArrayOrNullParms.d.ts │ ├── MethodWithStringArrayParms.d.ts │ ├── MethodWithStringOrNullParms.d.ts │ ├── MethodWithStringParmReturnBool.d.ts │ ├── MethodWithStringParms.d.ts │ ├── MethodWithTypeRefArrayOrNullParms.d.ts │ ├── MethodWithTypeRefArrayParms.d.ts │ ├── MethodWithTypeRefOrNullParms.d.ts │ ├── NumberArrayOrNullProperty.d.ts │ ├── NumberArrayProperty.d.ts │ ├── NumberOrNullProperty.d.ts │ ├── NumberProperty.d.ts │ ├── ObjOrNullProperty.d.ts │ ├── ReadOnlyObjectProperty.d.ts │ ├── ReadonlyIndexerProperty.d.ts │ ├── StringArrayOrNullProperty.d.ts │ ├── StringArrayProperty.d.ts │ ├── StringIndexerProperty.d.ts │ ├── StringOrNullProperty.d.ts │ ├── StringProperty.d.ts │ ├── TypeQueryProperty.d.ts │ ├── TypeRefArrayOrNullProperty.d.ts │ └── TypeRefArrayProperty.d.ts ├── tsconfig.json └── tslint.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | test/definitions/**/*.cs -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | 8 | { 9 | "type": "node", 10 | "request": "launch", 11 | "name": "Mocha Tests", 12 | "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", 13 | "args": [ 14 | "-u", 15 | "tdd", 16 | "--timeout", 17 | "999999", 18 | "--colors", 19 | "${workspaceFolder}/dist/TsToCSharpTests.js", 20 | ], 21 | "internalConsoleOptions": "openOnSessionStart", 22 | }, 23 | { 24 | "type": "node", 25 | "request": "launch", 26 | "name": "Mocha Tests Debug", 27 | "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", 28 | "protocol": "inspector", 29 | "args": [ 30 | "-u", 31 | "tdd", 32 | "--timeout", 33 | "999999", 34 | "--colors", 35 | "${workspaceFolder}/dist/TsToCSharpTests.js", 36 | ], 37 | "internalConsoleOptions": "openOnSessionStart", 38 | }, 39 | { 40 | "type": "node", 41 | "request": "launch", 42 | "name": "Launch Program", 43 | "program": "${workspaceFolder}/src/TStoCSharp.ts", 44 | "outFiles": [ 45 | "${workspaceFolder}/**/*.js" 46 | ], 47 | "args": [ 48 | "./test/definitions/interfaces/TypeQueryProperty.d.ts", 49 | "-o", 50 | "./test/cases/interfaces", 51 | "--noCaseChangeParameters", 52 | // For interface tests uncomment the following 53 | "--noPrefixInterface", 54 | "--noCaseChange", 55 | "--interfaceAccessModifier", 56 | "none" 57 | ] 58 | } 59 | ] 60 | } -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Mono Project 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TsToCSharp 2 | 3 | Emit C# strongly typed interface code from TypeScript definition files. 4 | 5 | This project is intended to read in TypeScript (.d.ts) defintions files and generate as closely as possible a C# strongly typed API for use from either WebAssembly code or .NET hosted in Electron. 6 | 7 | ## Current Work 8 | 9 | This is a work in progress, and we are only getting started. 10 | 11 | Only the very basic TypeScript AST parsing is present at this time. Mostly the basic types like `interface`, `boolean`, `number`, `arrays`, `properties`, `methods` and a handful of there associated complex types like `string | null`, `number | null`, `boolean | null` etc. 12 | 13 | 14 | ## Getting Started 15 | 16 | 1. [Installing](./docs/Installing.md) 17 | 2. [Usage](./docs/Usage.md) 18 | 3. [TypeScript to C# mapping](./docs/Mapping.md) 19 | 4. [Examples](./docs/Examples.md) 20 | 5. [Unit Tests](./docs/UnitTests.md) 21 | 22 | ## Obtaining Definition files 23 | 24 | Definitions files describe the shape of JavaScript to the TypeScript compiler and are used only to compile. 25 | 26 | The [Definitely Typed](https://github.com/DefinitelyTyped/DefinitelyTyped) github repository contains a large collection of TypeScript type definitions (.d.ts). 27 | 28 | ### Suggested resources on Definition Files 29 | 30 | - [TypeScript Handbook](https://github.com/Microsoft/TypeScript-Handbook) - A comprehensive guide to the TypeScript language 31 | - [TypeScript Declaration Files](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html) - Guide that is designed to teach you how to write a high-quality TypeScript Declaration File. 32 | - [Definitely Typed Repository](http://definitelytyped.org) - The repository for high quality TypeScript type definitions. 33 | - [Definitely Typed Website](http://definitelytyped.org) - The DefinitelyTyped website. 34 | - [Definitely Typed Guides](http://definitelytyped.org/guides/creating.html) - Creating a definition file. 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /docs/Examples.md: -------------------------------------------------------------------------------- 1 | # Examples 2 | 3 | -------------------------------------------------------------------------------- /docs/GenerateOptions.md: -------------------------------------------------------------------------------- 1 | # Generate Options 2 | 3 | The command line options that can be passed to TsToCSharp allow you to control aspects of the emitted C# code in the final output file. 4 | 5 | ## Generate Options 6 | 7 | | Option | Type | Default | Description | 8 | |---|---|---|---| 9 | | -h, --help | boolean | | Show help | 10 | | --interfacePrefix | string | "I" (uppercase `i`) | Prefix interfaces with the string provided. | 11 | | --interfaceAccessModifier | string | "public" | Default interface access identifier. | 12 | | --noCaseChange | boolean | true | Do not change case. Global| 13 | | --noCaseChangeClasses | boolean | true | Do not change case of Class Declarations. | 14 | | --noCaseChangeInterfaces | boolean | true | Do not change case of Interface Declarations. | 15 | | --noCaseChangeMethods | boolean | true | Do not change case of Method Declarations. | 16 | | --noCaseChangeParameters | boolean | true | Do not change case of Parameter Declarations. | 17 | | --noCaseChangeProperties | boolean | true | Do not change case of Property Declarations. | 18 | | --noEmitExports | boolean | true | Do not emit any Export attributes. Global| 19 | | --noEmitMethodExport | boolean | true | Do not emit Export attribute for methods. | 20 | | --noEmitPropertyExport | boolean | true | Do not emit Export attribute for properties. | 21 | | --noPrefixInterface | boolean | true | Do not prefix interface names. | 22 | | -o, --outDir | string | | Output directory for generated C# files. | 23 | | --removeComments | boolean | false | Do not emit comments contained in the definition file(s). | 24 | 25 | -------------------------------------------------------------------------------- /docs/Installing.md: -------------------------------------------------------------------------------- 1 | # Installing the project 2 | 3 | ## Github Repository 4 | 5 | * Clone the TsToCSharp repository 6 | * For SSH 7 | 8 | ``` bash 9 | # Mac Terminal 10 | $ mkdir projects 11 | $ cd projects 12 | projects$ 13 | projects$ git clone git@github.com:mono/TsToCSharp.git 14 | ``` 15 | 16 | * For HTTPS 17 | 18 | ``` bash 19 | # Mac Terminal 20 | $ mkdir projects 21 | $ cd projects 22 | projects$ 23 | projects$ git clone https://github.com/mono/TsToCSharp.git 24 | ``` 25 | 26 | ## Install NPM module dependencies 27 | 28 | The following command will install all the NPM module dependencies that are used in the project. 29 | 30 | ``` bash 31 | $ npm install 32 | ``` 33 | 34 | After the Node modules are installed and requirements setup the project will be ready to build. 35 | 36 | ## Build the project TypeScript files 37 | 38 | The following command will compile all the TypeScript (.ts) files. 39 | 40 | ``` bash 41 | $ npm run build-ts 42 | ``` 43 | 44 | After the compilation is complete project is ready for use. 45 | 46 | ## Command Line Interface 47 | 48 | The project can also be setup to run from the command line. 49 | 50 | ### Setup a symlink to TsToCSharp 51 | 52 | From the project directory execute the following: 53 | 54 | ``` bash 55 | npm link 56 | ``` 57 | 58 | To test this you can open a new Terminal or Command Prompt, make sure you are not in the project directory and execute the `TsToCSharp` command. 59 | 60 | ``` bash 61 | $ TsToCSharp 62 | ``` 63 | 64 | You should get a usage help screen because no parameters were specified. 65 | 66 | ``` 67 | Usage: TsToCSharp [options] file1.d.ts file2.d.ts 68 | 69 | Options: 70 | --version Show version number [boolean] 71 | -o, --outDir Output directory for generated C# files. 72 | --noEmitComments Do not emit comments contained in the definition 73 | file(s). 74 | --noEmitExports Do not emit any Export attributes. 75 | --noEmitMethodExport Do not emit Export attribute for methods. 76 | --noEmitPropertyExport Do not emit Export attribute for properties. 77 | -h, --help Show help [boolean] 78 | 79 | Examples: 80 | TsToCSharp file1.d.ts Emit strongly typed C# definition from TypeScript 81 | definition file(s) 82 | TsToCSharp -o ./ file1.d.ts Emit strongly typed C# definition from TypeScript 83 | definition file(s) 84 | 85 | Not enough non-option arguments: got 0, need at least 1 86 | 87 | ``` 88 | 89 | All the available command line options can be found in the [Generate Options](./GenerateOptions.md) document. 90 | 91 | ### Install globally 92 | 93 | To install globally make sure you are in the the project directory and execute the following command: 94 | 95 | ``` bash 96 | npm install -g 97 | ``` 98 | 99 | > Tip: On Windows Npm will install a `.cmd` wrapper so users can execute it from the command-line. 100 | 101 | -------------------------------------------------------------------------------- /docs/Mapping.md: -------------------------------------------------------------------------------- 1 | # Mapping 2 | 3 | - [Basic Types](./Mapping/BasicTypes.md) 4 | - [Rest Parameters](./Mapping/RestParameters.md) 5 | - [Generics](./Mapping/Generics.md) -------------------------------------------------------------------------------- /docs/Mapping/BasicTypes.md: -------------------------------------------------------------------------------- 1 | # Basic Types 2 | 3 | ## Introduction 4 | 5 | TypeScript contains a number of [Basic Types](https://www.typescriptlang.org/docs/handbook/basic-types.html) that model the JavaScript types closely but correspond loosely with C# primitive types. Because of this there may be some liberties taken to obtain a mapping which may later be edited by hand for the correct C# primitive. An example of this is the `number` type described below. 6 | 7 | ## Boolean 8 | 9 | The `boolean` type has a direct mapping to C# `bool`. 10 | 11 | Method returning boolean: 12 | 13 | ```typescript 14 | hasAttributes(): boolean; 15 | ``` 16 | 17 | ```csharp 18 | bool hasAttributes(); 19 | ``` 20 | 21 | Method with boolean parameter: 22 | 23 | ```typescript 24 | initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; 25 | ``` 26 | 27 | ```csharp 28 | void initEvent(string eventTypeArg, bool canBubbleArg, bool cancelableArg); 29 | ``` 30 | 31 | Property: 32 | 33 | ```typescript 34 | readonly cancelable: boolean; 35 | cancelBubble: boolean; 36 | ``` 37 | 38 | ```csharp 39 | bool cancelable { get; } 40 | bool cancelBubble { get; set; } 41 | ``` 42 | 43 | ## Number 44 | 45 | All numbers in TypeScript are floating point values and represented by a double precision 64-bit floating point value. The `number` type has a direct mapping to C# `double`. 46 | 47 | Method returning number: 48 | 49 | ```typescript 50 | now(): number; 51 | ``` 52 | 53 | ```csharp 54 | double now(); 55 | ``` 56 | 57 | Method with number parameter: 58 | 59 | ```typescript 60 | caretRangeFromPoint(x: number, y: number): Range; 61 | ``` 62 | 63 | ```csharp 64 | Range caretRangeFromPoint(double x, double y); 65 | ``` 66 | 67 | Property: 68 | 69 | ```typescript 70 | readonly accuracy: number; 71 | scrollTop: number; 72 | ``` 73 | 74 | ```csharp 75 | double accuracy { get; } 76 | double scrollTop { get; set; } 77 | ``` 78 | 79 | ## String 80 | 81 | Strings in TypeScript represet UTF-16 string data. 82 | 83 | The `string` type has a direct mapping to C# `string`. 84 | 85 | Method returning string: 86 | 87 | ```typescript 88 | toString(): string; 89 | ``` 90 | 91 | ```csharp 92 | string toString(); 93 | ``` 94 | 95 | Method with string parameter: 96 | 97 | ```typescript 98 | setAttribute(name: string, value: string): void; 99 | ``` 100 | 101 | ```csharp 102 | void setAttribute(string name, string value); 103 | ``` 104 | 105 | Property: 106 | 107 | ```typescript 108 | readonly baseURI: string; 109 | accessKey: string; 110 | ``` 111 | 112 | ```csharp 113 | string baseURI { get; } 114 | string accessKey { get; set; } 115 | ``` 116 | 117 | ## Array 118 | 119 | Array types can be written with a element type followed by `[]` (`elemType[]`) or as a generic array type, Array. 120 | 121 | ### elemType[] 122 | 123 | First some examples of the element type followed by `[]` 124 | 125 | Method returning `elemType[]`: 126 | 127 | ```typescript 128 | getLineDash(): number[]; 129 | getAll(name: string): string[]; 130 | deepPath(): EventTarget[]; 131 | ``` 132 | 133 | ```csharp 134 | double[] getLineDash(); 135 | string[] getAll(string name); 136 | EventTarget[] deepPath(); 137 | ``` 138 | 139 | Method with `elemType[]` parameter: 140 | 141 | ```typescript 142 | initFauxInterface(fauxArg: boolean[]): void; 143 | setLineDash(segments: number[]): void; 144 | msLockOrientation(orientations: string[]): boolean; 145 | makeCredential(accountInformation: Account, cryptoParameters: ScopedCredentialParameters[], attestationChallenge: BufferSource, options?: ScopedCredentialOptions): ScopedCredentialInfo; 146 | ``` 147 | 148 | ```csharp 149 | void initFauxInterface(bool[] fauxArg); 150 | void setLineDash(double[] segments); 151 | bool msLockOrientation(string[] orientations); 152 | ScopedCredentialInfo makeCredential(Account accountInformation, ScopedCredentialParameters[] cryptoParameters, BufferSource attestationChallenge, ScopedCredentialOptions options); 153 | ``` 154 | 155 | Property: 156 | 157 | ```typescript 158 | readonly axesAvailable: boolean[]; 159 | readonly axes: number[]; 160 | readonly languages: string[]; 161 | MessagePort[] ports { get; set; } 162 | ``` 163 | 164 | ```csharp 165 | bool[] axesAvailable { get; } 166 | double[] axes { get; } 167 | string[] languages { get; } 168 | MessagePort[] ports { get; set; } 169 | ``` 170 | 171 | ### Array 172 | 173 | Now some examples of Array. 174 | 175 | Method returning `Array`: 176 | 177 | ```typescript 178 | 179 | Not supported yet 180 | 181 | ``` 182 | 183 | ```csharp 184 | 185 | Not supported yet 186 | 187 | ``` 188 | 189 | Method with `Array` parameter: 190 | 191 | ```typescript 192 | 193 | Not supported yet 194 | 195 | ``` 196 | 197 | ```csharp 198 | 199 | Not supported yet 200 | 201 | ``` 202 | 203 | Property: 204 | 205 | ```typescript 206 | 207 | Not supported yet 208 | 209 | ``` 210 | 211 | ```csharp 212 | 213 | Not supported yet 214 | 215 | ``` 216 | 217 | ## Any 218 | 219 | The `any` keyword bows out of type checking. 220 | 221 | For all general purposes we will be mapping this to C# `object` type. 222 | 223 | Method returning `any`: 224 | 225 | ```typescript 226 | 227 | toJSON(): any; 228 | receiveMessage(message: any, targetOrigin: string): any[]; 229 | item(name?: any, index?: any): any; 230 | 231 | ``` 232 | 233 | ```csharp 234 | 235 | Object toJSON(); 236 | Object[] receiveMessage(Object message, string targetOrigin); 237 | Object item(Object name, Object index); 238 | ``` 239 | 240 | Method with `any` parameter: 241 | 242 | ```typescript 243 | 244 | warn(message?: any, ...optionalParams: any[]): void; 245 | 246 | ``` 247 | 248 | ```csharp 249 | 250 | void warn(Object message, params Object[] optionalParams); 251 | 252 | ``` 253 | 254 | Property: 255 | 256 | ```typescript 257 | 258 | data?: any; 259 | 260 | ``` 261 | 262 | ```csharp 263 | 264 | Object data { get; set; } 265 | 266 | ``` 267 | 268 | 269 | 270 | ## Void 271 | 272 | The `void` keyword represents a method or function that will not return back a value and thus has no type. 273 | 274 | The `void` keyword has a direct mapping to C# `void`. 275 | 276 | Method returning `void`: 277 | 278 | ```typescript 279 | 280 | dispatchEvent(): void; 281 | 282 | ``` 283 | 284 | ```csharp 285 | 286 | void dispatchEvent(); 287 | 288 | ``` 289 | 290 | ## Never 291 | 292 | The `never` type represents values that never occur. 293 | 294 | The `never` type has no direct mapping to C# and at this type defaults to `void`. 295 | 296 | Method returning `never`: 297 | 298 | ```typescript 299 | 300 | fail(): never; 301 | 302 | ``` 303 | 304 | ```csharp 305 | 306 | void fail(); 307 | 308 | ``` 309 | 310 | ## Null and undefined 311 | 312 | TypeScript defines both `undefined` and `null` and not extremely useful on their own. In the definition files the nullable definitions are paired with [Union Types](#union-types) defined with the pipe symbol (|). 313 | 314 | C# Nullable types represent value-type variables that can be assigned the value of null. You cannot create a nullable type based on a reference type. (Reference types already support the null value.) 315 | 316 | Method returning `nullable` type: 317 | 318 | ```typescript 319 | 320 | iceLite?: boolean | null; 321 | now(): number | null; 322 | getLineDash(): number[] | null; 323 | item(index: number): string | null; 324 | getAll(name: string): string[] | null; 325 | add(data: File): DataTransferItem | null; 326 | deepPath(): EventTarget[] | null; 327 | toJSON(): any | null; 328 | receiveMessage(message: any, targetOrigin: string): any[] | null; 329 | 330 | ``` 331 | 332 | ```csharp 333 | 334 | bool? iceLite { get; set; } 335 | double? now(); 336 | double?[] getLineDash(); 337 | string item(double index); 338 | string[] getAll(string name); 339 | DataTransferItem add(File data); 340 | EventTarget[] deepPath(); 341 | Object toJSON(); 342 | Object[] receiveMessage(Object message, string targetOrigin); 343 | 344 | ``` 345 | 346 | Method with `nullable` parameter: 347 | 348 | ```typescript 349 | 350 | initFaux(eventTypeArg: string, canBubbleArg: boolean | null, cancelableArg: boolean | null): void; 351 | initDeviceOrientationEvent(type: string, bubbles: boolean, cancelable: boolean, alpha: number | null, beta: number | null, gamma: number | null, absolute: boolean): void; 352 | setFauxLineDash(segments: number[] | null): void; 353 | getNamedItemNS(namespaceURI: string | null, localName: string | null): Attr; 354 | msLockOrientation(orientations: string[] | null): boolean; 355 | evaluate(expression: string, contextNode: Node, resolver: XPathNSResolver | null, type: number, result: XPathResult | null): XPathResult; 356 | makeCredential(accountInformation: Account, cryptoParameters: ScopedCredentialParameters[] | null, attestationChallenge: BufferSource, options?: ScopedCredentialOptions): ScopedCredentialInfo; 357 | 358 | ``` 359 | 360 | ```csharp 361 | 362 | void initFaux(string eventTypeArg, bool? canBubbleArg, bool? cancelableArg); 363 | void initFauxInterface(bool?[] fauxArg); 364 | void initDeviceOrientationEvent(string type, bool bubbles, bool cancelable, double? alpha, double? beta, double? gamma, bool absolute); 365 | void setFauxLineDash(double?[] segments); 366 | Attr getNamedItemNS(string namespaceURI, string localName); 367 | bool msLockOrientation(string[] orientations); 368 | XPathResult evaluate(string expression, Node contextNode, XPathNSResolver resolver, double type, XPathResult result); 369 | ScopedCredentialInfo makeCredential(Account accountInformation, ScopedCredentialParameters[] cryptoParameters, BufferSource attestationChallenge, ScopedCredentialOptions options); 370 | 371 | ``` 372 | -------------------------------------------------------------------------------- /docs/Mapping/Generics.md: -------------------------------------------------------------------------------- 1 | # Generics 2 | 3 | ## Interfaces 4 | 5 | ## Classes 6 | 7 | ## Methods 8 | 9 | ## Properties -------------------------------------------------------------------------------- /docs/Mapping/RestParameters.md: -------------------------------------------------------------------------------- 1 | # Rest Parameters 2 | 3 | ## Introduction 4 | 5 | The Rest parameters (denoted by ...parameterName for the last argument) gives the user the ability to group multiple parameters into one variable name and treat them as an array. 6 | 7 | ## Rest 8 | 9 | The Rest Parameter `...parameterName` has a direct mapping to C# `params` keyword. 10 | 11 | Methods with Rest Parameter: 12 | 13 | ```typescript 14 | log(message?: any, ...optionalParams: any[]): void; 15 | createTouchList(...touches: Touch[]): TouchList; 16 | writeln(...content: string[]): void; 17 | ``` 18 | 19 | ```csharp 20 | void log(Object message, params Object[] optionalParams); 21 | TouchList createTouchList(params Touch[] touches); 22 | void writeln(params string[] content); 23 | ``` 24 | -------------------------------------------------------------------------------- /docs/UnitTests.md: -------------------------------------------------------------------------------- 1 | # Unit Tests 2 | 3 | Right now the project is taking a Test Driven Development (TDD) approach. What this basically means is that as each TypeScript AST spec is implemented there will be a test setup for verifying the correct C# mapping. That way we can guarantee that any modifications to the C# code emitted from the TypeScript AST parsing can be verified to produce the expected result as the project advances. 4 | 5 | The unit tests are setup with predefined input [TypeScript definitions](/test/definitions) and a corresponding expected [C# result case](/test/cases). 6 | 7 | ## Current Work 8 | 9 | This is a work in progress and only the very basic AST parsing is present at this time. Mostly the basic types like `interface`, `boolean`, `number`, `arrays`, `properties`, `methods` and a handful of there associated complex types like `string | null`, `number | null`, `boolean | null` etc. 10 | 11 | A lot more work is required. 12 | 13 | ## Test directory structure 14 | 15 | The test files can be found in the [Test](/test) directory. 16 | 17 | ``` 18 | . 19 | |--- test 20 | |--- cases 21 | |--- interfaces // C# interface test case results used for correctness. 22 | |--- definitions 23 | |--- interfaces // TypeScript input definition files used to generate the C# code. 24 | ``` 25 | 26 | ## The testing framework 27 | 28 | The tesing is done using [Mocha](mochajs.org) which is popular testing framework and the [Chai](http://chaijs.com/) assertion library. 29 | 30 | ## Running the tests 31 | 32 | From the command line: 33 | 34 | ``` 35 | $ npm test 36 | ``` 37 | 38 | Sample output. 39 | 40 | ``` 41 | TypeScript version: 2.7.1 42 | Working Directory: /projects/TypeScript/TsToCSharp/dist 43 | 44 | 45 | TsToCSharpGenerator 46 | interfaces 47 | ✓ should generate simple interface 48 | ✓ should generate simple interface with closing brackets on separate lines 49 | ✓ should generate simple interface with leading and trailing comments 50 | ✓ should generate simple interface with leading and trailing comments on separate line 51 | ✓ should generate interface extending one interface 52 | ✓ should generate interface with method that returns void 53 | ✓ should generate interface with method that returns bool 54 | ✓ should generate interface with method that returns string 55 | ✓ should generate interface with method that returns any 56 | ✓ should generate interface with method that returns type reference 57 | ✓ should generate interface with 2 methods that returns type reference 58 | ✓ should generate interface with method with string parm that returns bool 59 | ✓ should generate interface with method with string parms 60 | ✓ should generate interface with method with string or null parms 61 | ✓ should generate interface with method leading and trailing comments 62 | ✓ should generate interface with string property 63 | ✓ should generate interface with readonly object property 64 | ✓ should generate interface with string or null property 65 | ✓ should generate interface with number or null property 66 | ✓ should generate interface with boolean or null property 67 | ✓ should generate interface with object or null property 68 | ✓ should generate interface with indexer 69 | ✓ should generate interface with readonly indexer 70 | ✓ should generate interface with string indexer 71 | ✓ should generate interface with string indexer 72 | ✓ should generate interface with indexer property with leading and trailing comments 73 | ✓ should generate interface with number and object array 74 | ✓ should generate interface with nullable number array 75 | ✓ should generate interface with nullable boolean array 76 | ✓ should generate interface with nullable object array 77 | ✓ should generate interface with nullable string array 78 | ✓ should generate interfaces extending one interface 79 | ✓ should generate multiple interfaces extending multiple interfaces 80 | 81 | 82 | 33 passing (98ms) 83 | ``` 84 | -------------------------------------------------------------------------------- /docs/Usage.md: -------------------------------------------------------------------------------- 1 | # Usage 2 | 3 | Using the project is a simple step of executing the project from the command line with a list of files specified. 4 | 5 | First you will need a TypeScript (.d.ts) definition file to be used as input. 6 | 7 | ``` bash 8 | $ npm start [options] path/to/file/definition.d.ts 9 | ``` 10 | 11 | By default the generated file will reside in the same path as the definition file and will have a `.cs` extension. 12 | 13 | ## Command Line Options 14 | 15 | All the available command line options can be found in the [Generate Options](./GenerateOptions.md) document. 16 | 17 | ## Sample run 18 | 19 | ``` bash 20 | npm start ../tests/interface.d.ts 21 | ``` 22 | 23 | Output: 24 | 25 | ``` 26 | > tstocsharp@1.0.0 start /projects/TypeScript/TsToCSharp 27 | > node ./dist/TStoCSharp.js "../tests/interface.d.ts" 28 | 29 | Starting Generation for file(s): ../tests/interface.d.ts 30 | Resolving File: ../tests/interface.d.ts => /projects/TypeScript/tests/interface.d.ts 31 | 32 | ``` 33 | 34 | The output will reside in the same directory as `/projects/TypeScript/tests/interface.cs`. 35 | 36 | ## Using the CLI 37 | 38 | If the CLI interface was setup by following the instructions [Command Line Interface](./Installing.md#command-line-interface) from the [Installing](./Installing.md) doc then you can simple do the following: 39 | 40 | ``` bash 41 | $ TsToCSharp [options] file1.d.ts file2.d.ts 42 | ``` 43 | 44 | From the Terminal or Command Prompt enter the following: 45 | 46 | ``` bash 47 | $ TsToCSharp 48 | ``` 49 | 50 | And you will be presented with a help screen 51 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tstocsharp", 3 | "version": "1.0.0", 4 | "description": "Emit C# code from TypeScrypt definition files", 5 | "main": "./dist/TStoCSharp.js", 6 | "bin": { 7 | "TsToCSharp": "./dist/TStoCSharp.js" 8 | }, 9 | "directories": { 10 | "test": "mocha" 11 | }, 12 | "dependencies": { 13 | "@types/yargs": "^10.0.2", 14 | "change-case": "^3.0.2", 15 | "ts-morph": "^1.2.0", 16 | "typescript": "^3.3.1", 17 | "yargs": "^11.1.0" 18 | }, 19 | "devDependencies": { 20 | "@types/chai": "^4.1.6", 21 | "@types/mocha": "^2.2.48", 22 | "@types/node": "^9.6.35", 23 | "chai": "^4.2.0", 24 | "mocha": "^5.2.0", 25 | "tslint": "^5.11.0" 26 | }, 27 | "scripts": { 28 | "start": "node ./dist/TStoCSharp.js", 29 | "test": "npm run lint && mocha ./dist/TsToCSharpTests.js", 30 | "build-ts": "tsc", 31 | "watch-ts": "tsc -w", 32 | "lint": "tslint test/**/*.d.ts -t verbose" 33 | }, 34 | "author": "Kenneth J. Pouncey", 35 | "license": "MIT" 36 | } 37 | -------------------------------------------------------------------------------- /src/CommandLineParser.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as yargs from "yargs"; 3 | import {GenOptionsInterface, GenOptions} from "./GenerateOptions"; 4 | 5 | export function ParseCommandLine() : GenOptionsInterface 6 | { 7 | const argv = yargs.usage("Usage: TsToCSharp [options] file1.d.ts file2.d.ts") 8 | .demandCommand(1) 9 | .example("TsToCSharp file1.d.ts", "Emit strongly typed C# definition from TypeScript definition file(s)") 10 | .example("TsToCSharp -o ./ file1.d.ts", "Emit strongly typed C# definition from TypeScript definition file(s)") 11 | .help("h") 12 | .alias("h", "help") 13 | .describe("combine", "Combine all specified definition files before processing.") 14 | .describe("defaultNameSpace", "Default name space to be emitted.") 15 | .describe("emitAllInterfaces", "Emit C# class implementations for all Interfaces and not just those declared.") 16 | .describe("emitUsings", "Emit default C# using statements.") 17 | .describe("interfacePrefix", "Prefix interfaces with the string provided. Default is \"I\"") 18 | .describe("interfaceAccessModifier", "Default interface access identifier. Default is \"public\"") 19 | .nargs("interfaceAccessModifier", 1) 20 | .choices("interfaceAccessModifier", ["public", "internal", "private", "none"]) 21 | .describe("noCaseChange", "Do not change case.") 22 | .describe("noCaseChangeClasses", "Do not change case of Class Declarations.") 23 | .describe("noCaseChangeIntefaces", "Do not change case of Interface Declarations.") 24 | .describe("noCaseChangeMethods", "Do not change case of Method Declarations.") 25 | .describe("noCaseChangeParameters", "Do not change case of Parameter Declarations.") 26 | .describe("noCaseChangeProperties", "Do not change case of Method Declarations.") 27 | .describe("noEmitExports", "Do not emit any Export attributes.") 28 | .describe("noEmitComments", "Do not emit comments.") 29 | .describe("noEmitMethodExport", "Do not emit Export attribute for methods.") 30 | .describe("noEmitPropertyExport", "Do not emit Export attribute for properties.") 31 | .describe("noPrefixInterface", "Do not prefix interface names.") 32 | .alias("o", "outDir") 33 | .describe("o", "Output directory for generated C# files.") 34 | .describe("removeComments", "Do not emit comments contained in the definition file(s).") 35 | .argv; 36 | 37 | //console.log('Yargs', argv); 38 | 39 | let options = new GenOptions(); 40 | 41 | options.fileList = argv._; 42 | 43 | if (argv.outDir) 44 | options.outDir = argv.outDir; 45 | 46 | if (argv.removeComments) 47 | options.emitComments = false; 48 | 49 | // overall Export Attribute emit control 50 | if (argv.noEmitExports) 51 | { 52 | options.emitExports = false; 53 | options.emitMethodExport = false; 54 | options.emitPropertyExport = false; 55 | } 56 | else 57 | { 58 | if (argv.noEmitMethodExport) 59 | { 60 | options.emitMethodExport = false; 61 | } 62 | if (argv.noEmitPropertyExport) 63 | { 64 | options.emitPropertyExport = false; 65 | } 66 | 67 | } 68 | 69 | if (argv.noPrefixInterface) 70 | { 71 | options.isPrefixInterface = false; 72 | } 73 | 74 | if (argv.interfacePrefix) 75 | { 76 | options.interfacePrefix = argv.interfacePrefix; 77 | } 78 | 79 | // overall Case Change emit control 80 | if (argv.noCaseChange) 81 | { 82 | options.isCaseChange = false; 83 | options.isCaseChangeClasses = false; 84 | options.isCaseChangeInterfaces = false; 85 | options.isCaseChangeMethods = false; 86 | options.isCaseChangeParameters = false; 87 | options.isCaseChangeProperties = false; 88 | 89 | } 90 | else 91 | { 92 | if (argv.noCaseChangeClasses) 93 | { 94 | options.isCaseChangeClasses = false; 95 | } 96 | if (argv.noCaseChangeInterfaces) 97 | { 98 | options.isCaseChangeInterfaces = false; 99 | } 100 | if (argv.noCaseChangeMethods) 101 | { 102 | options.isCaseChangeMethods = false; 103 | } 104 | if (argv.noCaseChangeParameters) 105 | { 106 | options.isCaseChangeParameters = false; 107 | } 108 | if (argv.noCaseChangeProperties) 109 | { 110 | options.isCaseChangeProperties = false; 111 | } 112 | 113 | } 114 | 115 | if (argv.emitAllInterfaces) 116 | { 117 | options.isEmitAllInterfaces = true; 118 | } 119 | 120 | if (argv.noEmitComments) 121 | { 122 | options.emitComments = false; 123 | } 124 | 125 | if (typeof(argv.interfaceAccessModifier) === "string" ) 126 | { 127 | options.interfaceAccessModifier = (argv.interfaceAccessModifier !== "none") ? argv.interfaceAccessModifier : undefined; 128 | } 129 | 130 | if (argv.defaultNameSpace) 131 | { 132 | options.defaultNameSpace = argv.defaultNameSpace; 133 | } 134 | 135 | if (argv.emitUsings) 136 | { 137 | options.isEmitUsings = true; 138 | } 139 | 140 | if (argv.combine) 141 | { 142 | options.isCombineFiles = true; 143 | } 144 | 145 | 146 | return options; 147 | } -------------------------------------------------------------------------------- /src/Context.ts: -------------------------------------------------------------------------------- 1 | import {GenOptionsInterface, GenOptions} from "./GenerateOptions"; 2 | import {DiagnosticsInterface, Diagnostics} from "./Diagnostics" 3 | 4 | export interface ContextInterface { 5 | offset: number; 6 | indent: number; 7 | emitImplementation: boolean; 8 | genOptions: GenOptionsInterface; 9 | diagnostics: DiagnosticsInterface; 10 | } 11 | 12 | export class Context implements ContextInterface { 13 | offset: number = 0; 14 | indent: number = 0; 15 | emitImplementation: boolean = false; 16 | genOptions: GenOptionsInterface; 17 | diagnostics: DiagnosticsInterface; 18 | constructor(options?: GenOptionsInterface) { 19 | if (options) 20 | this.genOptions = options; 21 | else 22 | this.genOptions = new GenOptions(); 23 | this.diagnostics = new Diagnostics() 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /src/DataStructures.ts: -------------------------------------------------------------------------------- 1 | 2 | import {Node} from "ts-morph"; 3 | 4 | export class Stack { 5 | _store: T[] = []; 6 | push(val: T) { 7 | this._store.push(val); 8 | } 9 | pop(): T | undefined { 10 | return this._store.pop(); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/Diagnostics.ts: -------------------------------------------------------------------------------- 1 | 2 | import {Node} from "ts-morph"; 3 | 4 | export interface DiagnosticsInterface 5 | { 6 | identifiedInterfaces: number; 7 | errors: string[]; 8 | pushError(message: string) : void; 9 | pushErrorAtLoc(message: string, node: Node) : void; 10 | warnings: string[]; 11 | pushWarning(message: string) : void; 12 | pushWarningAtLoc(message: string, node: Node) : void; 13 | } 14 | 15 | export class Diagnostics implements DiagnosticsInterface { 16 | identifiedInterfaces: number = 0; 17 | errors: string[] = []; 18 | warnings: string[] = []; 19 | constructor() { }; 20 | pushWarningAtLoc(message: string, node: Node) 21 | { 22 | if (node) 23 | { 24 | const col = node.getSourceFile().compilerNode.getLineAndCharacterOfPosition(node.getStart()).character + 1; 25 | const line = node.getSourceFile().compilerNode.getLineAndCharacterOfPosition(node.getStart()).line + 1; 26 | this.pushWarning(message + " at Line " + line + ", Col " + col + " Offset " + node.getStart()); 27 | } 28 | else 29 | { 30 | this.pushWarning(message); 31 | } 32 | } 33 | pushWarning(message: string) 34 | { 35 | this.warnings.push(message); 36 | } 37 | 38 | pushErrorAtLoc(message: string, node: Node) 39 | { 40 | if (node) 41 | { 42 | const col = node.getSourceFile().compilerNode.getLineAndCharacterOfPosition(node.getStart()).character + 1; 43 | const line = node.getSourceFile().compilerNode.getLineAndCharacterOfPosition(node.getStart()).line + 1; 44 | this.pushWarning(message + " at Line " + line + ", Col " + col + " Offset " + node.getStart()); 45 | } 46 | else 47 | { 48 | this.pushWarning(message); 49 | } 50 | } 51 | pushError(message: string) 52 | { 53 | this.warnings.push(message); 54 | } 55 | 56 | 57 | } -------------------------------------------------------------------------------- /src/GenerateOptions.ts: -------------------------------------------------------------------------------- 1 | export interface GenOptionsInterface 2 | { 3 | fileList: string[]; 4 | outDir?: string; 5 | defaultNameSpace: string; 6 | isCombineFiles: boolean; 7 | isCaseChange: boolean; 8 | isCaseChangeClasses: boolean; 9 | isCaseChangeInterfaces: boolean; 10 | isCaseChangeMethods: boolean; 11 | isCaseChangeParameters: boolean; 12 | isCaseChangeProperties: boolean; 13 | isEmitUsings: boolean; 14 | emitComments: boolean; 15 | emitExports: boolean; 16 | emitMethodExport: boolean; 17 | emitPropertyExport: boolean; 18 | interfacePrefix: string; 19 | isPrefixInterface: boolean; 20 | isEmitAllInterfaces: boolean; 21 | interfaceAccessModifier: string; 22 | } 23 | 24 | export class GenOptions implements GenOptionsInterface { 25 | fileList: string[]; 26 | outDir?: string; 27 | isCombineFiles: boolean = false; 28 | defaultNameSpace: string; 29 | isCaseChange: boolean = true; 30 | isCaseChangeClasses: boolean = true; 31 | isCaseChangeInterfaces: boolean = true; 32 | isCaseChangeMethods: boolean = true; 33 | isCaseChangeParameters: boolean = true; 34 | isCaseChangeProperties: boolean = true; 35 | isEmitUsings: boolean = false; 36 | emitComments: boolean = true; 37 | emitExports: boolean = true; 38 | emitMethodExport: boolean = true; 39 | emitPropertyExport: boolean = true; 40 | interfacePrefix: string = "I"; 41 | isPrefixInterface: boolean = true; 42 | isEmitAllInterfaces: boolean = false; 43 | interfaceAccessModifier: string = "public"; 44 | constructor() { } 45 | } -------------------------------------------------------------------------------- /src/TsToCSharp.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import * as fs from "fs"; 4 | import Ast, {ts, ScriptTarget, getCompilerOptionsFromTsConfig, ModuleResolutionKind} from "ts-morph"; 5 | import * as path from "path"; 6 | import * as os from "os"; 7 | 8 | 9 | import {ParseCommandLine} from "./CommandLineParser"; 10 | import { TsToCSharpGenerator } from './TsToCSharpGenerator'; 11 | import {Context} from "./Context"; 12 | 13 | function CreateAST(useVirtualFileSystem? : boolean) : Ast 14 | { 15 | let useVFS = false; 16 | if (useVirtualFileSystem) 17 | useVFS = true; 18 | 19 | const ast = new Ast({ 20 | compilerOptions: { 21 | target: ScriptTarget.ESNext, 22 | module: ts.ModuleKind.CommonJS, 23 | moduleResolution: ModuleResolutionKind.NodeJs, 24 | noLib: true 25 | }, 26 | useVirtualFileSystem: useVFS, 27 | }); 28 | return ast; 29 | } 30 | 31 | class Startup { 32 | 33 | public static main(): number { 34 | 35 | const genOptions = ParseCommandLine(); 36 | 37 | console.log('Starting Generation for file(s): ' + genOptions.fileList.join(",")); 38 | 39 | if (!genOptions.isCombineFiles) 40 | { 41 | genOptions.fileList.forEach(fileName => { 42 | 43 | const ast = CreateAST(); 44 | 45 | console.log('Resolving File: ' + fileName + ' => ' + path.resolve(fileName)); 46 | const sf = ast.addExistingSourceFileIfExists(path.resolve(fileName)); 47 | const sfs = ast.getSourceFiles(); 48 | const context = new Context(genOptions); 49 | 50 | sfs.forEach(astSourceFile => { 51 | 52 | let sourceCode = TsToCSharpGenerator(astSourceFile, context); 53 | 54 | // output the file. 55 | const filePath = (genOptions.outDir) ? genOptions.outDir : path.dirname(fileName); 56 | const justTheName = path.basename(fileName,".d.ts"); 57 | 58 | console.log('Generating File: ' + path.resolve(path.join(filePath,justTheName+".cs"))); 59 | fs.writeFileSync(path.join(filePath,justTheName+".cs"), sourceCode); 60 | 61 | if (context.diagnostics.errors.length > 0) 62 | { 63 | context.diagnostics.errors.forEach(warning => { 64 | console.log(warning); 65 | }); 66 | 67 | } 68 | if (context.diagnostics.warnings.length > 0) 69 | { 70 | context.diagnostics.warnings.forEach(warning => { 71 | console.log(warning); 72 | }); 73 | } 74 | }); 75 | 76 | }); 77 | } 78 | else 79 | { 80 | const ast = CreateAST(true); 81 | 82 | const vfs = ast.getFileSystem(); 83 | 84 | const cd = vfs.getCurrentDirectory(); 85 | const combinedSource : string[] = []; 86 | genOptions.fileList.forEach(fileName => { 87 | console.log('Resolving File: ' + fileName + ' => ' + path.resolve(fileName)); 88 | const fileContents = fs.readFileSync(path.resolve(fileName), "utf8"); 89 | combinedSource.push(fileContents); 90 | }); 91 | 92 | 93 | const virtualSource = combinedSource.join(os.EOL); 94 | const virtualFile = path.basename(genOptions.fileList[0]); 95 | console.log('Combining files: ' + virtualFile); 96 | vfs.writeFileSync(virtualFile, virtualSource); 97 | 98 | ast.addExistingSourceFileIfExists(virtualFile); 99 | 100 | const sfs = ast.getSourceFiles(); 101 | const context = new Context(genOptions); 102 | 103 | const astSourceFile = sfs[0]; 104 | 105 | let sourceCode = TsToCSharpGenerator(astSourceFile, context); 106 | 107 | // output the file. 108 | const fileName = genOptions.fileList[0]; 109 | const filePath = (genOptions.outDir) ? genOptions.outDir : path.dirname(fileName); 110 | const justTheName = path.basename(fileName,".d.ts"); 111 | 112 | console.log('Generating File: ' + path.resolve(path.join(filePath,justTheName+".cs"))); 113 | fs.writeFileSync(path.join(filePath,justTheName+".cs"), sourceCode); 114 | 115 | if (context.diagnostics.errors.length > 0) 116 | { 117 | context.diagnostics.errors.forEach(warning => { 118 | console.log(warning); 119 | }); 120 | 121 | } 122 | if (context.diagnostics.warnings.length > 0) 123 | { 124 | context.diagnostics.warnings.forEach(warning => { 125 | console.log(warning); 126 | }); 127 | } 128 | 129 | // }); 130 | } 131 | return 0; 132 | } 133 | } 134 | 135 | 136 | Startup.main(); -------------------------------------------------------------------------------- /test/cases/classes/InterfaceDeclaration.cs: -------------------------------------------------------------------------------- 1 | public interface IAudioListener { 2 | } 3 | 4 | [Export("AudioListener", typeof(JSObject))] 5 | public sealed class AudioListener : JSObject 6 | { 7 | internal AudioListener (int handle) : base (handle) {} 8 | 9 | public AudioListener () { } 10 | } 11 | -------------------------------------------------------------------------------- /test/cases/classes/InterfaceDeclaration1.cs: -------------------------------------------------------------------------------- 1 | public interface IAudioListener { 2 | [Export("dopplerFactor")] 3 | double DopplerFactor { get; set; } 4 | [Export("speedOfSound")] 5 | double SpeedOfSound { get; set; } 6 | [Export("setOrientation")] 7 | void SetOrientation(double x, double y, double z, double xUp, double yUp, double zUp); 8 | [Export("setPosition")] 9 | void SetPosition(double x, double y, double z); 10 | [Export("setVelocity")] 11 | void SetVelocity(double x, double y, double z); 12 | } 13 | 14 | [Export("AudioListener", typeof(JSObject))] 15 | public sealed class AudioListener : JSObject 16 | { 17 | internal AudioListener (int handle) : base (handle) {} 18 | 19 | public AudioListener () { } 20 | [Export("dopplerFactor")] 21 | public double DopplerFactor { get => GetProperty("dopplerFactor"); set => SetProperty("dopplerFactor", value); } 22 | [Export("speedOfSound")] 23 | public double SpeedOfSound { get => GetProperty("speedOfSound"); set => SetProperty("speedOfSound", value); } 24 | [Export("setOrientation")] 25 | public void SetOrientation(double x, double y, double z, double xUp, double yUp, double zUp) 26 | { 27 | InvokeMethod("setOrientation", x, y, z, xUp, yUp, zUp); 28 | } 29 | [Export("setPosition")] 30 | public void SetPosition(double x, double y, double z) 31 | { 32 | InvokeMethod("setPosition", x, y, z); 33 | } 34 | [Export("setVelocity")] 35 | public void SetVelocity(double x, double y, double z) 36 | { 37 | InvokeMethod("setVelocity", x, y, z); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /test/cases/classes/InterfaceDeclaration2.cs: -------------------------------------------------------------------------------- 1 | public interface IErrorEvent : IEvent { 2 | [Export("colno")] 3 | double Colno { get; } 4 | [Export("error")] 5 | Object Error { get; } 6 | [Export("filename")] 7 | string Filename { get; } 8 | [Export("lineno")] 9 | double Lineno { get; } 10 | [Export("message")] 11 | string Message { get; } 12 | [Export("initErrorEvent")] 13 | void InitErrorEvent(string typeArg, bool canBubbleArg, bool cancelableArg, string messageArg, string filenameArg, double linenoArg); 14 | } 15 | 16 | [Export("ErrorEvent", typeof(JSObject))] 17 | public sealed class ErrorEvent : JSObject { 18 | internal ErrorEvent (int handle) : base (handle) {} 19 | 20 | public ErrorEvent (string type, ErrorEventInit errorEventInitDict) { } 21 | [Export("colno")] 22 | public double Colno => GetProperty("colno"); 23 | [Export("error")] 24 | public Object Error => GetProperty("error"); 25 | [Export("filename")] 26 | public string Filename => GetProperty("filename"); 27 | [Export("lineno")] 28 | public double Lineno => GetProperty("lineno"); 29 | [Export("message")] 30 | public string Message => GetProperty("message"); 31 | [Export("bubbles")] 32 | public bool Bubbles => GetProperty("bubbles"); 33 | [Export("cancelable")] 34 | public bool Cancelable => GetProperty("cancelable"); 35 | [Export("cancelBubble")] 36 | public bool CancelBubble { get => GetProperty("cancelBubble"); set => SetProperty("cancelBubble", value); } 37 | [Export("currentTarget")] 38 | public EventTarget CurrentTarget => GetProperty("currentTarget"); 39 | [Export("defaultPrevented")] 40 | public bool DefaultPrevented => GetProperty("defaultPrevented"); 41 | [Export("eventPhase")] 42 | public double EventPhase => GetProperty("eventPhase"); 43 | [Export("isTrusted")] 44 | public bool IsTrusted => GetProperty("isTrusted"); 45 | [Export("returnValue")] 46 | public bool ReturnValue { get => GetProperty("returnValue"); set => SetProperty("returnValue", value); } 47 | [Export("srcElement")] 48 | public Element SrcElement => GetProperty("srcElement"); 49 | [Export("target")] 50 | public EventTarget Target => GetProperty("target"); 51 | [Export("timeStamp")] 52 | public double TimeStamp => GetProperty("timeStamp"); 53 | [Export("type")] 54 | public string Type => GetProperty("type"); 55 | [Export("scoped")] 56 | public bool Scoped => GetProperty("scoped"); 57 | [Export("AT_TARGET")] 58 | public double AtTarget => GetProperty("AT_TARGET"); 59 | [Export("BUBBLING_PHASE")] 60 | public double BubblingPhase => GetProperty("BUBBLING_PHASE"); 61 | [Export("CAPTURING_PHASE")] 62 | public double CapturingPhase => GetProperty("CAPTURING_PHASE"); 63 | [Export("initErrorEvent")] 64 | public void InitErrorEvent(string typeArg, bool canBubbleArg, bool cancelableArg, string messageArg, string filenameArg, double linenoArg) 65 | { 66 | InvokeMethod("initErrorEvent", typeArg, canBubbleArg, cancelableArg, messageArg, filenameArg, linenoArg); 67 | } 68 | [Export("initEvent")] 69 | public void InitEvent(string eventTypeArg, bool canBubbleArg, bool cancelableArg) 70 | { 71 | InvokeMethod("initEvent", eventTypeArg, canBubbleArg, cancelableArg); 72 | } 73 | [Export("preventDefault")] 74 | public void PreventDefault() 75 | { 76 | InvokeMethod("preventDefault"); 77 | } 78 | [Export("stopImmediatePropagation")] 79 | public void StopImmediatePropagation() 80 | { 81 | InvokeMethod("stopImmediatePropagation"); 82 | } 83 | [Export("stopPropagation")] 84 | public void StopPropagation() 85 | { 86 | InvokeMethod("stopPropagation"); 87 | } 88 | [Export("deepPath")] 89 | public EventTarget[] DeepPath() 90 | { 91 | return InvokeMethod("deepPath"); 92 | } 93 | } 94 | 95 | public interface IEvent { 96 | [Export("bubbles")] 97 | bool Bubbles { get; } 98 | [Export("cancelable")] 99 | bool Cancelable { get; } 100 | [Export("cancelBubble")] 101 | bool CancelBubble { get; set; } 102 | [Export("currentTarget")] 103 | EventTarget CurrentTarget { get; } 104 | [Export("defaultPrevented")] 105 | bool DefaultPrevented { get; } 106 | [Export("eventPhase")] 107 | double EventPhase { get; } 108 | [Export("isTrusted")] 109 | bool IsTrusted { get; } 110 | [Export("returnValue")] 111 | bool ReturnValue { get; set; } 112 | [Export("srcElement")] 113 | Element SrcElement { get; } 114 | [Export("target")] 115 | EventTarget Target { get; } 116 | [Export("timeStamp")] 117 | double TimeStamp { get; } 118 | [Export("type")] 119 | string Type { get; } 120 | [Export("scoped")] 121 | bool Scoped { get; } 122 | [Export("initEvent")] 123 | void InitEvent(string eventTypeArg, bool canBubbleArg, bool cancelableArg); 124 | [Export("preventDefault")] 125 | void PreventDefault(); 126 | [Export("stopImmediatePropagation")] 127 | void StopImmediatePropagation(); 128 | [Export("stopPropagation")] 129 | void StopPropagation(); 130 | [Export("deepPath")] 131 | EventTarget[] DeepPath(); 132 | [Export("AT_TARGET")] 133 | double AtTarget { get; } 134 | [Export("BUBBLING_PHASE")] 135 | double BubblingPhase { get; } 136 | [Export("CAPTURING_PHASE")] 137 | double CapturingPhase { get; } 138 | } 139 | 140 | [Export("Event", typeof(JSObject))] 141 | public sealed class Event : JSObject { 142 | internal Event (int handle) : base (handle) {} 143 | 144 | public Event (string typeArg, EventInit eventInitDict) { } 145 | [Export("AT_TARGET")] 146 | public double AtTarget => GetProperty("AT_TARGET"); 147 | [Export("BUBBLING_PHASE")] 148 | public double BubblingPhase => GetProperty("BUBBLING_PHASE"); 149 | [Export("CAPTURING_PHASE")] 150 | public double CapturingPhase => GetProperty("CAPTURING_PHASE"); 151 | [Export("bubbles")] 152 | public bool Bubbles => GetProperty("bubbles"); 153 | [Export("cancelable")] 154 | public bool Cancelable => GetProperty("cancelable"); 155 | [Export("cancelBubble")] 156 | public bool CancelBubble { get => GetProperty("cancelBubble"); set => SetProperty("cancelBubble", value); } 157 | [Export("currentTarget")] 158 | public EventTarget CurrentTarget => GetProperty("currentTarget"); 159 | [Export("defaultPrevented")] 160 | public bool DefaultPrevented => GetProperty("defaultPrevented"); 161 | [Export("eventPhase")] 162 | public double EventPhase => GetProperty("eventPhase"); 163 | [Export("isTrusted")] 164 | public bool IsTrusted => GetProperty("isTrusted"); 165 | [Export("returnValue")] 166 | public bool ReturnValue { get => GetProperty("returnValue"); set => SetProperty("returnValue", value); } 167 | [Export("srcElement")] 168 | public Element SrcElement => GetProperty("srcElement"); 169 | [Export("target")] 170 | public EventTarget Target => GetProperty("target"); 171 | [Export("timeStamp")] 172 | public double TimeStamp => GetProperty("timeStamp"); 173 | [Export("type")] 174 | public string Type => GetProperty("type"); 175 | [Export("scoped")] 176 | public bool Scoped => GetProperty("scoped"); 177 | [Export("initEvent")] 178 | public void InitEvent(string eventTypeArg, bool canBubbleArg, bool cancelableArg) 179 | { 180 | InvokeMethod("initEvent", eventTypeArg, canBubbleArg, cancelableArg); 181 | } 182 | [Export("preventDefault")] 183 | public void PreventDefault() 184 | { 185 | InvokeMethod("preventDefault"); 186 | } 187 | [Export("stopImmediatePropagation")] 188 | public void StopImmediatePropagation() 189 | { 190 | InvokeMethod("stopImmediatePropagation"); 191 | } 192 | [Export("stopPropagation")] 193 | public void StopPropagation() 194 | { 195 | InvokeMethod("stopPropagation"); 196 | } 197 | [Export("deepPath")] 198 | public EventTarget[] DeepPath() 199 | { 200 | return InvokeMethod("deepPath"); 201 | } 202 | } 203 | -------------------------------------------------------------------------------- /test/cases/classes/InterfaceDeclaration4.cs: -------------------------------------------------------------------------------- 1 | namespace Hello.World 2 | { 3 | 4 | public interface IURL { 5 | [Export("hash")] 6 | string Hash { get; set; } 7 | [Export("host")] 8 | string Host { get; set; } 9 | [Export("hostname")] 10 | string Hostname { get; set; } 11 | [Export("href")] 12 | string Href { get; set; } 13 | [Export("origin")] 14 | string Origin { get; } 15 | [Export("password")] 16 | string Password { get; set; } 17 | [Export("pathname")] 18 | string Pathname { get; set; } 19 | [Export("port")] 20 | string Port { get; set; } 21 | [Export("protocol")] 22 | string Protocol { get; set; } 23 | [Export("search")] 24 | string Search { get; set; } 25 | [Export("username")] 26 | string Username { get; set; } 27 | [Export("searchParams")] 28 | IURLSearchParams SearchParams { get; } 29 | [Export("toString")] 30 | string ToString(); 31 | } 32 | 33 | [Export("URL", typeof(JSObject))] 34 | public sealed class Url : JSObject { 35 | internal URL (int handle) : base (handle) {} 36 | 37 | public URL (string url, object base) { } 38 | [Export("hash")] 39 | public string Hash { get => GetProperty("hash"); set => SetProperty("hash", value); } 40 | [Export("host")] 41 | public string Host { get => GetProperty("host"); set => SetProperty("host", value); } 42 | [Export("hostname")] 43 | public string Hostname { get => GetProperty("hostname"); set => SetProperty("hostname", value); } 44 | [Export("href")] 45 | public string Href { get => GetProperty("href"); set => SetProperty("href", value); } 46 | [Export("origin")] 47 | public string Origin => GetProperty("origin"); 48 | [Export("password")] 49 | public string Password { get => GetProperty("password"); set => SetProperty("password", value); } 50 | [Export("pathname")] 51 | public string Pathname { get => GetProperty("pathname"); set => SetProperty("pathname", value); } 52 | [Export("port")] 53 | public string Port { get => GetProperty("port"); set => SetProperty("port", value); } 54 | [Export("protocol")] 55 | public string Protocol { get => GetProperty("protocol"); set => SetProperty("protocol", value); } 56 | [Export("search")] 57 | public string Search { get => GetProperty("search"); set => SetProperty("search", value); } 58 | [Export("username")] 59 | public string Username { get => GetProperty("username"); set => SetProperty("username", value); } 60 | [Export("searchParams")] 61 | public IURLSearchParams SearchParams => GetProperty("searchParams"); 62 | [Export("createObjectURL")] 63 | public string CreateObjectUrl(Object object, ObjectURLOptions options) 64 | { 65 | return InvokeMethod("createObjectURL", object, options); 66 | } 67 | [Export("revokeObjectURL")] 68 | public void RevokeObjectUrl(string url) 69 | { 70 | InvokeMethod("revokeObjectURL", url); 71 | } 72 | [Export("toString")] 73 | public string ToString() 74 | { 75 | return InvokeMethod("toString"); 76 | } 77 | } 78 | 79 | public interface IURLSearchParams { 80 | /** 81 | * Appends a specified key/value pair as a new search parameter. 82 | */ 83 | [Export("append")] 84 | void Append(string name, string value); 85 | /** 86 | * Deletes the given search parameter, and its associated value, from the list of all search parameters. 87 | */ 88 | [Export("delete")] 89 | void Delete(string name); 90 | /** 91 | * Returns the first value associated to the given search parameter. 92 | */ 93 | [Export("get")] 94 | string Get(string name); 95 | /** 96 | * Returns all the values association with a given search parameter. 97 | */ 98 | [Export("getAll")] 99 | string[] GetAll(string name); 100 | /** 101 | * Returns a Boolean indicating if such a search parameter exists. 102 | */ 103 | [Export("has")] 104 | bool Has(string name); 105 | /** 106 | * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. 107 | */ 108 | [Export("set")] 109 | void Set(string name, string value); 110 | } 111 | 112 | [Export("URLSearchParams", typeof(JSObject))] 113 | public sealed class UrlSearchParams : JSObject { 114 | internal URLSearchParams (int handle) : base (handle) {} 115 | 116 | /** 117 | * Constructor returning a URLSearchParams object. 118 | */ 119 | public URLSearchParams (object init) { } 120 | /** 121 | * Appends a specified key/value pair as a new search parameter. 122 | */ 123 | [Export("append")] 124 | public void Append(string name, string value) 125 | { 126 | InvokeMethod("append", name, value); 127 | } 128 | /** 129 | * Deletes the given search parameter, and its associated value, from the list of all search parameters. 130 | */ 131 | [Export("delete")] 132 | public void Delete(string name) 133 | { 134 | InvokeMethod("delete", name); 135 | } 136 | /** 137 | * Returns the first value associated to the given search parameter. 138 | */ 139 | [Export("get")] 140 | public string Get(string name) 141 | { 142 | return InvokeMethod("get", name); 146 | } 147 | /** 148 | * Returns all the values association with a given search parameter. 149 | */ 150 | [Export("getAll")] 151 | public string[] GetAll(string name) 152 | { 153 | return InvokeMethod("getAll", name); 154 | } 155 | /** 156 | * Returns a Boolean indicating if such a search parameter exists. 157 | */ 158 | [Export("has")] 159 | public bool Has(string name) 160 | { 161 | return InvokeMethod("has", name); 162 | } 163 | /** 164 | * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. 165 | */ 166 | [Export("set")] 167 | public void Set(string name, string value) 168 | { 169 | InvokeMethod("set", name, value); 170 | } 171 | } 172 | 173 | public interface IBlob { 174 | [Export("size")] 175 | double Size { get; } 176 | [Export("type")] 177 | string Type { get; } 178 | [Export("msClose")] 179 | void MsClose(); 180 | [Export("msDetachStream")] 181 | Object MsDetachStream(); 182 | [Export("slice")] 183 | IBlob Slice(double start, double end, string contentType); 184 | } 185 | 186 | [Export("Blob", typeof(JSObject))] 187 | public sealed class Blob : JSObject { 188 | internal Blob (int handle) : base (handle) {} 189 | 190 | public Blob (Object[] blobParts, IBlobPropertyBag options) { } 191 | [Export("size")] 192 | public double Size => GetProperty("size"); 193 | [Export("type")] 194 | public string Type => GetProperty("type"); 195 | [Export("msClose")] 196 | public void MsClose() 197 | { 198 | InvokeMethod("msClose"); 199 | } 200 | [Export("msDetachStream")] 201 | public Object MsDetachStream() 202 | { 203 | return InvokeMethod("msDetachStream"); 204 | } 205 | [Export("slice")] 206 | public IBlob Slice(double start, double end, string contentType) 207 | { 208 | return InvokeMethod("slice", start, end, contentType); 209 | } 210 | } 211 | 212 | public interface IBlobPropertyBag { 213 | [Export("type")] 214 | string Type { get; set; } 215 | [Export("endings")] 216 | string Endings { get; set; } 217 | } 218 | 219 | public interface IWindow 220 | { 221 | [Export("IURL")] 222 | IURL Url { get; set; } 223 | [Export("IURLSearchParams")] 224 | IURLSearchParams UrlSearchParams { get; set; } 225 | [Export("IBlob")] 226 | IBlob IBlob { get; set; } 227 | } 228 | 229 | [Export("Window", typeof(JSObject))] 230 | public sealed class Window : JSObject { 231 | internal Window (int handle) : base (handle) {} 232 | 233 | public Window () { } 234 | [Export("IURL")] 235 | public IURL Url { get => GetProperty< URL>("URL"); set => SetProperty< URL>("URL", value); } 236 | [Export("IURLSearchParams")] 237 | public IURLSearchParams UrlSearchParams { get => GetProperty< URLSearchParams>("URLSearchParams"); set => SetProperty< URLSearchParams>("URLSearchParams", value); } 238 | [Export("IBlob")] 239 | public IBlob IBlob { get => GetProperty< Blob>("Blob"); set => SetProperty< Blob>("Blob", value); } 240 | } 241 | 242 | } -------------------------------------------------------------------------------- /test/cases/classes/InterfaceDeclaration5.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using WebAssembly; 3 | 4 | namespace Hello.World 5 | { 6 | 7 | public interface IURL { 8 | [Export("hash")] 9 | string Hash { get; set; } 10 | [Export("host")] 11 | string Host { get; set; } 12 | [Export("hostname")] 13 | string Hostname { get; set; } 14 | [Export("href")] 15 | string Href { get; set; } 16 | [Export("origin")] 17 | string Origin { get; } 18 | [Export("password")] 19 | string Password { get; set; } 20 | [Export("pathname")] 21 | string Pathname { get; set; } 22 | [Export("port")] 23 | string Port { get; set; } 24 | [Export("protocol")] 25 | string Protocol { get; set; } 26 | [Export("search")] 27 | string Search { get; set; } 28 | [Export("username")] 29 | string Username { get; set; } 30 | [Export("searchParams")] 31 | IURLSearchParams SearchParams { get; } 32 | [Export("toString")] 33 | string ToString(); 34 | } 35 | 36 | [Export("URL", typeof(JSObject))] 37 | public sealed class Url : JSObject { 38 | internal URL (int handle) : base (handle) {} 39 | 40 | public URL (string url, object base) { } 41 | [Export("hash")] 42 | public string Hash { get => GetProperty("hash"); set => SetProperty("hash", value); } 43 | [Export("host")] 44 | public string Host { get => GetProperty("host"); set => SetProperty("host", value); } 45 | [Export("hostname")] 46 | public string Hostname { get => GetProperty("hostname"); set => SetProperty("hostname", value); } 47 | [Export("href")] 48 | public string Href { get => GetProperty("href"); set => SetProperty("href", value); } 49 | [Export("origin")] 50 | public string Origin => GetProperty("origin"); 51 | [Export("password")] 52 | public string Password { get => GetProperty("password"); set => SetProperty("password", value); } 53 | [Export("pathname")] 54 | public string Pathname { get => GetProperty("pathname"); set => SetProperty("pathname", value); } 55 | [Export("port")] 56 | public string Port { get => GetProperty("port"); set => SetProperty("port", value); } 57 | [Export("protocol")] 58 | public string Protocol { get => GetProperty("protocol"); set => SetProperty("protocol", value); } 59 | [Export("search")] 60 | public string Search { get => GetProperty("search"); set => SetProperty("search", value); } 61 | [Export("username")] 62 | public string Username { get => GetProperty("username"); set => SetProperty("username", value); } 63 | [Export("searchParams")] 64 | public IURLSearchParams SearchParams => GetProperty("searchParams"); 65 | [Export("createObjectURL")] 66 | public string CreateObjectUrl(Object object, ObjectURLOptions options) 67 | { 68 | return InvokeMethod("createObjectURL", object, options); 69 | } 70 | [Export("revokeObjectURL")] 71 | public void RevokeObjectUrl(string url) 72 | { 73 | InvokeMethod("revokeObjectURL", url); 74 | } 75 | [Export("toString")] 76 | public string ToString() 77 | { 78 | return InvokeMethod("toString"); 79 | } 80 | } 81 | 82 | public interface IURLSearchParams { 83 | /** 84 | * Appends a specified key/value pair as a new search parameter. 85 | */ 86 | [Export("append")] 87 | void Append(string name, string value); 88 | /** 89 | * Deletes the given search parameter, and its associated value, from the list of all search parameters. 90 | */ 91 | [Export("delete")] 92 | void Delete(string name); 93 | /** 94 | * Returns the first value associated to the given search parameter. 95 | */ 96 | [Export("get")] 97 | string Get(string name); 98 | /** 99 | * Returns all the values association with a given search parameter. 100 | */ 101 | [Export("getAll")] 102 | string[] GetAll(string name); 103 | /** 104 | * Returns a Boolean indicating if such a search parameter exists. 105 | */ 106 | [Export("has")] 107 | bool Has(string name); 108 | /** 109 | * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. 110 | */ 111 | [Export("set")] 112 | void Set(string name, string value); 113 | } 114 | 115 | [Export("URLSearchParams", typeof(JSObject))] 116 | public sealed class UrlSearchParams : JSObject { 117 | internal URLSearchParams (int handle) : base (handle) {} 118 | 119 | /** 120 | * Constructor returning a URLSearchParams object. 121 | */ 122 | public URLSearchParams (object init) { } 123 | /** 124 | * Appends a specified key/value pair as a new search parameter. 125 | */ 126 | [Export("append")] 127 | public void Append(string name, string value) 128 | { 129 | InvokeMethod("append", name, value); 130 | } 131 | /** 132 | * Deletes the given search parameter, and its associated value, from the list of all search parameters. 133 | */ 134 | [Export("delete")] 135 | public void Delete(string name) 136 | { 137 | InvokeMethod("delete", name); 138 | } 139 | /** 140 | * Returns the first value associated to the given search parameter. 141 | */ 142 | [Export("get")] 143 | public string Get(string name) 144 | { 145 | return InvokeMethod("get", name); 149 | } 150 | /** 151 | * Returns all the values association with a given search parameter. 152 | */ 153 | [Export("getAll")] 154 | public string[] GetAll(string name) 155 | { 156 | return InvokeMethod("getAll", name); 157 | } 158 | /** 159 | * Returns a Boolean indicating if such a search parameter exists. 160 | */ 161 | [Export("has")] 162 | public bool Has(string name) 163 | { 164 | return InvokeMethod("has", name); 165 | } 166 | /** 167 | * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. 168 | */ 169 | [Export("set")] 170 | public void Set(string name, string value) 171 | { 172 | InvokeMethod("set", name, value); 173 | } 174 | } 175 | 176 | public interface IBlob { 177 | [Export("size")] 178 | double Size { get; } 179 | [Export("type")] 180 | string Type { get; } 181 | [Export("msClose")] 182 | void MsClose(); 183 | [Export("msDetachStream")] 184 | Object MsDetachStream(); 185 | [Export("slice")] 186 | IBlob Slice(double start, double end, string contentType); 187 | } 188 | 189 | [Export("Blob", typeof(JSObject))] 190 | public sealed class Blob : JSObject { 191 | internal Blob (int handle) : base (handle) {} 192 | 193 | public Blob (Object[] blobParts, IBlobPropertyBag options) { } 194 | [Export("size")] 195 | public double Size => GetProperty("size"); 196 | [Export("type")] 197 | public string Type => GetProperty("type"); 198 | [Export("msClose")] 199 | public void MsClose() 200 | { 201 | InvokeMethod("msClose"); 202 | } 203 | [Export("msDetachStream")] 204 | public Object MsDetachStream() 205 | { 206 | return InvokeMethod("msDetachStream"); 207 | } 208 | [Export("slice")] 209 | public IBlob Slice(double start, double end, string contentType) 210 | { 211 | return InvokeMethod("slice", start, end, contentType); 212 | } 213 | } 214 | 215 | public interface IBlobPropertyBag { 216 | [Export("type")] 217 | string Type { get; set; } 218 | [Export("endings")] 219 | string Endings { get; set; } 220 | } 221 | 222 | public interface IWindow 223 | { 224 | [Export("IURL")] 225 | IURL Url { get; set; } 226 | [Export("IURLSearchParams")] 227 | IURLSearchParams UrlSearchParams { get; set; } 228 | [Export("IBlob")] 229 | IBlob IBlob { get; set; } 230 | } 231 | 232 | [Export("Window", typeof(JSObject))] 233 | public sealed class Window : JSObject { 234 | internal Window (int handle) : base (handle) {} 235 | 236 | public Window () { } 237 | [Export("IURL")] 238 | public IURL Url { get => GetProperty< URL>("URL"); set => SetProperty< URL>("URL", value); } 239 | [Export("IURLSearchParams")] 240 | public IURLSearchParams UrlSearchParams { get => GetProperty< URLSearchParams>("URLSearchParams"); set => SetProperty< URLSearchParams>("URLSearchParams", value); } 241 | [Export("IBlob")] 242 | public IBlob IBlob { get => GetProperty< Blob>("Blob"); set => SetProperty< Blob>("Blob", value); } 243 | } 244 | 245 | } -------------------------------------------------------------------------------- /test/cases/classes/InterfaceDeclarationNoEmitComments.cs: -------------------------------------------------------------------------------- 1 | public interface IAudioListener { 2 | } 3 | [Export("AudioListener", typeof(JSObject))] 4 | public sealed class AudioListener : JSObject 5 | { 6 | 7 | internal AudioListener (int handle) : base (handle) {} 8 | 9 | public AudioListener () { } 10 | } 11 | -------------------------------------------------------------------------------- /test/cases/classes/InterfaceDeclarationPropertyIndexer.cs: -------------------------------------------------------------------------------- 1 | public interface IFileList { 2 | [Export("length")] 3 | double Length { get; } 4 | [Export("item")] 5 | File Item(double index); 6 | File this[double index] { get; set; } 7 | } 8 | 9 | [Export("FileList", typeof(JSObject))] 10 | public sealed class FileList : JSObject { 11 | internal FileList (int handle) : base (handle) {} 12 | 13 | public FileList () { } 14 | [Export("length")] 15 | public double Length => GetProperty("length"); 16 | [Export("item")] 17 | public File Item(double index) 18 | { 19 | return InvokeMethod("item", index); 20 | } 21 | public File this[double index] { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } 22 | } 23 | -------------------------------------------------------------------------------- /test/cases/classes/InterfaceDeclarationWithComments.cs: -------------------------------------------------------------------------------- 1 | public interface IAudioListener { 2 | } // Trailing comment of interface defintion. 3 | 4 | // This is a leading comment 5 | [Export("AudioListener", typeof(JSObject))] 6 | public sealed class AudioListener : JSObject 7 | { // Here is another comment 8 | 9 | internal AudioListener (int handle) : base (handle) {} 10 | // Trailing of prototype 11 | /** 12 | * Creates a new AudioListener 13 | */ 14 | public AudioListener () { } // Trailing of constructor 15 | } // Trailing comments 16 | -------------------------------------------------------------------------------- /test/cases/classes/InterfaceDeclarationWithConstructorArgs.cs: -------------------------------------------------------------------------------- 1 | 2 | public interface IErrorEventInit { 3 | } 4 | 5 | public interface IErrorEvent { 6 | } 7 | 8 | [Export("ErrorEvent", typeof(JSObject))] 9 | public sealed class ErrorEvent : JSObject { 10 | internal ErrorEvent (int handle) : base (handle) {} 11 | 12 | public ErrorEvent (string type, IErrorEventInit errorEventInitDict) { } 13 | } 14 | -------------------------------------------------------------------------------- /test/cases/classes/InterfaceDeclarationWithInheritedMethods.cs: -------------------------------------------------------------------------------- 1 | public interface IAudioListener { 2 | [Export("setOrientation")] 3 | void SetOrientation(double x, double y, double z, double xUp, double yUp, double zUp); 4 | [Export("setPosition")] 5 | void SetPosition(double x, double y, double z); 6 | [Export("setVelocity")] 7 | void SetVelocity(double x, double y, double z); 8 | } 9 | 10 | [Export("AudioListener", typeof(JSObject))] 11 | public sealed class AudioListener : JSObject 12 | { 13 | internal AudioListener (int handle) : base (handle) {} 14 | 15 | public AudioListener () { } 16 | [Export("setOrientation")] 17 | public void SetOrientation(double x, double y, double z, double xUp, double yUp, double zUp) 18 | { 19 | InvokeMethod("setOrientation", x, y, z, xUp, yUp, zUp); 20 | } 21 | [Export("setPosition")] 22 | public void SetPosition(double x, double y, double z) 23 | { 24 | InvokeMethod("setPosition", x, y, z); 25 | } 26 | [Export("setVelocity")] 27 | public void SetVelocity(double x, double y, double z) 28 | { 29 | InvokeMethod("setVelocity", x, y, z); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/cases/classes/InterfaceDeclarationWithInheritedProperties.cs: -------------------------------------------------------------------------------- 1 | public interface IAudioListener { 2 | [Export("dopplerFactor")] 3 | double DopplerFactor { get; set; } 4 | [Export("speedOfSound")] 5 | double SpeedOfSound { get; set; } 6 | } 7 | 8 | [Export("AudioListener", typeof(JSObject))] 9 | public sealed class AudioListener : JSObject 10 | { 11 | internal AudioListener (int handle) : base (handle) {} 12 | 13 | public AudioListener () { } 14 | [Export("dopplerFactor")] 15 | public double DopplerFactor { get => GetProperty("dopplerFactor"); set => SetProperty("dopplerFactor", value); } 16 | [Export("speedOfSound")] 17 | public double SpeedOfSound { get => GetProperty("speedOfSound"); set => SetProperty("speedOfSound", value); } 18 | } 19 | -------------------------------------------------------------------------------- /test/cases/classes/InterfaceDeclarationWithMethods.cs: -------------------------------------------------------------------------------- 1 | 2 | public interface IRTCSrtpSdesTransport { 3 | } 4 | 5 | [Export("RTCSrtpSdesTransport", typeof(JSObject))] 6 | public sealed class RtcSrtpSdesTransport : JSObject { 7 | internal RTCSrtpSdesTransport (int handle) : base (handle) {} 8 | 9 | public RTCSrtpSdesTransport (RTCIceTransport transport, RTCSrtpSdesParameters encryptParameters, RTCSrtpSdesParameters decryptParameters) { } 10 | [Export("getLocalParameters")] 11 | public RTCSrtpSdesParameters[] GetLocalParameters() 12 | { 13 | return InvokeMethod("getLocalParameters"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/cases/classes/InterfaceDeclarationWithProperties.cs: -------------------------------------------------------------------------------- 1 | public interface IPerformanceNavigation { 2 | } 3 | 4 | [Export("PerformanceNavigation", typeof(JSObject))] 5 | public sealed class PerformanceNavigation : JSObject { 6 | internal PerformanceNavigation (int handle) : base (handle) {} 7 | 8 | public PerformanceNavigation () { } 9 | [Export("TYPE_BACK_FORWARD")] 10 | public double TypeBackForward => GetProperty("TYPE_BACK_FORWARD"); 11 | [Export("TYPE_NAVIGATE")] 12 | public double TypeNavigate => GetProperty("TYPE_NAVIGATE"); 13 | [Export("TYPE_RELOAD")] 14 | public double TypeReload => GetProperty("TYPE_RELOAD"); 15 | [Export("TYPE_RESERVED")] 16 | public double TypeReserved => GetProperty("TYPE_RESERVED"); 17 | } 18 | -------------------------------------------------------------------------------- /test/cases/classes/InterfaceDeclarationWithTypeQuery.cs: -------------------------------------------------------------------------------- 1 | 2 | public interface IURL { 3 | [Export("hash")] 4 | string Hash { get; set; } 5 | [Export("host")] 6 | string Host { get; set; } 7 | [Export("hostname")] 8 | string Hostname { get; set; } 9 | [Export("href")] 10 | string Href { get; set; } 11 | [Export("origin")] 12 | string Origin { get; } 13 | [Export("password")] 14 | string Password { get; set; } 15 | [Export("pathname")] 16 | string Pathname { get; set; } 17 | [Export("port")] 18 | string Port { get; set; } 19 | [Export("protocol")] 20 | string Protocol { get; set; } 21 | [Export("search")] 22 | string Search { get; set; } 23 | [Export("username")] 24 | string Username { get; set; } 25 | [Export("searchParams")] 26 | IURLSearchParams SearchParams { get; } 27 | [Export("toString")] 28 | string ToString(); 29 | } 30 | 31 | [Export("URL", typeof(JSObject))] 32 | public sealed class Url : JSObject { 33 | internal URL (int handle) : base (handle) {} 34 | 35 | public URL (string url, object base) { } 36 | [Export("hash")] 37 | public string Hash { get => GetProperty("hash"); set => SetProperty("hash", value); } 38 | [Export("host")] 39 | public string Host { get => GetProperty("host"); set => SetProperty("host", value); } 40 | [Export("hostname")] 41 | public string Hostname { get => GetProperty("hostname"); set => SetProperty("hostname", value); } 42 | [Export("href")] 43 | public string Href { get => GetProperty("href"); set => SetProperty("href", value); } 44 | [Export("origin")] 45 | public string Origin => GetProperty("origin"); 46 | [Export("password")] 47 | public string Password { get => GetProperty("password"); set => SetProperty("password", value); } 48 | [Export("pathname")] 49 | public string Pathname { get => GetProperty("pathname"); set => SetProperty("pathname", value); } 50 | [Export("port")] 51 | public string Port { get => GetProperty("port"); set => SetProperty("port", value); } 52 | [Export("protocol")] 53 | public string Protocol { get => GetProperty("protocol"); set => SetProperty("protocol", value); } 54 | [Export("search")] 55 | public string Search { get => GetProperty("search"); set => SetProperty("search", value); } 56 | [Export("username")] 57 | public string Username { get => GetProperty("username"); set => SetProperty("username", value); } 58 | [Export("searchParams")] 59 | public IURLSearchParams SearchParams => GetProperty("searchParams"); 60 | [Export("createObjectURL")] 61 | public string CreateObjectUrl(Object object, ObjectURLOptions options) 62 | { 63 | return InvokeMethod("createObjectURL", object, options); 64 | } 65 | [Export("revokeObjectURL")] 66 | public void RevokeObjectUrl(string url) 67 | { 68 | InvokeMethod("revokeObjectURL", url); 69 | } 70 | [Export("toString")] 71 | public string ToString() 72 | { 73 | return InvokeMethod("toString"); 74 | } 75 | } 76 | 77 | public interface IURLSearchParams { 78 | /** 79 | * Appends a specified key/value pair as a new search parameter. 80 | */ 81 | [Export("append")] 82 | void Append(string name, string value); 83 | /** 84 | * Deletes the given search parameter, and its associated value, from the list of all search parameters. 85 | */ 86 | [Export("delete")] 87 | void Delete(string name); 88 | /** 89 | * Returns the first value associated to the given search parameter. 90 | */ 91 | [Export("get")] 92 | string Get(string name); 93 | /** 94 | * Returns all the values association with a given search parameter. 95 | */ 96 | [Export("getAll")] 97 | string[] GetAll(string name); 98 | /** 99 | * Returns a Boolean indicating if such a search parameter exists. 100 | */ 101 | [Export("has")] 102 | bool Has(string name); 103 | /** 104 | * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. 105 | */ 106 | [Export("set")] 107 | void Set(string name, string value); 108 | } 109 | 110 | [Export("URLSearchParams", typeof(JSObject))] 111 | public sealed class UrlSearchParams : JSObject { 112 | internal URLSearchParams (int handle) : base (handle) {} 113 | 114 | /** 115 | * Constructor returning a URLSearchParams object. 116 | */ 117 | public URLSearchParams (object init) { } 118 | /** 119 | * Appends a specified key/value pair as a new search parameter. 120 | */ 121 | [Export("append")] 122 | public void Append(string name, string value) 123 | { 124 | InvokeMethod("append", name, value); 125 | } 126 | /** 127 | * Deletes the given search parameter, and its associated value, from the list of all search parameters. 128 | */ 129 | [Export("delete")] 130 | public void Delete(string name) 131 | { 132 | InvokeMethod("delete", name); 133 | } 134 | /** 135 | * Returns the first value associated to the given search parameter. 136 | */ 137 | [Export("get")] 138 | public string Get(string name) 139 | { 140 | return InvokeMethod("get", name); 144 | } 145 | /** 146 | * Returns all the values association with a given search parameter. 147 | */ 148 | [Export("getAll")] 149 | public string[] GetAll(string name) 150 | { 151 | return InvokeMethod("getAll", name); 152 | } 153 | /** 154 | * Returns a Boolean indicating if such a search parameter exists. 155 | */ 156 | [Export("has")] 157 | public bool Has(string name) 158 | { 159 | return InvokeMethod("has", name); 160 | } 161 | /** 162 | * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. 163 | */ 164 | [Export("set")] 165 | public void Set(string name, string value) 166 | { 167 | InvokeMethod("set", name, value); 168 | } 169 | } 170 | 171 | public interface IBlob { 172 | [Export("size")] 173 | double Size { get; } 174 | [Export("type")] 175 | string Type { get; } 176 | [Export("msClose")] 177 | void MsClose(); 178 | [Export("msDetachStream")] 179 | Object MsDetachStream(); 180 | [Export("slice")] 181 | IBlob Slice(double start, double end, string contentType); 182 | } 183 | 184 | [Export("Blob", typeof(JSObject))] 185 | public sealed class Blob : JSObject { 186 | internal Blob (int handle) : base (handle) {} 187 | 188 | public Blob (Object[] blobParts, IBlobPropertyBag options) { } 189 | [Export("size")] 190 | public double Size => GetProperty("size"); 191 | [Export("type")] 192 | public string Type => GetProperty("type"); 193 | [Export("msClose")] 194 | public void MsClose() 195 | { 196 | InvokeMethod("msClose"); 197 | } 198 | [Export("msDetachStream")] 199 | public Object MsDetachStream() 200 | { 201 | return InvokeMethod("msDetachStream"); 202 | } 203 | [Export("slice")] 204 | public IBlob Slice(double start, double end, string contentType) 205 | { 206 | return InvokeMethod("slice", start, end, contentType); 207 | } 208 | } 209 | 210 | public interface IBlobPropertyBag { 211 | [Export("type")] 212 | string Type { get; set; } 213 | [Export("endings")] 214 | string Endings { get; set; } 215 | } 216 | 217 | public interface IWindow 218 | { 219 | [Export("IURL")] 220 | IURL Url { get; set; } 221 | [Export("IURLSearchParams")] 222 | IURLSearchParams UrlSearchParams { get; set; } 223 | [Export("IBlob")] 224 | IBlob IBlob { get; set; } 225 | } 226 | 227 | [Export("Window", typeof(JSObject))] 228 | public sealed class Window : JSObject { 229 | internal Window (int handle) : base (handle) {} 230 | 231 | public Window () { } 232 | [Export("IURL")] 233 | public IURL Url { get => GetProperty< URL>("URL"); set => SetProperty< URL>("URL", value); } 234 | [Export("IURLSearchParams")] 235 | public IURLSearchParams UrlSearchParams { get => GetProperty< URLSearchParams>("URLSearchParams"); set => SetProperty< URLSearchParams>("URLSearchParams", value); } 236 | [Export("IBlob")] 237 | public IBlob IBlob { get => GetProperty< Blob>("Blob"); set => SetProperty< Blob>("Blob", value); } 238 | } 239 | -------------------------------------------------------------------------------- /test/cases/interfaces/ArrayProperty.cs: -------------------------------------------------------------------------------- 1 | interface MediaKeySystemConfiguration { 2 | [Export("initDataTypes")] 3 | string[] initDataTypes { get; set; } 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/ArrayProperty2.cs: -------------------------------------------------------------------------------- 1 | interface Gamepad { 2 | [Export("axes")] 3 | double[] axes { get; } 4 | [Export("buttons")] 5 | GamepadButton[] buttons { get; } 6 | [Export("connected")] 7 | bool connected { get; } 8 | [Export("id")] 9 | string id { get; } 10 | [Export("index")] 11 | double index { get; } 12 | [Export("mapping")] 13 | string mapping { get; } 14 | [Export("timestamp")] 15 | double timestamp { get; } 16 | } 17 | -------------------------------------------------------------------------------- /test/cases/interfaces/BooleanArrayOrNullProperty.cs: -------------------------------------------------------------------------------- 1 | interface GamepadFaux { 2 | [Export("axesAvailable")] 3 | bool?[] axesAvailable { get; } 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/BooleanArrayProperty.cs: -------------------------------------------------------------------------------- 1 | interface GamepadFaux { 2 | [Export("axesAvailable")] 3 | bool[] axesAvailable { get; } 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/BooleanOrNullProperty.cs: -------------------------------------------------------------------------------- 1 | interface RTCIceParameters { 2 | [Export("iceLite")] 3 | bool? iceLite { get; set; } 4 | [Export("password")] 5 | string password { get; set; } 6 | [Export("usernameFragment")] 7 | string usernameFragment { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /test/cases/interfaces/BooleanProperty.cs: -------------------------------------------------------------------------------- 1 | interface Event { 2 | [Export("bubbles")] 3 | bool bubbles { get; } 4 | [Export("cancelable")] 5 | bool cancelable { get; } 6 | [Export("cancelBubble")] 7 | bool cancelBubble { get; set; } 8 | [Export("defaultPrevented")] 9 | bool defaultPrevented { get; } 10 | [Export("isTrusted")] 11 | bool isTrusted { get; } 12 | [Export("returnValue")] 13 | bool returnValue { get; set; } 14 | [Export("scoped")] 15 | bool scoped { get; } 16 | } 17 | -------------------------------------------------------------------------------- /test/cases/interfaces/Comments.cs: -------------------------------------------------------------------------------- 1 | // This is a leading comment 2 | interface EventTarget { // This is a trailing comment 3 | 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/Comments2.cs: -------------------------------------------------------------------------------- 1 | // This is a leading comment 2 | interface EventTarget 3 | { // This is a trailing comment 4 | 5 | } 6 | -------------------------------------------------------------------------------- /test/cases/interfaces/EventHandlers.cs: -------------------------------------------------------------------------------- 1 | interface GlobalEventHandlers { 2 | event DOMEventHandler OnPointercancel; 3 | event DOMEventHandler OnPointerdown; 4 | event DOMEventHandler OnPointerenter; 5 | event DOMEventHandler OnPointerleave; 6 | event DOMEventHandler OnPointermove; 7 | event DOMEventHandler OnPointerout; 8 | event DOMEventHandler OnPointerover; 9 | event DOMEventHandler OnPointerup; 10 | event DOMEventHandler OnWheel; 11 | [Export("addEventListener")] 12 | void addEventListener(string type, DOMEventHandler listener, object options); 13 | [Export("removeEventListener")] 14 | void removeEventListener(string type, DOMEventHandler listener, object options); 15 | } 16 | -------------------------------------------------------------------------------- /test/cases/interfaces/Extends.cs: -------------------------------------------------------------------------------- 1 | interface Node : EventTarget {} 2 | -------------------------------------------------------------------------------- /test/cases/interfaces/Extends2.cs: -------------------------------------------------------------------------------- 1 | interface EventTarget { 2 | [Export("dispatchEvent")] 3 | bool dispatchEvent(Event evt); 4 | } 5 | 6 | interface Node : EventTarget { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /test/cases/interfaces/Extends3.cs: -------------------------------------------------------------------------------- 1 | interface Event { 2 | [Export("bubbles")] 3 | bool bubbles { get; } 4 | [Export("cancelable")] 5 | bool cancelable { get; } 6 | [Export("cancelBubble")] 7 | bool cancelBubble { get; set; } 8 | [Export("currentTarget")] 9 | EventTarget currentTarget { get; } 10 | [Export("defaultPrevented")] 11 | bool defaultPrevented { get; } 12 | [Export("eventPhase")] 13 | double eventPhase { get; } 14 | [Export("isTrusted")] 15 | bool isTrusted { get; } 16 | [Export("returnValue")] 17 | bool returnValue { get; set; } 18 | [Export("srcElement")] 19 | Element srcElement { get; } 20 | [Export("target")] 21 | EventTarget target { get; } 22 | [Export("timeStamp")] 23 | double timeStamp { get; } 24 | [Export("type")] 25 | string type { get; } 26 | [Export("scoped")] 27 | bool scoped { get; } 28 | [Export("initEvent")] 29 | void initEvent(string eventTypeArg, bool canBubbleArg, bool cancelableArg); 30 | [Export("preventDefault")] 31 | void preventDefault(); 32 | [Export("stopImmediatePropagation")] 33 | void stopImmediatePropagation(); 34 | [Export("stopPropagation")] 35 | void stopPropagation(); 36 | [Export("deepPath")] 37 | EventTarget[] deepPath(); 38 | [Export("AT_TARGET")] 39 | double AT_TARGET { get; } 40 | [Export("BUBBLING_PHASE")] 41 | double BUBBLING_PHASE { get; } 42 | [Export("CAPTURING_PHASE")] 43 | double CAPTURING_PHASE { get; } 44 | } 45 | 46 | interface EventTarget { 47 | [Export("dispatchEvent")] 48 | bool dispatchEvent(Event evt); 49 | } 50 | 51 | interface Node : EventTarget { 52 | [Export("nodeName")] 53 | string nodeName { get; } 54 | [Export("nodeType")] 55 | double nodeType { get; } 56 | } 57 | 58 | interface GlobalEventHandlers { 59 | } 60 | 61 | interface ElementTraversal { 62 | [Export("childElementCount")] 63 | double childElementCount { get; } 64 | } 65 | 66 | interface NodeSelector { 67 | } 68 | 69 | interface ChildNode { 70 | [Export("remove")] 71 | void remove(); 72 | } 73 | 74 | interface HTMLCollectionBase { 75 | /** 76 | * Sets or retrieves the number of objects in a collection. 77 | */ 78 | [Export("length")] 79 | double length { get; } 80 | /** 81 | * Retrieves an object from various collections. 82 | */ 83 | [Export("item")] 84 | Element item(double index); 85 | Element this[double index] { get; set; } 86 | } 87 | 88 | interface HTMLCollection : HTMLCollectionBase { 89 | /** 90 | * Retrieves a select object or an object from an options collection. 91 | */ 92 | [Export("namedItem")] 93 | Element namedItem(string name); 94 | } 95 | 96 | interface ParentNode { 97 | [Export("children")] 98 | HTMLCollection children { get; } 99 | [Export("childElementCount")] 100 | double childElementCount { get; } 101 | } 102 | 103 | interface DOMTokenList { 104 | [Export("length")] 105 | double length { get; } 106 | [Export("contains")] 107 | bool contains(string token); 108 | [Export("item")] 109 | string item(double index); 110 | [Export("toggle")] 111 | bool toggle(string token, bool force); 112 | [Export("toString")] 113 | string toString(); 114 | string this[double index] { get; set; } 115 | } 116 | 117 | interface Element : Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode, ParentNode { 118 | [Export("classList")] 119 | DOMTokenList classList { get; } 120 | [Export("className")] 121 | string className { get; set; } 122 | [Export("clientHeight")] 123 | double clientHeight { get; } 124 | [Export("clientLeft")] 125 | double clientLeft { get; } 126 | [Export("clientTop")] 127 | double clientTop { get; } 128 | [Export("clientWidth")] 129 | double clientWidth { get; } 130 | [Export("id")] 131 | string id { get; set; } 132 | [Export("innerHTML")] 133 | string innerHTML { get; set; } 134 | [Export("msContentZoomFactor")] 135 | double msContentZoomFactor { get; set; } 136 | [Export("msRegionOverflow")] 137 | string msRegionOverflow { get; } 138 | } 139 | -------------------------------------------------------------------------------- /test/cases/interfaces/Extends4.cs: -------------------------------------------------------------------------------- 1 | interface Event { 2 | [Export("bubbles")] 3 | bool bubbles { get; } 4 | [Export("cancelable")] 5 | bool cancelable { get; } 6 | [Export("cancelBubble")] 7 | bool cancelBubble { get; set; } 8 | [Export("currentTarget")] 9 | EventTarget currentTarget { get; } 10 | [Export("defaultPrevented")] 11 | bool defaultPrevented { get; } 12 | [Export("eventPhase")] 13 | double eventPhase { get; } 14 | [Export("isTrusted")] 15 | bool isTrusted { get; } 16 | [Export("returnValue")] 17 | bool returnValue { get; set; } 18 | [Export("srcElement")] 19 | Element srcElement { get; } 20 | [Export("target")] 21 | EventTarget target { get; } 22 | [Export("timeStamp")] 23 | double timeStamp { get; } 24 | [Export("type")] 25 | string type { get; } 26 | [Export("scoped")] 27 | bool scoped { get; } 28 | [Export("initEvent")] 29 | void initEvent(string eventTypeArg, bool canBubbleArg, bool cancelableArg); 30 | [Export("preventDefault")] 31 | void preventDefault(); 32 | [Export("stopImmediatePropagation")] 33 | void stopImmediatePropagation(); 34 | [Export("stopPropagation")] 35 | void stopPropagation(); 36 | [Export("deepPath")] 37 | EventTarget[] deepPath(); 38 | [Export("AT_TARGET")] 39 | double AT_TARGET { get; } 40 | [Export("BUBBLING_PHASE")] 41 | double BUBBLING_PHASE { get; } 42 | [Export("CAPTURING_PHASE")] 43 | double CAPTURING_PHASE { get; } 44 | } 45 | 46 | interface AnimationEvent : Event { 47 | [Export("animationName")] 48 | string animationName { get; } 49 | [Export("elapsedTime")] 50 | double elapsedTime { get; } 51 | [Export("initAnimationEvent")] 52 | void initAnimationEvent(string typeArg, bool canBubbleArg, bool cancelableArg, string animationNameArg, double elapsedTimeArg); 53 | } 54 | -------------------------------------------------------------------------------- /test/cases/interfaces/ExtendsGeneric.cs: -------------------------------------------------------------------------------- 1 | 2 | interface HTMLOptionsCollection : HTMLCollectionOf { 3 | [Export("length")] 4 | double length { get; set; } 5 | [Export("selectedIndex")] 6 | double selectedIndex { get; set; } 7 | [Export("add")] 8 | void add(object element, object before); 9 | [Export("remove")] 10 | void remove(double index); 11 | } 12 | 13 | interface HTMLCollectionOf : HTMLCollection where T : Element { 14 | [Export("item")] 15 | T item(double index); 16 | [Export("namedItem")] 17 | T namedItem(string name); 18 | T this[double index] { get; set; } 19 | } 20 | 21 | interface HTMLElement : Element { 22 | [Export("accessKey")] 23 | string accessKey { get; set; } 24 | [Export("children")] 25 | HTMLCollection children { get; } 26 | [Export("contentEditable")] 27 | string contentEditable { get; set; } 28 | [Export("dataset")] 29 | DOMStringMap dataset { get; } 30 | [Export("dir")] 31 | string dir { get; set; } 32 | [Export("draggable")] 33 | bool draggable { get; set; } 34 | [Export("hidden")] 35 | bool hidden { get; set; } 36 | [Export("hideFocus")] 37 | bool hideFocus { get; set; } 38 | [Export("innerText")] 39 | string innerText { get; set; } 40 | [Export("isContentEditable")] 41 | bool isContentEditable { get; } 42 | [Export("lang")] 43 | string lang { get; set; } 44 | [Export("offsetHeight")] 45 | double offsetHeight { get; } 46 | [Export("offsetLeft")] 47 | double offsetLeft { get; } 48 | [Export("offsetParent")] 49 | Element offsetParent { get; } 50 | [Export("offsetTop")] 51 | double offsetTop { get; } 52 | [Export("offsetWidth")] 53 | double offsetWidth { get; } 54 | [Export("outerText")] 55 | string outerText { get; set; } 56 | [Export("spellcheck")] 57 | bool spellcheck { get; set; } 58 | [Export("style")] 59 | CSSStyleDeclaration style { get; } 60 | [Export("tabIndex")] 61 | double tabIndex { get; set; } 62 | [Export("title")] 63 | string title { get; set; } 64 | [Export("blur")] 65 | void blur(); 66 | [Export("click")] 67 | void click(); 68 | [Export("dragDrop")] 69 | bool dragDrop(); 70 | [Export("focus")] 71 | void focus(); 72 | [Export("msGetInputContext")] 73 | MSInputMethodContext msGetInputContext(); 74 | } 75 | 76 | interface HTMLOptionElement : HTMLElement { 77 | /** 78 | * Sets or retrieves the status of an option. 79 | */ 80 | [Export("defaultSelected")] 81 | bool defaultSelected { get; set; } 82 | [Export("disabled")] 83 | bool disabled { get; set; } 84 | /** 85 | * Retrieves a reference to the form that the object is embedded in. 86 | */ 87 | [Export("form")] 88 | HTMLFormElement form { get; } 89 | /** 90 | * Sets or retrieves the ordinal position of an option in a list box. 91 | */ 92 | [Export("index")] 93 | double index { get; } 94 | /** 95 | * Sets or retrieves a value that you can use to implement your own label functionality for the object. 96 | */ 97 | [Export("label")] 98 | string label { get; set; } 99 | /** 100 | * Sets or retrieves whether the option in the list box is the default item. 101 | */ 102 | [Export("selected")] 103 | bool selected { get; set; } 104 | /** 105 | * Sets or retrieves the text string specified by the option tag. 106 | */ 107 | [Export("text")] 108 | string text { get; set; } 109 | /** 110 | * Sets or retrieves the value which is returned to the server when the form control is submitted. 111 | */ 112 | [Export("value")] 113 | string value { get; set; } 114 | } 115 | 116 | interface GlobalEventHandlers { 117 | } 118 | 119 | interface EventTarget { 120 | } 121 | 122 | interface Node : EventTarget { 123 | } 124 | 125 | interface Element : Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode, ParentNode { 126 | } 127 | 128 | interface ElementTraversal { 129 | } 130 | 131 | interface NodeSelector { 132 | } 133 | 134 | interface ChildNode { 135 | } 136 | 137 | interface ParentNode { 138 | } 139 | -------------------------------------------------------------------------------- /test/cases/interfaces/GenericInterfaceWithConstraint.cs: -------------------------------------------------------------------------------- 1 | 2 | interface NodeList { 3 | [Export("length")] 4 | double length { get; } 5 | [Export("item")] 6 | Node item(double index); 7 | Node this[double index] { get; set; } 8 | } 9 | 10 | interface NodeListOf : NodeList where TNode : Node { 11 | [Export("length")] 12 | double length { get; set; } 13 | [Export("item")] 14 | TNode item(double index); 15 | TNode this[double index] { get; set; } 16 | } 17 | -------------------------------------------------------------------------------- /test/cases/interfaces/GenericInterfaceWithConstraint2.cs: -------------------------------------------------------------------------------- 1 | 2 | interface HTMLCollectionBase { 3 | /** 4 | * Sets or retrieves the number of objects in a collection. 5 | */ 6 | [Export("length")] 7 | double length { get; } 8 | /** 9 | * Retrieves an object from various collections. 10 | */ 11 | [Export("item")] 12 | Element item(double index); 13 | Element this[double index] { get; set; } 14 | } 15 | 16 | interface HTMLCollection : HTMLCollectionBase { 17 | /** 18 | * Retrieves a select object or an object from an options collection. 19 | */ 20 | [Export("namedItem")] 21 | Element namedItem(string name); 22 | } 23 | 24 | interface GlobalEventHandlers { 25 | } 26 | 27 | interface EventTarget { 28 | } 29 | 30 | interface Node : EventTarget { 31 | } 32 | 33 | interface Element : Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode, ParentNode { 34 | } 35 | 36 | interface ElementTraversal { 37 | } 38 | 39 | interface NodeSelector { 40 | } 41 | 42 | interface ChildNode { 43 | } 44 | 45 | interface ParentNode { 46 | } 47 | 48 | interface HTMLCollectionOf : HTMLCollection where T : Element { 49 | [Export("item")] 50 | T item(double index); 51 | [Export("namedItem")] 52 | T namedItem(string name); 53 | T this[double index] { get; set; } 54 | } 55 | -------------------------------------------------------------------------------- /test/cases/interfaces/GenericInterfaceWithTypeDefault.cs: -------------------------------------------------------------------------------- 1 | interface CustomEvent : Event { 2 | [Export("detail")] 3 | T detail { get; } 4 | [Export("initCustomEvent")] 5 | void initCustomEvent(string typeArg, bool canBubbleArg, bool cancelableArg, T detailArg); 6 | } 7 | -------------------------------------------------------------------------------- /test/cases/interfaces/IndexerProperty.cs: -------------------------------------------------------------------------------- 1 | interface FileList { 2 | File this[double index] { get; set; } 3 | } 4 | -------------------------------------------------------------------------------- /test/cases/interfaces/IndexerPropertyComments.cs: -------------------------------------------------------------------------------- 1 | interface ClientRectList { 2 | // This is the length 3 | [Export("length")] 4 | double length { get; } /* returns a number */ 5 | [Export("item")] 6 | ClientRect item(double index); // Return the ClientRect at the specified index 7 | /** 8 | * Retrieves a ClientRect object ClientRectList. 9 | */ 10 | ClientRect this[double index] { get; set; } // Return the ClientRect at the specified index 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/cases/interfaces/Interface.cs: -------------------------------------------------------------------------------- 1 | interface EventTarget { 2 | } 3 | -------------------------------------------------------------------------------- /test/cases/interfaces/Interface2.cs: -------------------------------------------------------------------------------- 1 | interface EventTarget 2 | {} 3 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodComments.cs: -------------------------------------------------------------------------------- 1 | interface HTMLFormElement : HTMLElement { 2 | /** 3 | * Returns whether a form will validate when it is submitted, without having to submit it. 4 | */ 5 | [Export("checkValidity")] 6 | bool checkValidity(); // Returns bool 7 | /** 8 | * Retrieves a form object or an object from an elements collection. 9 | */ 10 | [Export("item")] 11 | Object item(Object name, Object index); // Returns the any value 12 | } 13 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnAny.cs: -------------------------------------------------------------------------------- 1 | interface PaymentAddress { 2 | [Export("toJSON")] 3 | Object toJSON(); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnAnyArray.cs: -------------------------------------------------------------------------------- 1 | interface Window : EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, GlobalFetch { 2 | [Export("receiveMessage")] 3 | Object[] receiveMessage(Object message, string targetOrigin); // This is not a real definition 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnAnyArrayOrNull.cs: -------------------------------------------------------------------------------- 1 | interface Window : EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, GlobalFetch { 2 | [Export("receiveMessage")] 3 | Object[] receiveMessage(Object message, string targetOrigin); // This is not a real definition 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnAnyOrNull.cs: -------------------------------------------------------------------------------- 1 | interface PaymentAddress { 2 | [Export("toJSON")] 3 | Object toJSON(); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnBool.cs: -------------------------------------------------------------------------------- 1 | interface Node { 2 | [Export("hasAttributes")] 3 | bool hasAttributes(); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnBoolOrNull.cs: -------------------------------------------------------------------------------- 1 | interface RTCIceParameters { 2 | [Export("iceLite")] 3 | bool? iceLite { get; set; } 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnNever.cs: -------------------------------------------------------------------------------- 1 | interface FauxInterface { 2 | [Export("fail")] 3 | void fail(); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnNumber.cs: -------------------------------------------------------------------------------- 1 | interface Performance { 2 | [Export("now")] 3 | double now(); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnNumberArray.cs: -------------------------------------------------------------------------------- 1 | interface CanvasRenderingContext2D : Object, CanvasPathMethods { 2 | [Export("getLineDash")] 3 | double[] getLineDash(); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnNumberArrayOrNull.cs: -------------------------------------------------------------------------------- 1 | interface CanvasRenderingContext2D : Object, CanvasPathMethods { 2 | [Export("getLineDash")] 3 | double?[] getLineDash(); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnNumberOrNull.cs: -------------------------------------------------------------------------------- 1 | interface Performance { 2 | [Export("now")] 3 | double? now(); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnRefType1.cs: -------------------------------------------------------------------------------- 1 | interface Element { 2 | [Export("getBoundingClientRect")] 3 | ClientRect getBoundingClientRect(); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnRefType2.cs: -------------------------------------------------------------------------------- 1 | interface Element { 2 | [Export("getBoundingClientRect")] 3 | ClientRect getBoundingClientRect(); 4 | [Export("getClientRects")] 5 | ClientRectList getClientRects(); 6 | } 7 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnRefTypeArray.cs: -------------------------------------------------------------------------------- 1 | interface Event { 2 | [Export("bubbles")] 3 | bool bubbles { get; } 4 | [Export("cancelable")] 5 | bool cancelable { get; } 6 | [Export("cancelBubble")] 7 | bool cancelBubble { get; set; } 8 | [Export("currentTarget")] 9 | EventTarget currentTarget { get; } 10 | [Export("defaultPrevented")] 11 | bool defaultPrevented { get; } 12 | [Export("eventPhase")] 13 | double eventPhase { get; } 14 | [Export("isTrusted")] 15 | bool isTrusted { get; } 16 | [Export("returnValue")] 17 | bool returnValue { get; set; } 18 | [Export("srcElement")] 19 | Element srcElement { get; } 20 | [Export("target")] 21 | EventTarget target { get; } 22 | [Export("timeStamp")] 23 | double timeStamp { get; } 24 | [Export("type")] 25 | string type { get; } 26 | [Export("scoped")] 27 | bool scoped { get; } 28 | [Export("initEvent")] 29 | void initEvent(string eventTypeArg, bool canBubbleArg, bool cancelableArg); 30 | [Export("preventDefault")] 31 | void preventDefault(); 32 | [Export("stopImmediatePropagation")] 33 | void stopImmediatePropagation(); 34 | [Export("stopPropagation")] 35 | void stopPropagation(); 36 | [Export("deepPath")] 37 | EventTarget[] deepPath(); 38 | [Export("AT_TARGET")] 39 | double AT_TARGET { get; } 40 | [Export("BUBBLING_PHASE")] 41 | double BUBBLING_PHASE { get; } 42 | [Export("CAPTURING_PHASE")] 43 | double CAPTURING_PHASE { get; } 44 | } 45 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnRefTypeArrayOrNull.cs: -------------------------------------------------------------------------------- 1 | interface Event { 2 | [Export("bubbles")] 3 | bool bubbles { get; } 4 | [Export("cancelable")] 5 | bool cancelable { get; } 6 | [Export("cancelBubble")] 7 | bool cancelBubble { get; set; } 8 | [Export("currentTarget")] 9 | EventTarget currentTarget { get; } 10 | [Export("defaultPrevented")] 11 | bool defaultPrevented { get; } 12 | [Export("eventPhase")] 13 | double eventPhase { get; } 14 | [Export("isTrusted")] 15 | bool isTrusted { get; } 16 | [Export("returnValue")] 17 | bool returnValue { get; set; } 18 | [Export("srcElement")] 19 | Element srcElement { get; } 20 | [Export("target")] 21 | EventTarget target { get; } 22 | [Export("timeStamp")] 23 | double timeStamp { get; } 24 | [Export("type")] 25 | string type { get; } 26 | [Export("scoped")] 27 | bool scoped { get; } 28 | [Export("initEvent")] 29 | void initEvent(string eventTypeArg, bool canBubbleArg, bool cancelableArg); 30 | [Export("preventDefault")] 31 | void preventDefault(); 32 | [Export("stopImmediatePropagation")] 33 | void stopImmediatePropagation(); 34 | [Export("stopPropagation")] 35 | void stopPropagation(); 36 | [Export("deepPath")] 37 | EventTarget[] deepPath(); 38 | [Export("AT_TARGET")] 39 | double AT_TARGET { get; } 40 | [Export("BUBBLING_PHASE")] 41 | double BUBBLING_PHASE { get; } 42 | [Export("CAPTURING_PHASE")] 43 | double CAPTURING_PHASE { get; } 44 | } 45 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnRefTypeOrNull.cs: -------------------------------------------------------------------------------- 1 | interface DataTransferItemList { 2 | [Export("length")] 3 | double length { get; } 4 | [Export("add")] 5 | DataTransferItem add(File data); 6 | [Export("clear")] 7 | void clear(); 8 | [Export("item")] 9 | DataTransferItem item(double index); 10 | [Export("remove")] 11 | void remove(double index); 12 | DataTransferItem this[double index] { get; set; } 13 | } 14 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnString.cs: -------------------------------------------------------------------------------- 1 | interface DOMError { 2 | [Export("toString")] 3 | string toString(); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnStringArray.cs: -------------------------------------------------------------------------------- 1 | interface URLSearchParams { 2 | /** 3 | * Appends a specified key/value pair as a new search parameter. 4 | */ 5 | [Export("append")] 6 | void append(string name, string value); 7 | /** 8 | * Deletes the given search parameter, and its associated value, from the list of all search parameters. 9 | */ 10 | [Export("delete")] 11 | void delete(string name); 12 | /** 13 | * Returns the first value associated to the given search parameter. 14 | */ 15 | [Export("get")] 16 | string get(string name); 17 | /** 18 | * Returns all the values association with a given search parameter. 19 | */ 20 | [Export("getAll")] 21 | string[] getAll(string name); 22 | /** 23 | * Returns a Boolean indicating if such a search parameter exists. 24 | */ 25 | [Export("has")] 26 | bool has(string name); 27 | /** 28 | * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. 29 | */ 30 | [Export("set")] 31 | void set(string name, string value); 32 | } 33 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnStringArrayOrNull.cs: -------------------------------------------------------------------------------- 1 | interface URLSearchParams { 2 | /** 3 | * Appends a specified key/value pair as a new search parameter. 4 | */ 5 | [Export("append")] 6 | void append(string name, string value); 7 | /** 8 | * Deletes the given search parameter, and its associated value, from the list of all search parameters. 9 | */ 10 | [Export("delete")] 11 | void delete(string name); 12 | /** 13 | * Returns the first value associated to the given search parameter. 14 | */ 15 | [Export("get")] 16 | string get(string name); 17 | /** 18 | * Returns all the values association with a given search parameter. 19 | */ 20 | [Export("getAll")] 21 | string[] getAll(string name); 22 | /** 23 | * Returns a Boolean indicating if such a search parameter exists. 24 | */ 25 | [Export("has")] 26 | bool has(string name); 27 | /** 28 | * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. 29 | */ 30 | [Export("set")] 31 | void set(string name, string value); 32 | } 33 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnStringOrNull.cs: -------------------------------------------------------------------------------- 1 | interface DOMStringList { 2 | [Export("length")] 3 | double length { get; } 4 | [Export("contains")] 5 | bool contains(string str); 6 | [Export("item")] 7 | string item(double index); 8 | string this[double index] { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodReturnVoid.cs: -------------------------------------------------------------------------------- 1 | interface EventTarget { 2 | [Export("dispatchEvent")] 3 | void dispatchEvent(); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithBooleanArrayOrNullParms.cs: -------------------------------------------------------------------------------- 1 | interface FauxInterface { 2 | [Export("initFauxInterface")] 3 | void initFauxInterface(bool?[] fauxArg); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithBooleanArrayParms.cs: -------------------------------------------------------------------------------- 1 | interface FauxInterface { 2 | [Export("initFauxInterface")] 3 | void initFauxInterface(bool[] fauxArg); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithBooleanOrNullParms.cs: -------------------------------------------------------------------------------- 1 | interface FauxInterface { 2 | [Export("initFaux")] 3 | void initFaux(string eventTypeArg, bool? canBubbleArg, bool? cancelableArg); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithBooleanParms.cs: -------------------------------------------------------------------------------- 1 | interface Event { 2 | [Export("initEvent")] 3 | void initEvent(string eventTypeArg, bool canBubbleArg, bool cancelableArg); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithDOMEventHandlerParms.cs: -------------------------------------------------------------------------------- 1 | interface EventTarget { 2 | [Export("addEventListener")] 3 | void addEventListener(string type, DOMEventHandler listener, object options); 4 | [Export("dispatchEvent")] 5 | bool dispatchEvent(Event evt); 6 | [Export("removeEventListener")] 7 | void removeEventListener(string type, DOMEventHandler listener, object options); 8 | } 9 | 10 | [Export("EventTarget", typeof(JSObject))] 11 | public sealed class EventTarget : JSObject { 12 | internal EventTarget (int handle) : base (handle) {} 13 | 14 | public EventTarget () { } 15 | [Export("addEventListener")] 16 | void addEventListener(string type, DOMEventHandler listener, object options) 17 | { 18 | InvokeMethod("addEventListener", type, listener, options); 19 | } 20 | [Export("dispatchEvent")] 21 | bool dispatchEvent(Event evt) 22 | { 23 | return InvokeMethod("dispatchEvent", evt); 24 | } 25 | [Export("removeEventListener")] 26 | void removeEventListener(string type, DOMEventHandler listener, object options) 27 | { 28 | InvokeMethod("removeEventListener", type, listener, options); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithLiteralTypeParm.cs: -------------------------------------------------------------------------------- 1 | interface Element : Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode, ParentNode { 2 | [Export("getElementsByTagNameNS")] 3 | HTMLCollectionOf getElementsByTagNameNS(string namespaceURI, string localName); 4 | [Export("getElementsByTagNameNS")] 5 | HTMLCollectionOf getElementsByTagNameNS(string namespaceURI, string localName); 6 | [Export("getElementsByTagNameNS")] 7 | HTMLCollectionOf getElementsByTagNameNS(string namespaceURI, string localName); 8 | } 9 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithNumberArrayOrNullParms.cs: -------------------------------------------------------------------------------- 1 | interface CanvasRenderingContext2D : Object, CanvasPathMethods { 2 | [Export("setFauxLineDash")] 3 | void setFauxLineDash(double?[] segments); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithNumberArrayParms.cs: -------------------------------------------------------------------------------- 1 | interface CanvasRenderingContext2D : Object, CanvasPathMethods { 2 | [Export("setLineDash")] 3 | void setLineDash(double[] segments); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithNumberOrNullParms.cs: -------------------------------------------------------------------------------- 1 | interface DeviceOrientationEvent : Event { 2 | [Export("absolute")] 3 | bool absolute { get; } 4 | [Export("alpha")] 5 | double? alpha { get; } 6 | [Export("beta")] 7 | double? beta { get; } 8 | [Export("gamma")] 9 | double? gamma { get; } 10 | [Export("initDeviceOrientationEvent")] 11 | void initDeviceOrientationEvent(string type, bool bubbles, bool cancelable, double? alpha, double? beta, double? gamma, bool absolute); 12 | } 13 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithNumberParms.cs: -------------------------------------------------------------------------------- 1 | interface Document : Node, GlobalEventHandlers, NodeSelector, DocumentEvent, ParentNode, DocumentOrShadowRoot { 2 | [Export("caretRangeFromPoint")] 3 | Range caretRangeFromPoint(double x, double y); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithRestAnyParms.cs: -------------------------------------------------------------------------------- 1 | interface Console { 2 | [Export("assert")] 3 | void assert(bool test, string message, params Object[] optionalParams); 4 | [Export("clear")] 5 | void clear(); 6 | [Export("count")] 7 | void count(string countTitle); 8 | [Export("debug")] 9 | void debug(Object message, params Object[] optionalParams); 10 | [Export("dir")] 11 | void dir(Object value, params Object[] optionalParams); 12 | [Export("dirxml")] 13 | void dirxml(Object value); 14 | [Export("error")] 15 | void error(Object message, params Object[] optionalParams); 16 | [Export("exception")] 17 | void exception(string message, params Object[] optionalParams); 18 | [Export("group")] 19 | void group(string groupTitle, params Object[] optionalParams); 20 | [Export("groupCollapsed")] 21 | void groupCollapsed(string groupTitle, params Object[] optionalParams); 22 | [Export("groupEnd")] 23 | void groupEnd(); 24 | [Export("info")] 25 | void info(Object message, params Object[] optionalParams); 26 | [Export("log")] 27 | void log(Object message, params Object[] optionalParams); 28 | [Export("msIsIndependentlyComposed")] 29 | bool msIsIndependentlyComposed(Element element); 30 | [Export("profile")] 31 | void profile(string reportName); 32 | [Export("profileEnd")] 33 | void profileEnd(); 34 | [Export("select")] 35 | void select(Element element); 36 | [Export("table")] 37 | void table(params Object[] data); 38 | [Export("time")] 39 | void time(string timerName); 40 | [Export("timeEnd")] 41 | void timeEnd(string timerName); 42 | [Export("trace")] 43 | void trace(Object message, params Object[] optionalParams); 44 | [Export("warn")] 45 | void warn(Object message, params Object[] optionalParams); 46 | } 47 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithRestStringParms.cs: -------------------------------------------------------------------------------- 1 | interface Document : Node, GlobalEventHandlers, NodeSelector, DocumentEvent, ParentNode, DocumentOrShadowRoot { 2 | /** 3 | * Writes one or more HTML expressions to a document in the specified window. 4 | * @param content Specifies the text and HTML tags to write. 5 | */ 6 | [Export("write")] 7 | void write(params string[] content); 8 | /** 9 | * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. 10 | * @param content The text and HTML tags to write. 11 | */ 12 | [Export("writeln")] 13 | void writeln(params string[] content); 14 | } 15 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithRestTypeRefParms.cs: -------------------------------------------------------------------------------- 1 | interface TouchList { 2 | [Export("length")] 3 | double length { get; } 4 | [Export("item")] 5 | Touch item(double index); 6 | Touch this[double index] { get; set; } 7 | } 8 | 9 | interface Touch { 10 | [Export("clientX")] 11 | double clientX { get; } 12 | [Export("clientY")] 13 | double clientY { get; } 14 | [Export("identifier")] 15 | double identifier { get; } 16 | [Export("pageX")] 17 | double pageX { get; } 18 | [Export("pageY")] 19 | double pageY { get; } 20 | [Export("screenX")] 21 | double screenX { get; } 22 | [Export("screenY")] 23 | double screenY { get; } 24 | [Export("target")] 25 | EventTarget target { get; } 26 | } 27 | 28 | interface Document : Node, GlobalEventHandlers, NodeSelector, DocumentEvent, ParentNode, DocumentOrShadowRoot { 29 | [Export("createTouchList")] 30 | TouchList createTouchList(params Touch[] touches); 31 | } 32 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithStringArrayOrNullParms.cs: -------------------------------------------------------------------------------- 1 | interface Screen : EventTarget { 2 | [Export("msLockOrientation")] 3 | bool msLockOrientation(string[] orientations); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithStringArrayParms.cs: -------------------------------------------------------------------------------- 1 | interface Screen : EventTarget { 2 | [Export("msLockOrientation")] 3 | bool msLockOrientation(string[] orientations); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithStringOrNullParms.cs: -------------------------------------------------------------------------------- 1 | interface NamedNodeMap { 2 | [Export("length")] 3 | double length { get; } 4 | [Export("getNamedItem")] 5 | Attr getNamedItem(string name); 6 | [Export("getNamedItemNS")] 7 | Attr getNamedItemNS(string namespaceURI, string localName); 8 | [Export("item")] 9 | Attr item(double index); 10 | [Export("removeNamedItem")] 11 | Attr removeNamedItem(string name); 12 | [Export("removeNamedItemNS")] 13 | Attr removeNamedItemNS(string namespaceURI, string localName); 14 | [Export("setNamedItem")] 15 | Attr setNamedItem(Attr arg); 16 | [Export("setNamedItemNS")] 17 | Attr setNamedItemNS(Attr arg); 18 | } 19 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithStringParmReturnBool.cs: -------------------------------------------------------------------------------- 1 | interface Element { 2 | [Export("hasAttribute")] 3 | bool hasAttribute(string name); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithStringParms.cs: -------------------------------------------------------------------------------- 1 | interface Element { 2 | [Export("setAttribute")] 3 | void setAttribute(string name, string value); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithTypeRefArrayOrNullParms.cs: -------------------------------------------------------------------------------- 1 | interface WebAuthentication { 2 | [Export("makeCredential")] 3 | ScopedCredentialInfo makeCredential(Account accountInformation, ScopedCredentialParameters[] cryptoParameters, BufferSource attestationChallenge, ScopedCredentialOptions options); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithTypeRefArrayParms.cs: -------------------------------------------------------------------------------- 1 | interface WebAuthentication { 2 | [Export("makeCredential")] 3 | ScopedCredentialInfo makeCredential(Account accountInformation, ScopedCredentialParameters[] cryptoParameters, BufferSource attestationChallenge, ScopedCredentialOptions options); 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/MethodWithTypeRefOrNullParms.cs: -------------------------------------------------------------------------------- 1 | interface Document : Node, GlobalEventHandlers, NodeSelector, DocumentEvent, ParentNode, DocumentOrShadowRoot { 2 | [Export("evaluate")] 3 | XPathResult evaluate(string expression, Node contextNode, XPathNSResolver resolver, double type, XPathResult result); 4 | 5 | } 6 | -------------------------------------------------------------------------------- /test/cases/interfaces/NumberArrayOrNullProperty.cs: -------------------------------------------------------------------------------- 1 | interface Gamepad { 2 | [Export("axes")] 3 | double?[] axes { get; } 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/NumberArrayProperty.cs: -------------------------------------------------------------------------------- 1 | interface Gamepad { 2 | [Export("axes")] 3 | double[] axes { get; } 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/NumberOrNullProperty.cs: -------------------------------------------------------------------------------- 1 | interface Coordinates { 2 | [Export("accuracy")] 3 | double accuracy { get; } 4 | [Export("altitude")] 5 | double? altitude { get; } 6 | [Export("altitudeAccuracy")] 7 | double? altitudeAccuracy { get; } 8 | [Export("heading")] 9 | double? heading { get; } 10 | [Export("latitude")] 11 | double latitude { get; } 12 | [Export("longitude")] 13 | double longitude { get; } 14 | [Export("speed")] 15 | double? speed { get; } 16 | } 17 | -------------------------------------------------------------------------------- /test/cases/interfaces/NumberProperty.cs: -------------------------------------------------------------------------------- 1 | interface Element : Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode, ParentNode { 2 | [Export("scrollLeft")] 3 | double scrollLeft { get; set; } 4 | [Export("scrollTop")] 5 | double scrollTop { get; set; } 6 | } 7 | -------------------------------------------------------------------------------- /test/cases/interfaces/ObjOrNullProperty.cs: -------------------------------------------------------------------------------- 1 | 2 | interface DeviceAcceleration { 3 | [Export("x")] 4 | double? x { get; } 5 | [Export("y")] 6 | double? y { get; } 7 | [Export("z")] 8 | double? z { get; } 9 | } 10 | 11 | interface DeviceRotationRate { 12 | [Export("alpha")] 13 | double? alpha { get; } 14 | [Export("beta")] 15 | double? beta { get; } 16 | [Export("gamma")] 17 | double? gamma { get; } 18 | } 19 | 20 | interface DeviceMotionEvent : Event { 21 | [Export("acceleration")] 22 | DeviceAcceleration acceleration { get; } 23 | [Export("accelerationIncludingGravity")] 24 | DeviceAcceleration accelerationIncludingGravity { get; } 25 | [Export("interval")] 26 | double? interval { get; } 27 | [Export("rotationRate")] 28 | DeviceRotationRate rotationRate { get; } 29 | } 30 | -------------------------------------------------------------------------------- /test/cases/interfaces/ReadOnlyIndexerProperty.cs: -------------------------------------------------------------------------------- 1 | interface FileList { 2 | File this[double index] { get; } 3 | } 4 | -------------------------------------------------------------------------------- /test/cases/interfaces/ReadOnlyObjectProperty.cs: -------------------------------------------------------------------------------- 1 | interface HTMLElement { 2 | [Export("children")] 3 | HTMLCollection children { get; } 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/StringArrayOrNullProperty.cs: -------------------------------------------------------------------------------- 1 | interface ConfirmSiteSpecificExceptionsInformation : ExceptionInformation { 2 | [Export("arrayOfDomainStrings")] 3 | string[] arrayOfDomainStrings { get; set; } 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/StringArrayProperty.cs: -------------------------------------------------------------------------------- 1 | interface Navigator : Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorUserMedia { 2 | [Export("authentication")] 3 | WebAuthentication authentication { get; } 4 | [Export("cookieEnabled")] 5 | bool cookieEnabled { get; } 6 | [Export("gamepadInputEmulation")] 7 | GamepadInputEmulationType gamepadInputEmulation { get; set; } 8 | [Export("language")] 9 | string language { get; } 10 | [Export("maxTouchPoints")] 11 | double maxTouchPoints { get; } 12 | [Export("mimeTypes")] 13 | MimeTypeArray mimeTypes { get; } 14 | [Export("msManipulationViewsEnabled")] 15 | bool msManipulationViewsEnabled { get; } 16 | [Export("msMaxTouchPoints")] 17 | double msMaxTouchPoints { get; } 18 | [Export("msPointerEnabled")] 19 | bool msPointerEnabled { get; } 20 | [Export("plugins")] 21 | PluginArray plugins { get; } 22 | [Export("pointerEnabled")] 23 | bool pointerEnabled { get; } 24 | [Export("serviceWorker")] 25 | ServiceWorkerContainer serviceWorker { get; } 26 | [Export("webdriver")] 27 | bool webdriver { get; } 28 | [Export("doNotTrack")] 29 | string doNotTrack { get; } 30 | [Export("hardwareConcurrency")] 31 | double hardwareConcurrency { get; } 32 | [Export("languages")] 33 | string[] languages { get; } 34 | [Export("getGamepads")] 35 | Gamepad[] getGamepads(); 36 | [Export("javaEnabled")] 37 | bool javaEnabled(); 38 | [Export("msLaunchUri")] 39 | void msLaunchUri(string uri, MSLaunchUriCallback successCallback, MSLaunchUriCallback noHandlerCallback); 40 | [Export("vibrate")] 41 | bool vibrate(object pattern); 42 | } 43 | -------------------------------------------------------------------------------- /test/cases/interfaces/StringIndexerProperty.cs: -------------------------------------------------------------------------------- 1 | interface HTMLFormElement : HTMLElement { 2 | /** 3 | * Sets or retrieves a list of character encodings for input data that must be accepted by the server processing the form. 4 | */ 5 | [Export("acceptCharset")] 6 | string acceptCharset { get; set; } 7 | /** 8 | * Sets or retrieves the URL to which the form content is sent for processing. 9 | */ 10 | [Export("action")] 11 | string action { get; set; } 12 | /** 13 | * Specifies whether autocomplete is applied to an editable text field. 14 | */ 15 | [Export("autocomplete")] 16 | string autocomplete { get; set; } 17 | /** 18 | * Retrieves a collection, in source order, of all controls in a given form. 19 | */ 20 | [Export("elements")] 21 | HTMLFormControlsCollection elements { get; } 22 | /** 23 | * Sets or retrieves the MIME encoding for the form. 24 | */ 25 | [Export("encoding")] 26 | string encoding { get; set; } 27 | /** 28 | * Sets or retrieves the encoding type for the form. 29 | */ 30 | [Export("enctype")] 31 | string enctype { get; set; } 32 | /** 33 | * Sets or retrieves the number of objects in a collection. 34 | */ 35 | [Export("length")] 36 | double length { get; } 37 | /** 38 | * Sets or retrieves how to send the form data to the server. 39 | */ 40 | [Export("method")] 41 | string method { get; set; } 42 | /** 43 | * Sets or retrieves the name of the object. 44 | */ 45 | [Export("name")] 46 | string name { get; set; } 47 | /** 48 | * Designates a form that is not validated when submitted. 49 | */ 50 | [Export("noValidate")] 51 | bool noValidate { get; set; } 52 | /** 53 | * Sets or retrieves the window or frame at which to target content. 54 | */ 55 | [Export("target")] 56 | string target { get; set; } 57 | /** 58 | * Returns whether a form will validate when it is submitted, without having to submit it. 59 | */ 60 | [Export("checkValidity")] 61 | bool checkValidity(); 62 | /** 63 | * Retrieves a form object or an object from an elements collection. 64 | * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is a Number, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. 65 | * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. 66 | */ 67 | [Export("item")] 68 | Object item(Object name, Object index); 69 | /** 70 | * Retrieves a form object or an object from an elements collection. 71 | */ 72 | [Export("namedItem")] 73 | Object namedItem(string name); 74 | /** 75 | * Fires when the user resets a form. 76 | */ 77 | [Export("reset")] 78 | void reset(); 79 | /** 80 | * Fires when a FORM is about to be submitted. 81 | */ 82 | [Export("submit")] 83 | void submit(); 84 | [Export("reportValidity")] 85 | bool reportValidity(); 86 | Object this[string name] { get; set; } 87 | } 88 | -------------------------------------------------------------------------------- /test/cases/interfaces/StringOrNullProperty.cs: -------------------------------------------------------------------------------- 1 | interface Node : EventTarget { 2 | [Export("baseURIFoo")] 3 | string baseURIFoo { get; } 4 | [Export("baseURI")] 5 | string baseURI { get; } 6 | } 7 | -------------------------------------------------------------------------------- /test/cases/interfaces/StringProperty.cs: -------------------------------------------------------------------------------- 1 | interface HTMLElement { 2 | [Export("accessKey")] 3 | string accessKey { get; set; } 4 | } 5 | -------------------------------------------------------------------------------- /test/cases/interfaces/TypeQueryProperty.cs: -------------------------------------------------------------------------------- 1 | 2 | interface URL { 3 | [Export("hash")] 4 | string hash { get; set; } 5 | [Export("host")] 6 | string host { get; set; } 7 | [Export("hostname")] 8 | string hostname { get; set; } 9 | [Export("href")] 10 | string href { get; set; } 11 | [Export("origin")] 12 | string origin { get; } 13 | [Export("password")] 14 | string password { get; set; } 15 | [Export("pathname")] 16 | string pathname { get; set; } 17 | [Export("port")] 18 | string port { get; set; } 19 | [Export("protocol")] 20 | string protocol { get; set; } 21 | [Export("search")] 22 | string search { get; set; } 23 | [Export("username")] 24 | string username { get; set; } 25 | [Export("searchParams")] 26 | URLSearchParams searchParams { get; } 27 | [Export("toString")] 28 | string toString(); 29 | } 30 | 31 | interface URLSearchParams { 32 | /** 33 | * Appends a specified key/value pair as a new search parameter. 34 | */ 35 | [Export("append")] 36 | void append(string name, string value); 37 | /** 38 | * Deletes the given search parameter, and its associated value, from the list of all search parameters. 39 | */ 40 | [Export("delete")] 41 | void delete(string name); 42 | /** 43 | * Returns the first value associated to the given search parameter. 44 | */ 45 | [Export("get")] 46 | string get(string name); 47 | /** 48 | * Returns all the values association with a given search parameter. 49 | */ 50 | [Export("getAll")] 51 | string[] getAll(string name); 52 | /** 53 | * Returns a Boolean indicating if such a search parameter exists. 54 | */ 55 | [Export("has")] 56 | bool has(string name); 57 | /** 58 | * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. 59 | */ 60 | [Export("set")] 61 | void set(string name, string value); 62 | } 63 | 64 | interface Blob { 65 | [Export("size")] 66 | double size { get; } 67 | [Export("type")] 68 | string type { get; } 69 | [Export("msClose")] 70 | void msClose(); 71 | [Export("msDetachStream")] 72 | Object msDetachStream(); 73 | [Export("slice")] 74 | Blob slice(double start, double end, string contentType); 75 | } 76 | 77 | interface BlobPropertyBag { 78 | [Export("type")] 79 | string type { get; set; } 80 | [Export("endings")] 81 | string endings { get; set; } 82 | } 83 | 84 | interface Window 85 | { 86 | [Export("URL")] 87 | URL URL { get; set; } 88 | [Export("URLSearchParams")] 89 | URLSearchParams URLSearchParams { get; set; } 90 | [Export("Blob")] 91 | Blob Blob { get; set; } 92 | } 93 | -------------------------------------------------------------------------------- /test/cases/interfaces/TypeRefArrayOrNullProperty.cs: -------------------------------------------------------------------------------- 1 | interface ServiceWorkerMessageEventInit : EventInit { 2 | [Export("data")] 3 | Object data { get; set; } 4 | [Export("lastEventId")] 5 | string lastEventId { get; set; } 6 | [Export("origin")] 7 | string origin { get; set; } 8 | [Export("ports")] 9 | MessagePort[] ports { get; set; } 10 | [Export("source")] 11 | object source { get; set; } 12 | } 13 | -------------------------------------------------------------------------------- /test/cases/interfaces/TypeRefArrayProperty.cs: -------------------------------------------------------------------------------- 1 | interface ServiceWorkerMessageEventInit : EventInit { 2 | [Export("data")] 3 | Object data { get; set; } 4 | [Export("lastEventId")] 5 | string lastEventId { get; set; } 6 | [Export("origin")] 7 | string origin { get; set; } 8 | [Export("ports")] 9 | MessagePort[] ports { get; set; } 10 | [Export("source")] 11 | object source { get; set; } 12 | } 13 | -------------------------------------------------------------------------------- /test/definitions/classes/InterfaceDeclaration.d.ts: -------------------------------------------------------------------------------- 1 | interface AudioListener { 2 | } 3 | 4 | declare var AudioListener: 5 | { 6 | prototype: AudioListener; 7 | new(): AudioListener; 8 | }; 9 | -------------------------------------------------------------------------------- /test/definitions/classes/InterfaceDeclaration1.d.ts: -------------------------------------------------------------------------------- 1 | interface AudioListener { 2 | dopplerFactor: number; 3 | speedOfSound: number; 4 | setOrientation(x: number, y: number, z: number, xUp: number, yUp: number, zUp: number): void; 5 | setPosition(x: number, y: number, z: number): void; 6 | setVelocity(x: number, y: number, z: number): void; 7 | } 8 | 9 | declare var AudioListener: 10 | { 11 | prototype: AudioListener; 12 | new(): AudioListener; 13 | }; 14 | -------------------------------------------------------------------------------- /test/definitions/classes/InterfaceDeclaration2.d.ts: -------------------------------------------------------------------------------- 1 | interface ErrorEvent extends Event { 2 | readonly colno: number; 3 | readonly error: any; 4 | readonly filename: string; 5 | readonly lineno: number; 6 | readonly message: string; 7 | initErrorEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, messageArg: string, filenameArg: string, linenoArg: number): void; 8 | } 9 | 10 | declare var ErrorEvent: { 11 | prototype: ErrorEvent; 12 | new(type: string, errorEventInitDict?: ErrorEventInit): ErrorEvent; 13 | }; 14 | 15 | interface Event { 16 | readonly bubbles: boolean; 17 | readonly cancelable: boolean; 18 | cancelBubble: boolean; 19 | readonly currentTarget: EventTarget; 20 | readonly defaultPrevented: boolean; 21 | readonly eventPhase: number; 22 | readonly isTrusted: boolean; 23 | returnValue: boolean; 24 | readonly srcElement: Element | null; 25 | readonly target: EventTarget; 26 | readonly timeStamp: number; 27 | readonly type: string; 28 | readonly scoped: boolean; 29 | initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; 30 | preventDefault(): void; 31 | stopImmediatePropagation(): void; 32 | stopPropagation(): void; 33 | deepPath(): EventTarget[]; 34 | readonly AT_TARGET: number; 35 | readonly BUBBLING_PHASE: number; 36 | readonly CAPTURING_PHASE: number; 37 | } 38 | 39 | declare var Event: { 40 | prototype: Event; 41 | new(typeArg: string, eventInitDict?: EventInit): Event; 42 | readonly AT_TARGET: number; 43 | readonly BUBBLING_PHASE: number; 44 | readonly CAPTURING_PHASE: number; 45 | }; 46 | -------------------------------------------------------------------------------- /test/definitions/classes/InterfaceDeclaration3.d.ts: -------------------------------------------------------------------------------- 1 | interface MouseEventInit extends EventModifierInit 2 | { 3 | button?: number; 4 | buttons?: number; 5 | clientX?: number; 6 | clientY?: number; 7 | relatedTarget?: EventTarget | null; 8 | screenX?: number; 9 | screenY?: number; 10 | } 11 | 12 | interface PointerEventInit extends MouseEventInit 13 | { 14 | height?: number; 15 | isPrimary?: boolean; 16 | pointerId?: number; 17 | pointerType?: string; 18 | pressure?: number; 19 | tiltX?: number; 20 | tiltY?: number; 21 | width?: number; 22 | } 23 | 24 | interface PointerEvent extends MouseEvent { 25 | readonly currentPoint: any; 26 | readonly height: number; 27 | readonly hwTimestamp: number; 28 | readonly intermediatePoints: any; 29 | readonly isPrimary: boolean; 30 | readonly pointerId: number; 31 | readonly pointerType: any; 32 | readonly pressure: number; 33 | readonly rotation: number; 34 | readonly tiltX: number; 35 | readonly tiltY: number; 36 | readonly width: number; 37 | getCurrentPoint(element: Element): void; 38 | getIntermediatePoints(element: Element): void; 39 | initPointerEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, offsetXArg: number, offsetYArg: number, widthArg: number, heightArg: number, pressure: number, rotation: number, tiltX: number, tiltY: number, pointerIdArg: number, pointerType: any, hwTimestampArg: number, isPrimary: boolean): void; 40 | } 41 | 42 | declare var PointerEvent: { 43 | prototype: PointerEvent; 44 | new(typeArg: string, eventInitDict?: PointerEventInit): PointerEvent; 45 | }; 46 | 47 | interface MouseEvent extends UIEvent { 48 | readonly altKey: boolean; 49 | readonly button: number; 50 | readonly buttons: number; 51 | readonly clientX: number; 52 | readonly clientY: number; 53 | readonly ctrlKey: boolean; 54 | readonly fromElement: Element; 55 | readonly layerX: number; 56 | readonly layerY: number; 57 | readonly metaKey: boolean; 58 | readonly movementX: number; 59 | readonly movementY: number; 60 | readonly offsetX: number; 61 | readonly offsetY: number; 62 | readonly pageX: number; 63 | readonly pageY: number; 64 | readonly relatedTarget: EventTarget; 65 | readonly screenX: number; 66 | readonly screenY: number; 67 | readonly shiftKey: boolean; 68 | readonly toElement: Element; 69 | readonly which: number; 70 | readonly x: number; 71 | readonly y: number; 72 | getModifierState(keyArg: string): boolean; 73 | initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget | null): void; 74 | } 75 | 76 | declare var MouseEvent: { 77 | prototype: MouseEvent; 78 | new(typeArg: string, eventInitDict?: MouseEventInit): MouseEvent; 79 | }; 80 | 81 | interface UIEvent extends Event { 82 | readonly detail: number; 83 | readonly view: Window; 84 | initUIEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number): void; 85 | } 86 | 87 | declare var UIEvent: { 88 | prototype: UIEvent; 89 | new(typeArg: string, eventInitDict?: UIEventInit): UIEvent; 90 | }; 91 | 92 | interface Event { 93 | readonly bubbles: boolean; 94 | readonly cancelable: boolean; 95 | cancelBubble: boolean; 96 | readonly currentTarget: EventTarget; 97 | readonly defaultPrevented: boolean; 98 | readonly eventPhase: number; 99 | readonly isTrusted: boolean; 100 | returnValue: boolean; 101 | readonly srcElement: Element | null; 102 | readonly target: EventTarget; 103 | readonly timeStamp: number; 104 | readonly type: string; 105 | readonly scoped: boolean; 106 | initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; 107 | preventDefault(): void; 108 | stopImmediatePropagation(): void; 109 | stopPropagation(): void; 110 | deepPath(): EventTarget[]; 111 | readonly AT_TARGET: number; 112 | readonly BUBBLING_PHASE: number; 113 | readonly CAPTURING_PHASE: number; 114 | } 115 | 116 | declare var Event: { 117 | prototype: Event; 118 | new(typeArg: string, eventInitDict?: EventInit): Event; 119 | readonly AT_TARGET: number; 120 | readonly BUBBLING_PHASE: number; 121 | readonly CAPTURING_PHASE: number; 122 | }; 123 | -------------------------------------------------------------------------------- /test/definitions/classes/InterfaceDeclaration4.d.ts: -------------------------------------------------------------------------------- 1 | 2 | interface URL { 3 | hash: string; 4 | host: string; 5 | hostname: string; 6 | href: string; 7 | readonly origin: string; 8 | password: string; 9 | pathname: string; 10 | port: string; 11 | protocol: string; 12 | search: string; 13 | username: string; 14 | readonly searchParams: URLSearchParams; 15 | toString(): string; 16 | } 17 | 18 | declare var URL: { 19 | prototype: URL; 20 | new(url: string, base?: string | URL): URL; 21 | createObjectURL(object: any, options?: ObjectURLOptions): string; 22 | revokeObjectURL(url: string): void; 23 | }; 24 | 25 | interface URLSearchParams { 26 | /** 27 | * Appends a specified key/value pair as a new search parameter. 28 | */ 29 | append(name: string, value: string): void; 30 | /** 31 | * Deletes the given search parameter, and its associated value, from the list of all search parameters. 32 | */ 33 | delete(name: string): void; 34 | /** 35 | * Returns the first value associated to the given search parameter. 36 | */ 37 | get(name: string): string | null; 38 | /** 39 | * Returns all the values association with a given search parameter. 40 | */ 41 | getAll(name: string): string[]; 42 | /** 43 | * Returns a Boolean indicating if such a search parameter exists. 44 | */ 45 | has(name: string): boolean; 46 | /** 47 | * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. 48 | */ 49 | set(name: string, value: string): void; 50 | } 51 | 52 | declare var URLSearchParams: { 53 | prototype: URLSearchParams; 54 | /** 55 | * Constructor returning a URLSearchParams object. 56 | */ 57 | new (init?: string | URLSearchParams): URLSearchParams; 58 | }; 59 | 60 | interface Blob { 61 | readonly size: number; 62 | readonly type: string; 63 | msClose(): void; 64 | msDetachStream(): any; 65 | slice(start?: number, end?: number, contentType?: string): Blob; 66 | } 67 | 68 | declare var Blob: { 69 | prototype: Blob; 70 | new (blobParts?: any[], options?: BlobPropertyBag): Blob; 71 | }; 72 | 73 | interface BlobPropertyBag { 74 | type?: string; 75 | endings?: string; 76 | } 77 | 78 | interface Window 79 | { 80 | URL: typeof URL; 81 | URLSearchParams: typeof URLSearchParams; 82 | Blob: typeof Blob; 83 | } 84 | 85 | declare var Window: { 86 | prototype: Window; 87 | new(): Window; 88 | }; 89 | -------------------------------------------------------------------------------- /test/definitions/classes/InterfaceDeclaration5.d.ts: -------------------------------------------------------------------------------- 1 | 2 | interface URL { 3 | hash: string; 4 | host: string; 5 | hostname: string; 6 | href: string; 7 | readonly origin: string; 8 | password: string; 9 | pathname: string; 10 | port: string; 11 | protocol: string; 12 | search: string; 13 | username: string; 14 | readonly searchParams: URLSearchParams; 15 | toString(): string; 16 | } 17 | 18 | declare var URL: { 19 | prototype: URL; 20 | new(url: string, base?: string | URL): URL; 21 | createObjectURL(object: any, options?: ObjectURLOptions): string; 22 | revokeObjectURL(url: string): void; 23 | }; 24 | 25 | interface URLSearchParams { 26 | /** 27 | * Appends a specified key/value pair as a new search parameter. 28 | */ 29 | append(name: string, value: string): void; 30 | /** 31 | * Deletes the given search parameter, and its associated value, from the list of all search parameters. 32 | */ 33 | delete(name: string): void; 34 | /** 35 | * Returns the first value associated to the given search parameter. 36 | */ 37 | get(name: string): string | null; 38 | /** 39 | * Returns all the values association with a given search parameter. 40 | */ 41 | getAll(name: string): string[]; 42 | /** 43 | * Returns a Boolean indicating if such a search parameter exists. 44 | */ 45 | has(name: string): boolean; 46 | /** 47 | * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. 48 | */ 49 | set(name: string, value: string): void; 50 | } 51 | 52 | declare var URLSearchParams: { 53 | prototype: URLSearchParams; 54 | /** 55 | * Constructor returning a URLSearchParams object. 56 | */ 57 | new (init?: string | URLSearchParams): URLSearchParams; 58 | }; 59 | 60 | interface Blob { 61 | readonly size: number; 62 | readonly type: string; 63 | msClose(): void; 64 | msDetachStream(): any; 65 | slice(start?: number, end?: number, contentType?: string): Blob; 66 | } 67 | 68 | declare var Blob: { 69 | prototype: Blob; 70 | new (blobParts?: any[], options?: BlobPropertyBag): Blob; 71 | }; 72 | 73 | interface BlobPropertyBag { 74 | type?: string; 75 | endings?: string; 76 | } 77 | 78 | interface Window 79 | { 80 | URL: typeof URL; 81 | URLSearchParams: typeof URLSearchParams; 82 | Blob: typeof Blob; 83 | } 84 | 85 | declare var Window: { 86 | prototype: Window; 87 | new(): Window; 88 | }; 89 | -------------------------------------------------------------------------------- /test/definitions/classes/InterfaceDeclarationNoEmitComments.d.ts: -------------------------------------------------------------------------------- 1 | interface AudioListener { 2 | } // Trailing comment of interface defintion. 3 | 4 | // This is a leading comment 5 | declare var AudioListener: 6 | { // Here is another comment 7 | 8 | /** 9 | * We will extend the AudioListener interface defined above. 10 | */ 11 | 12 | prototype: AudioListener; // Trailing of prototype 13 | /** 14 | * Creates a new AudioListener 15 | */ 16 | new(): AudioListener; // Trailing of constructor 17 | }; // Trailing comments 18 | -------------------------------------------------------------------------------- /test/definitions/classes/InterfaceDeclarationPropertyIndexer.d.ts: -------------------------------------------------------------------------------- 1 | interface FileList { 2 | readonly length: number; 3 | item(index: number): File; 4 | [index: number]: File; 5 | } 6 | 7 | declare var FileList: { 8 | prototype: FileList; 9 | new(): FileList; 10 | }; 11 | -------------------------------------------------------------------------------- /test/definitions/classes/InterfaceDeclarationWithComments.d.ts: -------------------------------------------------------------------------------- 1 | interface AudioListener { 2 | } // Trailing comment of interface defintion. 3 | 4 | // This is a leading comment 5 | declare var AudioListener: 6 | { // Here is another comment 7 | 8 | /** 9 | * We will extend the AudioListener interface defined above. 10 | */ 11 | 12 | prototype: AudioListener; // Trailing of prototype 13 | /** 14 | * Creates a new AudioListener 15 | */ 16 | new(): AudioListener; // Trailing of constructor 17 | }; // Trailing comments 18 | -------------------------------------------------------------------------------- /test/definitions/classes/InterfaceDeclarationWithConstructorArgs.d.ts: -------------------------------------------------------------------------------- 1 | 2 | interface ErrorEventInit { 3 | } 4 | 5 | interface ErrorEvent { 6 | } 7 | 8 | declare var ErrorEvent: { 9 | prototype: ErrorEvent; 10 | new(type: string, errorEventInitDict?: ErrorEventInit): ErrorEvent; 11 | }; 12 | -------------------------------------------------------------------------------- /test/definitions/classes/InterfaceDeclarationWithEventHandlers.d.ts: -------------------------------------------------------------------------------- 1 | 2 | interface GlobalEventHandlers { 3 | onpointercancel: (this: GlobalEventHandlers, ev: PointerEvent) => any; 4 | onpointerdown: (this: GlobalEventHandlers, ev: PointerEvent) => any; 5 | onpointerenter: (this: GlobalEventHandlers, ev: PointerEvent) => any; 6 | onpointerleave: (this: GlobalEventHandlers, ev: PointerEvent) => any; 7 | onpointermove: (this: GlobalEventHandlers, ev: PointerEvent) => any; 8 | onpointerout: (this: GlobalEventHandlers, ev: PointerEvent) => any; 9 | onpointerover: (this: GlobalEventHandlers, ev: PointerEvent) => any; 10 | onpointerup: (this: GlobalEventHandlers, ev: PointerEvent) => any; 11 | onwheel: (this: GlobalEventHandlers, ev: WheelEvent) => any; 12 | addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; 13 | removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; 14 | } 15 | 16 | interface EventTarget { 17 | addEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; 18 | dispatchEvent(evt: Event): boolean; 19 | removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; 20 | } 21 | 22 | declare var EventTarget: { 23 | prototype: EventTarget; 24 | new(): EventTarget; 25 | }; 26 | 27 | interface Window extends EventTarget, GlobalEventHandlers { 28 | 29 | onabort: (this: Window, ev: UIEvent) => any; 30 | onafterprint: (this: Window, ev: Event) => any; 31 | onbeforeprint: (this: Window, ev: Event) => any; 32 | onbeforeunload: (this: Window, ev: BeforeUnloadEvent) => any; 33 | onblur: (this: Window, ev: FocusEvent) => any; 34 | oncanplay: (this: Window, ev: Event) => any; 35 | oncanplaythrough: (this: Window, ev: Event) => any; 36 | onchange: (this: Window, ev: Event) => any; 37 | onclick: (this: Window, ev: MouseEvent) => any; 38 | oncompassneedscalibration: (this: Window, ev: Event) => any; 39 | oncontextmenu: (this: Window, ev: PointerEvent) => any; 40 | ondblclick: (this: Window, ev: MouseEvent) => any; 41 | ondevicelight: (this: Window, ev: DeviceLightEvent) => any; 42 | ondevicemotion: (this: Window, ev: DeviceMotionEvent) => any; 43 | ondeviceorientation: (this: Window, ev: DeviceOrientationEvent) => any; 44 | ondrag: (this: Window, ev: DragEvent) => any; 45 | ondragend: (this: Window, ev: DragEvent) => any; 46 | ondragenter: (this: Window, ev: DragEvent) => any; 47 | ondragleave: (this: Window, ev: DragEvent) => any; 48 | ondragover: (this: Window, ev: DragEvent) => any; 49 | ondragstart: (this: Window, ev: DragEvent) => any; 50 | ondrop: (this: Window, ev: DragEvent) => any; 51 | ondurationchange: (this: Window, ev: Event) => any; 52 | onemptied: (this: Window, ev: Event) => any; 53 | onended: (this: Window, ev: MediaStreamErrorEvent) => any; 54 | onfocus: (this: Window, ev: FocusEvent) => any; 55 | onhashchange: (this: Window, ev: HashChangeEvent) => any; 56 | oninput: (this: Window, ev: Event) => any; 57 | oninvalid: (this: Window, ev: Event) => any; 58 | onkeydown: (this: Window, ev: KeyboardEvent) => any; 59 | onkeypress: (this: Window, ev: KeyboardEvent) => any; 60 | onkeyup: (this: Window, ev: KeyboardEvent) => any; 61 | onload: (this: Window, ev: Event) => any; 62 | onloadeddata: (this: Window, ev: Event) => any; 63 | onloadedmetadata: (this: Window, ev: Event) => any; 64 | onloadstart: (this: Window, ev: Event) => any; 65 | onmessage: (this: Window, ev: MessageEvent) => any; 66 | onmousedown: (this: Window, ev: MouseEvent) => any; 67 | onmouseenter: (this: Window, ev: MouseEvent) => any; 68 | onmouseleave: (this: Window, ev: MouseEvent) => any; 69 | onmousemove: (this: Window, ev: MouseEvent) => any; 70 | onmouseout: (this: Window, ev: MouseEvent) => any; 71 | onmouseover: (this: Window, ev: MouseEvent) => any; 72 | onmouseup: (this: Window, ev: MouseEvent) => any; 73 | onmousewheel: (this: Window, ev: WheelEvent) => any; 74 | onmsgesturechange: (this: Window, ev: MSGestureEvent) => any; 75 | onmsgesturedoubletap: (this: Window, ev: MSGestureEvent) => any; 76 | onmsgestureend: (this: Window, ev: MSGestureEvent) => any; 77 | onmsgesturehold: (this: Window, ev: MSGestureEvent) => any; 78 | onmsgesturestart: (this: Window, ev: MSGestureEvent) => any; 79 | onmsgesturetap: (this: Window, ev: MSGestureEvent) => any; 80 | onmsinertiastart: (this: Window, ev: MSGestureEvent) => any; 81 | onmspointercancel: (this: Window, ev: MSPointerEvent) => any; 82 | onmspointerdown: (this: Window, ev: MSPointerEvent) => any; 83 | onmspointerenter: (this: Window, ev: MSPointerEvent) => any; 84 | onmspointerleave: (this: Window, ev: MSPointerEvent) => any; 85 | onmspointermove: (this: Window, ev: MSPointerEvent) => any; 86 | onmspointerout: (this: Window, ev: MSPointerEvent) => any; 87 | onmspointerover: (this: Window, ev: MSPointerEvent) => any; 88 | onmspointerup: (this: Window, ev: MSPointerEvent) => any; 89 | onoffline: (this: Window, ev: Event) => any; 90 | ononline: (this: Window, ev: Event) => any; 91 | onorientationchange: (this: Window, ev: Event) => any; 92 | onpagehide: (this: Window, ev: PageTransitionEvent) => any; 93 | onpageshow: (this: Window, ev: PageTransitionEvent) => any; 94 | onpause: (this: Window, ev: Event) => any; 95 | onplay: (this: Window, ev: Event) => any; 96 | onplaying: (this: Window, ev: Event) => any; 97 | onpopstate: (this: Window, ev: PopStateEvent) => any; 98 | onprogress: (this: Window, ev: ProgressEvent) => any; 99 | onratechange: (this: Window, ev: Event) => any; 100 | onreadystatechange: (this: Window, ev: ProgressEvent) => any; 101 | onreset: (this: Window, ev: Event) => any; 102 | onresize: (this: Window, ev: UIEvent) => any; 103 | onscroll: (this: Window, ev: UIEvent) => any; 104 | onseeked: (this: Window, ev: Event) => any; 105 | onseeking: (this: Window, ev: Event) => any; 106 | onselect: (this: Window, ev: UIEvent) => any; 107 | onstalled: (this: Window, ev: Event) => any; 108 | onstorage: (this: Window, ev: StorageEvent) => any; 109 | onsubmit: (this: Window, ev: Event) => any; 110 | onsuspend: (this: Window, ev: Event) => any; 111 | ontimeupdate: (this: Window, ev: Event) => any; 112 | onunload: (this: Window, ev: Event) => any; 113 | onvolumechange: (this: Window, ev: Event) => any; 114 | onwaiting: (this: Window, ev: Event) => any; 115 | 116 | } 117 | 118 | declare var Window: { 119 | prototype: Window; 120 | new(): Window; 121 | }; 122 | -------------------------------------------------------------------------------- /test/definitions/classes/InterfaceDeclarationWithInheritedMethods.d.ts: -------------------------------------------------------------------------------- 1 | interface AudioListener { 2 | setOrientation(x: number, y: number, z: number, xUp: number, yUp: number, zUp: number): void; 3 | setPosition(x: number, y: number, z: number): void; 4 | setVelocity(x: number, y: number, z: number): void; 5 | } 6 | 7 | declare var AudioListener: 8 | { 9 | prototype: AudioListener; 10 | new(): AudioListener; 11 | }; 12 | -------------------------------------------------------------------------------- /test/definitions/classes/InterfaceDeclarationWithInheritedProperties.d.ts: -------------------------------------------------------------------------------- 1 | interface AudioListener { 2 | dopplerFactor: number; 3 | speedOfSound: number; 4 | } 5 | 6 | declare var AudioListener: 7 | { 8 | prototype: AudioListener; 9 | new(): AudioListener; 10 | }; 11 | -------------------------------------------------------------------------------- /test/definitions/classes/InterfaceDeclarationWithMethods.d.ts: -------------------------------------------------------------------------------- 1 | 2 | interface RTCSrtpSdesTransport { 3 | } 4 | 5 | declare var RTCSrtpSdesTransport: { 6 | prototype: RTCSrtpSdesTransport; 7 | new(transport: RTCIceTransport, encryptParameters: RTCSrtpSdesParameters, decryptParameters: RTCSrtpSdesParameters): RTCSrtpSdesTransport; 8 | getLocalParameters(): RTCSrtpSdesParameters[]; 9 | }; 10 | -------------------------------------------------------------------------------- /test/definitions/classes/InterfaceDeclarationWithProperties.d.ts: -------------------------------------------------------------------------------- 1 | interface PerformanceNavigation { 2 | } 3 | 4 | declare var PerformanceNavigation: { 5 | prototype: PerformanceNavigation; 6 | new(): PerformanceNavigation; 7 | readonly TYPE_BACK_FORWARD: number; 8 | readonly TYPE_NAVIGATE: number; 9 | readonly TYPE_RELOAD: number; 10 | readonly TYPE_RESERVED: number; 11 | }; 12 | -------------------------------------------------------------------------------- /test/definitions/classes/InterfaceDeclarationWithTypeQuery.d.ts: -------------------------------------------------------------------------------- 1 | 2 | interface URL { 3 | hash: string; 4 | host: string; 5 | hostname: string; 6 | href: string; 7 | readonly origin: string; 8 | password: string; 9 | pathname: string; 10 | port: string; 11 | protocol: string; 12 | search: string; 13 | username: string; 14 | readonly searchParams: URLSearchParams; 15 | toString(): string; 16 | } 17 | 18 | declare var URL: { 19 | prototype: URL; 20 | new(url: string, base?: string | URL): URL; 21 | createObjectURL(object: any, options?: ObjectURLOptions): string; 22 | revokeObjectURL(url: string): void; 23 | }; 24 | 25 | interface URLSearchParams { 26 | /** 27 | * Appends a specified key/value pair as a new search parameter. 28 | */ 29 | append(name: string, value: string): void; 30 | /** 31 | * Deletes the given search parameter, and its associated value, from the list of all search parameters. 32 | */ 33 | delete(name: string): void; 34 | /** 35 | * Returns the first value associated to the given search parameter. 36 | */ 37 | get(name: string): string | null; 38 | /** 39 | * Returns all the values association with a given search parameter. 40 | */ 41 | getAll(name: string): string[]; 42 | /** 43 | * Returns a Boolean indicating if such a search parameter exists. 44 | */ 45 | has(name: string): boolean; 46 | /** 47 | * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. 48 | */ 49 | set(name: string, value: string): void; 50 | } 51 | 52 | declare var URLSearchParams: { 53 | prototype: URLSearchParams; 54 | /** 55 | * Constructor returning a URLSearchParams object. 56 | */ 57 | new (init?: string | URLSearchParams): URLSearchParams; 58 | }; 59 | 60 | interface Blob { 61 | readonly size: number; 62 | readonly type: string; 63 | msClose(): void; 64 | msDetachStream(): any; 65 | slice(start?: number, end?: number, contentType?: string): Blob; 66 | } 67 | 68 | declare var Blob: { 69 | prototype: Blob; 70 | new (blobParts?: any[], options?: BlobPropertyBag): Blob; 71 | }; 72 | 73 | interface BlobPropertyBag { 74 | type?: string; 75 | endings?: string; 76 | } 77 | 78 | interface Window 79 | { 80 | URL: typeof URL; 81 | URLSearchParams: typeof URLSearchParams; 82 | Blob: typeof Blob; 83 | } 84 | 85 | declare var Window: { 86 | prototype: Window; 87 | new(): Window; 88 | }; 89 | -------------------------------------------------------------------------------- /test/definitions/diagnostics/DeclarationOfNonInterface.d.ts: -------------------------------------------------------------------------------- 1 | interface OtherListener { 2 | } 3 | 4 | declare var AudioListener: 5 | { 6 | prototype: AudioListener; 7 | new(): AudioListener; 8 | }; 9 | -------------------------------------------------------------------------------- /test/definitions/diagnostics/GenericInterfaceWithTypeDefault.d.ts: -------------------------------------------------------------------------------- 1 | interface CustomEvent extends Event { 2 | readonly detail: T; 3 | initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: T): void; 4 | } 5 | -------------------------------------------------------------------------------- /test/definitions/interfaces/ArrayProperty.d.ts: -------------------------------------------------------------------------------- 1 | interface MediaKeySystemConfiguration { 2 | initDataTypes?: string[]; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/ArrayProperty2.d.ts: -------------------------------------------------------------------------------- 1 | interface Gamepad { 2 | readonly axes: number[]; 3 | readonly buttons: GamepadButton[]; 4 | readonly connected: boolean; 5 | readonly id: string; 6 | readonly index: number; 7 | readonly mapping: string; 8 | readonly timestamp: number; 9 | } 10 | -------------------------------------------------------------------------------- /test/definitions/interfaces/BooleanArrayOrNullProperty.d.ts: -------------------------------------------------------------------------------- 1 | interface GamepadFaux { 2 | readonly axesAvailable: boolean[] | null; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/BooleanArrayProperty.d.ts: -------------------------------------------------------------------------------- 1 | interface GamepadFaux { 2 | readonly axesAvailable: boolean[]; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/BooleanOrNullProperty.d.ts: -------------------------------------------------------------------------------- 1 | interface RTCIceParameters { 2 | iceLite?: boolean | null; 3 | password?: string; 4 | usernameFragment?: string; 5 | } 6 | -------------------------------------------------------------------------------- /test/definitions/interfaces/BooleanProperty.d.ts: -------------------------------------------------------------------------------- 1 | interface Event { 2 | readonly bubbles: boolean; 3 | readonly cancelable: boolean; 4 | cancelBubble: boolean; 5 | readonly defaultPrevented: boolean; 6 | readonly isTrusted: boolean; 7 | returnValue: boolean; 8 | readonly scoped: boolean; 9 | } 10 | -------------------------------------------------------------------------------- /test/definitions/interfaces/Comments.d.ts: -------------------------------------------------------------------------------- 1 | // This is a leading comment 2 | interface EventTarget { // This is a trailing comment 3 | 4 | } 5 | -------------------------------------------------------------------------------- /test/definitions/interfaces/Comments2.d.ts: -------------------------------------------------------------------------------- 1 | // This is a leading comment 2 | interface EventTarget 3 | { // This is a trailing comment 4 | 5 | } 6 | -------------------------------------------------------------------------------- /test/definitions/interfaces/EventHandlers.d.ts: -------------------------------------------------------------------------------- 1 | interface GlobalEventHandlers { 2 | onpointercancel: (this: GlobalEventHandlers, ev: PointerEvent) => any; 3 | onpointerdown: (this: GlobalEventHandlers, ev: PointerEvent) => any; 4 | onpointerenter: (this: GlobalEventHandlers, ev: PointerEvent) => any; 5 | onpointerleave: (this: GlobalEventHandlers, ev: PointerEvent) => any; 6 | onpointermove: (this: GlobalEventHandlers, ev: PointerEvent) => any; 7 | onpointerout: (this: GlobalEventHandlers, ev: PointerEvent) => any; 8 | onpointerover: (this: GlobalEventHandlers, ev: PointerEvent) => any; 9 | onpointerup: (this: GlobalEventHandlers, ev: PointerEvent) => any; 10 | onwheel: (this: GlobalEventHandlers, ev: WheelEvent) => any; 11 | addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; 12 | removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; 13 | } 14 | -------------------------------------------------------------------------------- /test/definitions/interfaces/Extends.d.ts: -------------------------------------------------------------------------------- 1 | interface Node extends EventTarget {} 2 | -------------------------------------------------------------------------------- /test/definitions/interfaces/Extends2.d.ts: -------------------------------------------------------------------------------- 1 | interface EventTarget { 2 | dispatchEvent(evt: Event): boolean; 3 | } 4 | 5 | interface Node extends EventTarget { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /test/definitions/interfaces/Extends3.d.ts: -------------------------------------------------------------------------------- 1 | interface Event { 2 | readonly bubbles: boolean; 3 | readonly cancelable: boolean; 4 | cancelBubble: boolean; 5 | readonly currentTarget: EventTarget; 6 | readonly defaultPrevented: boolean; 7 | readonly eventPhase: number; 8 | readonly isTrusted: boolean; 9 | returnValue: boolean; 10 | readonly srcElement: Element | null; 11 | readonly target: EventTarget; 12 | readonly timeStamp: number; 13 | readonly type: string; 14 | readonly scoped: boolean; 15 | initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; 16 | preventDefault(): void; 17 | stopImmediatePropagation(): void; 18 | stopPropagation(): void; 19 | deepPath(): EventTarget[]; 20 | readonly AT_TARGET: number; 21 | readonly BUBBLING_PHASE: number; 22 | readonly CAPTURING_PHASE: number; 23 | } 24 | 25 | interface EventTarget { 26 | dispatchEvent(evt: Event): boolean; 27 | } 28 | 29 | interface Node extends EventTarget { 30 | readonly nodeName: string; 31 | readonly nodeType: number; 32 | } 33 | 34 | interface GlobalEventHandlers { 35 | } 36 | 37 | interface ElementTraversal { 38 | readonly childElementCount: number; 39 | } 40 | 41 | interface NodeSelector { 42 | } 43 | 44 | interface ChildNode { 45 | remove(): void; 46 | } 47 | 48 | interface HTMLCollectionBase { 49 | /** 50 | * Sets or retrieves the number of objects in a collection. 51 | */ 52 | readonly length: number; 53 | /** 54 | * Retrieves an object from various collections. 55 | */ 56 | item(index: number): Element; 57 | [index: number]: Element; 58 | } 59 | 60 | interface HTMLCollection extends HTMLCollectionBase { 61 | /** 62 | * Retrieves a select object or an object from an options collection. 63 | */ 64 | namedItem(name: string): Element | null; 65 | } 66 | 67 | interface ParentNode { 68 | readonly children: HTMLCollection; 69 | readonly childElementCount: number; 70 | } 71 | 72 | interface DOMTokenList { 73 | readonly length: number; 74 | contains(token: string): boolean; 75 | item(index: number): string; 76 | toggle(token: string, force?: boolean): boolean; 77 | toString(): string; 78 | [index: number]: string; 79 | } 80 | 81 | interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode, ParentNode { 82 | readonly classList: DOMTokenList; 83 | className: string; 84 | readonly clientHeight: number; 85 | readonly clientLeft: number; 86 | readonly clientTop: number; 87 | readonly clientWidth: number; 88 | id: string; 89 | innerHTML: string; 90 | msContentZoomFactor: number; 91 | readonly msRegionOverflow: string; 92 | } 93 | -------------------------------------------------------------------------------- /test/definitions/interfaces/Extends4.d.ts: -------------------------------------------------------------------------------- 1 | interface Event { 2 | readonly bubbles: boolean; 3 | readonly cancelable: boolean; 4 | cancelBubble: boolean; 5 | readonly currentTarget: EventTarget; 6 | readonly defaultPrevented: boolean; 7 | readonly eventPhase: number; 8 | readonly isTrusted: boolean; 9 | returnValue: boolean; 10 | readonly srcElement: Element | null; 11 | readonly target: EventTarget; 12 | readonly timeStamp: number; 13 | readonly type: string; 14 | readonly scoped: boolean; 15 | initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; 16 | preventDefault(): void; 17 | stopImmediatePropagation(): void; 18 | stopPropagation(): void; 19 | deepPath(): EventTarget[]; 20 | readonly AT_TARGET: number; 21 | readonly BUBBLING_PHASE: number; 22 | readonly CAPTURING_PHASE: number; 23 | } 24 | 25 | interface AnimationEvent extends Event { 26 | readonly animationName: string; 27 | readonly elapsedTime: number; 28 | initAnimationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, animationNameArg: string, elapsedTimeArg: number): void; 29 | } 30 | -------------------------------------------------------------------------------- /test/definitions/interfaces/ExtendsGeneric.d.ts: -------------------------------------------------------------------------------- 1 | 2 | interface HTMLOptionsCollection extends HTMLCollectionOf { 3 | length: number; 4 | selectedIndex: number; 5 | add(element: HTMLOptionElement | HTMLOptGroupElement, before?: HTMLElement | number): void; 6 | remove(index: number): void; 7 | } 8 | 9 | interface HTMLCollectionOf extends HTMLCollection { 10 | item(index: number): T; 11 | namedItem(name: string): T; 12 | [index: number]: T; 13 | } 14 | 15 | interface HTMLElement extends Element { 16 | accessKey: string; 17 | readonly children: HTMLCollection; 18 | contentEditable: string; 19 | readonly dataset: DOMStringMap; 20 | dir: string; 21 | draggable: boolean; 22 | hidden: boolean; 23 | hideFocus: boolean; 24 | innerText: string; 25 | readonly isContentEditable: boolean; 26 | lang: string; 27 | readonly offsetHeight: number; 28 | readonly offsetLeft: number; 29 | readonly offsetParent: Element; 30 | readonly offsetTop: number; 31 | readonly offsetWidth: number; 32 | outerText: string; 33 | spellcheck: boolean; 34 | readonly style: CSSStyleDeclaration; 35 | tabIndex: number; 36 | title: string; 37 | blur(): void; 38 | click(): void; 39 | dragDrop(): boolean; 40 | focus(): void; 41 | msGetInputContext(): MSInputMethodContext; 42 | } 43 | 44 | interface HTMLOptionElement extends HTMLElement { 45 | /** 46 | * Sets or retrieves the status of an option. 47 | */ 48 | defaultSelected: boolean; 49 | disabled: boolean; 50 | /** 51 | * Retrieves a reference to the form that the object is embedded in. 52 | */ 53 | readonly form: HTMLFormElement | null; 54 | /** 55 | * Sets or retrieves the ordinal position of an option in a list box. 56 | */ 57 | readonly index: number; 58 | /** 59 | * Sets or retrieves a value that you can use to implement your own label functionality for the object. 60 | */ 61 | label: string; 62 | /** 63 | * Sets or retrieves whether the option in the list box is the default item. 64 | */ 65 | selected: boolean; 66 | /** 67 | * Sets or retrieves the text string specified by the option tag. 68 | */ 69 | text: string; 70 | /** 71 | * Sets or retrieves the value which is returned to the server when the form control is submitted. 72 | */ 73 | value: string; 74 | } 75 | 76 | interface GlobalEventHandlers { 77 | } 78 | 79 | interface EventTarget { 80 | } 81 | 82 | interface Node extends EventTarget { 83 | } 84 | 85 | interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode, ParentNode { 86 | } 87 | 88 | interface ElementTraversal { 89 | } 90 | 91 | interface NodeSelector { 92 | } 93 | 94 | interface ChildNode { 95 | } 96 | 97 | interface ParentNode { 98 | } 99 | -------------------------------------------------------------------------------- /test/definitions/interfaces/GenericInterfaceWithConstraint.d.ts: -------------------------------------------------------------------------------- 1 | 2 | interface NodeList { 3 | readonly length: number; 4 | item(index: number): Node; 5 | [index: number]: Node; 6 | } 7 | 8 | interface NodeListOf extends NodeList { 9 | length: number; 10 | item(index: number): TNode; 11 | [index: number]: TNode; 12 | } 13 | -------------------------------------------------------------------------------- /test/definitions/interfaces/GenericInterfaceWithConstraint2.d.ts: -------------------------------------------------------------------------------- 1 | 2 | interface HTMLCollectionBase { 3 | /** 4 | * Sets or retrieves the number of objects in a collection. 5 | */ 6 | readonly length: number; 7 | /** 8 | * Retrieves an object from various collections. 9 | */ 10 | item(index: number): Element; 11 | [index: number]: Element; 12 | } 13 | 14 | interface HTMLCollection extends HTMLCollectionBase { 15 | /** 16 | * Retrieves a select object or an object from an options collection. 17 | */ 18 | namedItem(name: string): Element | null; 19 | } 20 | 21 | interface GlobalEventHandlers { 22 | } 23 | 24 | interface EventTarget { 25 | } 26 | 27 | interface Node extends EventTarget { 28 | } 29 | 30 | interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode, ParentNode { 31 | } 32 | 33 | interface ElementTraversal { 34 | } 35 | 36 | interface NodeSelector { 37 | } 38 | 39 | interface ChildNode { 40 | } 41 | 42 | interface ParentNode { 43 | } 44 | 45 | interface HTMLCollectionOf extends HTMLCollection { 46 | item(index: number): T; 47 | namedItem(name: string): T; 48 | [index: number]: T; 49 | } 50 | -------------------------------------------------------------------------------- /test/definitions/interfaces/GenericInterfaceWithTypeDefault.d.ts: -------------------------------------------------------------------------------- 1 | interface CustomEvent extends Event { 2 | readonly detail: T; 3 | initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: T): void; 4 | } 5 | -------------------------------------------------------------------------------- /test/definitions/interfaces/IndexerProperty.d.ts: -------------------------------------------------------------------------------- 1 | interface FileList { 2 | [index: number]: File; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/IndexerPropertyComments.d.ts: -------------------------------------------------------------------------------- 1 | interface ClientRectList { 2 | // This is the length 3 | readonly length: number; /* returns a number */ 4 | item(index: number): ClientRect; // Return the ClientRect at the specified index 5 | /** 6 | * Retrieves a ClientRect object ClientRectList. 7 | */ 8 | [index: number]: ClientRect; // Return the ClientRect at the specified index 9 | 10 | } 11 | -------------------------------------------------------------------------------- /test/definitions/interfaces/Interface.d.ts: -------------------------------------------------------------------------------- 1 | interface EventTarget { 2 | } 3 | -------------------------------------------------------------------------------- /test/definitions/interfaces/Interface2.d.ts: -------------------------------------------------------------------------------- 1 | interface EventTarget 2 | {} 3 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodComments.d.ts: -------------------------------------------------------------------------------- 1 | interface HTMLFormElement extends HTMLElement { 2 | /** 3 | * Returns whether a form will validate when it is submitted, without having to submit it. 4 | */ 5 | checkValidity(): boolean; // Returns bool 6 | /** 7 | * Retrieves a form object or an object from an elements collection. 8 | */ 9 | item(name?: any, index?: any): any; // Returns the any value 10 | } 11 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnAny.d.ts: -------------------------------------------------------------------------------- 1 | interface PaymentAddress { 2 | toJSON(): any; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnAnyArray.d.ts: -------------------------------------------------------------------------------- 1 | interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, GlobalFetch { 2 | receiveMessage(message: any, targetOrigin: string): any[]; // This is not a real definition 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnAnyArrayOrNull.d.ts: -------------------------------------------------------------------------------- 1 | interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, GlobalFetch { 2 | receiveMessage(message: any, targetOrigin: string): any[] | null; // This is not a real definition 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnAnyOrNull.d.ts: -------------------------------------------------------------------------------- 1 | interface PaymentAddress { 2 | toJSON(): any | null; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnBool.d.ts: -------------------------------------------------------------------------------- 1 | interface Node { 2 | hasAttributes(): boolean; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnBoolOrNull.d.ts: -------------------------------------------------------------------------------- 1 | interface RTCIceParameters { 2 | iceLite?: boolean | null; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnNever.d.ts: -------------------------------------------------------------------------------- 1 | interface FauxInterface { 2 | fail(): never; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnNumber.d.ts: -------------------------------------------------------------------------------- 1 | interface Performance { 2 | now(): number; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnNumberArray.d.ts: -------------------------------------------------------------------------------- 1 | interface CanvasRenderingContext2D extends Object, CanvasPathMethods { 2 | getLineDash(): number[]; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnNumberArrayOrNull.d.ts: -------------------------------------------------------------------------------- 1 | interface CanvasRenderingContext2D extends Object, CanvasPathMethods { 2 | getLineDash(): number[] | null; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnNumberOrNull.d.ts: -------------------------------------------------------------------------------- 1 | interface Performance { 2 | now(): number | null; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnRefType1.d.ts: -------------------------------------------------------------------------------- 1 | interface Element { 2 | getBoundingClientRect(): ClientRect; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnRefType2.d.ts: -------------------------------------------------------------------------------- 1 | interface Element { 2 | getBoundingClientRect(): ClientRect; 3 | getClientRects(): ClientRectList; 4 | } 5 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnRefTypeArray.d.ts: -------------------------------------------------------------------------------- 1 | interface Event { 2 | readonly bubbles: boolean; 3 | readonly cancelable: boolean; 4 | cancelBubble: boolean; 5 | readonly currentTarget: EventTarget; 6 | readonly defaultPrevented: boolean; 7 | readonly eventPhase: number; 8 | readonly isTrusted: boolean; 9 | returnValue: boolean; 10 | readonly srcElement: Element | null; 11 | readonly target: EventTarget; 12 | readonly timeStamp: number; 13 | readonly type: string; 14 | readonly scoped: boolean; 15 | initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; 16 | preventDefault(): void; 17 | stopImmediatePropagation(): void; 18 | stopPropagation(): void; 19 | deepPath(): EventTarget[]; 20 | readonly AT_TARGET: number; 21 | readonly BUBBLING_PHASE: number; 22 | readonly CAPTURING_PHASE: number; 23 | } 24 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnRefTypeArrayOrNull.d.ts: -------------------------------------------------------------------------------- 1 | interface Event { 2 | readonly bubbles: boolean; 3 | readonly cancelable: boolean; 4 | cancelBubble: boolean; 5 | readonly currentTarget: EventTarget; 6 | readonly defaultPrevented: boolean; 7 | readonly eventPhase: number; 8 | readonly isTrusted: boolean; 9 | returnValue: boolean; 10 | readonly srcElement: Element | null; 11 | readonly target: EventTarget; 12 | readonly timeStamp: number; 13 | readonly type: string; 14 | readonly scoped: boolean; 15 | initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; 16 | preventDefault(): void; 17 | stopImmediatePropagation(): void; 18 | stopPropagation(): void; 19 | deepPath(): EventTarget[] | null; 20 | readonly AT_TARGET: number; 21 | readonly BUBBLING_PHASE: number; 22 | readonly CAPTURING_PHASE: number; 23 | } 24 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnRefTypeOrNull.d.ts: -------------------------------------------------------------------------------- 1 | interface DataTransferItemList { 2 | readonly length: number; 3 | add(data: File): DataTransferItem | null; 4 | clear(): void; 5 | item(index: number): DataTransferItem; 6 | remove(index: number): void; 7 | [index: number]: DataTransferItem; 8 | } 9 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnString.d.ts: -------------------------------------------------------------------------------- 1 | interface DOMError { 2 | toString(): string; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnStringArray.d.ts: -------------------------------------------------------------------------------- 1 | interface URLSearchParams { 2 | /** 3 | * Appends a specified key/value pair as a new search parameter. 4 | */ 5 | append(name: string, value: string): void; 6 | /** 7 | * Deletes the given search parameter, and its associated value, from the list of all search parameters. 8 | */ 9 | delete(name: string): void; 10 | /** 11 | * Returns the first value associated to the given search parameter. 12 | */ 13 | get(name: string): string | null; 14 | /** 15 | * Returns all the values association with a given search parameter. 16 | */ 17 | getAll(name: string): string[]; 18 | /** 19 | * Returns a Boolean indicating if such a search parameter exists. 20 | */ 21 | has(name: string): boolean; 22 | /** 23 | * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. 24 | */ 25 | set(name: string, value: string): void; 26 | } 27 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnStringArrayOrNull.d.ts: -------------------------------------------------------------------------------- 1 | interface URLSearchParams { 2 | /** 3 | * Appends a specified key/value pair as a new search parameter. 4 | */ 5 | append(name: string, value: string): void; 6 | /** 7 | * Deletes the given search parameter, and its associated value, from the list of all search parameters. 8 | */ 9 | delete(name: string): void; 10 | /** 11 | * Returns the first value associated to the given search parameter. 12 | */ 13 | get(name: string): string | null; 14 | /** 15 | * Returns all the values association with a given search parameter. 16 | */ 17 | getAll(name: string): string[] | null; 18 | /** 19 | * Returns a Boolean indicating if such a search parameter exists. 20 | */ 21 | has(name: string): boolean; 22 | /** 23 | * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. 24 | */ 25 | set(name: string, value: string): void; 26 | } 27 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnStringOrNull.d.ts: -------------------------------------------------------------------------------- 1 | interface DOMStringList { 2 | readonly length: number; 3 | contains(str: string): boolean; 4 | item(index: number): string | null; 5 | [index: number]: string; 6 | } 7 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodReturnVoid.d.ts: -------------------------------------------------------------------------------- 1 | interface EventTarget { 2 | dispatchEvent(): void; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithBooleanArrayOrNullParms.d.ts: -------------------------------------------------------------------------------- 1 | interface FauxInterface { 2 | initFauxInterface(fauxArg: boolean[] | null): void; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithBooleanArrayParms.d.ts: -------------------------------------------------------------------------------- 1 | interface FauxInterface { 2 | initFauxInterface(fauxArg: boolean[]): void; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithBooleanOrNullParms.d.ts: -------------------------------------------------------------------------------- 1 | interface FauxInterface { 2 | initFaux(eventTypeArg: string, canBubbleArg: boolean | null, cancelableArg: boolean | null): void; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithBooleanParms.d.ts: -------------------------------------------------------------------------------- 1 | interface Event { 2 | initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithDOMEventHandlerParms.d.ts: -------------------------------------------------------------------------------- 1 | interface EventTarget { 2 | addEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; 3 | dispatchEvent(evt: Event): boolean; 4 | removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; 5 | } 6 | 7 | declare var EventTarget: { 8 | prototype: EventTarget; 9 | new(): EventTarget; 10 | }; 11 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithLiteralTypeParm.d.ts: -------------------------------------------------------------------------------- 1 | interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode, ParentNode { 2 | getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf; 3 | getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf; 4 | getElementsByTagNameNS(namespaceURI: string, localName: string): HTMLCollectionOf; 5 | } 6 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithNumberArrayOrNullParms.d.ts: -------------------------------------------------------------------------------- 1 | interface CanvasRenderingContext2D extends Object, CanvasPathMethods { 2 | setFauxLineDash(segments: number[] | null): void; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithNumberArrayParms.d.ts: -------------------------------------------------------------------------------- 1 | interface CanvasRenderingContext2D extends Object, CanvasPathMethods { 2 | setLineDash(segments: number[]): void; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithNumberOrNullParms.d.ts: -------------------------------------------------------------------------------- 1 | interface DeviceOrientationEvent extends Event { 2 | readonly absolute: boolean; 3 | readonly alpha: number | null; 4 | readonly beta: number | null; 5 | readonly gamma: number | null; 6 | initDeviceOrientationEvent(type: string, bubbles: boolean, cancelable: boolean, alpha: number | null, beta: number | null, gamma: number | null, absolute: boolean): void; 7 | } 8 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithNumberParms.d.ts: -------------------------------------------------------------------------------- 1 | interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEvent, ParentNode, DocumentOrShadowRoot { 2 | caretRangeFromPoint(x: number, y: number): Range; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithRestAnyParms.d.ts: -------------------------------------------------------------------------------- 1 | interface Console { 2 | assert(test?: boolean, message?: string, ...optionalParams: any[]): void; 3 | clear(): void; 4 | count(countTitle?: string): void; 5 | debug(message?: any, ...optionalParams: any[]): void; 6 | dir(value?: any, ...optionalParams: any[]): void; 7 | dirxml(value: any): void; 8 | error(message?: any, ...optionalParams: any[]): void; 9 | exception(message?: string, ...optionalParams: any[]): void; 10 | group(groupTitle?: string, ...optionalParams: any[]): void; 11 | groupCollapsed(groupTitle?: string, ...optionalParams: any[]): void; 12 | groupEnd(): void; 13 | info(message?: any, ...optionalParams: any[]): void; 14 | log(message?: any, ...optionalParams: any[]): void; 15 | msIsIndependentlyComposed(element: Element): boolean; 16 | profile(reportName?: string): void; 17 | profileEnd(): void; 18 | select(element: Element): void; 19 | table(...data: any[]): void; 20 | time(timerName?: string): void; 21 | timeEnd(timerName?: string): void; 22 | trace(message?: any, ...optionalParams: any[]): void; 23 | warn(message?: any, ...optionalParams: any[]): void; 24 | } 25 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithRestStringParms.d.ts: -------------------------------------------------------------------------------- 1 | interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEvent, ParentNode, DocumentOrShadowRoot { 2 | /** 3 | * Writes one or more HTML expressions to a document in the specified window. 4 | * @param content Specifies the text and HTML tags to write. 5 | */ 6 | write(...content: string[]): void; 7 | /** 8 | * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. 9 | * @param content The text and HTML tags to write. 10 | */ 11 | writeln(...content: string[]): void; 12 | } 13 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithRestTypeRefParms.d.ts: -------------------------------------------------------------------------------- 1 | interface TouchList { 2 | readonly length: number; 3 | item(index: number): Touch | null; 4 | [index: number]: Touch; 5 | } 6 | 7 | interface Touch { 8 | readonly clientX: number; 9 | readonly clientY: number; 10 | readonly identifier: number; 11 | readonly pageX: number; 12 | readonly pageY: number; 13 | readonly screenX: number; 14 | readonly screenY: number; 15 | readonly target: EventTarget; 16 | } 17 | 18 | interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEvent, ParentNode, DocumentOrShadowRoot { 19 | createTouchList(...touches: Touch[]): TouchList; 20 | } 21 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithStringArrayOrNullParms.d.ts: -------------------------------------------------------------------------------- 1 | interface Screen extends EventTarget { 2 | msLockOrientation(orientations: string[] | null): boolean; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithStringArrayParms.d.ts: -------------------------------------------------------------------------------- 1 | interface Screen extends EventTarget { 2 | msLockOrientation(orientations: string[]): boolean; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithStringOrNullParms.d.ts: -------------------------------------------------------------------------------- 1 | interface NamedNodeMap { 2 | readonly length: number; 3 | getNamedItem(name: string): Attr; 4 | getNamedItemNS(namespaceURI: string | null, localName: string | null): Attr; 5 | item(index: number): Attr; 6 | removeNamedItem(name: string): Attr; 7 | removeNamedItemNS(namespaceURI: string | null, localName: string | null): Attr; 8 | setNamedItem(arg: Attr): Attr; 9 | setNamedItemNS(arg: Attr): Attr; 10 | } 11 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithStringParmReturnBool.d.ts: -------------------------------------------------------------------------------- 1 | interface Element { 2 | hasAttribute(name: string): boolean; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithStringParms.d.ts: -------------------------------------------------------------------------------- 1 | interface Element { 2 | setAttribute(name: string, value: string): void; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithTypeRefArrayOrNullParms.d.ts: -------------------------------------------------------------------------------- 1 | interface WebAuthentication { 2 | makeCredential(accountInformation: Account, cryptoParameters: ScopedCredentialParameters[] | null, attestationChallenge: BufferSource, options?: ScopedCredentialOptions): ScopedCredentialInfo; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithTypeRefArrayParms.d.ts: -------------------------------------------------------------------------------- 1 | interface WebAuthentication { 2 | makeCredential(accountInformation: Account, cryptoParameters: ScopedCredentialParameters[], attestationChallenge: BufferSource, options?: ScopedCredentialOptions): ScopedCredentialInfo; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/MethodWithTypeRefOrNullParms.d.ts: -------------------------------------------------------------------------------- 1 | interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEvent, ParentNode, DocumentOrShadowRoot { 2 | evaluate(expression: string, contextNode: Node, resolver: XPathNSResolver | null, type: number, result: XPathResult | null): XPathResult; 3 | 4 | } 5 | -------------------------------------------------------------------------------- /test/definitions/interfaces/NumberArrayOrNullProperty.d.ts: -------------------------------------------------------------------------------- 1 | interface Gamepad { 2 | readonly axes: number[] | null; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/NumberArrayProperty.d.ts: -------------------------------------------------------------------------------- 1 | interface Gamepad { 2 | readonly axes: number[]; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/NumberOrNullProperty.d.ts: -------------------------------------------------------------------------------- 1 | interface Coordinates { 2 | readonly accuracy: number; 3 | readonly altitude: number | null; 4 | readonly altitudeAccuracy: number | null; 5 | readonly heading: number | null; 6 | readonly latitude: number; 7 | readonly longitude: number; 8 | readonly speed: number | null; 9 | } 10 | -------------------------------------------------------------------------------- /test/definitions/interfaces/NumberProperty.d.ts: -------------------------------------------------------------------------------- 1 | interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode, ParentNode { 2 | scrollLeft: number; 3 | scrollTop: number; 4 | } 5 | -------------------------------------------------------------------------------- /test/definitions/interfaces/ObjOrNullProperty.d.ts: -------------------------------------------------------------------------------- 1 | 2 | interface DeviceAcceleration { 3 | readonly x: number | null; 4 | readonly y: number | null; 5 | readonly z: number | null; 6 | } 7 | 8 | interface DeviceRotationRate { 9 | readonly alpha: number | null; 10 | readonly beta: number | null; 11 | readonly gamma: number | null; 12 | } 13 | 14 | interface DeviceMotionEvent extends Event { 15 | readonly acceleration: DeviceAcceleration | null; 16 | readonly accelerationIncludingGravity: DeviceAcceleration | null; 17 | readonly interval: number | null; 18 | readonly rotationRate: DeviceRotationRate | null; 19 | } 20 | -------------------------------------------------------------------------------- /test/definitions/interfaces/ReadOnlyObjectProperty.d.ts: -------------------------------------------------------------------------------- 1 | interface HTMLElement { 2 | readonly children: HTMLCollection; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/ReadonlyIndexerProperty.d.ts: -------------------------------------------------------------------------------- 1 | interface FileList { 2 | readonly [index: number]: File; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/StringArrayOrNullProperty.d.ts: -------------------------------------------------------------------------------- 1 | interface ConfirmSiteSpecificExceptionsInformation extends ExceptionInformation { 2 | arrayOfDomainStrings?: string[] | null; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/StringArrayProperty.d.ts: -------------------------------------------------------------------------------- 1 | interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorUserMedia { 2 | readonly authentication: WebAuthentication; 3 | readonly cookieEnabled: boolean; 4 | gamepadInputEmulation: GamepadInputEmulationType; 5 | readonly language: string; 6 | readonly maxTouchPoints: number; 7 | readonly mimeTypes: MimeTypeArray; 8 | readonly msManipulationViewsEnabled: boolean; 9 | readonly msMaxTouchPoints: number; 10 | readonly msPointerEnabled: boolean; 11 | readonly plugins: PluginArray; 12 | readonly pointerEnabled: boolean; 13 | readonly serviceWorker: ServiceWorkerContainer; 14 | readonly webdriver: boolean; 15 | readonly doNotTrack: string | null; 16 | readonly hardwareConcurrency: number; 17 | readonly languages: string[]; 18 | getGamepads(): Gamepad[]; 19 | javaEnabled(): boolean; 20 | msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; 21 | vibrate(pattern: number | number[]): boolean; 22 | } 23 | -------------------------------------------------------------------------------- /test/definitions/interfaces/StringIndexerProperty.d.ts: -------------------------------------------------------------------------------- 1 | interface HTMLFormElement extends HTMLElement { 2 | /** 3 | * Sets or retrieves a list of character encodings for input data that must be accepted by the server processing the form. 4 | */ 5 | acceptCharset: string; 6 | /** 7 | * Sets or retrieves the URL to which the form content is sent for processing. 8 | */ 9 | action: string; 10 | /** 11 | * Specifies whether autocomplete is applied to an editable text field. 12 | */ 13 | autocomplete: string; 14 | /** 15 | * Retrieves a collection, in source order, of all controls in a given form. 16 | */ 17 | readonly elements: HTMLFormControlsCollection; 18 | /** 19 | * Sets or retrieves the MIME encoding for the form. 20 | */ 21 | encoding: string; 22 | /** 23 | * Sets or retrieves the encoding type for the form. 24 | */ 25 | enctype: string; 26 | /** 27 | * Sets or retrieves the number of objects in a collection. 28 | */ 29 | readonly length: number; 30 | /** 31 | * Sets or retrieves how to send the form data to the server. 32 | */ 33 | method: string; 34 | /** 35 | * Sets or retrieves the name of the object. 36 | */ 37 | name: string; 38 | /** 39 | * Designates a form that is not validated when submitted. 40 | */ 41 | noValidate: boolean; 42 | /** 43 | * Sets or retrieves the window or frame at which to target content. 44 | */ 45 | target: string; 46 | /** 47 | * Returns whether a form will validate when it is submitted, without having to submit it. 48 | */ 49 | checkValidity(): boolean; 50 | /** 51 | * Retrieves a form object or an object from an elements collection. 52 | * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is a Number, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. 53 | * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. 54 | */ 55 | item(name?: any, index?: any): any; 56 | /** 57 | * Retrieves a form object or an object from an elements collection. 58 | */ 59 | namedItem(name: string): any; 60 | /** 61 | * Fires when the user resets a form. 62 | */ 63 | reset(): void; 64 | /** 65 | * Fires when a FORM is about to be submitted. 66 | */ 67 | submit(): void; 68 | reportValidity(): boolean; 69 | [name: string]: any; 70 | } 71 | -------------------------------------------------------------------------------- /test/definitions/interfaces/StringOrNullProperty.d.ts: -------------------------------------------------------------------------------- 1 | interface Node extends EventTarget { 2 | readonly baseURIFoo: string; 3 | readonly baseURI: string | null; 4 | } 5 | -------------------------------------------------------------------------------- /test/definitions/interfaces/StringProperty.d.ts: -------------------------------------------------------------------------------- 1 | interface HTMLElement { 2 | accessKey: string; 3 | } 4 | -------------------------------------------------------------------------------- /test/definitions/interfaces/TypeQueryProperty.d.ts: -------------------------------------------------------------------------------- 1 | 2 | interface URL { 3 | hash: string; 4 | host: string; 5 | hostname: string; 6 | href: string; 7 | readonly origin: string; 8 | password: string; 9 | pathname: string; 10 | port: string; 11 | protocol: string; 12 | search: string; 13 | username: string; 14 | readonly searchParams: URLSearchParams; 15 | toString(): string; 16 | } 17 | 18 | interface URLSearchParams { 19 | /** 20 | * Appends a specified key/value pair as a new search parameter. 21 | */ 22 | append(name: string, value: string): void; 23 | /** 24 | * Deletes the given search parameter, and its associated value, from the list of all search parameters. 25 | */ 26 | delete(name: string): void; 27 | /** 28 | * Returns the first value associated to the given search parameter. 29 | */ 30 | get(name: string): string | null; 31 | /** 32 | * Returns all the values association with a given search parameter. 33 | */ 34 | getAll(name: string): string[]; 35 | /** 36 | * Returns a Boolean indicating if such a search parameter exists. 37 | */ 38 | has(name: string): boolean; 39 | /** 40 | * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. 41 | */ 42 | set(name: string, value: string): void; 43 | } 44 | 45 | interface Blob { 46 | readonly size: number; 47 | readonly type: string; 48 | msClose(): void; 49 | msDetachStream(): any; 50 | slice(start?: number, end?: number, contentType?: string): Blob; 51 | } 52 | 53 | interface BlobPropertyBag { 54 | type?: string; 55 | endings?: string; 56 | } 57 | 58 | interface Window 59 | { 60 | URL: typeof URL; 61 | URLSearchParams: typeof URLSearchParams; 62 | Blob: typeof Blob; 63 | } 64 | -------------------------------------------------------------------------------- /test/definitions/interfaces/TypeRefArrayOrNullProperty.d.ts: -------------------------------------------------------------------------------- 1 | interface ServiceWorkerMessageEventInit extends EventInit { 2 | data?: any; 3 | lastEventId?: string; 4 | origin?: string; 5 | ports?: MessagePort[] | null; 6 | source?: ServiceWorker | MessagePort | null; 7 | } 8 | -------------------------------------------------------------------------------- /test/definitions/interfaces/TypeRefArrayProperty.d.ts: -------------------------------------------------------------------------------- 1 | interface ServiceWorkerMessageEventInit extends EventInit { 2 | data?: any; 3 | lastEventId?: string; 4 | origin?: string; 5 | ports?: MessagePort[]; 6 | source?: ServiceWorker | MessagePort | null; 7 | } 8 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "ESNext", 5 | "noImplicitAny": true, 6 | "moduleResolution": "node", 7 | "sourceMap": true, 8 | "outDir": "dist", 9 | "baseUrl": ".", 10 | "paths": { 11 | "*": [ 12 | "node_modules/*" 13 | ] 14 | } 15 | }, 16 | "include": [ 17 | "src/**/*.ts" 18 | ], 19 | "exclude": [ 20 | "node_modules", 21 | ] 22 | } -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultSeverity": "error", 3 | "extends": [ 4 | "tslint:recommended" 5 | ], 6 | "jsRules": {}, 7 | "rules": { 8 | "align": [ 9 | true, 10 | "parameters", 11 | "statements" 12 | ], 13 | "interface-name": [ false ], 14 | "max-line-length": [ false ], 15 | "member-access": false, 16 | "member-ordering": [ 17 | false, 18 | "variables-before-functions" 19 | ], 20 | "no-bitwise": false, 21 | "no-empty": false, 22 | "no-string-literal": false, 23 | "ordered-imports": false, 24 | "arrow-parens": [ true, "ban-single-arg-parens" ], 25 | "unified-signatures": false, 26 | "array-type": [ "array-simple" ], 27 | "ban-types": false, 28 | "max-classes-per-file": [ false ], 29 | "no-unused-expression": false, 30 | "one-line": [ 31 | true, 32 | "check-catch", 33 | "check-whitespace" 34 | ], 35 | "object-literal-sort-keys": false, 36 | "trailing-comma": [ 37 | true, 38 | { 39 | "singleline": "never", 40 | "multiline": "never" 41 | } 42 | ], 43 | "variable-name": false, 44 | "no-reference": false, 45 | "curly": false, 46 | "no-console": [ false ], 47 | "prefer-conditional-expression": false, 48 | "no-empty-interface": false, 49 | "no-object-literal-type-assertion": false, 50 | "no-this-assignment": false, 51 | "prefer-object-spread": false, 52 | "no-unnecessary-initializer": false, 53 | "prefer-for-of": false, 54 | "no-implicit-dependencies": [ "dev" ], 55 | "typeof-compare": false, 56 | "no-invalid-template-strings": false 57 | }, 58 | "rulesDirectory": [] 59 | } --------------------------------------------------------------------------------