diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8459e873..0a89c531 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,8 +55,8 @@ jobs: - name: Install OCaml Dependencies run: opam install . --deps-only - - name: Run build.fs - run: dotnet run target Test + - name: Build and test the project + run: bash fake test auto-merge: name: Auto-Merge PRs by Dependabot diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 847c341e..85916da7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -48,8 +48,8 @@ jobs: - name: Install OCaml Dependencies run: opam install . --deps-only - - name: Run build.fs - run: dotnet run target All + - name: Build & test & publish the project + run: bash fake all - name: Push js_of_ocaml standard library to jsoo-stdlib if: success() diff --git a/CHANGELOG.md b/CHANGELOG.md index 0843425e..c5ec4494 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.0.0-alpha.0] +- Upgrade TypeScript to v5. +- Added an explicit support of ambient modules. + - Topological sorting inside ambient modules now works as expected (#157). +- Perform various improvements over messages. + - Messages now come with color (warning: yellow, error: red). + - The error location is now shown with a code frame. +- Deprecate the `--safe-arity` option. + - Ts2ocaml now generates minimal arity-safe output by default. +- Perform massive internal refactoring. + ## [1.4.6] - 2023-07-13 - Fix a bug which generated unnecessarily duplicated option type (#315). diff --git a/build/BindingUpdater.fs b/build/BindingUpdater.fs new file mode 100644 index 00000000..c455ad45 --- /dev/null +++ b/build/BindingUpdater.fs @@ -0,0 +1,34 @@ +module BindingUpdater + +open Fake.Core +open Fake.IO +open System.Text.RegularExpressions + +let commonOptions = "--noresizearray --convertpropfns --tagged-union --remove-obsolete" +let ts2fable (srcs: string list) (dest: string) = + let src = srcs |> String.concat " " + Shell.Exec( + "yarn", + $"ts2fable {src} {dest} {commonOptions}" + ) + +let typeParamConstraints = + new Regex("""when '\w+ :> \w+(?: and '\w+ :> \w+)*""", RegexOptions.Compiled) + +let erasedCast = + new Regex("""static member inline op_ErasedCast.+$""", RegexOptions.Compiled ||| RegexOptions.Multiline) + +let replace (regex: Regex) (replacement: string) (s: string) = + printfn $"{regex.ToString()} ==> {replacement}" + regex.Replace(s, replacement) + +let typescript () = + let dest = "lib/Bindings/TypeScript.fs" + ts2fable ["node_modules/typescript/lib/typescript.d.ts"] dest |> ignore + File.readAsString dest + |> replace typeParamConstraints "" + |> replace erasedCast "// $&" + |> File.writeString false dest + +let run () = + typescript () diff --git a/build.fs b/build/build.fs similarity index 95% rename from build.fs rename to build/build.fs index 83bd4759..3df90a61 100644 --- a/build.fs +++ b/build/build.fs @@ -55,12 +55,11 @@ let setup () = Target.create "Restore" <| fun _ -> DotNet.restore - (DotNet.Options.withWorkingDirectory __SOURCE_DIRECTORY__) + id "ts2ocaml.sln" Target.create "YarnInstall" <| fun _ -> - Yarn.installFrozenLockFile (fun ``params`` -> - { ``params`` with WorkingDirectory = "./" }) + Yarn.installFrozenLockFile id Target.create "Prepare" ignore @@ -132,7 +131,7 @@ module Test = "safe", !! "node_modules/@types/yargs-parser/index.d.ts", []; "safe", !! "node_modules/@types/yargs/index.d.ts", ["--rec-module=off"]; - "minimal", !! "node_modules/@types/vscode/index.d.ts", ["--safe-arity=full"; "--readable-names"]; + "minimal", !! "node_modules/@types/vscode/index.d.ts", ["--readable-names"]; ] for preset, package, additionalOptions in packages do @@ -234,9 +233,17 @@ module Publish = "Build" ?=> "Test" ?=> "Publish" +// Utility targets + +module Utility = + let setup () = + Target.create "UpdateBindings" <| fun _ -> BindingUpdater.run () + "Prepare" ==> "UpdateBindings" + [] let main argv = - Shell.cd __SOURCE_DIRECTORY__ + // ensure working at the repository root + Shell.cd (Path.combine __SOURCE_DIRECTORY__ "..") argv |> Array.toList @@ -247,6 +254,7 @@ let main argv = setup () Test.setup () Publish.setup () + Utility.setup () Target.create "All" ignore "Prepare" diff --git a/build.fsproj b/build/build.fsproj similarity index 89% rename from build.fsproj rename to build/build.fsproj index 0679a0d3..9d9942e3 100644 --- a/build.fsproj +++ b/build/build.fsproj @@ -1,14 +1,12 @@ - - - - Exe - net6.0 - - - - - - + + + Exe + net6.0 + + + + + @@ -18,6 +16,5 @@ - - - + + \ No newline at end of file diff --git a/dist_jsoo/dune-project b/dist_jsoo/dune-project index dd44ba8b..623adbbd 100644 --- a/dist_jsoo/dune-project +++ b/dist_jsoo/dune-project @@ -1,6 +1,6 @@ (lang dune 3.0) (name ts2ocaml-jsoo-stdlib) -(version 1.4.6) +(version 2.0.0-alpha.0) (maintainers "dev@ocsigen.org") (authors diff --git a/dist_jsoo/ts2ocaml-jsoo-stdlib.opam b/dist_jsoo/ts2ocaml-jsoo-stdlib.opam index b2a162b8..f5b6c2cd 100644 --- a/dist_jsoo/ts2ocaml-jsoo-stdlib.opam +++ b/dist_jsoo/ts2ocaml-jsoo-stdlib.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "1.4.6" +version: "2.0.0-alpha.0" synopsis: "Standard library for ts2ocaml generated bindings (js_of_ocaml target)" description: diff --git a/docs/development.md b/docs/development.md index b5cc20f6..a42146ff 100644 --- a/docs/development.md +++ b/docs/development.md @@ -42,7 +42,7 @@ Modules with **\[\\]** does not require `open` to use. - [.NET SDK 6.0](https://dotnet.microsoft.com/download/dotnet/6.0) - [Fable](https://fable.io/) is required to build this tool. - - Run `dotnet tool restore` in the root directory of this repo to install them. + - Run `dotnet tool restore` in the root directory of this repo to install it. - OCaml 4.08 or higher - [js_of_ocaml](https://github.com/ocsigen/js_of_ocaml) should be installed to your opam switch. @@ -54,13 +54,13 @@ Modules with **\[\\]** does not require `open` to use. ## Debugging -`dotnet run -t Watch` to live update `dist/ts2ocaml.js`. +`./fake watch` to live update `dist/ts2ocaml.js`. It will be bundled by Webpack with the `development` mode. ## Building -`dotnet run -t Build` performs the followings: +`./fake build` performs the followings: - `yarn install` to populate `node_modules` - `dotnet restore ts2ocaml.sln` to install required F# libraries - Compile F# source files into JS source files (through Fable) @@ -70,7 +70,7 @@ The resulting `dist/ts2ocaml.js` is then ready to run through `node`. ## Testing -`dotnet run -t Test` builds the tool and then performs the followings: +`./fake test` builds the tool and then performs the followings: ### Test the tool for [`js_of_ocaml` target](js_of_ocaml.md) @@ -92,7 +92,7 @@ The resulting `dist/ts2ocaml.js` is then ready to run through `node`. ## Publishing -`dotnet run -t Publish` builds the tool, runs the tests, and then performs the followings: +`./fake publish` builds the tool, runs the tests, and then performs the followings: ### Prepare for publishing the standard library for [`js_of_ocaml` target](js_of_ocaml.md) to the `jsoo-stdlib` branch diff --git a/docs/js_of_ocaml.md b/docs/js_of_ocaml.md index 2245012d..126e642d 100644 --- a/docs/js_of_ocaml.md +++ b/docs/js_of_ocaml.md @@ -318,7 +318,7 @@ Specify the preset to use. * `--preset=minimal` - It sets `--simplify=all` and `--rec-module=optimized`. * `--preset=safe` - - It sets `--safe-arity=full` and `--subtyping=cast-function`. + - It sets `--subtyping=cast-function`. - It also sets all the options `--preset=minimal` sets. * `--preset=full` - It sets `--inherit-with-tags=full` and `--subtyping=tag`. @@ -577,98 +577,8 @@ Otherwise, you can't safely cast `B.t` to `A.t`. To do it, you will have to * set [`--subtyping=cast-function`](#feature-cast-function) to obtain `val cast_to_A: t -> A.t`, or * manually add `` `A `` to the definition of `B.t` (and `B.tags` if you choose to provide). -> **Note:** `TypeName.tags` types will come with the "arity-safe" version of them if [`--safe-arity`](#--safe-arity) is also set. - # Code Generator Options -## `--safe-arity` - -Use `TypeName.t_n` type names to safely use overloaded types from other packages. - -* `--safe-arity=full` - - It generates `t_n` types in the module, and tries to use `t_n` type if the type is unknown (e.g. from another package). -* `--safe-arity=provide` - - It only generates `t_n` types in the module. -* `--safe-arity=consume` - - It only tries to use `t_n` type if the type is unknown. -* `--safe-arity=off` (default) - - It disables any usage of `t_n` types. - -For example, assume we have `node_modules/foo/index.d.ts` and `node_modules/bar/index.d.ts` as the following: - -```typescript -// foo/index.d.ts - -declare namespace foo { - interface A { ... } - - interface B { ... } -} - -export = foo; -``` - -```typescript -// bar/index.d.ts - -import * as Foo from 'foo'; - -declare function useA(a: Foo.A) : void; - -declare function useB(b: Foo.B) : void; - -declare function useBDefault(b: Foo.B) : void; -``` - -Then the outputs will look like depending on the option you set: - -```ocaml -(* Foo.mli *) - -module Foo : sig - module A : sig - type 'T t = [`A of 'T] intf - - (* this will be generated if `full` or `provide` is set *) - type 'T t_1 = 'T t (* for arity 1 *) - - ... - end - - module B : sig - type 'T t = [`B of 'T] intf - - (* this will be generated if `full` or `provide` is set *) - type 'T t_1 = 'T t (* for arity 1 *) - - (* this will be generated regardless of the option, since B contains an optional type parameter *) - type t_0 = any t (* for arity 0 *) - - ... - end -end - -(* export = foo; *) -module Export = Foo -``` - -```ocaml -(* Bar.mli *) - -(* import * as Foo from "foo"; *) -module Foo = Foo.Export - -(* if `full` or `consume` is set, this will be generated *) -val useA: 'T Foo.A.t_1 -> unit -val useB: 'T Foo.B.t_1 -> unit -val useBDefault: Foo.B.t_0 -> unit - -(* otherwise, this will be generated *) -val useA: 'T Foo.A.t -> unit -val useB: 'T Foo.B.t -> unit -val useBDefault: Foo.B.t -> unit (* this does not compile! *) -``` - ## `--rec-module` Use recursive modules to simplify the output. Can impact the compilation time. @@ -1093,3 +1003,74 @@ end > end > end > ``` + +# Deprecated Options in v2 + +## `--safe-arity` (deprecated) + +~~Use `TypeName.t_n` type names to safely use overloaded types from other packages.~~ + +From v2, `ts2ocaml` uses TypeScript API to check if a generic type has optional type parameters, +and generates the minimum type-safe output. This option is deprecated because the current behavior is the optimal. + +For example, assume we have `node_modules/foo/index.d.ts` and `node_modules/bar/index.d.ts` as the following: + +```typescript +// foo/index.d.ts + +declare namespace foo { + interface A { ... } + + interface B { ... } +} + +export = foo; +``` + +```typescript +// bar/index.d.ts + +import * as Foo from 'foo'; + +declare function useA(a: Foo.A) : void; + +declare function useB(b: Foo.B) : void; + +declare function useBDefault(b: Foo.B) : void; +``` + +Then the outputs will look like this: + +```ocaml +(* Foo.mli *) + +module Foo : sig + module A : sig + type 'T t = [`A of 'T] intf + + ... + end + + module B : sig + type 'T t = [`B of 'T] intf + + type t_0 = any t + + ... + end +end + +(* export = foo; *) +module Export = Foo +``` + +```ocaml +(* Bar.mli *) + +(* import * as Foo from "foo"; *) +module Foo = Foo.Export + +val useA: 'T Foo.A.t -> unit +val useB: 'T Foo.B.t -> unit +val useBDefault: Foo.B.t_0 -> unit +``` diff --git a/fake b/fake new file mode 100644 index 00000000..66ad9506 --- /dev/null +++ b/fake @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -eu +set -o pipefail + +echo "Restoring dotnet tools..." +dotnet tool restore + +if [ -z "$@" ]; then + FAKE_DETAILED_ERRORS=true dotnet run --project ./build/build.fsproj +else + FAKE_DETAILED_ERRORS=true dotnet run --project ./build/build.fsproj -- -t "$@" +fi diff --git a/fake.cmd b/fake.cmd new file mode 100644 index 00000000..140db8b3 --- /dev/null +++ b/fake.cmd @@ -0,0 +1,4 @@ +echo Restoring dotnet tools... +dotnet tool restore + +dotnet run --project ./build/build.fsproj -- -t %* diff --git a/lib/Bindings/Chalk.fs b/lib/Bindings/Chalk.fs new file mode 100644 index 00000000..e195f588 --- /dev/null +++ b/lib/Bindings/Chalk.fs @@ -0,0 +1,153 @@ +module Chalk + +#nowarn "3390" // disable warnings for invalid XML comments + +open System +open Fable.Core +open Fable.Core.JS + +type ColorSupportLevel = + | L0 = 0 + | L1 = 1 + | L2 = 2 + | L3 = 3 + +type ColorInfo = U2 + +type [] ChalkInstance = + [] abstract draw: [] text: obj[] -> string + [] abstract Item: [] text: obj[] -> string + /// + /// The color support for Chalk. + /// + /// By default, color support is automatically detected based on the environment. + /// + /// Levels: + /// - 0 - All colors disabled. + /// - 1 - Basic 16 colors support. + /// - 2 - ANSI 256 colors support. + /// - 3 - Truecolor 16 million colors support. + /// + abstract level: ColorSupportLevel with get, set + /// Use RGB values to set text color. + /// + /// + /// import chalk from 'chalk'; + /// chalk.rgb(222, 173, 237); + /// + /// + abstract rgb: float * float * float -> ChalkInstance + /// Use HEX value to set text color. + /// Hexadecimal value representing the desired color. + /// + /// + /// import chalk from 'chalk'; + /// chalk.hex('#DEADED'); + /// + /// + abstract hex: string -> ChalkInstance + /// Use an 8-bit unsigned number to set text color. + /// + /// + /// import chalk from 'chalk'; + /// chalk.ansi256(201); + /// + /// + abstract ansi256: float -> ChalkInstance + /// Use RGB values to set background color. + /// + /// + /// import chalk from 'chalk'; + /// chalk.bgRgb(222, 173, 237); + /// + /// + abstract bgRgb: float * float * float -> ChalkInstance + /// Use HEX value to set background color. + /// Hexadecimal value representing the desired color. + /// + /// + /// import chalk from 'chalk'; + /// chalk.bgHex('#DEADED'); + /// + /// + abstract bgHex: string -> ChalkInstance + /// Use a 8-bit unsigned number to set background color. + /// + /// + /// import chalk from 'chalk'; + /// chalk.bgAnsi256(201); + /// + /// + abstract bgAnsi256: float -> ChalkInstance + /// Modifier: Reset the current style. + abstract reset: ChalkInstance + /// Modifier: Make the text bold. + abstract bold: ChalkInstance + /// Modifier: Make the text have lower opacity. + abstract dim: ChalkInstance + /// Modifier: Make the text italic. *(Not widely supported)* + abstract italic: ChalkInstance + /// Modifier: Put a horizontal line below the text. *(Not widely supported)* + abstract underline: ChalkInstance + /// Modifier: Put a horizontal line above the text. *(Not widely supported)* + abstract overline: ChalkInstance + /// Modifier: Invert background and foreground colors. + abstract inverse: ChalkInstance + /// Modifier: Print the text but make it invisible. + abstract hidden: ChalkInstance + /// Modifier: Puts a horizontal line through the center of the text. *(Not widely supported)* + abstract strikethrough: ChalkInstance + /// Modifier: Print the text only when Chalk has a color level above zero. + /// + /// Can be useful for things that are purely cosmetic. + abstract visible: ChalkInstance + abstract black: ChalkInstance + abstract red: ChalkInstance + abstract green: ChalkInstance + abstract yellow: ChalkInstance + abstract blue: ChalkInstance + abstract magenta: ChalkInstance + abstract cyan: ChalkInstance + abstract white: ChalkInstance + abstract gray: ChalkInstance + abstract grey: ChalkInstance + abstract blackBright: ChalkInstance + abstract redBright: ChalkInstance + abstract greenBright: ChalkInstance + abstract yellowBright: ChalkInstance + abstract blueBright: ChalkInstance + abstract magentaBright: ChalkInstance + abstract cyanBright: ChalkInstance + abstract whiteBright: ChalkInstance + abstract bgBlack: ChalkInstance + abstract bgRed: ChalkInstance + abstract bgGreen: ChalkInstance + abstract bgYellow: ChalkInstance + abstract bgBlue: ChalkInstance + abstract bgMagenta: ChalkInstance + abstract bgCyan: ChalkInstance + abstract bgWhite: ChalkInstance + abstract bgGray: ChalkInstance + abstract bgGrey: ChalkInstance + abstract bgBlackBright: ChalkInstance + abstract bgRedBright: ChalkInstance + abstract bgGreenBright: ChalkInstance + abstract bgYellowBright: ChalkInstance + abstract bgBlueBright: ChalkInstance + abstract bgMagentaBright: ChalkInstance + abstract bgCyanBright: ChalkInstance + abstract bgWhiteBright: ChalkInstance + +/// +/// Main Chalk object that allows to chain styles together. +/// +/// Call the last one as a method with a string argument. +/// +/// Order doesn't matter, and later styles take precedent in case of a conflict. +/// +/// This simply means that chalk.red.yellow.green is equivalent to chalk.green. +/// +let [] chalk: ChalkInstance = jsNative +let [] chalkStderr: ChalkInstance = jsNative +let [] supportsColor: ColorInfo = jsNative +let [] supportsColorStderr: ColorInfo = jsNative \ No newline at end of file diff --git a/lib/Bindings/Codeframe.fs b/lib/Bindings/Codeframe.fs new file mode 100644 index 00000000..0903bda5 --- /dev/null +++ b/lib/Bindings/Codeframe.fs @@ -0,0 +1,68 @@ +module Codeframe + +#nowarn "3390" // disable warnings for invalid XML comments + +open System +open Fable.Core +open Fable.Core.JS + +type Position = {| line: int; column: int option |} + +type [] SourceLocation = + abstract start: Position with get, set + abstract ``end``: Position option with get, set + +type [] BabelCodeFrameOptions = + /// Syntax highlight the code as JavaScript for terminals. default: false + abstract highlightCode: bool option with get, set + /// The number of lines to show above the error. default: 2 + abstract linesAbove: int option with get, set + /// The number of lines to show below the error. default: 3 + abstract linesBelow: int option with get, set + /// Forcibly syntax highlight the code as JavaScript (for non-terminals); + /// overrides highlightCode. + /// default: false + abstract forceColor: bool option with get, set + /// Pass in a string to be displayed inline (if possible) next to the + /// highlighted location in the code. If it can't be positioned inline, + /// it will be placed above the code frame. + /// default: nothing + abstract message: string option with get, set + +type [] ICodeframe = + [] + abstract Invoke: rawLines: string * lineNumber: int * colNumber: int * ?options: BabelCodeFrameOptions -> string + +type [] ICodeframeColumns = + [] + abstract Invoke: rawLines: string * location: SourceLocation * ?options: BabelCodeFrameOptions -> string + +let [] codeFrame: ICodeframe = jsNative + +let [] codeFrameColumns: ICodeframeColumns = jsNative + +type Codeframe = + static member CreateColumns(rawLines, startLine, ?startCol, ?endLine, ?endCol, ?highlightCode, ?linesAbove, ?linesBelow, ?forceColor, ?message) = + let options : BabelCodeFrameOptions = JsInterop.createEmpty + options.highlightCode <- highlightCode + options.linesAbove <- linesAbove + options.linesBelow <- linesBelow + options.forceColor <- forceColor + options.message <- message + let startPos = {| line = startLine; column = startCol |} + let endPos = + match endLine with + | Some x -> Some {| line = x; column = endCol |} + | None -> None + let loc : SourceLocation = JsInterop.createEmpty + loc.start <- startPos + loc.``end`` <- endPos + codeFrameColumns.Invoke(rawLines, loc, options) + static member Create(rawLines, line, col, ?highlightCode, ?linesAbove, ?linesBelow, ?forceColor, ?message) = + let options : BabelCodeFrameOptions = JsInterop.createEmpty + options.highlightCode <- highlightCode + options.linesAbove <- linesAbove + options.linesBelow <- linesBelow + options.forceColor <- forceColor + options.message <- message + codeFrame.Invoke(rawLines, line, col, options) \ No newline at end of file diff --git a/lib/Bindings/TypeScript.fs b/lib/Bindings/TypeScript.fs index 1b2c5c06..ffa9cc4b 100644 --- a/lib/Bindings/TypeScript.fs +++ b/lib/Bindings/TypeScript.fs @@ -1,29 +1,29 @@ -// ts2fable 0.7.1 +// ts2fable 0.8.0-build.723 module rec TypeScript + +#nowarn "3390" // disable warnings for invalid XML comments +#nowarn "0044" // disable warnings for `Obsolete` usage + open System open Fable.Core open Fable.Core.JS type Array<'T> = System.Collections.Generic.IList<'T> type ReadonlyArray<'T> = System.Collections.Generic.IReadOnlyList<'T> -type ReadonlySet<'T> = Set<'T> +type ReadonlyMap<'K, 'V> = Map<'K, 'V> type Symbol = obj -let [] ts: Ts.IExports = jsNative - -type [] IExports = - abstract setTimeout: handler: (ResizeArray -> unit) * timeout: float -> obj option - abstract clearTimeout: handle: obj option -> unit +let [] ts: Ts.IExports = jsNative module Ts = let [] scriptSnapshot: ScriptSnapshot.IExports = jsNative type [] IExports = abstract versionMajorMinor: obj + /// The version of the TypeScript compiler release abstract version: string abstract OperationCanceledException: OperationCanceledExceptionStatic - abstract getNodeMajorVersion: unit -> float option - abstract sys: System + abstract sys: System with get, set abstract tokenToString: t: SyntaxKind -> string option abstract getPositionOfLineAndCharacter: sourceFile: SourceFileLike * line: float * character: float -> float abstract getLineAndCharacterOfPosition: sourceFile: SourceFileLike * position: float -> LineAndCharacter @@ -36,17 +36,17 @@ module Ts = abstract forEachLeadingCommentRange: text: string * pos: float * cb: (float -> float -> CommentKind -> bool -> 'T -> 'U) * state: 'T -> 'U option abstract forEachTrailingCommentRange: text: string * pos: float * cb: (float -> float -> CommentKind -> bool -> 'U) -> 'U option abstract forEachTrailingCommentRange: text: string * pos: float * cb: (float -> float -> CommentKind -> bool -> 'T -> 'U) * state: 'T -> 'U option - abstract reduceEachLeadingCommentRange: text: string * pos: float * cb: (float -> float -> CommentKind -> bool -> 'T -> 'U -> 'U) * state: 'T * initial: 'U -> 'U option - abstract reduceEachTrailingCommentRange: text: string * pos: float * cb: (float -> float -> CommentKind -> bool -> 'T -> 'U -> 'U) * state: 'T * initial: 'U -> 'U option - abstract getLeadingCommentRanges: text: string * pos: float -> ResizeArray option - abstract getTrailingCommentRanges: text: string * pos: float -> ResizeArray option + abstract reduceEachLeadingCommentRange: text: string * pos: float * cb: (float -> float -> CommentKind -> bool -> 'T -> 'U) * state: 'T * initial: 'U -> 'U option + abstract reduceEachTrailingCommentRange: text: string * pos: float * cb: (float -> float -> CommentKind -> bool -> 'T -> 'U) * state: 'T * initial: 'U -> 'U option + abstract getLeadingCommentRanges: text: string * pos: float -> CommentRange[] option + abstract getTrailingCommentRanges: text: string * pos: float -> CommentRange[] option /// Optionally, get the shebang abstract getShebang: text: string -> string option abstract isIdentifierStart: ch: float * languageVersion: ScriptTarget option -> bool abstract isIdentifierPart: ch: float * languageVersion: ScriptTarget option * ?identifierVariant: LanguageVariant -> bool abstract createScanner: languageVersion: ScriptTarget * skipTrivia: bool * ?languageVariant: LanguageVariant * ?textInitial: string * ?onError: ErrorCallback * ?start: float * ?length: float -> Scanner abstract isExternalModuleNameRelative: moduleName: string -> bool - abstract sortAndDeduplicateDiagnostics: diagnostics: ResizeArray<'T> -> SortedReadonlyArray<'T> + abstract sortAndDeduplicateDiagnostics: diagnostics: 'T[] -> SortedReadonlyArray<'T> abstract getDefaultLibFileName: options: CompilerOptions -> string abstract textSpanEnd: span: TextSpan -> float abstract textSpanIsEmpty: span: TextSpan -> bool @@ -64,63 +64,92 @@ module Ts = abstract textChangeRangeNewSpan: range: TextChangeRange -> TextSpan abstract textChangeRangeIsUnchanged: range: TextChangeRange -> bool abstract createTextChangeRange: span: TextSpan * newLength: float -> TextChangeRange - abstract unchangedTextChangeRange: TextChangeRange /// Called to merge all the changes that occurred across several versions of a script snapshot /// into a single change. i.e. if a user keeps making successive edits to a script we will /// have a text change from V1 to V2, V2 to V3, ..., Vn. - /// + /// /// This function will then merge those changes into a single change range valid between V1 and /// Vn. - abstract collapseTextChangeRangesAcrossMultipleVersions: changes: ResizeArray -> TextChangeRange + abstract collapseTextChangeRangesAcrossMultipleVersions: changes: TextChangeRange[] -> TextChangeRange abstract getTypeParameterOwner: d: Declaration -> Declaration option abstract isParameterPropertyDeclaration: node: Node * parent: Node -> bool abstract isEmptyBindingPattern: node: BindingName -> bool - abstract isEmptyBindingElement: node: BindingElement -> bool + abstract isEmptyBindingElement: node: U2 -> bool abstract walkUpBindingElementsAndPatterns: binding: BindingElement -> U2 abstract getCombinedModifierFlags: node: Declaration -> ModifierFlags abstract getCombinedNodeFlags: node: Node -> NodeFlags /// Checks to see if the locale is in the appropriate format, /// and if it is, attempts to set the appropriate language. - abstract validateLocaleAndSetLanguage: locale: string * sys: ValidateLocaleAndSetLanguageSys * ?errors: Push -> unit + abstract validateLocaleAndSetLanguage: locale: string * sys: {| getExecutingFilePath: unit -> string; resolvePath: string -> string; fileExists: string -> bool; readFile: string -> string option |} * ?errors: Diagnostic[] -> unit abstract getOriginalNode: node: Node -> Node - abstract getOriginalNode: node: Node * nodeTest: (Node -> bool) -> 'T + abstract getOriginalNode: node: Node * nodeTest: (Node -> bool) -> 'T abstract getOriginalNode: node: Node option -> Node option - abstract getOriginalNode: node: Node option * nodeTest: (Node option -> bool) -> 'T option + abstract getOriginalNode: node: Node option * nodeTest: (Node -> bool) -> 'T option /// Iterates through the parent chain of a node and performs the callback on each parent until the callback /// returns a truthy value, then returns that value. /// If no such value is found, it applies the callback until the parent pointer is undefined or the callback returns "quit" /// At that point findAncestor returns undefined. - abstract findAncestor: node: Node option * callback: (Node -> bool) -> 'T option + abstract findAncestor: node: Node option * callback: (Node -> bool) -> 'T option abstract findAncestor: node: Node option * callback: (Node -> U2) -> Node option /// Gets a value indicating whether a node originated in the parse tree. /// The node to test. abstract isParseTreeNode: node: Node -> bool /// Gets the original parse tree node for a node. /// The original node. + /// The original parse tree node if found; otherwise, undefined. abstract getParseTreeNode: node: Node option -> Node option /// Gets the original parse tree node for a node. /// The original node. /// A callback used to ensure the correct type of parse tree node is returned. - abstract getParseTreeNode: node: 'T option * ?nodeTest: (Node -> bool) -> 'T option + /// The original parse tree node if found; otherwise, undefined. + abstract getParseTreeNode: node: 'T option * ?nodeTest: (Node -> bool) -> 'T option /// Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' abstract escapeLeadingUnderscores: identifier: string -> __String /// Remove extra underscore from escaped identifier text content. /// The escaped identifier text. + /// The unescaped identifier text. abstract unescapeLeadingUnderscores: identifier: __String -> string abstract idText: identifierOrPrivateName: U2 -> string + /// If the text of an Identifier matches a keyword (including contextual and TypeScript-specific keywords), returns the + /// SyntaxKind for the matching keyword. + abstract identifierToKeywordKind: node: Identifier -> KeywordSyntaxKind option abstract symbolName: symbol: Symbol -> string abstract getNameOfJSDocTypedef: declaration: JSDocTypedefTag -> U2 option abstract getNameOfDeclaration: declaration: U2 option -> DeclarationName option - /// Gets the JSDoc parameter tags for the node if present. - abstract getJSDocParameterTags: param: ParameterDeclaration -> ResizeArray - /// Gets the JSDoc type parameter tags for the node if present. - abstract getJSDocTypeParameterTags: param: TypeParameterDeclaration -> ResizeArray - /// Return true if the node has JSDoc parameter tags. + abstract getDecorators: node: HasDecorators -> Decorator[] option + abstract getModifiers: node: HasModifiers -> Modifier[] option + /// Gets the JSDoc parameter tags for the node if present. + /// + /// Returns any JSDoc param tag whose name matches the provided + /// parameter, whether a param tag on a containing function + /// expression, or a param tag on a variable declaration whose + /// initializer is the containing function. The tags closest to the + /// node are returned first, so in the previous example, the param + /// tag on the containing function expression would be first. + /// + /// For binding patterns, parameter tags are matched by position. + /// + abstract getJSDocParameterTags: param: ParameterDeclaration -> JSDocParameterTag[] + /// Gets the JSDoc type parameter tags for the node if present. + /// + /// Returns any JSDoc template tag whose names match the provided + /// parameter, whether a template tag on a containing function + /// expression, or a template tag on a variable declaration whose + /// initializer is the containing function. The tags closest to the + /// node are returned first, so in the previous example, the template + /// tag on the containing function expression would be first. + /// + abstract getJSDocTypeParameterTags: param: TypeParameterDeclaration -> JSDocTemplateTag[] + /// Return true if the node has JSDoc parameter tags. + /// + /// Includes parameter tags that are not directly on the node, + /// for example on a variable declaration whose initializer is a function expression. + /// abstract hasJSDocParameterTags: node: U2 -> bool /// Gets the JSDoc augments tag for the node if present abstract getJSDocAugmentsTag: node: Node -> JSDocAugmentsTag option /// Gets the JSDoc implements tags for the node if present - abstract getJSDocImplementsTags: node: Node -> ResizeArray + abstract getJSDocImplementsTags: node: Node -> JSDocImplementsTag[] /// Gets the JSDoc class tag for the node if present abstract getJSDocClassTag: node: Node -> JSDocClassTag option /// Gets the JSDoc public tag for the node if present @@ -142,23 +171,45 @@ module Ts = abstract getJSDocReturnTag: node: Node -> JSDocReturnTag option /// Gets the JSDoc template tag for the node if present abstract getJSDocTemplateTag: node: Node -> JSDocTemplateTag option + abstract getJSDocSatisfiesTag: node: Node -> JSDocSatisfiesTag option /// Gets the JSDoc type tag for the node if present and valid abstract getJSDocTypeTag: node: Node -> JSDocTypeTag option - /// Gets the type node for the node if provided via JSDoc. + /// Gets the type node for the node if provided via JSDoc. + /// + /// The search includes any JSDoc param tag that relates + /// to the provided parameter, for example a type tag on the + /// parameter itself, or a param tag on a containing function + /// expression, or a param tag on a variable declaration whose + /// initializer is the containing function. The tags closest to the + /// node are examined first, so in the previous example, the type + /// tag directly on the node would be returned. + /// abstract getJSDocType: node: Node -> TypeNode option - /// Gets the return type node for the node if provided via JSDoc return tag or type tag. + /// Gets the return type node for the node if provided via JSDoc return tag or type tag. + /// + /// getJSDocReturnTag just gets the whole JSDoc tag. This function + /// gets the type from inside the braces, after the fat arrow, etc. + /// abstract getJSDocReturnType: node: Node -> TypeNode option /// Get all JSDoc tags related to a node, including those on parent nodes. - abstract getJSDocTags: node: Node -> ResizeArray + abstract getJSDocTags: node: Node -> JSDocTag[] /// Gets all JSDoc tags that match a specified predicate - abstract getAllJSDocTags: node: Node * predicate: (JSDocTag -> bool) -> ResizeArray<'T> + abstract getAllJSDocTags: node: Node * predicate: (JSDocTag -> bool) -> 'T[] /// Gets all JSDoc tags of a specified kind - abstract getAllJSDocTagsOfKind: node: Node * kind: SyntaxKind -> ResizeArray + abstract getAllJSDocTagsOfKind: node: Node * kind: SyntaxKind -> JSDocTag[] /// Gets the text of a jsdoc comment, flattening links to their text. - abstract getTextOfJSDocComment: ?comment: U2> -> string option + abstract getTextOfJSDocComment: ?comment: U2 -> string option + /// /// Gets the effective type parameters. If the node was parsed in a - /// JavaScript file, gets the type parameters from the `@template` tag from JSDoc. - abstract getEffectiveTypeParameterDeclarations: node: DeclarationWithTypeParameters -> ResizeArray + /// JavaScript file, gets the type parameters from the @template tag from JSDoc. + /// + /// This does *not* return type parameters from a jsdoc reference to a generic type, eg + /// + /// type Id = <T>(x: T) => T + /// /** @type {Id} / + /// function id(x) { return x } + /// + abstract getEffectiveTypeParameterDeclarations: node: DeclarationWithTypeParameters -> TypeParameterDeclaration[] abstract getEffectiveConstraintOfTypeParameter: node: TypeParameterDeclaration -> TypeNode option abstract isMemberName: node: Node -> bool abstract isPropertyAccessChain: node: Node -> bool @@ -172,8 +223,6 @@ module Ts = abstract isNonNullChain: node: Node -> bool abstract isBreakOrContinueStatement: node: Node -> bool abstract isNamedExportBindings: node: Node -> bool - abstract isUnparsedTextLike: node: Node -> bool - abstract isUnparsedNode: node: Node -> bool abstract isJSDocPropertyLikeTag: node: Node -> bool /// True if kind is of some token syntax kind. /// For example, this is true for an IfKeyword but not for an IfStatement. @@ -187,6 +236,8 @@ module Ts = abstract isTemplateLiteralToken: node: Node -> bool abstract isTemplateMiddleOrTemplateTail: node: Node -> bool abstract isImportOrExportSpecifier: node: Node -> bool + abstract isTypeOnlyImportDeclaration: node: Node -> bool + abstract isTypeOnlyExportDeclaration: node: Node -> bool abstract isTypeOnlyImportOrExportDeclaration: node: Node -> bool abstract isAssertionKey: node: Node -> bool abstract isStringTextContainingNode: node: Node -> bool @@ -198,21 +249,40 @@ module Ts = abstract isClassElement: node: Node -> bool abstract isClassLike: node: Node -> bool abstract isAccessor: node: Node -> bool + abstract isAutoAccessorPropertyDeclaration: node: Node -> bool + abstract isModifierLike: node: Node -> bool abstract isTypeElement: node: Node -> bool abstract isClassOrTypeElement: node: Node -> bool abstract isObjectLiteralElementLike: node: Node -> bool + /// /// Node test that determines whether a node is a valid type node. - /// This differs from the `isPartOfTypeNode` function which determines whether a node is *part* + /// This differs from the isPartOfTypeNode function which determines whether a node is *part* /// of a TypeNode. + /// abstract isTypeNode: node: Node -> bool abstract isFunctionOrConstructorTypeNode: node: Node -> bool + abstract isArrayBindingElement: node: Node -> bool abstract isPropertyAccessOrQualifiedName: node: Node -> bool abstract isCallLikeExpression: node: Node -> bool abstract isCallOrNewExpression: node: Node -> bool abstract isTemplateLiteral: node: Node -> bool + abstract isLeftHandSideExpression: node: Node -> bool + abstract isLiteralTypeLiteral: node: Node -> bool + /// Determines whether a node is an expression based only on its kind. + abstract isExpression: node: Node -> bool abstract isAssertionExpression: node: Node -> bool - abstract isIterationStatement: node: Node * lookInLabeledStatements: obj -> bool + [] abstract isIterationStatement_false: node: Node -> bool abstract isIterationStatement: node: Node * lookInLabeledStatements: bool -> bool + abstract isConciseBody: node: Node -> bool + abstract isForInitializer: node: Node -> bool + abstract isModuleBody: node: Node -> bool + abstract isNamedImportBindings: node: Node -> bool + abstract isStatement: node: Node -> bool + abstract isModuleReference: node: Node -> bool + abstract isJsxTagNameExpression: node: Node -> bool + abstract isJsxChild: node: Node -> bool + abstract isJsxAttributeLike: node: Node -> bool + abstract isStringLiteralOrJsxExpression: node: Node -> bool abstract isJsxOpeningLikeElement: node: Node -> bool abstract isCaseOrDefaultClause: node: Node -> bool /// True if node is of a kind that may contain comment text. @@ -222,54 +292,71 @@ module Ts = /// True if has initializer node attached to it. abstract hasOnlyExpressionInitializer: node: Node -> bool abstract isObjectLiteralElement: node: Node -> bool - abstract isStringLiteralLike: node: Node -> bool + abstract isStringLiteralLike: node: U2 -> bool abstract isJSDocLinkLike: node: Node -> bool - abstract factory: NodeFactory - abstract createUnparsedSourceFile: text: string -> UnparsedSource - abstract createUnparsedSourceFile: inputFile: InputFiles * ``type``: CreateUnparsedSourceFileType * ?stripInternal: bool -> UnparsedSource - abstract createUnparsedSourceFile: text: string * mapPath: string option * map: string option -> UnparsedSource - abstract createInputFiles: javascriptText: string * declarationText: string -> InputFiles - abstract createInputFiles: readFileText: (string -> string option) * javascriptPath: string * javascriptMapPath: string option * declarationPath: string * declarationMapPath: string option * buildInfoPath: string option -> InputFiles - abstract createInputFiles: javascriptText: string * declarationText: string * javascriptMapPath: string option * javascriptMapText: string option * declarationMapPath: string option * declarationMapText: string option -> InputFiles + abstract hasRestParameter: s: U2 -> bool + abstract isRestParameter: node: U2 -> bool + abstract unchangedTextChangeRange: TextChangeRange with get, set + /// + /// This function checks multiple locations for JSDoc comments that apply to a host node. + /// At each location, the whole comment may apply to the node, or only a specific tag in + /// the comment. In the first case, location adds the entire object. In the + /// second case, it adds the applicable . + /// + /// For example, a JSDoc comment before a parameter adds the entire . But a + /// @param tag on the parent function only adds the for the @param. + /// + /// + /// /** JSDoc will be returned for `a` *\/ + /// const a = 0 + /// /** + /// * Entire JSDoc will be returned for `b` + /// * @param c JSDocTag will be returned for `c` + /// *\/ + /// function b(/** JSDoc will be returned for `c` *\/ c) {} + /// + /// + abstract getJSDocCommentsAndTags: hostNode: Node -> U2[] /// Create an external source map source file reference abstract createSourceMapSource: fileName: string * text: string * ?skipTrivia: (float -> float) -> SourceMapSource - abstract setOriginalNode: node: 'T * original: Node option -> 'T - /// Clears any `EmitNode` entries from parse-tree nodes. + abstract setOriginalNode: node: 'T * original: Node option -> 'T + abstract factory: NodeFactory + /// Clears any EmitNode entries from parse-tree nodes. /// A source file. abstract disposeEmitNodes: sourceFile: SourceFile option -> unit /// Sets flags that control emit behavior of a node. - abstract setEmitFlags: node: 'T * emitFlags: EmitFlags -> 'T + abstract setEmitFlags: node: 'T * emitFlags: EmitFlags -> 'T /// Gets a custom text range to use when emitting source maps. abstract getSourceMapRange: node: Node -> SourceMapRange /// Sets a custom text range to use when emitting source maps. - abstract setSourceMapRange: node: 'T * range: SourceMapRange option -> 'T + abstract setSourceMapRange: node: 'T * range: SourceMapRange option -> 'T /// Gets the TextRange to use for source maps for a token of a node. abstract getTokenSourceMapRange: node: Node * token: SyntaxKind -> SourceMapRange option /// Sets the TextRange to use for source maps for a token of a node. - abstract setTokenSourceMapRange: node: 'T * token: SyntaxKind * range: SourceMapRange option -> 'T + abstract setTokenSourceMapRange: node: 'T * token: SyntaxKind * range: SourceMapRange option -> 'T /// Gets a custom text range to use when emitting comments. abstract getCommentRange: node: Node -> TextRange /// Sets a custom text range to use when emitting comments. - abstract setCommentRange: node: 'T * range: TextRange -> 'T - abstract getSyntheticLeadingComments: node: Node -> ResizeArray option - abstract setSyntheticLeadingComments: node: 'T * comments: ResizeArray option -> 'T - abstract addSyntheticLeadingComment: node: 'T * kind: SyntaxKind * text: string * ?hasTrailingNewLine: bool -> 'T - abstract getSyntheticTrailingComments: node: Node -> ResizeArray option - abstract setSyntheticTrailingComments: node: 'T * comments: ResizeArray option -> 'T - abstract addSyntheticTrailingComment: node: 'T * kind: SyntaxKind * text: string * ?hasTrailingNewLine: bool -> 'T - abstract moveSyntheticComments: node: 'T * original: Node -> 'T + abstract setCommentRange: node: 'T * range: TextRange -> 'T + abstract getSyntheticLeadingComments: node: Node -> SynthesizedComment[] option + abstract setSyntheticLeadingComments: node: 'T * comments: SynthesizedComment[] option -> 'T + abstract addSyntheticLeadingComment: node: 'T * kind: SyntaxKind * text: string * ?hasTrailingNewLine: bool -> 'T + abstract getSyntheticTrailingComments: node: Node -> SynthesizedComment[] option + abstract setSyntheticTrailingComments: node: 'T * comments: SynthesizedComment[] option -> 'T + abstract addSyntheticTrailingComment: node: 'T * kind: SyntaxKind * text: string * ?hasTrailingNewLine: bool -> 'T + abstract moveSyntheticComments: node: 'T * original: Node -> 'T /// Gets the constant value to emit for an expression representing an enum. abstract getConstantValue: node: AccessExpression -> U2 option /// Sets the constant value to emit for an expression. abstract setConstantValue: node: AccessExpression * value: U2 -> AccessExpression /// Adds an EmitHelper to a node. - abstract addEmitHelper: node: 'T * helper: EmitHelper -> 'T + abstract addEmitHelper: node: 'T * helper: EmitHelper -> 'T /// Add EmitHelpers to a node. - abstract addEmitHelpers: node: 'T * helpers: ResizeArray option -> 'T + abstract addEmitHelpers: node: 'T * helpers: EmitHelper[] option -> 'T /// Removes an EmitHelper from a node. abstract removeEmitHelper: node: Node * helper: EmitHelper -> bool /// Gets the EmitHelpers of a node. - abstract getEmitHelpers: node: Node -> ResizeArray option + abstract getEmitHelpers: node: Node -> EmitHelper[] option /// Moves matching emit helpers from a source node to a target node. abstract moveEmitHelpers: source: Node * target: Node * predicate: (EmitHelper -> bool) -> unit abstract isNumericLiteral: node: Node -> bool @@ -285,8 +372,15 @@ module Ts = abstract isPlusToken: node: Node -> bool abstract isMinusToken: node: Node -> bool abstract isAsteriskToken: node: Node -> bool + abstract isExclamationToken: node: Node -> bool + abstract isQuestionToken: node: Node -> bool + abstract isColonToken: node: Node -> bool + abstract isQuestionDotToken: node: Node -> bool + abstract isEqualsGreaterThanToken: node: Node -> bool abstract isIdentifier: node: Node -> bool abstract isPrivateIdentifier: node: Node -> bool + abstract isAssertsKeyword: node: Node -> bool + abstract isAwaitKeyword: node: Node -> bool abstract isQualifiedName: node: Node -> bool abstract isComputedPropertyName: node: Node -> bool abstract isTypeParameterDeclaration: node: Node -> bool @@ -356,6 +450,7 @@ module Ts = abstract isOmittedExpression: node: Node -> bool abstract isExpressionWithTypeArguments: node: Node -> bool abstract isAsExpression: node: Node -> bool + abstract isSatisfiesExpression: node: Node -> bool abstract isNonNullExpression: node: Node -> bool abstract isMetaProperty: node: Node -> bool abstract isSyntheticExpression: node: Node -> bool @@ -396,6 +491,7 @@ module Ts = abstract isImportEqualsDeclaration: node: Node -> bool abstract isImportDeclaration: node: Node -> bool abstract isImportClause: node: Node -> bool + abstract isImportTypeAssertionContainer: node: Node -> bool abstract isAssertClause: node: Node -> bool abstract isAssertEntry: node: Node -> bool abstract isNamespaceImport: node: Node -> bool @@ -420,6 +516,7 @@ module Ts = abstract isJsxAttributes: node: Node -> bool abstract isJsxSpreadAttribute: node: Node -> bool abstract isJsxExpression: node: Node -> bool + abstract isJsxNamespacedName: node: Node -> bool abstract isCaseClause: node: Node -> bool abstract isDefaultClause: node: Node -> bool abstract isHeritageClause: node: Node -> bool @@ -428,10 +525,8 @@ module Ts = abstract isShorthandPropertyAssignment: node: Node -> bool abstract isSpreadAssignment: node: Node -> bool abstract isEnumMember: node: Node -> bool - abstract isUnparsedPrepend: node: Node -> bool abstract isSourceFile: node: Node -> bool abstract isBundle: node: Node -> bool - abstract isUnparsedSource: node: Node -> bool abstract isJSDocTypeExpression: node: Node -> bool abstract isJSDocNameReference: node: Node -> bool abstract isJSDocMemberName: node: Node -> bool @@ -458,6 +553,7 @@ module Ts = abstract isJSDocProtectedTag: node: Node -> bool abstract isJSDocReadonlyTag: node: Node -> bool abstract isJSDocOverrideTag: node: Node -> bool + abstract isJSDocOverloadTag: node: Node -> bool abstract isJSDocDeprecatedTag: node: Node -> bool abstract isJSDocSeeTag: node: Node -> bool abstract isJSDocEnumTag: node: Node -> bool @@ -470,100 +566,158 @@ module Ts = abstract isJSDocUnknownTag: node: Node -> bool abstract isJSDocPropertyTag: node: Node -> bool abstract isJSDocImplementsTag: node: Node -> bool - abstract setTextRange: range: 'T * location: TextRange option -> 'T - /// Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes + abstract isJSDocSatisfiesTag: node: Node -> bool + abstract isJSDocThrowsTag: node: Node -> bool + abstract isQuestionOrExclamationToken: node: Node -> bool + abstract isIdentifierOrThisTypeNode: node: Node -> bool + abstract isReadonlyKeywordOrPlusOrMinusToken: node: Node -> bool + abstract isQuestionOrPlusOrMinusToken: node: Node -> bool + abstract isModuleName: node: Node -> bool + abstract isBinaryOperatorToken: node: Node -> bool + abstract setTextRange: range: 'T * location: TextRange option -> 'T + abstract canHaveModifiers: node: Node -> bool + abstract canHaveDecorators: node: Node -> bool + /// + /// Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes /// stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, /// embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns - /// a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned. + /// a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned. + /// /// a given node to visit its children /// a callback to be invoked for all child nodes /// a callback to be invoked for embedded array - abstract forEachChild: node: Node * cbNode: (Node -> 'T option) * ?cbNodes: (ResizeArray -> 'T option) -> 'T option - abstract createSourceFile: fileName: string * sourceText: string * languageVersion: ScriptTarget * ?setParentNodes: bool * ?scriptKind: ScriptKind -> SourceFile + /// + /// forEachChild must visit the children of a node in the order + /// that they appear in the source code. The language service depends on this property to locate nodes by position. + /// + abstract forEachChild: node: Node * cbNode: (Node -> 'T option) * ?cbNodes: (Node[] -> 'T option) -> 'T option + abstract createSourceFile: fileName: string * sourceText: string * languageVersionOrOptions: U2 * ?setParentNodes: bool * ?scriptKind: ScriptKind -> SourceFile abstract parseIsolatedEntityName: text: string * languageVersion: ScriptTarget -> EntityName option - /// Parse json text into SyntaxTree and return node and parse errors if any + /// Parse json text into SyntaxTree and return node and parse errors if any + /// + /// abstract parseJsonText: fileName: string * sourceText: string -> JsonSourceFile abstract isExternalModule: file: SourceFile -> bool abstract updateSourceFile: sourceFile: SourceFile * newText: string * textChangeRange: TextChangeRange * ?aggressiveChecks: bool -> SourceFile - abstract parseCommandLine: commandLine: ResizeArray * ?readFile: (string -> string option) -> ParsedCommandLine + abstract parseCommandLine: commandLine: string[] * ?readFile: (string -> string option) -> ParsedCommandLine /// Reads the config file, reports errors if any and exits if the config file cannot be found - abstract getParsedCommandLineOfConfigFile: configFileName: string * optionsToExtend: CompilerOptions option * host: ParseConfigFileHost * ?extendedConfigCache: Map * ?watchOptionsToExtend: WatchOptions * ?extraFileExtensions: ResizeArray -> ParsedCommandLine option + abstract getParsedCommandLineOfConfigFile: configFileName: string * optionsToExtend: CompilerOptions option * host: ParseConfigFileHost * ?extendedConfigCache: Map * ?watchOptionsToExtend: WatchOptions * ?extraFileExtensions: FileExtensionInfo[] -> ParsedCommandLine option /// Read tsconfig.json file /// The path to the config file - abstract readConfigFile: fileName: string * readFile: (string -> string option) -> ReadConfigFileReturn + abstract readConfigFile: fileName: string * readFile: (string -> string option) -> {| config: obj option; error: Diagnostic option |} /// Parse the text of the tsconfig.json file /// The path to the config file /// The text of the config file - abstract parseConfigFileTextToJson: fileName: string * jsonText: string -> ParseConfigFileTextToJsonReturn + abstract parseConfigFileTextToJson: fileName: string * jsonText: string -> {| config: obj option; error: Diagnostic option |} /// Read tsconfig.json file /// The path to the config file abstract readJsonConfigFile: fileName: string * readFile: (string -> string option) -> TsConfigSourceFile /// Convert the json syntax tree into the json value - abstract convertToObject: sourceFile: JsonSourceFile * errors: Push -> obj option + abstract convertToObject: sourceFile: JsonSourceFile * errors: Diagnostic[] -> obj option /// Parse the contents of a config file (tsconfig.json). /// The contents of the config file to parse /// Instance of ParseConfigHost used to enumerate files in folder. - /// A root directory to resolve relative path entries in the config - /// file to. e.g. outDir - abstract parseJsonConfigFileContent: json: obj option * host: ParseConfigHost * basePath: string * ?existingOptions: CompilerOptions * ?configFileName: string * ?resolutionStack: ResizeArray * ?extraFileExtensions: ResizeArray * ?extendedConfigCache: Map * ?existingWatchOptions: WatchOptions -> ParsedCommandLine + /// + /// A root directory to resolve relative path entries in the config + /// file to. e.g. outDir + /// + abstract parseJsonConfigFileContent: json: obj option * host: ParseConfigHost * basePath: string * ?existingOptions: CompilerOptions * ?configFileName: string * ?resolutionStack: Path[] * ?extraFileExtensions: FileExtensionInfo[] * ?extendedConfigCache: Map * ?existingWatchOptions: WatchOptions -> ParsedCommandLine /// Parse the contents of a config file (tsconfig.json). + /// The contents of the config file to parse /// Instance of ParseConfigHost used to enumerate files in folder. - /// A root directory to resolve relative path entries in the config - /// file to. e.g. outDir - abstract parseJsonSourceFileConfigFileContent: sourceFile: TsConfigSourceFile * host: ParseConfigHost * basePath: string * ?existingOptions: CompilerOptions * ?configFileName: string * ?resolutionStack: ResizeArray * ?extraFileExtensions: ResizeArray * ?extendedConfigCache: Map * ?existingWatchOptions: WatchOptions -> ParsedCommandLine - abstract convertCompilerOptionsFromJson: jsonOptions: obj option * basePath: string * ?configFileName: string -> ConvertCompilerOptionsFromJsonReturn - abstract convertTypeAcquisitionFromJson: jsonOptions: obj option * basePath: string * ?configFileName: string -> ConvertTypeAcquisitionFromJsonReturn - abstract getEffectiveTypeRoots: options: CompilerOptions * host: GetEffectiveTypeRootsHost -> ResizeArray option - /// - file that contains type reference directive, can be undefined if containing file is unknown. + /// + /// A root directory to resolve relative path entries in the config + /// file to. e.g. outDir + /// + abstract parseJsonSourceFileConfigFileContent: sourceFile: TsConfigSourceFile * host: ParseConfigHost * basePath: string * ?existingOptions: CompilerOptions * ?configFileName: string * ?resolutionStack: Path[] * ?extraFileExtensions: FileExtensionInfo[] * ?extendedConfigCache: Map * ?existingWatchOptions: WatchOptions -> ParsedCommandLine + abstract convertCompilerOptionsFromJson: jsonOptions: obj option * basePath: string * ?configFileName: string -> {| options: CompilerOptions; errors: Diagnostic[] |} + abstract convertTypeAcquisitionFromJson: jsonOptions: obj option * basePath: string * ?configFileName: string -> {| options: TypeAcquisition; errors: Diagnostic[] |} + abstract getEffectiveTypeRoots: options: CompilerOptions * host: GetEffectiveTypeRootsHost -> string[] option + /// + /// file that contains type reference directive, can be undefined if containing file is unknown. /// This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups - /// is assumed to be the same as root directory of the project. - abstract resolveTypeReferenceDirective: typeReferenceDirectiveName: string * containingFile: string option * options: CompilerOptions * host: ModuleResolutionHost * ?redirectedReference: ResolvedProjectReference * ?cache: TypeReferenceDirectiveResolutionCache -> ResolvedTypeReferenceDirectiveWithFailedLookupLocations + /// is assumed to be the same as root directory of the project. + /// + abstract resolveTypeReferenceDirective: typeReferenceDirectiveName: string * containingFile: string option * options: CompilerOptions * host: ModuleResolutionHost * ?redirectedReference: ResolvedProjectReference * ?cache: TypeReferenceDirectiveResolutionCache * ?resolutionMode: ResolutionMode -> ResolvedTypeReferenceDirectiveWithFailedLookupLocations /// Given a set of options, returns the set of type directive names /// that should be included for this program automatically. /// This list could either come from the config file, /// or from enumerating the types root + initial secondary types lookup location. /// More type directives might appear in the program later as a result of loading actual source files; /// this list is only the set of defaults that are implicitly included. - abstract getAutomaticTypeDirectiveNames: options: CompilerOptions * host: ModuleResolutionHost -> ResizeArray - abstract createModuleResolutionCache: currentDirectory: string * getCanonicalFileName: (string -> string) * ?options: CompilerOptions -> ModuleResolutionCache + abstract getAutomaticTypeDirectiveNames: options: CompilerOptions * host: ModuleResolutionHost -> string[] + abstract createModuleResolutionCache: currentDirectory: string * getCanonicalFileName: (string -> string) * ?options: CompilerOptions * ?packageJsonInfoCache: PackageJsonInfoCache -> ModuleResolutionCache abstract createTypeReferenceDirectiveResolutionCache: currentDirectory: string * getCanonicalFileName: (string -> string) * ?options: CompilerOptions * ?packageJsonInfoCache: PackageJsonInfoCache -> TypeReferenceDirectiveResolutionCache - abstract resolveModuleNameFromCache: moduleName: string * containingFile: string * cache: ModuleResolutionCache * ?mode: ModuleKind -> ResolvedModuleWithFailedLookupLocations option - abstract resolveModuleName: moduleName: string * containingFile: string * compilerOptions: CompilerOptions * host: ModuleResolutionHost * ?cache: ModuleResolutionCache * ?redirectedReference: ResolvedProjectReference * ?resolutionMode: ModuleKind -> ResolvedModuleWithFailedLookupLocations + abstract resolveModuleNameFromCache: moduleName: string * containingFile: string * cache: ModuleResolutionCache * ?mode: ResolutionMode -> ResolvedModuleWithFailedLookupLocations option + abstract resolveModuleName: moduleName: string * containingFile: string * compilerOptions: CompilerOptions * host: ModuleResolutionHost * ?cache: ModuleResolutionCache * ?redirectedReference: ResolvedProjectReference * ?resolutionMode: ResolutionMode -> ResolvedModuleWithFailedLookupLocations + abstract bundlerModuleNameResolver: moduleName: string * containingFile: string * compilerOptions: CompilerOptions * host: ModuleResolutionHost * ?cache: ModuleResolutionCache * ?redirectedReference: ResolvedProjectReference -> ResolvedModuleWithFailedLookupLocations abstract nodeModuleNameResolver: moduleName: string * containingFile: string * compilerOptions: CompilerOptions * host: ModuleResolutionHost * ?cache: ModuleResolutionCache * ?redirectedReference: ResolvedProjectReference -> ResolvedModuleWithFailedLookupLocations abstract classicNameResolver: moduleName: string * containingFile: string * compilerOptions: CompilerOptions * host: ModuleResolutionHost * ?cache: NonRelativeModuleNameResolutionCache * ?redirectedReference: ResolvedProjectReference -> ResolvedModuleWithFailedLookupLocations - /// Visits a Node using the supplied visitor, possibly returning a new Node in its place. + /// + /// Visits a Node using the supplied visitor, possibly returning a new Node in its place. + /// + /// - If the input node is undefined, then the output is undefined. + /// - If the visitor returns undefined, then the output is undefined. + /// - If the output node is not undefined, then it will satisfy the test function. + /// - In order to obtain a return type that is more specific than Node, a test + /// function _must_ be provided, and that function must be a type predicate. + /// /// The Node to visit. /// The callback used to visit the Node. /// A callback to execute to verify the Node is valid. /// An optional callback to execute to lift a NodeArray into a valid Node. - abstract visitNode: node: 'T * visitor: Visitor option * ?test: (Node -> bool) * ?lift: (ResizeArray -> 'T) -> 'T - /// Visits a Node using the supplied visitor, possibly returning a new Node in its place. + abstract visitNode: node: 'TIn * visitor: Visitor<'TIn, 'TVisited> * test: (Node -> bool) * ?lift: (Node[] -> Node) -> U2<'TOut, obj> + /// + /// Visits a Node using the supplied visitor, possibly returning a new Node in its place. + /// + /// - If the input node is undefined, then the output is undefined. + /// - If the visitor returns undefined, then the output is undefined. + /// - If the output node is not undefined, then it will satisfy the test function. + /// - In order to obtain a return type that is more specific than Node, a test + /// function _must_ be provided, and that function must be a type predicate. + /// /// The Node to visit. /// The callback used to visit the Node. /// A callback to execute to verify the Node is valid. /// An optional callback to execute to lift a NodeArray into a valid Node. - abstract visitNode: node: 'T option * visitor: Visitor option * ?test: (Node -> bool) * ?lift: (ResizeArray -> 'T) -> 'T option - /// Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. + abstract visitNode: node: 'TIn * visitor: Visitor<'TIn, 'TVisited> * ?test: (Node -> bool) * ?lift: (Node[] -> Node) -> U2 + /// + /// Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. + /// + /// - If the input node array is undefined, the output is undefined. + /// - If the visitor can return undefined, the node it visits in the array will be reused. + /// - If the output node array is not undefined, then its contents will satisfy the test. + /// - In order to obtain a return type that is more specific than NodeArray<Node>, a test + /// function _must_ be provided, and that function must be a type predicate. + /// /// The NodeArray to visit. /// The callback used to visit a Node. /// A node test to execute for each node. /// An optional value indicating the starting offset at which to start visiting. /// An optional value indicating the maximum number of nodes to visit. - abstract visitNodes: nodes: ResizeArray<'T> * visitor: Visitor option * ?test: (Node -> bool) * ?start: float * ?count: float -> ResizeArray<'T> - /// Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. + abstract visitNodes: nodes: 'TInArray * visitor: Visitor<'TIn, Node option> * test: (Node -> bool) * ?start: float * ?count: float -> U2<'TOut[], obj> + /// + /// Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. + /// + /// - If the input node array is undefined, the output is undefined. + /// - If the visitor can return undefined, the node it visits in the array will be reused. + /// - If the output node array is not undefined, then its contents will satisfy the test. + /// - In order to obtain a return type that is more specific than NodeArray<Node>, a test + /// function _must_ be provided, and that function must be a type predicate. + /// /// The NodeArray to visit. /// The callback used to visit a Node. /// A node test to execute for each node. /// An optional value indicating the starting offset at which to start visiting. /// An optional value indicating the maximum number of nodes to visit. - abstract visitNodes: nodes: ResizeArray<'T> option * visitor: Visitor option * ?test: (Node -> bool) * ?start: float * ?count: float -> ResizeArray<'T> option + abstract visitNodes: nodes: 'TInArray * visitor: Visitor<'TIn, Node option> * ?test: (Node -> bool) * ?start: float * ?count: float -> U2 /// Starts a new lexical environment and visits a statement list, ending the lexical environment /// and merging hoisted declarations upon completion. - abstract visitLexicalEnvironment: statements: ResizeArray * visitor: Visitor * context: TransformationContext * ?start: float * ?ensureUseStrict: bool * ?nodesVisitor: NodesVisitor -> ResizeArray + abstract visitLexicalEnvironment: statements: Statement[] * visitor: Visitor * context: TransformationContext * ?start: float * ?ensureUseStrict: bool * ?nodesVisitor: NodesVisitor -> Statement[] /// Starts a new lexical environment and visits a parameter list, suspending the lexical /// environment upon completion. - abstract visitParameterList: nodes: ResizeArray * visitor: Visitor * context: TransformationContext * ?nodesVisitor: NodesVisitor -> ResizeArray - abstract visitParameterList: nodes: ResizeArray option * visitor: Visitor * context: TransformationContext * ?nodesVisitor: NodesVisitor -> ResizeArray option + abstract visitParameterList: nodes: ParameterDeclaration[] * visitor: Visitor * context: TransformationContext * ?nodesVisitor: NodesVisitor -> ParameterDeclaration[] + abstract visitParameterList: nodes: ParameterDeclaration[] option * visitor: Visitor * context: TransformationContext * ?nodesVisitor: NodesVisitor -> ParameterDeclaration[] option /// Resumes a suspended lexical environment and visits a function body, ending the lexical /// environment and merging hoisted declarations upon completion. abstract visitFunctionBody: node: FunctionBody * visitor: Visitor * context: TransformationContext -> FunctionBody @@ -575,485 +729,149 @@ module Ts = abstract visitFunctionBody: node: ConciseBody * visitor: Visitor * context: TransformationContext -> ConciseBody /// Visits an iteration body, adding any block-scoped variables required by the transformation. abstract visitIterationBody: body: Statement * visitor: Visitor * context: TransformationContext -> Statement + /// Visits the elements of a . + /// The visitor to use when visiting expressions whose result will not be discarded at runtime. + /// The visitor to use when visiting expressions whose result will be discarded at runtime. Defaults to . + abstract visitCommaListElements: elements: Expression[] * visitor: Visitor * ?discardVisitor: Visitor -> Expression[] /// Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place. /// The Node whose children will be visited. /// The callback used to visit each child. /// A lexical environment context for the visitor. - abstract visitEachChild: node: 'T * visitor: Visitor * context: TransformationContext -> 'T + abstract visitEachChild: node: 'T * visitor: Visitor * context: TransformationContext -> 'T /// Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place. /// The Node whose children will be visited. /// The callback used to visit each child. /// A lexical environment context for the visitor. - abstract visitEachChild: node: 'T option * visitor: Visitor * context: TransformationContext * ?nodesVisitor: obj * ?tokenVisitor: Visitor -> 'T option + abstract visitEachChild: node: 'T option * visitor: Visitor * context: TransformationContext * ?nodesVisitor: obj * ?tokenVisitor: Visitor -> 'T option abstract getTsBuildInfoEmitOutputFilePath: options: CompilerOptions -> string option - abstract getOutputFileNames: commandLine: ParsedCommandLine * inputFileName: string * ignoreCase: bool -> ResizeArray + abstract getOutputFileNames: commandLine: ParsedCommandLine * inputFileName: string * ignoreCase: bool -> string[] abstract createPrinter: ?printerOptions: PrinterOptions * ?handlers: PrintHandlers -> Printer abstract findConfigFile: searchPath: string * fileExists: (string -> bool) * ?configName: string -> string option abstract resolveTripleslashReference: moduleName: string * containingFile: string -> string abstract createCompilerHost: options: CompilerOptions * ?setParentNodes: bool -> CompilerHost - abstract getPreEmitDiagnostics: program: Program * ?sourceFile: SourceFile * ?cancellationToken: CancellationToken -> ResizeArray - abstract formatDiagnostics: diagnostics: ResizeArray * host: FormatDiagnosticsHost -> string + abstract getPreEmitDiagnostics: program: Program * ?sourceFile: SourceFile * ?cancellationToken: CancellationToken -> Diagnostic[] + abstract formatDiagnostics: diagnostics: Diagnostic[] * host: FormatDiagnosticsHost -> string abstract formatDiagnostic: diagnostic: Diagnostic * host: FormatDiagnosticsHost -> string - abstract formatDiagnosticsWithColorAndContext: diagnostics: ResizeArray * host: FormatDiagnosticsHost -> string + abstract formatDiagnosticsWithColorAndContext: diagnostics: Diagnostic[] * host: FormatDiagnosticsHost -> string abstract flattenDiagnosticMessageText: diag: U2 option * newLine: string * ?indent: float -> string - abstract getConfigFileParsingDiagnostics: configFileParseResult: ParsedCommandLine -> ResizeArray - /// A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the - /// `options` parameter. + /// Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly + /// provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file. + abstract getModeForFileReference: ref: U2 * containingFileMode: ResolutionMode -> ResolutionMode + /// + /// Calculates the final resolution mode for an import at some index within a file's imports list. This is generally the explicitly + /// defined mode of the import if provided, or, if not, the mode of the containing file (with some exceptions: import=require is always commonjs, dynamic import is always esm). + /// If you have an actual import node, prefer using getModeForUsageLocation on the reference string node. + /// + /// File to fetch the resolution mode within + /// Index into the file's complete resolution list to get the resolution of - this is a concatenation of the file's imports and module augmentations + abstract getModeForResolutionAtIndex: file: SourceFile * index: float -> ResolutionMode + /// + /// Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if + /// one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm). + /// Notably, this function always returns undefined if the containing file has an undefined impliedNodeFormat - this field is only set when + /// moduleResolution is node16+. + /// + /// The file the import or import-like reference is contained within + /// The module reference string + /// The final resolution mode of the import + abstract getModeForUsageLocation: file: {| impliedNodeFormat: ResolutionMode option |} * usage: StringLiteralLike -> ModuleKind option + abstract getConfigFileParsingDiagnostics: configFileParseResult: ParsedCommandLine -> Diagnostic[] + /// + /// A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the + /// options parameter. + /// /// The normalized absolute path to check the format of (it need not exist on disk) /// A cache for package file lookups - it's best to have a cache when this function is called often /// The ModuleResolutionHost which can perform the filesystem lookups for package json data - /// The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution` - abstract getImpliedNodeFormatForFile: fileName: Path * packageJsonInfoCache: PackageJsonInfoCache option * host: ModuleResolutionHost * options: CompilerOptions -> ModuleKind option - /// Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' + /// The compiler options to perform the analysis under - relevant options are moduleResolution and traceResolution + /// undefined if the path has no relevant implied format, ModuleKind.ESNext for esm format, and ModuleKind.CommonJS for cjs format + abstract getImpliedNodeFormatForFile: fileName: Path * packageJsonInfoCache: PackageJsonInfoCache option * host: ModuleResolutionHost * options: CompilerOptions -> ResolutionMode + /// + /// Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' /// that represent a compilation unit. - /// + /// /// Creating a program proceeds from a set of root files, expanding the set of inputs by following imports and - /// triple-slash-reference-path directives transitively. '@types' and triple-slash-reference-types are also pulled in. - /// - The options for creating a program. + /// triple-slash-reference-path directives transitively. '@types' and triple-slash-reference-types are also pulled in. + /// + /// The options for creating a program. + /// A 'Program' object. abstract createProgram: createProgramOptions: CreateProgramOptions -> Program - /// Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' + /// + /// Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' /// that represent a compilation unit. - /// + /// /// Creating a program proceeds from a set of root files, expanding the set of inputs by following imports and - /// triple-slash-reference-path directives transitively. '@types' and triple-slash-reference-types are also pulled in. - /// - A set of root files. - /// - The compiler options which should be used. - /// - The host interacts with the underlying file system. - /// - Reuses an old program structure. - /// - error during config file parsing - abstract createProgram: rootNames: ResizeArray * options: CompilerOptions * ?host: CompilerHost * ?oldProgram: Program * ?configFileParsingDiagnostics: ResizeArray -> Program + /// triple-slash-reference-path directives transitively. '@types' and triple-slash-reference-types are also pulled in. + /// + /// A set of root files. + /// The compiler options which should be used. + /// The host interacts with the underlying file system. + /// Reuses an old program structure. + /// error during config file parsing + /// A 'Program' object. + abstract createProgram: rootNames: string[] * options: CompilerOptions * ?host: CompilerHost * ?oldProgram: Program * ?configFileParsingDiagnostics: Diagnostic[] -> Program /// Returns the target config filename of a project reference. /// Note: The file might not exist. abstract resolveProjectReferencePath: ref: ProjectReference -> ResolvedConfigFileName - abstract resolveProjectReferencePath: host: ResolveProjectReferencePathHost * ref: ProjectReference -> ResolvedConfigFileName /// Create the builder to manage semantic diagnostics and cache them - abstract createSemanticDiagnosticsBuilderProgram: newProgram: Program * host: BuilderProgramHost * ?oldProgram: SemanticDiagnosticsBuilderProgram * ?configFileParsingDiagnostics: ResizeArray -> SemanticDiagnosticsBuilderProgram - abstract createSemanticDiagnosticsBuilderProgram: rootNames: ResizeArray option * options: CompilerOptions option * ?host: CompilerHost * ?oldProgram: SemanticDiagnosticsBuilderProgram * ?configFileParsingDiagnostics: ResizeArray * ?projectReferences: ResizeArray -> SemanticDiagnosticsBuilderProgram + abstract createSemanticDiagnosticsBuilderProgram: newProgram: Program * host: BuilderProgramHost * ?oldProgram: SemanticDiagnosticsBuilderProgram * ?configFileParsingDiagnostics: Diagnostic[] -> SemanticDiagnosticsBuilderProgram + abstract createSemanticDiagnosticsBuilderProgram: rootNames: string[] option * options: CompilerOptions option * ?host: CompilerHost * ?oldProgram: SemanticDiagnosticsBuilderProgram * ?configFileParsingDiagnostics: Diagnostic[] * ?projectReferences: ProjectReference[] -> SemanticDiagnosticsBuilderProgram /// Create the builder that can handle the changes in program and iterate through changed files /// to emit the those files and manage semantic diagnostics cache as well - abstract createEmitAndSemanticDiagnosticsBuilderProgram: newProgram: Program * host: BuilderProgramHost * ?oldProgram: EmitAndSemanticDiagnosticsBuilderProgram * ?configFileParsingDiagnostics: ResizeArray -> EmitAndSemanticDiagnosticsBuilderProgram - abstract createEmitAndSemanticDiagnosticsBuilderProgram: rootNames: ResizeArray option * options: CompilerOptions option * ?host: CompilerHost * ?oldProgram: EmitAndSemanticDiagnosticsBuilderProgram * ?configFileParsingDiagnostics: ResizeArray * ?projectReferences: ResizeArray -> EmitAndSemanticDiagnosticsBuilderProgram + abstract createEmitAndSemanticDiagnosticsBuilderProgram: newProgram: Program * host: BuilderProgramHost * ?oldProgram: EmitAndSemanticDiagnosticsBuilderProgram * ?configFileParsingDiagnostics: Diagnostic[] -> EmitAndSemanticDiagnosticsBuilderProgram + abstract createEmitAndSemanticDiagnosticsBuilderProgram: rootNames: string[] option * options: CompilerOptions option * ?host: CompilerHost * ?oldProgram: EmitAndSemanticDiagnosticsBuilderProgram * ?configFileParsingDiagnostics: Diagnostic[] * ?projectReferences: ProjectReference[] -> EmitAndSemanticDiagnosticsBuilderProgram /// Creates a builder thats just abstraction over program and can be used with watch - abstract createAbstractBuilder: newProgram: Program * host: BuilderProgramHost * ?oldProgram: BuilderProgram * ?configFileParsingDiagnostics: ResizeArray -> BuilderProgram - abstract createAbstractBuilder: rootNames: ResizeArray option * options: CompilerOptions option * ?host: CompilerHost * ?oldProgram: BuilderProgram * ?configFileParsingDiagnostics: ResizeArray * ?projectReferences: ResizeArray -> BuilderProgram + abstract createAbstractBuilder: newProgram: Program * host: BuilderProgramHost * ?oldProgram: BuilderProgram * ?configFileParsingDiagnostics: Diagnostic[] -> BuilderProgram + abstract createAbstractBuilder: rootNames: string[] option * options: CompilerOptions option * ?host: CompilerHost * ?oldProgram: BuilderProgram * ?configFileParsingDiagnostics: Diagnostic[] * ?projectReferences: ProjectReference[] -> BuilderProgram abstract readBuilderProgram: compilerOptions: CompilerOptions * host: ReadBuildProgramHost -> EmitAndSemanticDiagnosticsBuilderProgram option abstract createIncrementalCompilerHost: options: CompilerOptions * ?system: System -> CompilerHost - abstract createIncrementalProgram: p0: IncrementalProgramOptions<'T> -> 'T + abstract createIncrementalProgram: p0: IncrementalProgramOptions<'T> -> 'T /// Create the watch compiler host for either configFile or fileNames and its options - abstract createWatchCompilerHost: configFileName: string * optionsToExtend: CompilerOptions option * system: System * ?createProgram: CreateProgram<'T> * ?reportDiagnostic: DiagnosticReporter * ?reportWatchStatus: WatchStatusReporter * ?watchOptionsToExtend: WatchOptions * ?extraFileExtensions: ResizeArray -> WatchCompilerHostOfConfigFile<'T> - abstract createWatchCompilerHost: rootFiles: ResizeArray * options: CompilerOptions * system: System * ?createProgram: CreateProgram<'T> * ?reportDiagnostic: DiagnosticReporter * ?reportWatchStatus: WatchStatusReporter * ?projectReferences: ResizeArray * ?watchOptions: WatchOptions -> WatchCompilerHostOfFilesAndCompilerOptions<'T> + abstract createWatchCompilerHost: configFileName: string * optionsToExtend: CompilerOptions option * system: System * ?createProgram: CreateProgram<'T> * ?reportDiagnostic: DiagnosticReporter * ?reportWatchStatus: WatchStatusReporter * ?watchOptionsToExtend: WatchOptions * ?extraFileExtensions: FileExtensionInfo[] -> WatchCompilerHostOfConfigFile<'T> + abstract createWatchCompilerHost: rootFiles: string[] * options: CompilerOptions * system: System * ?createProgram: CreateProgram<'T> * ?reportDiagnostic: DiagnosticReporter * ?reportWatchStatus: WatchStatusReporter * ?projectReferences: ProjectReference[] * ?watchOptions: WatchOptions -> WatchCompilerHostOfFilesAndCompilerOptions<'T> /// Creates the watch from the host for root files and compiler options - abstract createWatchProgram: host: WatchCompilerHostOfFilesAndCompilerOptions<'T> -> WatchOfFilesAndCompilerOptions<'T> + abstract createWatchProgram: host: WatchCompilerHostOfFilesAndCompilerOptions<'T> -> WatchOfFilesAndCompilerOptions<'T> /// Creates the watch from the host for config file - abstract createWatchProgram: host: WatchCompilerHostOfConfigFile<'T> -> WatchOfConfigFile<'T> + abstract createWatchProgram: host: WatchCompilerHostOfConfigFile<'T> -> WatchOfConfigFile<'T> /// Create a function that reports watch status by writing to the system and handles the formating of the diagnostic abstract createBuilderStatusReporter: system: System * ?pretty: bool -> DiagnosticReporter - abstract createSolutionBuilderHost: ?system: System * ?createProgram: CreateProgram<'T> * ?reportDiagnostic: DiagnosticReporter * ?reportSolutionBuilderStatus: DiagnosticReporter * ?reportErrorSummary: ReportEmitErrorSummary -> SolutionBuilderHost<'T> - abstract createSolutionBuilderWithWatchHost: ?system: System * ?createProgram: CreateProgram<'T> * ?reportDiagnostic: DiagnosticReporter * ?reportSolutionBuilderStatus: DiagnosticReporter * ?reportWatchStatus: WatchStatusReporter -> SolutionBuilderWithWatchHost<'T> - abstract createSolutionBuilder: host: SolutionBuilderHost<'T> * rootNames: ResizeArray * defaultOptions: BuildOptions -> SolutionBuilder<'T> - abstract createSolutionBuilderWithWatch: host: SolutionBuilderWithWatchHost<'T> * rootNames: ResizeArray * defaultOptions: BuildOptions * ?baseWatchOptions: WatchOptions -> SolutionBuilder<'T> + abstract createSolutionBuilderHost: ?system: System * ?createProgram: CreateProgram<'T> * ?reportDiagnostic: DiagnosticReporter * ?reportSolutionBuilderStatus: DiagnosticReporter * ?reportErrorSummary: ReportEmitErrorSummary -> SolutionBuilderHost<'T> + abstract createSolutionBuilderWithWatchHost: ?system: System * ?createProgram: CreateProgram<'T> * ?reportDiagnostic: DiagnosticReporter * ?reportSolutionBuilderStatus: DiagnosticReporter * ?reportWatchStatus: WatchStatusReporter -> SolutionBuilderWithWatchHost<'T> + abstract createSolutionBuilder: host: SolutionBuilderHost<'T> * rootNames: string[] * defaultOptions: BuildOptions -> SolutionBuilder<'T> + abstract createSolutionBuilderWithWatch: host: SolutionBuilderWithWatchHost<'T> * rootNames: string[] * defaultOptions: BuildOptions * ?baseWatchOptions: WatchOptions -> SolutionBuilder<'T> abstract getDefaultFormatCodeSettings: ?newLineCharacter: string -> FormatCodeSettings /// The classifier is used for syntactic highlighting in editors via the TSServer abstract createClassifier: unit -> Classifier abstract createDocumentRegistry: ?useCaseSensitiveFileNames: bool * ?currentDirectory: string -> DocumentRegistry abstract preProcessFile: sourceText: string * ?readImportFiles: bool * ?detectJavaScriptImports: bool -> PreProcessedFileInfo abstract transpileModule: input: string * transpileOptions: TranspileOptions -> TranspileOutput - abstract transpile: input: string * ?compilerOptions: CompilerOptions * ?fileName: string * ?diagnostics: ResizeArray * ?moduleName: string -> string - abstract servicesVersion: obj + abstract transpile: input: string * ?compilerOptions: CompilerOptions * ?fileName: string * ?diagnostics: Diagnostic[] * ?moduleName: string -> string abstract toEditorSettings: options: U2 -> EditorSettings - abstract displayPartsToString: displayParts: ResizeArray option -> string + abstract displayPartsToString: displayParts: SymbolDisplayPart[] option -> string abstract getDefaultCompilerOptions: unit -> CompilerOptions - abstract getSupportedCodeFixes: unit -> ResizeArray - abstract createLanguageServiceSourceFile: fileName: string * scriptSnapshot: IScriptSnapshot * scriptTarget: ScriptTarget * version: string * setNodeParents: bool * ?scriptKind: ScriptKind -> SourceFile + abstract getSupportedCodeFixes: unit -> string[] + abstract createLanguageServiceSourceFile: fileName: string * scriptSnapshot: IScriptSnapshot * scriptTargetOrOptions: U2 * version: string * setNodeParents: bool * ?scriptKind: ScriptKind -> SourceFile abstract updateLanguageServiceSourceFile: sourceFile: SourceFile * scriptSnapshot: IScriptSnapshot * version: string * textChangeRange: TextChangeRange option * ?aggressiveChecks: bool -> SourceFile abstract createLanguageService: host: LanguageServiceHost * ?documentRegistry: DocumentRegistry * ?syntaxOnlyOrLanguageServiceMode: U2 -> LanguageService /// Get the path of the default library files (lib.d.ts) as distributed with the typescript /// node package. /// The functionality is not supported if the ts module is consumed outside of a node module. abstract getDefaultLibFilePath: options: CompilerOptions -> string + /// The version of the language service API + abstract servicesVersion: obj /// Transform one or more nodes using the supplied transformers. - /// A single `Node` or an array of `Node` objects. - /// An array of `TransformerFactory` callbacks used to process the transformation. + /// A single Node or an array of Node objects. + /// An array of TransformerFactory callbacks used to process the transformation. /// Optional compiler options. - abstract transform: source: U2<'T, ResizeArray<'T>> * transformers: ResizeArray> * ?compilerOptions: CompilerOptions -> TransformationResult<'T> - abstract createNodeArray: ResizeArray<'T> -> bool -> ResizeArray<'T> - abstract createNumericLiteral: (U2 -> TokenFlags -> NumericLiteral) - abstract createBigIntLiteral: (U2 -> BigIntLiteral) - abstract createStringLiteral: IExportsCreateStringLiteral - abstract createStringLiteralFromNode: (PropertyNameLiteral -> bool -> StringLiteral) - abstract createRegularExpressionLiteral: (string -> RegularExpressionLiteral) - abstract createLoopVariable: (bool -> Identifier) - abstract createUniqueName: (string -> GeneratedIdentifierFlags -> Identifier) - abstract createPrivateIdentifier: (string -> PrivateIdentifier) - abstract createSuper: (unit -> SuperExpression) - abstract createThis: (unit -> ThisExpression) - abstract createNull: (unit -> NullLiteral) - abstract createTrue: (unit -> TrueLiteral) - abstract createFalse: (unit -> FalseLiteral) - abstract createModifier: 'T -> ModifierToken<'T> - abstract createModifiersFromModifierFlags: (ModifierFlags -> ResizeArray) - abstract createQualifiedName: (EntityName -> U2 -> QualifiedName) - abstract updateQualifiedName: (QualifiedName -> EntityName -> Identifier -> QualifiedName) - abstract createComputedPropertyName: (Expression -> ComputedPropertyName) - abstract updateComputedPropertyName: (ComputedPropertyName -> Expression -> ComputedPropertyName) - abstract createTypeParameterDeclaration: (U2 -> TypeNode -> TypeNode -> TypeParameterDeclaration) - abstract updateTypeParameterDeclaration: (TypeParameterDeclaration -> Identifier -> TypeNode option -> TypeNode option -> TypeParameterDeclaration) - abstract createParameter: (ResizeArray option -> ResizeArray option -> DotDotDotToken option -> U2 -> QuestionToken -> TypeNode -> Expression -> ParameterDeclaration) - abstract updateParameter: (ParameterDeclaration -> ResizeArray option -> ResizeArray option -> DotDotDotToken option -> U2 -> QuestionToken option -> TypeNode option -> Expression option -> ParameterDeclaration) - abstract createDecorator: (Expression -> Decorator) - abstract updateDecorator: (Decorator -> Expression -> Decorator) - abstract createProperty: (ResizeArray option -> ResizeArray option -> U2 -> U2 option -> TypeNode option -> Expression option -> PropertyDeclaration) - abstract updateProperty: (PropertyDeclaration -> ResizeArray option -> ResizeArray option -> U2 -> U2 option -> TypeNode option -> Expression option -> PropertyDeclaration) - abstract createMethod: (ResizeArray option -> ResizeArray option -> AsteriskToken option -> U2 -> QuestionToken option -> ResizeArray option -> ResizeArray -> TypeNode option -> Block option -> MethodDeclaration) - abstract updateMethod: (MethodDeclaration -> ResizeArray option -> ResizeArray option -> AsteriskToken option -> PropertyName -> QuestionToken option -> ResizeArray option -> ResizeArray -> TypeNode option -> Block option -> MethodDeclaration) - abstract createConstructor: (ResizeArray option -> ResizeArray option -> ResizeArray -> Block option -> ConstructorDeclaration) - abstract updateConstructor: (ConstructorDeclaration -> ResizeArray option -> ResizeArray option -> ResizeArray -> Block option -> ConstructorDeclaration) - abstract createGetAccessor: (ResizeArray option -> ResizeArray option -> U2 -> ResizeArray -> TypeNode option -> Block option -> GetAccessorDeclaration) - abstract updateGetAccessor: (GetAccessorDeclaration -> ResizeArray option -> ResizeArray option -> PropertyName -> ResizeArray -> TypeNode option -> Block option -> GetAccessorDeclaration) - abstract createSetAccessor: (ResizeArray option -> ResizeArray option -> U2 -> ResizeArray -> Block option -> SetAccessorDeclaration) - abstract updateSetAccessor: (SetAccessorDeclaration -> ResizeArray option -> ResizeArray option -> PropertyName -> ResizeArray -> Block option -> SetAccessorDeclaration) - abstract createCallSignature: (ResizeArray option -> ResizeArray -> TypeNode option -> CallSignatureDeclaration) - abstract updateCallSignature: (CallSignatureDeclaration -> ResizeArray option -> ResizeArray -> TypeNode option -> CallSignatureDeclaration) - abstract createConstructSignature: (ResizeArray option -> ResizeArray -> TypeNode option -> ConstructSignatureDeclaration) - abstract updateConstructSignature: (ConstructSignatureDeclaration -> ResizeArray option -> ResizeArray -> TypeNode option -> ConstructSignatureDeclaration) - abstract updateIndexSignature: (IndexSignatureDeclaration -> ResizeArray option -> ResizeArray option -> ResizeArray -> TypeNode -> IndexSignatureDeclaration) - abstract createKeywordTypeNode: 'TKind -> KeywordTypeNode<'TKind> - abstract createTypePredicateNodeWithModifier: (AssertsKeyword option -> U3 -> TypeNode option -> TypePredicateNode) - abstract updateTypePredicateNodeWithModifier: (TypePredicateNode -> AssertsKeyword option -> U2 -> TypeNode option -> TypePredicateNode) - abstract createTypeReferenceNode: (U2 -> ResizeArray -> TypeReferenceNode) - abstract updateTypeReferenceNode: (TypeReferenceNode -> EntityName -> ResizeArray option -> TypeReferenceNode) - abstract createFunctionTypeNode: (ResizeArray option -> ResizeArray -> TypeNode -> FunctionTypeNode) - abstract updateFunctionTypeNode: (FunctionTypeNode -> ResizeArray option -> ResizeArray -> TypeNode -> FunctionTypeNode) - abstract createConstructorTypeNode: (ResizeArray option -> ResizeArray -> TypeNode -> ConstructorTypeNode) - abstract updateConstructorTypeNode: (ConstructorTypeNode -> ResizeArray option -> ResizeArray -> TypeNode -> ConstructorTypeNode) - abstract createTypeQueryNode: (EntityName -> TypeQueryNode) - abstract updateTypeQueryNode: (TypeQueryNode -> EntityName -> TypeQueryNode) - abstract createTypeLiteralNode: (ResizeArray option -> TypeLiteralNode) - abstract updateTypeLiteralNode: (TypeLiteralNode -> ResizeArray -> TypeLiteralNode) - abstract createArrayTypeNode: (TypeNode -> ArrayTypeNode) - abstract updateArrayTypeNode: (ArrayTypeNode -> TypeNode -> ArrayTypeNode) - abstract createTupleTypeNode: (ResizeArray> -> TupleTypeNode) - abstract updateTupleTypeNode: (TupleTypeNode -> ResizeArray> -> TupleTypeNode) - abstract createOptionalTypeNode: (TypeNode -> OptionalTypeNode) - abstract updateOptionalTypeNode: (OptionalTypeNode -> TypeNode -> OptionalTypeNode) - abstract createRestTypeNode: (TypeNode -> RestTypeNode) - abstract updateRestTypeNode: (RestTypeNode -> TypeNode -> RestTypeNode) - abstract createUnionTypeNode: (ResizeArray -> UnionTypeNode) - abstract updateUnionTypeNode: (UnionTypeNode -> ResizeArray -> UnionTypeNode) - abstract createIntersectionTypeNode: (ResizeArray -> IntersectionTypeNode) - abstract updateIntersectionTypeNode: (IntersectionTypeNode -> ResizeArray -> IntersectionTypeNode) - abstract createConditionalTypeNode: (TypeNode -> TypeNode -> TypeNode -> TypeNode -> ConditionalTypeNode) - abstract updateConditionalTypeNode: (ConditionalTypeNode -> TypeNode -> TypeNode -> TypeNode -> TypeNode -> ConditionalTypeNode) - abstract createInferTypeNode: (TypeParameterDeclaration -> InferTypeNode) - abstract updateInferTypeNode: (InferTypeNode -> TypeParameterDeclaration -> InferTypeNode) - abstract createImportTypeNode: (TypeNode -> EntityName -> ResizeArray -> bool -> ImportTypeNode) - abstract updateImportTypeNode: (ImportTypeNode -> TypeNode -> EntityName option -> ResizeArray option -> bool -> ImportTypeNode) - abstract createParenthesizedType: (TypeNode -> ParenthesizedTypeNode) - abstract updateParenthesizedType: (ParenthesizedTypeNode -> TypeNode -> ParenthesizedTypeNode) - abstract createThisTypeNode: (unit -> ThisTypeNode) - abstract updateTypeOperatorNode: (TypeOperatorNode -> TypeNode -> TypeOperatorNode) - abstract createIndexedAccessTypeNode: (TypeNode -> TypeNode -> IndexedAccessTypeNode) - abstract updateIndexedAccessTypeNode: (IndexedAccessTypeNode -> TypeNode -> TypeNode -> IndexedAccessTypeNode) - abstract createMappedTypeNode: (U3 option -> TypeParameterDeclaration -> TypeNode option -> U3 option -> TypeNode option -> ResizeArray option -> MappedTypeNode) - abstract updateMappedTypeNode: (MappedTypeNode -> U3 option -> TypeParameterDeclaration -> TypeNode option -> U3 option -> TypeNode option -> ResizeArray option -> MappedTypeNode) - abstract createLiteralTypeNode: (U4 -> LiteralTypeNode) - abstract updateLiteralTypeNode: (LiteralTypeNode -> U4 -> LiteralTypeNode) - abstract createObjectBindingPattern: (ResizeArray -> ObjectBindingPattern) - abstract updateObjectBindingPattern: (ObjectBindingPattern -> ResizeArray -> ObjectBindingPattern) - abstract createArrayBindingPattern: (ResizeArray -> ArrayBindingPattern) - abstract updateArrayBindingPattern: (ArrayBindingPattern -> ResizeArray -> ArrayBindingPattern) - abstract createBindingElement: (DotDotDotToken option -> U2 option -> U2 -> Expression -> BindingElement) - abstract updateBindingElement: (BindingElement -> DotDotDotToken option -> PropertyName option -> BindingName -> Expression option -> BindingElement) - abstract createArrayLiteral: (ResizeArray -> bool -> ArrayLiteralExpression) - abstract updateArrayLiteral: (ArrayLiteralExpression -> ResizeArray -> ArrayLiteralExpression) - abstract createObjectLiteral: (ResizeArray -> bool -> ObjectLiteralExpression) - abstract updateObjectLiteral: (ObjectLiteralExpression -> ResizeArray -> ObjectLiteralExpression) - abstract createPropertyAccess: (Expression -> U2 -> PropertyAccessExpression) - abstract updatePropertyAccess: (PropertyAccessExpression -> Expression -> MemberName -> PropertyAccessExpression) - abstract createPropertyAccessChain: (Expression -> QuestionDotToken option -> U2 -> PropertyAccessChain) - abstract updatePropertyAccessChain: (PropertyAccessChain -> Expression -> QuestionDotToken option -> MemberName -> PropertyAccessChain) - abstract createElementAccess: (Expression -> U2 -> ElementAccessExpression) - abstract updateElementAccess: (ElementAccessExpression -> Expression -> Expression -> ElementAccessExpression) - abstract createElementAccessChain: (Expression -> QuestionDotToken option -> U2 -> ElementAccessChain) - abstract updateElementAccessChain: (ElementAccessChain -> Expression -> QuestionDotToken option -> Expression -> ElementAccessChain) - abstract createCall: (Expression -> ResizeArray option -> ResizeArray option -> CallExpression) - abstract updateCall: (CallExpression -> Expression -> ResizeArray option -> ResizeArray -> CallExpression) - abstract createCallChain: (Expression -> QuestionDotToken option -> ResizeArray option -> ResizeArray option -> CallChain) - abstract updateCallChain: (CallChain -> Expression -> QuestionDotToken option -> ResizeArray option -> ResizeArray -> CallChain) - abstract createNew: (Expression -> ResizeArray option -> ResizeArray option -> NewExpression) - abstract updateNew: (NewExpression -> Expression -> ResizeArray option -> ResizeArray option -> NewExpression) - abstract createTypeAssertion: (TypeNode -> Expression -> TypeAssertion) - abstract updateTypeAssertion: (TypeAssertion -> TypeNode -> Expression -> TypeAssertion) - abstract createParen: (Expression -> ParenthesizedExpression) - abstract updateParen: (ParenthesizedExpression -> Expression -> ParenthesizedExpression) - abstract createFunctionExpression: (ResizeArray option -> AsteriskToken option -> U2 option -> ResizeArray option -> ResizeArray option -> TypeNode option -> Block -> FunctionExpression) - abstract updateFunctionExpression: (FunctionExpression -> ResizeArray option -> AsteriskToken option -> Identifier option -> ResizeArray option -> ResizeArray -> TypeNode option -> Block -> FunctionExpression) - abstract createDelete: (Expression -> DeleteExpression) - abstract updateDelete: (DeleteExpression -> Expression -> DeleteExpression) - abstract createTypeOf: (Expression -> TypeOfExpression) - abstract updateTypeOf: (TypeOfExpression -> Expression -> TypeOfExpression) - abstract createVoid: (Expression -> VoidExpression) - abstract updateVoid: (VoidExpression -> Expression -> VoidExpression) - abstract createAwait: (Expression -> AwaitExpression) - abstract updateAwait: (AwaitExpression -> Expression -> AwaitExpression) - abstract createPrefix: (PrefixUnaryOperator -> Expression -> PrefixUnaryExpression) - abstract updatePrefix: (PrefixUnaryExpression -> Expression -> PrefixUnaryExpression) - abstract createPostfix: (Expression -> PostfixUnaryOperator -> PostfixUnaryExpression) - abstract updatePostfix: (PostfixUnaryExpression -> Expression -> PostfixUnaryExpression) - abstract createBinary: (Expression -> U2 -> Expression -> BinaryExpression) - abstract updateConditional: (ConditionalExpression -> Expression -> QuestionToken -> Expression -> ColonToken -> Expression -> ConditionalExpression) - abstract createTemplateExpression: (TemplateHead -> ResizeArray -> TemplateExpression) - abstract updateTemplateExpression: (TemplateExpression -> TemplateHead -> ResizeArray -> TemplateExpression) - abstract createTemplateHead: IExportsCreateTemplateHead - abstract createTemplateMiddle: IExportsCreateTemplateMiddle - abstract createTemplateTail: IExportsCreateTemplateTail - abstract createNoSubstitutionTemplateLiteral: IExportsCreateNoSubstitutionTemplateLiteral - abstract updateYield: (YieldExpression -> AsteriskToken option -> Expression option -> YieldExpression) - abstract createSpread: (Expression -> SpreadElement) - abstract updateSpread: (SpreadElement -> Expression -> SpreadElement) - abstract createOmittedExpression: (unit -> OmittedExpression) - abstract createAsExpression: (Expression -> TypeNode -> AsExpression) - abstract updateAsExpression: (AsExpression -> Expression -> TypeNode -> AsExpression) - abstract createNonNullExpression: (Expression -> NonNullExpression) - abstract updateNonNullExpression: (NonNullExpression -> Expression -> NonNullExpression) - abstract createNonNullChain: (Expression -> NonNullChain) - abstract updateNonNullChain: (NonNullChain -> Expression -> NonNullChain) - abstract createMetaProperty: (SyntaxKind -> Identifier -> MetaProperty) - abstract updateMetaProperty: (MetaProperty -> Identifier -> MetaProperty) - abstract createTemplateSpan: (Expression -> U2 -> TemplateSpan) - abstract updateTemplateSpan: (TemplateSpan -> Expression -> U2 -> TemplateSpan) - abstract createSemicolonClassElement: (unit -> SemicolonClassElement) - abstract createBlock: (ResizeArray -> bool -> Block) - abstract updateBlock: (Block -> ResizeArray -> Block) - abstract createVariableStatement: (ResizeArray option -> U2> -> VariableStatement) - abstract updateVariableStatement: (VariableStatement -> ResizeArray option -> VariableDeclarationList -> VariableStatement) - abstract createEmptyStatement: (unit -> EmptyStatement) - abstract createExpressionStatement: (Expression -> ExpressionStatement) - abstract updateExpressionStatement: (ExpressionStatement -> Expression -> ExpressionStatement) - abstract createStatement: (Expression -> ExpressionStatement) - abstract updateStatement: (ExpressionStatement -> Expression -> ExpressionStatement) - abstract createIf: (Expression -> Statement -> Statement -> IfStatement) - abstract updateIf: (IfStatement -> Expression -> Statement -> Statement option -> IfStatement) - abstract createDo: (Statement -> Expression -> DoStatement) - abstract updateDo: (DoStatement -> Statement -> Expression -> DoStatement) - abstract createWhile: (Expression -> Statement -> WhileStatement) - abstract updateWhile: (WhileStatement -> Expression -> Statement -> WhileStatement) - abstract createFor: (ForInitializer option -> Expression option -> Expression option -> Statement -> ForStatement) - abstract updateFor: (ForStatement -> ForInitializer option -> Expression option -> Expression option -> Statement -> ForStatement) - abstract createForIn: (ForInitializer -> Expression -> Statement -> ForInStatement) - abstract updateForIn: (ForInStatement -> ForInitializer -> Expression -> Statement -> ForInStatement) - abstract createForOf: (AwaitKeyword option -> ForInitializer -> Expression -> Statement -> ForOfStatement) - abstract updateForOf: (ForOfStatement -> AwaitKeyword option -> ForInitializer -> Expression -> Statement -> ForOfStatement) - abstract createContinue: (U2 -> ContinueStatement) - abstract updateContinue: (ContinueStatement -> Identifier option -> ContinueStatement) - abstract createBreak: (U2 -> BreakStatement) - abstract updateBreak: (BreakStatement -> Identifier option -> BreakStatement) - abstract createReturn: (Expression -> ReturnStatement) - abstract updateReturn: (ReturnStatement -> Expression option -> ReturnStatement) - abstract createWith: (Expression -> Statement -> WithStatement) - abstract updateWith: (WithStatement -> Expression -> Statement -> WithStatement) - abstract createSwitch: (Expression -> CaseBlock -> SwitchStatement) - abstract updateSwitch: (SwitchStatement -> Expression -> CaseBlock -> SwitchStatement) - abstract createLabel: (U2 -> Statement -> LabeledStatement) - abstract updateLabel: (LabeledStatement -> Identifier -> Statement -> LabeledStatement) - abstract createThrow: (Expression -> ThrowStatement) - abstract updateThrow: (ThrowStatement -> Expression -> ThrowStatement) - abstract createTry: (Block -> CatchClause option -> Block option -> TryStatement) - abstract updateTry: (TryStatement -> Block -> CatchClause option -> Block option -> TryStatement) - abstract createDebuggerStatement: (unit -> DebuggerStatement) - abstract createVariableDeclarationList: (ResizeArray -> NodeFlags -> VariableDeclarationList) - abstract updateVariableDeclarationList: (VariableDeclarationList -> ResizeArray -> VariableDeclarationList) - abstract createFunctionDeclaration: (ResizeArray option -> ResizeArray option -> AsteriskToken option -> U2 option -> ResizeArray option -> ResizeArray -> TypeNode option -> Block option -> FunctionDeclaration) - abstract updateFunctionDeclaration: (FunctionDeclaration -> ResizeArray option -> ResizeArray option -> AsteriskToken option -> Identifier option -> ResizeArray option -> ResizeArray -> TypeNode option -> Block option -> FunctionDeclaration) - abstract createClassDeclaration: (ResizeArray option -> ResizeArray option -> U2 option -> ResizeArray option -> ResizeArray option -> ResizeArray -> ClassDeclaration) - abstract updateClassDeclaration: (ClassDeclaration -> ResizeArray option -> ResizeArray option -> Identifier option -> ResizeArray option -> ResizeArray option -> ResizeArray -> ClassDeclaration) - abstract createInterfaceDeclaration: (ResizeArray option -> ResizeArray option -> U2 -> ResizeArray option -> ResizeArray option -> ResizeArray -> InterfaceDeclaration) - abstract updateInterfaceDeclaration: (InterfaceDeclaration -> ResizeArray option -> ResizeArray option -> Identifier -> ResizeArray option -> ResizeArray option -> ResizeArray -> InterfaceDeclaration) - abstract createTypeAliasDeclaration: (ResizeArray option -> ResizeArray option -> U2 -> ResizeArray option -> TypeNode -> TypeAliasDeclaration) - abstract updateTypeAliasDeclaration: (TypeAliasDeclaration -> ResizeArray option -> ResizeArray option -> Identifier -> ResizeArray option -> TypeNode -> TypeAliasDeclaration) - abstract createEnumDeclaration: (ResizeArray option -> ResizeArray option -> U2 -> ResizeArray -> EnumDeclaration) - abstract updateEnumDeclaration: (EnumDeclaration -> ResizeArray option -> ResizeArray option -> Identifier -> ResizeArray -> EnumDeclaration) - abstract createModuleDeclaration: (ResizeArray option -> ResizeArray option -> ModuleName -> ModuleBody option -> NodeFlags -> ModuleDeclaration) - abstract updateModuleDeclaration: (ModuleDeclaration -> ResizeArray option -> ResizeArray option -> ModuleName -> ModuleBody option -> ModuleDeclaration) - abstract createModuleBlock: (ResizeArray -> ModuleBlock) - abstract updateModuleBlock: (ModuleBlock -> ResizeArray -> ModuleBlock) - abstract createCaseBlock: (ResizeArray -> CaseBlock) - abstract updateCaseBlock: (CaseBlock -> ResizeArray -> CaseBlock) - abstract createNamespaceExportDeclaration: (U2 -> NamespaceExportDeclaration) - abstract updateNamespaceExportDeclaration: (NamespaceExportDeclaration -> Identifier -> NamespaceExportDeclaration) - abstract createImportEqualsDeclaration: (ResizeArray option -> ResizeArray option -> bool -> U2 -> ModuleReference -> ImportEqualsDeclaration) - abstract updateImportEqualsDeclaration: (ImportEqualsDeclaration -> ResizeArray option -> ResizeArray option -> bool -> Identifier -> ModuleReference -> ImportEqualsDeclaration) - abstract createImportDeclaration: (ResizeArray option -> ResizeArray option -> ImportClause option -> Expression -> AssertClause -> ImportDeclaration) - abstract updateImportDeclaration: (ImportDeclaration -> ResizeArray option -> ResizeArray option -> ImportClause option -> Expression -> AssertClause option -> ImportDeclaration) - abstract createNamespaceImport: (Identifier -> NamespaceImport) - abstract updateNamespaceImport: (NamespaceImport -> Identifier -> NamespaceImport) - abstract createNamedImports: (ResizeArray -> NamedImports) - abstract updateNamedImports: (NamedImports -> ResizeArray -> NamedImports) - abstract createImportSpecifier: (bool -> Identifier option -> Identifier -> ImportSpecifier) - abstract updateImportSpecifier: (ImportSpecifier -> bool -> Identifier option -> Identifier -> ImportSpecifier) - abstract createExportAssignment: (ResizeArray option -> ResizeArray option -> bool option -> Expression -> ExportAssignment) - abstract updateExportAssignment: (ExportAssignment -> ResizeArray option -> ResizeArray option -> Expression -> ExportAssignment) - abstract createNamedExports: (ResizeArray -> NamedExports) - abstract updateNamedExports: (NamedExports -> ResizeArray -> NamedExports) - abstract createExportSpecifier: (bool -> U2 option -> U2 -> ExportSpecifier) - abstract updateExportSpecifier: (ExportSpecifier -> bool -> Identifier option -> Identifier -> ExportSpecifier) - abstract createExternalModuleReference: (Expression -> ExternalModuleReference) - abstract updateExternalModuleReference: (ExternalModuleReference -> Expression -> ExternalModuleReference) - abstract createJSDocTypeExpression: (TypeNode -> JSDocTypeExpression) - abstract createJSDocTypeTag: (Identifier option -> JSDocTypeExpression -> U2> -> JSDocTypeTag) - abstract createJSDocReturnTag: (Identifier option -> JSDocTypeExpression -> U2> -> JSDocReturnTag) - abstract createJSDocThisTag: (Identifier option -> JSDocTypeExpression -> U2> -> JSDocThisTag) - abstract createJSDocComment: (U2> -> ResizeArray -> JSDoc) - abstract createJSDocParameterTag: (Identifier option -> EntityName -> bool -> JSDocTypeExpression -> bool -> U2> -> JSDocParameterTag) - abstract createJSDocClassTag: (Identifier option -> U2> -> JSDocClassTag) - abstract createJSDocAugmentsTag: (Identifier option -> obj -> U2> -> JSDocAugmentsTag) - abstract createJSDocEnumTag: (Identifier option -> JSDocTypeExpression -> U2> -> JSDocEnumTag) - abstract createJSDocTemplateTag: (Identifier option -> JSDocTypeExpression option -> ResizeArray -> U2> -> JSDocTemplateTag) - abstract createJSDocTypedefTag: (Identifier option -> U2 -> U2 -> U2> -> JSDocTypedefTag) - abstract createJSDocCallbackTag: (Identifier option -> JSDocSignature -> U2 -> U2> -> JSDocCallbackTag) - abstract createJSDocSignature: (ResizeArray option -> ResizeArray -> JSDocReturnTag -> JSDocSignature) - abstract createJSDocPropertyTag: (Identifier option -> EntityName -> bool -> JSDocTypeExpression -> bool -> U2> -> JSDocPropertyTag) - abstract createJSDocTypeLiteral: (ResizeArray -> bool -> JSDocTypeLiteral) - abstract createJSDocImplementsTag: (Identifier option -> obj -> U2> -> JSDocImplementsTag) - abstract createJSDocAuthorTag: (Identifier option -> U2> -> JSDocAuthorTag) - abstract createJSDocPublicTag: (Identifier option -> U2> -> JSDocPublicTag) - abstract createJSDocPrivateTag: (Identifier option -> U2> -> JSDocPrivateTag) - abstract createJSDocProtectedTag: (Identifier option -> U2> -> JSDocProtectedTag) - abstract createJSDocReadonlyTag: (Identifier option -> U2> -> JSDocReadonlyTag) - abstract createJSDocTag: (Identifier -> U2> -> JSDocUnknownTag) - abstract createJsxElement: (JsxOpeningElement -> ResizeArray -> JsxClosingElement -> JsxElement) - abstract updateJsxElement: (JsxElement -> JsxOpeningElement -> ResizeArray -> JsxClosingElement -> JsxElement) - abstract createJsxSelfClosingElement: (JsxTagNameExpression -> ResizeArray option -> JsxAttributes -> JsxSelfClosingElement) - abstract updateJsxSelfClosingElement: (JsxSelfClosingElement -> JsxTagNameExpression -> ResizeArray option -> JsxAttributes -> JsxSelfClosingElement) - abstract createJsxOpeningElement: (JsxTagNameExpression -> ResizeArray option -> JsxAttributes -> JsxOpeningElement) - abstract updateJsxOpeningElement: (JsxOpeningElement -> JsxTagNameExpression -> ResizeArray option -> JsxAttributes -> JsxOpeningElement) - abstract createJsxClosingElement: (JsxTagNameExpression -> JsxClosingElement) - abstract updateJsxClosingElement: (JsxClosingElement -> JsxTagNameExpression -> JsxClosingElement) - abstract createJsxFragment: (JsxOpeningFragment -> ResizeArray -> JsxClosingFragment -> JsxFragment) - abstract createJsxText: (string -> bool -> JsxText) - abstract updateJsxText: (JsxText -> string -> bool -> JsxText) - abstract createJsxOpeningFragment: (unit -> JsxOpeningFragment) - abstract createJsxJsxClosingFragment: (unit -> JsxClosingFragment) - abstract updateJsxFragment: (JsxFragment -> JsxOpeningFragment -> ResizeArray -> JsxClosingFragment -> JsxFragment) - abstract createJsxAttribute: (Identifier -> U2 option -> JsxAttribute) - abstract updateJsxAttribute: (JsxAttribute -> Identifier -> U2 option -> JsxAttribute) - abstract createJsxAttributes: (ResizeArray -> JsxAttributes) - abstract updateJsxAttributes: (JsxAttributes -> ResizeArray -> JsxAttributes) - abstract createJsxSpreadAttribute: (Expression -> JsxSpreadAttribute) - abstract updateJsxSpreadAttribute: (JsxSpreadAttribute -> Expression -> JsxSpreadAttribute) - abstract createJsxExpression: (DotDotDotToken option -> Expression option -> JsxExpression) - abstract updateJsxExpression: (JsxExpression -> Expression option -> JsxExpression) - abstract createCaseClause: (Expression -> ResizeArray -> CaseClause) - abstract updateCaseClause: (CaseClause -> Expression -> ResizeArray -> CaseClause) - abstract createDefaultClause: (ResizeArray -> DefaultClause) - abstract updateDefaultClause: (DefaultClause -> ResizeArray -> DefaultClause) - abstract createHeritageClause: (SyntaxKind -> ResizeArray -> HeritageClause) - abstract updateHeritageClause: (HeritageClause -> ResizeArray -> HeritageClause) - abstract createCatchClause: (U3 option -> Block -> CatchClause) - abstract updateCatchClause: (CatchClause -> VariableDeclaration option -> Block -> CatchClause) - abstract createPropertyAssignment: (U2 -> Expression -> PropertyAssignment) - abstract updatePropertyAssignment: (PropertyAssignment -> PropertyName -> Expression -> PropertyAssignment) - abstract createShorthandPropertyAssignment: (U2 -> Expression -> ShorthandPropertyAssignment) - abstract updateShorthandPropertyAssignment: (ShorthandPropertyAssignment -> Identifier -> Expression option -> ShorthandPropertyAssignment) - abstract createSpreadAssignment: (Expression -> SpreadAssignment) - abstract updateSpreadAssignment: (SpreadAssignment -> Expression -> SpreadAssignment) - abstract createEnumMember: (U2 -> Expression -> EnumMember) - abstract updateEnumMember: (EnumMember -> PropertyName -> Expression option -> EnumMember) - abstract updateSourceFileNode: (SourceFile -> ResizeArray -> bool -> ResizeArray -> ResizeArray -> bool -> ResizeArray -> SourceFile) - abstract createNotEmittedStatement: (Node -> NotEmittedStatement) - abstract createPartiallyEmittedExpression: (Expression -> Node -> PartiallyEmittedExpression) - abstract updatePartiallyEmittedExpression: (PartiallyEmittedExpression -> Expression -> PartiallyEmittedExpression) - abstract createCommaList: (ResizeArray -> CommaListExpression) - abstract updateCommaList: (CommaListExpression -> ResizeArray -> CommaListExpression) - abstract createBundle: (ResizeArray -> ResizeArray> -> Bundle) - abstract updateBundle: (Bundle -> ResizeArray -> ResizeArray> -> Bundle) - abstract createImmediatelyInvokedFunctionExpression: IExportsCreateImmediatelyInvokedFunctionExpression - abstract createImmediatelyInvokedArrowFunction: IExportsCreateImmediatelyInvokedFunctionExpression - abstract createVoidZero: (unit -> VoidExpression) - abstract createExportDefault: (Expression -> ExportAssignment) - abstract createExternalModuleExport: (Identifier -> ExportDeclaration) - abstract createNamespaceExport: (Identifier -> NamespaceExport) - abstract updateNamespaceExport: (NamespaceExport -> Identifier -> NamespaceExport) - abstract createToken: 'TKind -> Token<'TKind> - abstract createIdentifier: (string -> Identifier) - abstract createTempVariable: ((Identifier -> unit) option -> Identifier) - abstract getGeneratedNameForNode: (Node option -> Identifier) - abstract createOptimisticUniqueName: (string -> Identifier) - abstract createFileLevelUniqueName: (string -> Identifier) - abstract createIndexSignature: (ResizeArray option -> ResizeArray option -> ResizeArray -> TypeNode -> IndexSignatureDeclaration) - abstract createTypePredicateNode: (U3 -> TypeNode -> TypePredicateNode) - abstract updateTypePredicateNode: (TypePredicateNode -> U2 -> TypeNode -> TypePredicateNode) - abstract createLiteral: IExportsCreateLiteral - abstract createMethodSignature: (ResizeArray option -> ResizeArray -> TypeNode option -> U2 -> QuestionToken option -> MethodSignature) - abstract updateMethodSignature: (MethodSignature -> ResizeArray option -> ResizeArray -> TypeNode option -> PropertyName -> QuestionToken option -> MethodSignature) - abstract createTypeOperatorNode: IExportsCreateTypeOperatorNode - abstract createTaggedTemplate: IExportsCreateTaggedTemplate - abstract updateTaggedTemplate: IExportsUpdateTaggedTemplate - abstract updateBinary: (BinaryExpression -> Expression -> Expression -> U2 -> BinaryExpression) - abstract createConditional: IExportsCreateConditional - abstract createYield: IExportsCreateYield - abstract createClassExpression: (ResizeArray option -> U2 option -> ResizeArray option -> ResizeArray option -> ResizeArray -> ClassExpression) - abstract updateClassExpression: (ClassExpression -> ResizeArray option -> Identifier option -> ResizeArray option -> ResizeArray option -> ResizeArray -> ClassExpression) - abstract createPropertySignature: (ResizeArray option -> U2 -> QuestionToken option -> TypeNode option -> Expression -> PropertySignature) - abstract updatePropertySignature: (PropertySignature -> ResizeArray option -> PropertyName -> QuestionToken option -> TypeNode option -> Expression option -> PropertySignature) - abstract createExpressionWithTypeArguments: (ResizeArray option -> Expression -> ExpressionWithTypeArguments) - abstract updateExpressionWithTypeArguments: (ExpressionWithTypeArguments -> ResizeArray option -> Expression -> ExpressionWithTypeArguments) - abstract createArrowFunction: IExportsCreateArrowFunction - abstract updateArrowFunction: IExportsUpdateArrowFunction - abstract createVariableDeclaration: IExportsCreateVariableDeclaration - abstract updateVariableDeclaration: IExportsUpdateVariableDeclaration - abstract createImportClause: (Identifier option -> NamedImportBindings option -> obj -> ImportClause) - abstract updateImportClause: (ImportClause -> Identifier option -> NamedImportBindings option -> bool -> ImportClause) - abstract createExportDeclaration: (ResizeArray option -> ResizeArray option -> NamedExportBindings option -> Expression -> obj -> ExportDeclaration) - abstract updateExportDeclaration: (ExportDeclaration -> ResizeArray option -> ResizeArray option -> NamedExportBindings option -> Expression option -> bool -> ExportDeclaration) - abstract createJSDocParamTag: (EntityName -> bool -> JSDocTypeExpression -> string -> JSDocParameterTag) - abstract createComma: (Expression -> Expression -> Expression) - abstract createLessThan: (Expression -> Expression -> Expression) - abstract createAssignment: (Expression -> Expression -> BinaryExpression) - abstract createStrictEquality: (Expression -> Expression -> BinaryExpression) - abstract createStrictInequality: (Expression -> Expression -> BinaryExpression) - abstract createAdd: (Expression -> Expression -> BinaryExpression) - abstract createSubtract: (Expression -> Expression -> BinaryExpression) - abstract createLogicalAnd: (Expression -> Expression -> BinaryExpression) - abstract createLogicalOr: (Expression -> Expression -> BinaryExpression) - abstract createPostfixIncrement: (Expression -> PostfixUnaryExpression) - abstract createLogicalNot: (Expression -> PrefixUnaryExpression) - abstract createNode: (SyntaxKind -> obj -> obj -> Node) - abstract getMutableClone: 'T -> 'T - abstract isTypeAssertion: (Node -> bool) - abstract isIdentifierOrPrivateIdentifier: (Node -> bool) - - type [] ValidateLocaleAndSetLanguageSys = - abstract getExecutingFilePath: unit -> string - abstract resolvePath: path: string -> string - abstract fileExists: fileName: string -> bool - abstract readFile: fileName: string -> string option - - type [] [] CreateUnparsedSourceFileType = - | Js - | Dts - - type [] ReadConfigFileReturn = - abstract config: obj option with get, set - abstract error: Diagnostic option with get, set - - type [] ParseConfigFileTextToJsonReturn = - abstract config: obj option with get, set - abstract error: Diagnostic option with get, set - - type [] ConvertCompilerOptionsFromJsonReturn = - abstract options: CompilerOptions with get, set - abstract errors: ResizeArray with get, set - - type [] ConvertTypeAcquisitionFromJsonReturn = - abstract options: TypeAcquisition with get, set - abstract errors: ResizeArray with get, set + abstract transform: source: U2<'T, 'T[]> * transformers: TransformerFactory<'T>[] * ?compilerOptions: CompilerOptions -> TransformationResult<'T> + /// /// Type of objects whose values are all of the same type. - /// The `in` and `for-in` operators can *not* be safely used, - /// since `Object.prototype` may be modified by outside code. + /// The in and for-in operators can *not* be safely used, + /// since Object.prototype may be modified by outside code. + /// type [] MapLike<'T> = - [] abstract Item: index: string -> 'T with get, set + [] abstract Item: index: string -> 'T with get, set type [] SortedReadonlyArray<'T> = inherit ReadonlyArray<'T> @@ -1063,63 +881,6 @@ module Ts = inherit Array<'T> abstract `` __sortedArrayBrand``: obj option with get, set - /// Common read methods for ES6 Map/Set. - type [] ReadonlyCollection<'K> = - abstract size: float - abstract has: key: 'K -> bool - abstract keys: unit -> Iterator<'K> - - /// Common write methods for ES6 Map/Set. - type [] Collection<'K> = - inherit ReadonlyCollection<'K> - abstract delete: key: 'K -> bool - abstract clear: unit -> unit - - /// ES6 Map interface, only read methods included. - type [] ReadonlyESMap<'K, 'V> = - inherit ReadonlyCollection<'K> - abstract get: key: 'K -> 'V option - abstract values: unit -> Iterator<'V> - abstract entries: unit -> Iterator<'K * 'V> - abstract forEach: action: ('V -> 'K -> unit) -> unit - - /// ES6 Map interface, only read methods included. - type [] ReadonlyMap<'T> = - inherit ReadonlyESMap - - /// ES6 Map interface. - type [] ESMap<'K, 'V> = - inherit ReadonlyESMap<'K, 'V> - inherit Collection<'K> - abstract set: key: 'K * value: 'V -> ESMap<'K, 'V> - - /// ES6 Map interface. - type [] Map<'T> = - inherit ESMap - - /// ES6 Set interface, only read methods included. - type [] ReadonlySet<'T> = - inherit ReadonlyCollection<'T> - abstract has: value: 'T -> bool - abstract values: unit -> Iterator<'T> - abstract entries: unit -> Iterator<'T * 'T> - abstract forEach: action: ('T -> 'T -> unit) -> unit - - /// ES6 Set interface. - type [] Set<'T> = - inherit ReadonlySet<'T> - inherit Collection<'T> - abstract add: value: 'T -> Set<'T> - abstract delete: value: 'T -> bool - - /// ES6 Iterator type. - type [] Iterator<'T> = - abstract next: unit -> U2, IteratorNext2> - - /// Array that is only intended to be pushed to, never read. - type [] Push<'T> = - abstract push: [] values: ResizeArray<'T> -> unit - type [] Path = interface end @@ -1140,413 +901,492 @@ module Ts = | WhitespaceTrivia = 5 | ShebangTrivia = 6 | ConflictMarkerTrivia = 7 - | NumericLiteral = 8 - | BigIntLiteral = 9 - | StringLiteral = 10 - | JsxText = 11 - | JsxTextAllWhiteSpaces = 12 - | RegularExpressionLiteral = 13 - | NoSubstitutionTemplateLiteral = 14 - | TemplateHead = 15 - | TemplateMiddle = 16 - | TemplateTail = 17 - | OpenBraceToken = 18 - | CloseBraceToken = 19 - | OpenParenToken = 20 - | CloseParenToken = 21 - | OpenBracketToken = 22 - | CloseBracketToken = 23 - | DotToken = 24 - | DotDotDotToken = 25 - | SemicolonToken = 26 - | CommaToken = 27 - | QuestionDotToken = 28 - | LessThanToken = 29 - | LessThanSlashToken = 30 - | GreaterThanToken = 31 - | LessThanEqualsToken = 32 - | GreaterThanEqualsToken = 33 - | EqualsEqualsToken = 34 - | ExclamationEqualsToken = 35 - | EqualsEqualsEqualsToken = 36 - | ExclamationEqualsEqualsToken = 37 - | EqualsGreaterThanToken = 38 - | PlusToken = 39 - | MinusToken = 40 - | AsteriskToken = 41 - | AsteriskAsteriskToken = 42 - | SlashToken = 43 - | PercentToken = 44 - | PlusPlusToken = 45 - | MinusMinusToken = 46 - | LessThanLessThanToken = 47 - | GreaterThanGreaterThanToken = 48 - | GreaterThanGreaterThanGreaterThanToken = 49 - | AmpersandToken = 50 - | BarToken = 51 - | CaretToken = 52 - | ExclamationToken = 53 - | TildeToken = 54 - | AmpersandAmpersandToken = 55 - | BarBarToken = 56 - | QuestionToken = 57 - | ColonToken = 58 - | AtToken = 59 - | QuestionQuestionToken = 60 - | BacktickToken = 61 - | HashToken = 62 - | EqualsToken = 63 - | PlusEqualsToken = 64 - | MinusEqualsToken = 65 - | AsteriskEqualsToken = 66 - | AsteriskAsteriskEqualsToken = 67 - | SlashEqualsToken = 68 - | PercentEqualsToken = 69 - | LessThanLessThanEqualsToken = 70 - | GreaterThanGreaterThanEqualsToken = 71 - | GreaterThanGreaterThanGreaterThanEqualsToken = 72 - | AmpersandEqualsToken = 73 - | BarEqualsToken = 74 - | BarBarEqualsToken = 75 - | AmpersandAmpersandEqualsToken = 76 - | QuestionQuestionEqualsToken = 77 - | CaretEqualsToken = 78 - | Identifier = 79 - | PrivateIdentifier = 80 - | BreakKeyword = 81 - | CaseKeyword = 82 - | CatchKeyword = 83 - | ClassKeyword = 84 - | ConstKeyword = 85 - | ContinueKeyword = 86 - | DebuggerKeyword = 87 - | DefaultKeyword = 88 - | DeleteKeyword = 89 - | DoKeyword = 90 - | ElseKeyword = 91 - | EnumKeyword = 92 - | ExportKeyword = 93 - | ExtendsKeyword = 94 - | FalseKeyword = 95 - | FinallyKeyword = 96 - | ForKeyword = 97 - | FunctionKeyword = 98 - | IfKeyword = 99 - | ImportKeyword = 100 - | InKeyword = 101 - | InstanceOfKeyword = 102 - | NewKeyword = 103 - | NullKeyword = 104 - | ReturnKeyword = 105 - | SuperKeyword = 106 - | SwitchKeyword = 107 - | ThisKeyword = 108 - | ThrowKeyword = 109 - | TrueKeyword = 110 - | TryKeyword = 111 - | TypeOfKeyword = 112 - | VarKeyword = 113 - | VoidKeyword = 114 - | WhileKeyword = 115 - | WithKeyword = 116 - | ImplementsKeyword = 117 - | InterfaceKeyword = 118 - | LetKeyword = 119 - | PackageKeyword = 120 - | PrivateKeyword = 121 - | ProtectedKeyword = 122 - | PublicKeyword = 123 - | StaticKeyword = 124 - | YieldKeyword = 125 - | AbstractKeyword = 126 - | AsKeyword = 127 - | AssertsKeyword = 128 - | AssertKeyword = 129 - | AnyKeyword = 130 - | AsyncKeyword = 131 - | AwaitKeyword = 132 - | BooleanKeyword = 133 - | ConstructorKeyword = 134 - | DeclareKeyword = 135 - | GetKeyword = 136 - | InferKeyword = 137 - | IntrinsicKeyword = 138 - | IsKeyword = 139 - | KeyOfKeyword = 140 - | ModuleKeyword = 141 - | NamespaceKeyword = 142 - | NeverKeyword = 143 - | ReadonlyKeyword = 144 - | RequireKeyword = 145 - | NumberKeyword = 146 - | ObjectKeyword = 147 - | SetKeyword = 148 - | StringKeyword = 149 - | SymbolKeyword = 150 - | TypeKeyword = 151 - | UndefinedKeyword = 152 - | UniqueKeyword = 153 - | UnknownKeyword = 154 - | FromKeyword = 155 - | GlobalKeyword = 156 - | BigIntKeyword = 157 - | OverrideKeyword = 158 - | OfKeyword = 159 - | QualifiedName = 160 - | ComputedPropertyName = 161 - | TypeParameter = 162 - | Parameter = 163 - | Decorator = 164 - | PropertySignature = 165 - | PropertyDeclaration = 166 - | MethodSignature = 167 - | MethodDeclaration = 168 - | ClassStaticBlockDeclaration = 169 - | Constructor = 170 - | GetAccessor = 171 - | SetAccessor = 172 - | CallSignature = 173 - | ConstructSignature = 174 - | IndexSignature = 175 - | TypePredicate = 176 - | TypeReference = 177 - | FunctionType = 178 - | ConstructorType = 179 - | TypeQuery = 180 - | TypeLiteral = 181 - | ArrayType = 182 - | TupleType = 183 - | OptionalType = 184 - | RestType = 185 - | UnionType = 186 - | IntersectionType = 187 - | ConditionalType = 188 - | InferType = 189 - | ParenthesizedType = 190 - | ThisType = 191 - | TypeOperator = 192 - | IndexedAccessType = 193 - | MappedType = 194 - | LiteralType = 195 - | NamedTupleMember = 196 - | TemplateLiteralType = 197 - | TemplateLiteralTypeSpan = 198 - | ImportType = 199 - | ObjectBindingPattern = 200 - | ArrayBindingPattern = 201 - | BindingElement = 202 - | ArrayLiteralExpression = 203 - | ObjectLiteralExpression = 204 - | PropertyAccessExpression = 205 - | ElementAccessExpression = 206 - | CallExpression = 207 - | NewExpression = 208 - | TaggedTemplateExpression = 209 - | TypeAssertionExpression = 210 - | ParenthesizedExpression = 211 - | FunctionExpression = 212 - | ArrowFunction = 213 - | DeleteExpression = 214 - | TypeOfExpression = 215 - | VoidExpression = 216 - | AwaitExpression = 217 - | PrefixUnaryExpression = 218 - | PostfixUnaryExpression = 219 - | BinaryExpression = 220 - | ConditionalExpression = 221 - | TemplateExpression = 222 - | YieldExpression = 223 - | SpreadElement = 224 - | ClassExpression = 225 - | OmittedExpression = 226 - | ExpressionWithTypeArguments = 227 - | AsExpression = 228 - | NonNullExpression = 229 - | MetaProperty = 230 - | SyntheticExpression = 231 - | TemplateSpan = 232 - | SemicolonClassElement = 233 - | Block = 234 - | EmptyStatement = 235 - | VariableStatement = 236 - | ExpressionStatement = 237 - | IfStatement = 238 - | DoStatement = 239 - | WhileStatement = 240 - | ForStatement = 241 - | ForInStatement = 242 - | ForOfStatement = 243 - | ContinueStatement = 244 - | BreakStatement = 245 - | ReturnStatement = 246 - | WithStatement = 247 - | SwitchStatement = 248 - | LabeledStatement = 249 - | ThrowStatement = 250 - | TryStatement = 251 - | DebuggerStatement = 252 - | VariableDeclaration = 253 - | VariableDeclarationList = 254 - | FunctionDeclaration = 255 - | ClassDeclaration = 256 - | InterfaceDeclaration = 257 - | TypeAliasDeclaration = 258 - | EnumDeclaration = 259 - | ModuleDeclaration = 260 - | ModuleBlock = 261 - | CaseBlock = 262 - | NamespaceExportDeclaration = 263 - | ImportEqualsDeclaration = 264 - | ImportDeclaration = 265 - | ImportClause = 266 - | NamespaceImport = 267 - | NamedImports = 268 - | ImportSpecifier = 269 - | ExportAssignment = 270 - | ExportDeclaration = 271 - | NamedExports = 272 - | NamespaceExport = 273 - | ExportSpecifier = 274 - | MissingDeclaration = 275 - | ExternalModuleReference = 276 - | JsxElement = 277 - | JsxSelfClosingElement = 278 - | JsxOpeningElement = 279 - | JsxClosingElement = 280 - | JsxFragment = 281 - | JsxOpeningFragment = 282 - | JsxClosingFragment = 283 - | JsxAttribute = 284 - | JsxAttributes = 285 - | JsxSpreadAttribute = 286 - | JsxExpression = 287 - | CaseClause = 288 - | DefaultClause = 289 - | HeritageClause = 290 - | CatchClause = 291 - | AssertClause = 292 - | AssertEntry = 293 - | PropertyAssignment = 294 - | ShorthandPropertyAssignment = 295 - | SpreadAssignment = 296 - | EnumMember = 297 - | UnparsedPrologue = 298 - | UnparsedPrepend = 299 - | UnparsedText = 300 - | UnparsedInternalText = 301 - | UnparsedSyntheticReference = 302 - | SourceFile = 303 - | Bundle = 304 - | UnparsedSource = 305 - | InputFiles = 306 - | JSDocTypeExpression = 307 - | JSDocNameReference = 308 - | JSDocMemberName = 309 - | JSDocAllType = 310 - | JSDocUnknownType = 311 - | JSDocNullableType = 312 - | JSDocNonNullableType = 313 - | JSDocOptionalType = 314 - | JSDocFunctionType = 315 - | JSDocVariadicType = 316 - | JSDocNamepathType = 317 - | JSDocComment = 318 - | JSDocText = 319 - | JSDocTypeLiteral = 320 - | JSDocSignature = 321 - | JSDocLink = 322 - | JSDocLinkCode = 323 - | JSDocLinkPlain = 324 - | JSDocTag = 325 - | JSDocAugmentsTag = 326 - | JSDocImplementsTag = 327 - | JSDocAuthorTag = 328 - | JSDocDeprecatedTag = 329 - | JSDocClassTag = 330 - | JSDocPublicTag = 331 - | JSDocPrivateTag = 332 - | JSDocProtectedTag = 333 - | JSDocReadonlyTag = 334 - | JSDocOverrideTag = 335 - | JSDocCallbackTag = 336 - | JSDocEnumTag = 337 - | JSDocParameterTag = 338 - | JSDocReturnTag = 339 - | JSDocThisTag = 340 - | JSDocTypeTag = 341 - | JSDocTemplateTag = 342 - | JSDocTypedefTag = 343 - | JSDocSeeTag = 344 - | JSDocPropertyTag = 345 - | SyntaxList = 346 - | NotEmittedStatement = 347 - | PartiallyEmittedExpression = 348 - | CommaListExpression = 349 - | MergeDeclarationMarker = 350 - | EndOfDeclarationMarker = 351 - | SyntheticReferenceExpression = 352 - | Count = 353 - | FirstAssignment = 63 - | LastAssignment = 78 - | FirstCompoundAssignment = 64 - | LastCompoundAssignment = 78 - | FirstReservedWord = 81 - | LastReservedWord = 116 - | FirstKeyword = 81 - | LastKeyword = 159 - | FirstFutureReservedWord = 117 - | LastFutureReservedWord = 125 - | FirstTypeNode = 176 - | LastTypeNode = 199 - | FirstPunctuation = 18 - | LastPunctuation = 78 + | NonTextFileMarkerTrivia = 8 + | NumericLiteral = 9 + | BigIntLiteral = 10 + | StringLiteral = 11 + | JsxText = 12 + | JsxTextAllWhiteSpaces = 13 + | RegularExpressionLiteral = 14 + | NoSubstitutionTemplateLiteral = 15 + | TemplateHead = 16 + | TemplateMiddle = 17 + | TemplateTail = 18 + | OpenBraceToken = 19 + | CloseBraceToken = 20 + | OpenParenToken = 21 + | CloseParenToken = 22 + | OpenBracketToken = 23 + | CloseBracketToken = 24 + | DotToken = 25 + | DotDotDotToken = 26 + | SemicolonToken = 27 + | CommaToken = 28 + | QuestionDotToken = 29 + | LessThanToken = 30 + | LessThanSlashToken = 31 + | GreaterThanToken = 32 + | LessThanEqualsToken = 33 + | GreaterThanEqualsToken = 34 + | EqualsEqualsToken = 35 + | ExclamationEqualsToken = 36 + | EqualsEqualsEqualsToken = 37 + | ExclamationEqualsEqualsToken = 38 + | EqualsGreaterThanToken = 39 + | PlusToken = 40 + | MinusToken = 41 + | AsteriskToken = 42 + | AsteriskAsteriskToken = 43 + | SlashToken = 44 + | PercentToken = 45 + | PlusPlusToken = 46 + | MinusMinusToken = 47 + | LessThanLessThanToken = 48 + | GreaterThanGreaterThanToken = 49 + | GreaterThanGreaterThanGreaterThanToken = 50 + | AmpersandToken = 51 + | BarToken = 52 + | CaretToken = 53 + | ExclamationToken = 54 + | TildeToken = 55 + | AmpersandAmpersandToken = 56 + | BarBarToken = 57 + | QuestionToken = 58 + | ColonToken = 59 + | AtToken = 60 + | QuestionQuestionToken = 61 + /// Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. + | BacktickToken = 62 + /// Only the JSDoc scanner produces HashToken. The normal scanner produces PrivateIdentifier. + | HashToken = 63 + | EqualsToken = 64 + | PlusEqualsToken = 65 + | MinusEqualsToken = 66 + | AsteriskEqualsToken = 67 + | AsteriskAsteriskEqualsToken = 68 + | SlashEqualsToken = 69 + | PercentEqualsToken = 70 + | LessThanLessThanEqualsToken = 71 + | GreaterThanGreaterThanEqualsToken = 72 + | GreaterThanGreaterThanGreaterThanEqualsToken = 73 + | AmpersandEqualsToken = 74 + | BarEqualsToken = 75 + | BarBarEqualsToken = 76 + | AmpersandAmpersandEqualsToken = 77 + | QuestionQuestionEqualsToken = 78 + | CaretEqualsToken = 79 + | Identifier = 80 + | PrivateIdentifier = 81 + | BreakKeyword = 83 + | CaseKeyword = 84 + | CatchKeyword = 85 + | ClassKeyword = 86 + | ConstKeyword = 87 + | ContinueKeyword = 88 + | DebuggerKeyword = 89 + | DefaultKeyword = 90 + | DeleteKeyword = 91 + | DoKeyword = 92 + | ElseKeyword = 93 + | EnumKeyword = 94 + | ExportKeyword = 95 + | ExtendsKeyword = 96 + | FalseKeyword = 97 + | FinallyKeyword = 98 + | ForKeyword = 99 + | FunctionKeyword = 100 + | IfKeyword = 101 + | ImportKeyword = 102 + | InKeyword = 103 + | InstanceOfKeyword = 104 + | NewKeyword = 105 + | NullKeyword = 106 + | ReturnKeyword = 107 + | SuperKeyword = 108 + | SwitchKeyword = 109 + | ThisKeyword = 110 + | ThrowKeyword = 111 + | TrueKeyword = 112 + | TryKeyword = 113 + | TypeOfKeyword = 114 + | VarKeyword = 115 + | VoidKeyword = 116 + | WhileKeyword = 117 + | WithKeyword = 118 + | ImplementsKeyword = 119 + | InterfaceKeyword = 120 + | LetKeyword = 121 + | PackageKeyword = 122 + | PrivateKeyword = 123 + | ProtectedKeyword = 124 + | PublicKeyword = 125 + | StaticKeyword = 126 + | YieldKeyword = 127 + | AbstractKeyword = 128 + | AccessorKeyword = 129 + | AsKeyword = 130 + | AssertsKeyword = 131 + | AssertKeyword = 132 + | AnyKeyword = 133 + | AsyncKeyword = 134 + | AwaitKeyword = 135 + | BooleanKeyword = 136 + | ConstructorKeyword = 137 + | DeclareKeyword = 138 + | GetKeyword = 139 + | InferKeyword = 140 + | IntrinsicKeyword = 141 + | IsKeyword = 142 + | KeyOfKeyword = 143 + | ModuleKeyword = 144 + | NamespaceKeyword = 145 + | NeverKeyword = 146 + | OutKeyword = 147 + | ReadonlyKeyword = 148 + | RequireKeyword = 149 + | NumberKeyword = 150 + | ObjectKeyword = 151 + | SatisfiesKeyword = 152 + | SetKeyword = 153 + | StringKeyword = 154 + | SymbolKeyword = 155 + | TypeKeyword = 156 + | UndefinedKeyword = 157 + | UniqueKeyword = 158 + | UnknownKeyword = 159 + | FromKeyword = 160 + | GlobalKeyword = 161 + | BigIntKeyword = 162 + | OverrideKeyword = 163 + | OfKeyword = 164 + | QualifiedName = 165 + | ComputedPropertyName = 166 + | TypeParameter = 167 + | Parameter = 168 + | Decorator = 169 + | PropertySignature = 170 + | PropertyDeclaration = 171 + | MethodSignature = 172 + | MethodDeclaration = 173 + | ClassStaticBlockDeclaration = 174 + | Constructor = 175 + | GetAccessor = 176 + | SetAccessor = 177 + | CallSignature = 178 + | ConstructSignature = 179 + | IndexSignature = 180 + | TypePredicate = 181 + | TypeReference = 182 + | FunctionType = 183 + | ConstructorType = 184 + | TypeQuery = 185 + | TypeLiteral = 186 + | ArrayType = 187 + | TupleType = 188 + | OptionalType = 189 + | RestType = 190 + | UnionType = 191 + | IntersectionType = 192 + | ConditionalType = 193 + | InferType = 194 + | ParenthesizedType = 195 + | ThisType = 196 + | TypeOperator = 197 + | IndexedAccessType = 198 + | MappedType = 199 + | LiteralType = 200 + | NamedTupleMember = 201 + | TemplateLiteralType = 202 + | TemplateLiteralTypeSpan = 203 + | ImportType = 204 + | ObjectBindingPattern = 205 + | ArrayBindingPattern = 206 + | BindingElement = 207 + | ArrayLiteralExpression = 208 + | ObjectLiteralExpression = 209 + | PropertyAccessExpression = 210 + | ElementAccessExpression = 211 + | CallExpression = 212 + | NewExpression = 213 + | TaggedTemplateExpression = 214 + | TypeAssertionExpression = 215 + | ParenthesizedExpression = 216 + | FunctionExpression = 217 + | ArrowFunction = 218 + | DeleteExpression = 219 + | TypeOfExpression = 220 + | VoidExpression = 221 + | AwaitExpression = 222 + | PrefixUnaryExpression = 223 + | PostfixUnaryExpression = 224 + | BinaryExpression = 225 + | ConditionalExpression = 226 + | TemplateExpression = 227 + | YieldExpression = 228 + | SpreadElement = 229 + | ClassExpression = 230 + | OmittedExpression = 231 + | ExpressionWithTypeArguments = 232 + | AsExpression = 233 + | NonNullExpression = 234 + | MetaProperty = 235 + | SyntheticExpression = 236 + | SatisfiesExpression = 237 + | TemplateSpan = 238 + | SemicolonClassElement = 239 + | Block = 240 + | EmptyStatement = 241 + | VariableStatement = 242 + | ExpressionStatement = 243 + | IfStatement = 244 + | DoStatement = 245 + | WhileStatement = 246 + | ForStatement = 247 + | ForInStatement = 248 + | ForOfStatement = 249 + | ContinueStatement = 250 + | BreakStatement = 251 + | ReturnStatement = 252 + | WithStatement = 253 + | SwitchStatement = 254 + | LabeledStatement = 255 + | ThrowStatement = 256 + | TryStatement = 257 + | DebuggerStatement = 258 + | VariableDeclaration = 259 + | VariableDeclarationList = 260 + | FunctionDeclaration = 261 + | ClassDeclaration = 262 + | InterfaceDeclaration = 263 + | TypeAliasDeclaration = 264 + | EnumDeclaration = 265 + | ModuleDeclaration = 266 + | ModuleBlock = 267 + | CaseBlock = 268 + | NamespaceExportDeclaration = 269 + | ImportEqualsDeclaration = 270 + | ImportDeclaration = 271 + | ImportClause = 272 + | NamespaceImport = 273 + | NamedImports = 274 + | ImportSpecifier = 275 + | ExportAssignment = 276 + | ExportDeclaration = 277 + | NamedExports = 278 + | NamespaceExport = 279 + | ExportSpecifier = 280 + | MissingDeclaration = 281 + | ExternalModuleReference = 282 + | JsxElement = 283 + | JsxSelfClosingElement = 284 + | JsxOpeningElement = 285 + | JsxClosingElement = 286 + | JsxFragment = 287 + | JsxOpeningFragment = 288 + | JsxClosingFragment = 289 + | JsxAttribute = 290 + | JsxAttributes = 291 + | JsxSpreadAttribute = 292 + | JsxExpression = 293 + | JsxNamespacedName = 294 + | CaseClause = 295 + | DefaultClause = 296 + | HeritageClause = 297 + | CatchClause = 298 + | AssertClause = 299 + | AssertEntry = 300 + | ImportTypeAssertionContainer = 301 + | PropertyAssignment = 302 + | ShorthandPropertyAssignment = 303 + | SpreadAssignment = 304 + | EnumMember = 305 + /// + | UnparsedPrologue = 306 + /// + | UnparsedPrepend = 307 + /// + | UnparsedText = 308 + /// + | UnparsedInternalText = 309 + /// + | UnparsedSyntheticReference = 310 + | SourceFile = 311 + | Bundle = 312 + /// + | UnparsedSource = 313 + /// + | InputFiles = 314 + | JSDocTypeExpression = 315 + | JSDocNameReference = 316 + | JSDocMemberName = 317 + | JSDocAllType = 318 + | JSDocUnknownType = 319 + | JSDocNullableType = 320 + | JSDocNonNullableType = 321 + | JSDocOptionalType = 322 + | JSDocFunctionType = 323 + | JSDocVariadicType = 324 + | JSDocNamepathType = 325 + | JSDoc = 326 + /// Use SyntaxKind.JSDoc + | JSDocComment = 326 + | JSDocText = 327 + | JSDocTypeLiteral = 328 + | JSDocSignature = 329 + | JSDocLink = 330 + | JSDocLinkCode = 331 + | JSDocLinkPlain = 332 + | JSDocTag = 333 + | JSDocAugmentsTag = 334 + | JSDocImplementsTag = 335 + | JSDocAuthorTag = 336 + | JSDocDeprecatedTag = 337 + | JSDocClassTag = 338 + | JSDocPublicTag = 339 + | JSDocPrivateTag = 340 + | JSDocProtectedTag = 341 + | JSDocReadonlyTag = 342 + | JSDocOverrideTag = 343 + | JSDocCallbackTag = 344 + | JSDocOverloadTag = 345 + | JSDocEnumTag = 346 + | JSDocParameterTag = 347 + | JSDocReturnTag = 348 + | JSDocThisTag = 349 + | JSDocTypeTag = 350 + | JSDocTemplateTag = 351 + | JSDocTypedefTag = 352 + | JSDocSeeTag = 353 + | JSDocPropertyTag = 354 + | JSDocThrowsTag = 355 + | JSDocSatisfiesTag = 356 + | SyntaxList = 357 + | NotEmittedStatement = 358 + | PartiallyEmittedExpression = 359 + | CommaListExpression = 360 + | SyntheticReferenceExpression = 361 + | Count = 362 + | FirstAssignment = 64 + | LastAssignment = 79 + | FirstCompoundAssignment = 65 + | LastCompoundAssignment = 79 + | FirstReservedWord = 83 + | LastReservedWord = 118 + | FirstKeyword = 83 + | LastKeyword = 164 + | FirstFutureReservedWord = 119 + | LastFutureReservedWord = 127 + | FirstTypeNode = 181 + | LastTypeNode = 204 + | FirstPunctuation = 19 + | LastPunctuation = 79 | FirstToken = 0 - | LastToken = 159 + | LastToken = 164 | FirstTriviaToken = 2 | LastTriviaToken = 7 - | FirstLiteralToken = 8 - | LastLiteralToken = 14 - | FirstTemplateToken = 14 - | LastTemplateToken = 17 - | FirstBinaryOperator = 29 - | LastBinaryOperator = 78 - | FirstStatement = 236 - | LastStatement = 252 - | FirstNode = 160 - | FirstJSDocNode = 307 - | LastJSDocNode = 345 - | FirstJSDocTagNode = 325 - | LastJSDocTagNode = 345 - + | FirstLiteralToken = 9 + | LastLiteralToken = 15 + | FirstTemplateToken = 15 + | LastTemplateToken = 18 + | FirstBinaryOperator = 30 + | LastBinaryOperator = 79 + | FirstStatement = 242 + | LastStatement = 258 + | FirstNode = 165 + | FirstJSDocNode = 315 + | LastJSDocNode = 356 + | FirstJSDocTagNode = 333 + | LastJSDocTagNode = 356 + + /// + /// Original in TypeScript: + /// + /// SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia + /// + /// type TriviaSyntaxKind = SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral + /// + /// type LiteralSyntaxKind = SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail + /// + /// type PseudoLiteralSyntaxKind = SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.AmpersandAmpersandEqualsToken | SyntaxKind.BarBarToken | SyntaxKind.BarBarEqualsToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionQuestionEqualsToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken + /// + /// type PunctuationSyntaxKind = SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.AbstractKeyword | SyntaxKind.AccessorKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SatisfiesKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword + /// + /// type KeywordSyntaxKind = SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.AbstractKeyword | SyntaxKind.AccessorKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.InKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword + /// + /// type ModifierSyntaxKind = SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword + /// + /// type KeywordTypeSyntaxKind = SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | TriviaSyntaxKind | LiteralSyntaxKind | PseudoLiteralSyntaxKind | PunctuationSyntaxKind | SyntaxKind.Identifier | KeywordSyntaxKind + /// + /// type TokenSyntaxKind = - U6 + SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken + /// + /// type JsxTokenSyntaxKind = SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.Unknown | KeywordSyntaxKind + /// + /// type JSDocSyntaxKind = - U2 + SyntaxKind type [] NodeFlags = | None = 0 @@ -1566,16 +1406,17 @@ module Ts = | YieldContext = 8192 | DecoratorContext = 16384 | AwaitContext = 32768 - | ThisNodeHasError = 65536 - | JavaScriptFile = 131072 - | ThisNodeOrAnySubNodesHasError = 262144 - | HasAggregatedChildData = 524288 - | JSDoc = 4194304 - | JsonFile = 33554432 + | DisallowConditionalTypesContext = 65536 + | ThisNodeHasError = 131072 + | JavaScriptFile = 262144 + | ThisNodeOrAnySubNodesHasError = 524288 + | HasAggregatedChildData = 1048576 + | JSDoc = 8388608 + | JsonFile = 67108864 | BlockScoped = 3 | ReachabilityCheckFlags = 768 | ReachabilityAndEmitFlags = 2816 - | ContextFlags = 25358336 + | ContextFlags = 50720768 | TypeExcludesFlags = 40960 type [] ModifierFlags = @@ -1587,24 +1428,31 @@ module Ts = | Protected = 16 | Static = 32 | Readonly = 64 - | Abstract = 128 - | Async = 256 - | Default = 512 + | Accessor = 128 + | Abstract = 256 + | Async = 512 + | Default = 1024 | Const = 2048 | HasComputedJSDocModifiers = 4096 | Deprecated = 8192 | Override = 16384 + | In = 32768 + | Out = 65536 + | Decorator = 131072 | HasComputedFlags = 536870912 | AccessibilityModifier = 28 | ParameterPropertyModifier = 16476 | NonPublicAccessibilityModifier = 24 - | TypeScriptModifier = 18654 - | ExportDefault = 513 - | All = 27647 + | TypeScriptModifier = 117086 + | ExportDefault = 1025 + | All = 258047 + | Modifier = 126975 type [] JsxFlags = | None = 0 + /// An element from a named property of the JSX.IntrinsicElements interface | IntrinsicNamedElement = 1 + /// An element inferred from the string index signature of the JSX.IntrinsicElements interface | IntrinsicIndexedElement = 2 | IntrinsicElement = 3 @@ -1612,13 +1460,11 @@ module Ts = inherit ReadonlyTextRange abstract kind: SyntaxKind abstract flags: NodeFlags - abstract decorators: ResizeArray option - abstract modifiers: ModifiersArray option abstract parent: Node abstract getSourceFile: unit -> SourceFile abstract getChildCount: ?sourceFile: SourceFile -> float abstract getChildAt: index: float * ?sourceFile: SourceFile -> Node - abstract getChildren: ?sourceFile: SourceFile -> ResizeArray + abstract getChildren: ?sourceFile: SourceFile -> Node[] abstract getStart: ?sourceFile: SourceFile * ?includeJsDocComment: bool -> float abstract getFullStart: unit -> float abstract getEnd: unit -> float @@ -1629,27 +1475,202 @@ module Ts = abstract getText: ?sourceFile: SourceFile -> string abstract getFirstToken: ?sourceFile: SourceFile -> Node option abstract getLastToken: ?sourceFile: SourceFile -> Node option - abstract forEachChild: cbNode: (Node -> 'T option) * ?cbNodeArray: (ResizeArray -> 'T option) -> 'T option + abstract forEachChild: cbNode: (Node -> 'T option) * ?cbNodeArray: (Node[] -> 'T option) -> 'T option type [] JSDocContainer = - interface end - - type HasJSDoc = - obj - - type HasType = - obj + inherit Node + abstract _jsdocContainerBrand: obj option with get, set - type HasTypeArguments = - U5 + type [] LocalsContainer = + inherit Node + abstract _localsContainerBrand: obj option with get, set - type HasInitializer = - U5 + type [] FlowContainer = + inherit Node + abstract _flowContainerBrand: obj option with get, set - type HasExpressionInitializer = - U7 + type HasJSDoc = + obj - type [] NodeArray<'T> = + type [] [] HasType = + | [] ArrowFunction of ArrowFunction + | [] AsExpression of AsExpression + | [] CallSignatureDeclaration of CallSignatureDeclaration + | [] ConstructSignatureDeclaration of ConstructSignatureDeclaration + | [] ConstructorDeclaration of ConstructorDeclaration + | [] ConstructorTypeNode of ConstructorTypeNode + | [] FunctionDeclaration of FunctionDeclaration + | [] FunctionExpression of FunctionExpression + | [] FunctionTypeNode of FunctionTypeNode + | [] GetAccessorDeclaration of GetAccessorDeclaration + | [] IndexSignatureDeclaration of IndexSignatureDeclaration + | [] JSDocFunctionType of JSDocFunctionType + | [] JSDocNonNullableType of JSDocNonNullableType + | [] JSDocNullableType of JSDocNullableType + | [] JSDocOptionalType of JSDocOptionalType + | [] JSDocTypeExpression of JSDocTypeExpression + | [] JSDocVariadicType of JSDocVariadicType + | [] MappedTypeNode of MappedTypeNode + | [] MethodDeclaration of MethodDeclaration + | [] MethodSignature of MethodSignature + | [] ParameterDeclaration of ParameterDeclaration + | [] ParenthesizedTypeNode of ParenthesizedTypeNode + | [] PropertyDeclaration of PropertyDeclaration + | [] PropertySignature of PropertySignature + | [] SetAccessorDeclaration of SetAccessorDeclaration + | [] TypeAliasDeclaration of TypeAliasDeclaration + | [] TypeAssertion of TypeAssertion + | [] TypeOperatorNode of TypeOperatorNode + | [] TypePredicateNode of TypePredicateNode + | [] VariableDeclaration of VariableDeclaration + // static member inline op_ErasedCast(x: ArrowFunction) = ArrowFunction x + // static member inline op_ErasedCast(x: AsExpression) = AsExpression x + // static member inline op_ErasedCast(x: CallSignatureDeclaration) = CallSignatureDeclaration x + // static member inline op_ErasedCast(x: ConstructSignatureDeclaration) = ConstructSignatureDeclaration x + // static member inline op_ErasedCast(x: ConstructorDeclaration) = ConstructorDeclaration x + // static member inline op_ErasedCast(x: ConstructorTypeNode) = ConstructorTypeNode x + // static member inline op_ErasedCast(x: FunctionDeclaration) = FunctionDeclaration x + // static member inline op_ErasedCast(x: FunctionExpression) = FunctionExpression x + // static member inline op_ErasedCast(x: FunctionTypeNode) = FunctionTypeNode x + // static member inline op_ErasedCast(x: GetAccessorDeclaration) = GetAccessorDeclaration x + // static member inline op_ErasedCast(x: IndexSignatureDeclaration) = IndexSignatureDeclaration x + // static member inline op_ErasedCast(x: JSDocFunctionType) = JSDocFunctionType x + // static member inline op_ErasedCast(x: JSDocNonNullableType) = JSDocNonNullableType x + // static member inline op_ErasedCast(x: JSDocNullableType) = JSDocNullableType x + // static member inline op_ErasedCast(x: JSDocOptionalType) = JSDocOptionalType x + // static member inline op_ErasedCast(x: JSDocTypeExpression) = JSDocTypeExpression x + // static member inline op_ErasedCast(x: JSDocVariadicType) = JSDocVariadicType x + // static member inline op_ErasedCast(x: MappedTypeNode) = MappedTypeNode x + // static member inline op_ErasedCast(x: MethodDeclaration) = MethodDeclaration x + // static member inline op_ErasedCast(x: MethodSignature) = MethodSignature x + // static member inline op_ErasedCast(x: ParameterDeclaration) = ParameterDeclaration x + // static member inline op_ErasedCast(x: ParenthesizedTypeNode) = ParenthesizedTypeNode x + // static member inline op_ErasedCast(x: PropertyDeclaration) = PropertyDeclaration x + // static member inline op_ErasedCast(x: PropertySignature) = PropertySignature x + // static member inline op_ErasedCast(x: SetAccessorDeclaration) = SetAccessorDeclaration x + // static member inline op_ErasedCast(x: TypeAliasDeclaration) = TypeAliasDeclaration x + // static member inline op_ErasedCast(x: TypeAssertion) = TypeAssertion x + // static member inline op_ErasedCast(x: TypeOperatorNode) = TypeOperatorNode x + // static member inline op_ErasedCast(x: TypePredicateNode) = TypePredicateNode x + // static member inline op_ErasedCast(x: VariableDeclaration) = VariableDeclaration x + + type [] [] HasTypeArguments = + | [] CallExpression of CallExpression + | [] JsxOpeningElement of JsxOpeningElement + | [] JsxSelfClosingElement of JsxSelfClosingElement + | [] NewExpression of NewExpression + | [] TaggedTemplateExpression of TaggedTemplateExpression + // static member inline op_ErasedCast(x: CallExpression) = CallExpression x + // static member inline op_ErasedCast(x: JsxOpeningElement) = JsxOpeningElement x + // static member inline op_ErasedCast(x: JsxSelfClosingElement) = JsxSelfClosingElement x + // static member inline op_ErasedCast(x: NewExpression) = NewExpression x + // static member inline op_ErasedCast(x: TaggedTemplateExpression) = TaggedTemplateExpression x + + type [] [] HasInitializer = + | [] BindingElement of BindingElement + | [] EnumMember of EnumMember + | [] ForInStatement of ForInStatement + | [] ForOfStatement of ForOfStatement + | [] ForStatement of ForStatement + | [] JsxAttribute of JsxAttribute + | [] ParameterDeclaration of ParameterDeclaration + | [] PropertyAssignment of PropertyAssignment + | [] PropertyDeclaration of PropertyDeclaration + | [] VariableDeclaration of VariableDeclaration + // static member inline op_ErasedCast(x: BindingElement) = BindingElement x + // static member inline op_ErasedCast(x: EnumMember) = EnumMember x + // static member inline op_ErasedCast(x: ForInStatement) = ForInStatement x + // static member inline op_ErasedCast(x: ForOfStatement) = ForOfStatement x + // static member inline op_ErasedCast(x: ForStatement) = ForStatement x + // static member inline op_ErasedCast(x: JsxAttribute) = JsxAttribute x + // static member inline op_ErasedCast(x: ParameterDeclaration) = ParameterDeclaration x + // static member inline op_ErasedCast(x: PropertyAssignment) = PropertyAssignment x + // static member inline op_ErasedCast(x: PropertyDeclaration) = PropertyDeclaration x + // static member inline op_ErasedCast(x: VariableDeclaration) = VariableDeclaration x + + type [] [] HasExpressionInitializer = + | [] BindingElement of BindingElement + | [] EnumMember of EnumMember + | [] ParameterDeclaration of ParameterDeclaration + | [] PropertyAssignment of PropertyAssignment + | [] PropertyDeclaration of PropertyDeclaration + | [] VariableDeclaration of VariableDeclaration + // static member inline op_ErasedCast(x: BindingElement) = BindingElement x + // static member inline op_ErasedCast(x: EnumMember) = EnumMember x + // static member inline op_ErasedCast(x: ParameterDeclaration) = ParameterDeclaration x + // static member inline op_ErasedCast(x: PropertyAssignment) = PropertyAssignment x + // static member inline op_ErasedCast(x: PropertyDeclaration) = PropertyDeclaration x + // static member inline op_ErasedCast(x: VariableDeclaration) = VariableDeclaration x + + type [] [] HasDecorators = + | [] ClassDeclaration of ClassDeclaration + | [] ClassExpression of ClassExpression + | [] GetAccessorDeclaration of GetAccessorDeclaration + | [] MethodDeclaration of MethodDeclaration + | [] ParameterDeclaration of ParameterDeclaration + | [] PropertyDeclaration of PropertyDeclaration + | [] SetAccessorDeclaration of SetAccessorDeclaration + // static member inline op_ErasedCast(x: ClassDeclaration) = ClassDeclaration x + // static member inline op_ErasedCast(x: ClassExpression) = ClassExpression x + // static member inline op_ErasedCast(x: GetAccessorDeclaration) = GetAccessorDeclaration x + // static member inline op_ErasedCast(x: MethodDeclaration) = MethodDeclaration x + // static member inline op_ErasedCast(x: ParameterDeclaration) = ParameterDeclaration x + // static member inline op_ErasedCast(x: PropertyDeclaration) = PropertyDeclaration x + // static member inline op_ErasedCast(x: SetAccessorDeclaration) = SetAccessorDeclaration x + + type [] [] HasModifiers = + | [] ArrowFunction of ArrowFunction + | [] ClassDeclaration of ClassDeclaration + | [] ClassExpression of ClassExpression + | [] ConstructorDeclaration of ConstructorDeclaration + | [] ConstructorTypeNode of ConstructorTypeNode + | [] EnumDeclaration of EnumDeclaration + | [] ExportAssignment of ExportAssignment + | [] ExportDeclaration of ExportDeclaration + | [] FunctionDeclaration of FunctionDeclaration + | [] FunctionExpression of FunctionExpression + | [] GetAccessorDeclaration of GetAccessorDeclaration + | [] ImportDeclaration of ImportDeclaration + | [] ImportEqualsDeclaration of ImportEqualsDeclaration + | [] IndexSignatureDeclaration of IndexSignatureDeclaration + | [] InterfaceDeclaration of InterfaceDeclaration + | [] MethodDeclaration of MethodDeclaration + | [] MethodSignature of MethodSignature + | [] ModuleDeclaration of ModuleDeclaration + | [] ParameterDeclaration of ParameterDeclaration + | [] PropertyDeclaration of PropertyDeclaration + | [] PropertySignature of PropertySignature + | [] SetAccessorDeclaration of SetAccessorDeclaration + | [] TypeAliasDeclaration of TypeAliasDeclaration + | [] TypeParameterDeclaration of TypeParameterDeclaration + | [] VariableStatement of VariableStatement + // static member inline op_ErasedCast(x: ArrowFunction) = ArrowFunction x + // static member inline op_ErasedCast(x: ClassDeclaration) = ClassDeclaration x + // static member inline op_ErasedCast(x: ClassExpression) = ClassExpression x + // static member inline op_ErasedCast(x: ConstructorDeclaration) = ConstructorDeclaration x + // static member inline op_ErasedCast(x: ConstructorTypeNode) = ConstructorTypeNode x + // static member inline op_ErasedCast(x: EnumDeclaration) = EnumDeclaration x + // static member inline op_ErasedCast(x: ExportAssignment) = ExportAssignment x + // static member inline op_ErasedCast(x: ExportDeclaration) = ExportDeclaration x + // static member inline op_ErasedCast(x: FunctionDeclaration) = FunctionDeclaration x + // static member inline op_ErasedCast(x: FunctionExpression) = FunctionExpression x + // static member inline op_ErasedCast(x: GetAccessorDeclaration) = GetAccessorDeclaration x + // static member inline op_ErasedCast(x: ImportDeclaration) = ImportDeclaration x + // static member inline op_ErasedCast(x: ImportEqualsDeclaration) = ImportEqualsDeclaration x + // static member inline op_ErasedCast(x: IndexSignatureDeclaration) = IndexSignatureDeclaration x + // static member inline op_ErasedCast(x: InterfaceDeclaration) = InterfaceDeclaration x + // static member inline op_ErasedCast(x: MethodDeclaration) = MethodDeclaration x + // static member inline op_ErasedCast(x: MethodSignature) = MethodSignature x + // static member inline op_ErasedCast(x: ModuleDeclaration) = ModuleDeclaration x + // static member inline op_ErasedCast(x: ParameterDeclaration) = ParameterDeclaration x + // static member inline op_ErasedCast(x: PropertyDeclaration) = PropertyDeclaration x + // static member inline op_ErasedCast(x: PropertySignature) = PropertySignature x + // static member inline op_ErasedCast(x: SetAccessorDeclaration) = SetAccessorDeclaration x + // static member inline op_ErasedCast(x: TypeAliasDeclaration) = TypeAliasDeclaration x + // static member inline op_ErasedCast(x: TypeParameterDeclaration) = TypeParameterDeclaration x + // static member inline op_ErasedCast(x: VariableStatement) = VariableStatement x + + type [] NodeArray<'T > = inherit ReadonlyArray<'T> inherit ReadonlyTextRange abstract hasTrailingComma: bool @@ -1664,113 +1685,409 @@ module Ts = type [] PunctuationToken<'TKind> = inherit Token<'TKind> + /// + /// Original in TypeScript: + /// + /// PunctuationToken<SyntaxKind.DotToken> + /// + /// type DotToken = PunctuationToken + /// + /// Original in TypeScript: + /// + /// PunctuationToken<SyntaxKind.DotDotDotToken> + /// + /// type DotDotDotToken = PunctuationToken + /// + /// Original in TypeScript: + /// + /// PunctuationToken<SyntaxKind.QuestionToken> + /// + /// type QuestionToken = PunctuationToken + /// + /// Original in TypeScript: + /// + /// PunctuationToken<SyntaxKind.ExclamationToken> + /// + /// type ExclamationToken = PunctuationToken + /// + /// Original in TypeScript: + /// + /// PunctuationToken<SyntaxKind.ColonToken> + /// + /// type ColonToken = PunctuationToken + /// + /// Original in TypeScript: + /// + /// PunctuationToken<SyntaxKind.EqualsToken> + /// + /// type EqualsToken = PunctuationToken + /// + /// Original in TypeScript: + /// + /// PunctuationToken<SyntaxKind.AmpersandAmpersandEqualsToken> + /// + /// + type AmpersandAmpersandEqualsToken = + PunctuationToken + + /// + /// Original in TypeScript: + /// + /// PunctuationToken<SyntaxKind.BarBarEqualsToken> + /// + /// + type BarBarEqualsToken = + PunctuationToken + + /// + /// Original in TypeScript: + /// + /// PunctuationToken<SyntaxKind.QuestionQuestionEqualsToken> + /// + /// + type QuestionQuestionEqualsToken = + PunctuationToken + + /// + /// Original in TypeScript: + /// + /// PunctuationToken<SyntaxKind.AsteriskToken> + /// + /// type AsteriskToken = PunctuationToken + /// + /// Original in TypeScript: + /// + /// PunctuationToken<SyntaxKind.EqualsGreaterThanToken> + /// + /// type EqualsGreaterThanToken = PunctuationToken + /// + /// Original in TypeScript: + /// + /// PunctuationToken<SyntaxKind.PlusToken> + /// + /// type PlusToken = PunctuationToken + /// + /// Original in TypeScript: + /// + /// PunctuationToken<SyntaxKind.MinusToken> + /// + /// type MinusToken = PunctuationToken + /// + /// Original in TypeScript: + /// + /// PunctuationToken<SyntaxKind.QuestionDotToken> + /// + /// type QuestionDotToken = PunctuationToken type [] KeywordToken<'TKind> = inherit Token<'TKind> + /// + /// Original in TypeScript: + /// + /// KeywordToken<SyntaxKind.AssertsKeyword> + /// + /// type AssertsKeyword = KeywordToken + /// + /// Original in TypeScript: + /// + /// KeywordToken<SyntaxKind.AssertKeyword> + /// + /// type AssertKeyword = KeywordToken + /// + /// Original in TypeScript: + /// + /// KeywordToken<SyntaxKind.AwaitKeyword> + /// + /// type AwaitKeyword = KeywordToken - type AwaitKeywordToken = - AwaitKeyword - - type AssertsToken = - AssertsKeyword + /// + /// Original in TypeScript: + /// + /// KeywordToken<SyntaxKind.CaseKeyword> + /// + /// + type CaseKeyword = + KeywordToken type [] ModifierToken<'TKind> = inherit KeywordToken<'TKind> + /// + /// Original in TypeScript: + /// + /// ModifierToken<SyntaxKind.AbstractKeyword> + /// + /// type AbstractKeyword = ModifierToken + /// + /// Original in TypeScript: + /// + /// ModifierToken<SyntaxKind.AccessorKeyword> + /// + /// + type AccessorKeyword = + ModifierToken + + /// + /// Original in TypeScript: + /// + /// ModifierToken<SyntaxKind.AsyncKeyword> + /// + /// type AsyncKeyword = ModifierToken + /// + /// Original in TypeScript: + /// + /// ModifierToken<SyntaxKind.ConstKeyword> + /// + /// type ConstKeyword = ModifierToken + /// + /// Original in TypeScript: + /// + /// ModifierToken<SyntaxKind.DeclareKeyword> + /// + /// type DeclareKeyword = ModifierToken + /// + /// Original in TypeScript: + /// + /// ModifierToken<SyntaxKind.DefaultKeyword> + /// + /// type DefaultKeyword = ModifierToken + /// + /// Original in TypeScript: + /// + /// ModifierToken<SyntaxKind.ExportKeyword> + /// + /// type ExportKeyword = ModifierToken + /// + /// Original in TypeScript: + /// + /// ModifierToken<SyntaxKind.InKeyword> + /// + /// + type InKeyword = + ModifierToken + + /// + /// Original in TypeScript: + /// + /// ModifierToken<SyntaxKind.PrivateKeyword> + /// + /// type PrivateKeyword = ModifierToken + /// + /// Original in TypeScript: + /// + /// ModifierToken<SyntaxKind.ProtectedKeyword> + /// + /// type ProtectedKeyword = ModifierToken + /// + /// Original in TypeScript: + /// + /// ModifierToken<SyntaxKind.PublicKeyword> + /// + /// type PublicKeyword = ModifierToken + /// + /// Original in TypeScript: + /// + /// ModifierToken<SyntaxKind.ReadonlyKeyword> + /// + /// type ReadonlyKeyword = ModifierToken + /// + /// Original in TypeScript: + /// + /// ModifierToken<SyntaxKind.OutKeyword> + /// + /// + type OutKeyword = + ModifierToken + + /// + /// Original in TypeScript: + /// + /// ModifierToken<SyntaxKind.OverrideKeyword> + /// + /// type OverrideKeyword = ModifierToken + /// + /// Original in TypeScript: + /// + /// ModifierToken<SyntaxKind.StaticKeyword> + /// + /// type StaticKeyword = ModifierToken - type ReadonlyToken = - ReadonlyKeyword - - type Modifier = - Token - - type AccessibilityModifier = - U3 - - type ParameterPropertyModifier = - U2 - - type ClassMemberModifier = - U3 + type [] [] Modifier = + | [] AbstractKeyword of AbstractKeyword + | [] AccessorKeyword of AccessorKeyword + | [] AsyncKeyword of AsyncKeyword + | [] ConstKeyword of ConstKeyword + | [] DeclareKeyword of DeclareKeyword + | [] DefaultKeyword of DefaultKeyword + | [] ExportKeyword of ExportKeyword + | [] InKeyword of InKeyword + | [] OutKeyword of OutKeyword + | [] OverrideKeyword of OverrideKeyword + | [] PrivateKeyword of PrivateKeyword + | [] ProtectedKeyword of ProtectedKeyword + | [] PublicKeyword of PublicKeyword + | [] ReadonlyKeyword of ReadonlyKeyword + | [] StaticKeyword of StaticKeyword + // static member inline op_ErasedCast(x: AbstractKeyword) = AbstractKeyword x + // static member inline op_ErasedCast(x: AccessorKeyword) = AccessorKeyword x + // static member inline op_ErasedCast(x: AsyncKeyword) = AsyncKeyword x + // static member inline op_ErasedCast(x: ConstKeyword) = ConstKeyword x + // static member inline op_ErasedCast(x: DeclareKeyword) = DeclareKeyword x + // static member inline op_ErasedCast(x: DefaultKeyword) = DefaultKeyword x + // static member inline op_ErasedCast(x: ExportKeyword) = ExportKeyword x + // static member inline op_ErasedCast(x: InKeyword) = InKeyword x + // static member inline op_ErasedCast(x: OutKeyword) = OutKeyword x + // static member inline op_ErasedCast(x: OverrideKeyword) = OverrideKeyword x + // static member inline op_ErasedCast(x: PrivateKeyword) = PrivateKeyword x + // static member inline op_ErasedCast(x: ProtectedKeyword) = ProtectedKeyword x + // static member inline op_ErasedCast(x: PublicKeyword) = PublicKeyword x + // static member inline op_ErasedCast(x: ReadonlyKeyword) = ReadonlyKeyword x + // static member inline op_ErasedCast(x: StaticKeyword) = StaticKeyword x + + type [] [] ModifierLike = + | [] AbstractKeyword of AbstractKeyword + | [] AccessorKeyword of AccessorKeyword + | [] AsyncKeyword of AsyncKeyword + | [] ConstKeyword of ConstKeyword + | [] DeclareKeyword of DeclareKeyword + | [] Decorator of Decorator + | [] DefaultKeyword of DefaultKeyword + | [] ExportKeyword of ExportKeyword + | [] InKeyword of InKeyword + | [] OutKeyword of OutKeyword + | [] OverrideKeyword of OverrideKeyword + | [] PrivateKeyword of PrivateKeyword + | [] ProtectedKeyword of ProtectedKeyword + | [] PublicKeyword of PublicKeyword + | [] ReadonlyKeyword of ReadonlyKeyword + | [] StaticKeyword of StaticKeyword + // static member inline op_ErasedCast(x: AbstractKeyword) = AbstractKeyword x + // static member inline op_ErasedCast(x: AccessorKeyword) = AccessorKeyword x + // static member inline op_ErasedCast(x: AsyncKeyword) = AsyncKeyword x + // static member inline op_ErasedCast(x: ConstKeyword) = ConstKeyword x + // static member inline op_ErasedCast(x: DeclareKeyword) = DeclareKeyword x + // static member inline op_ErasedCast(x: Decorator) = Decorator x + // static member inline op_ErasedCast(x: DefaultKeyword) = DefaultKeyword x + // static member inline op_ErasedCast(x: ExportKeyword) = ExportKeyword x + // static member inline op_ErasedCast(x: InKeyword) = InKeyword x + // static member inline op_ErasedCast(x: OutKeyword) = OutKeyword x + // static member inline op_ErasedCast(x: OverrideKeyword) = OverrideKeyword x + // static member inline op_ErasedCast(x: PrivateKeyword) = PrivateKeyword x + // static member inline op_ErasedCast(x: ProtectedKeyword) = ProtectedKeyword x + // static member inline op_ErasedCast(x: PublicKeyword) = PublicKeyword x + // static member inline op_ErasedCast(x: ReadonlyKeyword) = ReadonlyKeyword x + // static member inline op_ErasedCast(x: StaticKeyword) = StaticKeyword x + + type [] [] AccessibilityModifier = + | [] PrivateKeyword of PrivateKeyword + | [] ProtectedKeyword of ProtectedKeyword + | [] PublicKeyword of PublicKeyword + // static member inline op_ErasedCast(x: PrivateKeyword) = PrivateKeyword x + // static member inline op_ErasedCast(x: ProtectedKeyword) = ProtectedKeyword x + // static member inline op_ErasedCast(x: PublicKeyword) = PublicKeyword x + + type [] [] ParameterPropertyModifier = + | [] PrivateKeyword of PrivateKeyword + | [] ProtectedKeyword of ProtectedKeyword + | [] PublicKeyword of PublicKeyword + | [] ReadonlyKeyword of ReadonlyKeyword + // static member inline op_ErasedCast(x: PrivateKeyword) = PrivateKeyword x + // static member inline op_ErasedCast(x: ProtectedKeyword) = ProtectedKeyword x + // static member inline op_ErasedCast(x: PublicKeyword) = PublicKeyword x + // static member inline op_ErasedCast(x: ReadonlyKeyword) = ReadonlyKeyword x + + type [] [] ClassMemberModifier = + | [] AccessorKeyword of AccessorKeyword + | [] PrivateKeyword of PrivateKeyword + | [] ProtectedKeyword of ProtectedKeyword + | [] PublicKeyword of PublicKeyword + | [] ReadonlyKeyword of ReadonlyKeyword + | [] StaticKeyword of StaticKeyword + // static member inline op_ErasedCast(x: AccessorKeyword) = AccessorKeyword x + // static member inline op_ErasedCast(x: PrivateKeyword) = PrivateKeyword x + // static member inline op_ErasedCast(x: ProtectedKeyword) = ProtectedKeyword x + // static member inline op_ErasedCast(x: PublicKeyword) = PublicKeyword x + // static member inline op_ErasedCast(x: ReadonlyKeyword) = ReadonlyKeyword x + // static member inline op_ErasedCast(x: StaticKeyword) = StaticKeyword x type ModifiersArray = - ResizeArray + Modifier[] type [] GeneratedIdentifierFlags = | None = 0 @@ -1782,12 +2099,14 @@ module Ts = type [] Identifier = inherit PrimaryExpression inherit Declaration + inherit JSDocContainer + inherit FlowContainer abstract kind: SyntaxKind - /// Prefer to use `id.unescapedText`. (Note: This is available only in services, not internally to the TypeScript compiler.) + /// + /// Prefer to use id.unescapedText. (Note: This is available only in services, not internally to the TypeScript compiler.) /// Text of identifier, but if the identifier begins with two underscores, this will begin with three. + /// abstract escapedText: __String - abstract originalKeywordKind: SyntaxKind option - abstract isInJSDocNamespace: bool option with get, set abstract text: string type [] TransientIdentifier = @@ -1796,21 +2115,58 @@ module Ts = type [] QualifiedName = inherit Node + inherit FlowContainer abstract kind: SyntaxKind abstract left: EntityName abstract right: Identifier - type EntityName = - U2 - - type PropertyName = - U5 - - type MemberName = - U2 - - type DeclarationName = - U8 + type [] [] EntityName = + | [] Identifier of Identifier + | [] QualifiedName of QualifiedName + // static member inline op_ErasedCast(x: Identifier) = Identifier x + // static member inline op_ErasedCast(x: QualifiedName) = QualifiedName x + + type [] [] PropertyName = + | [] ComputedPropertyName of ComputedPropertyName + | [] Identifier of Identifier + | [] NumericLiteral of NumericLiteral + | [] PrivateIdentifier of PrivateIdentifier + | [] StringLiteral of StringLiteral + // static member inline op_ErasedCast(x: ComputedPropertyName) = ComputedPropertyName x + // static member inline op_ErasedCast(x: Identifier) = Identifier x + // static member inline op_ErasedCast(x: NumericLiteral) = NumericLiteral x + // static member inline op_ErasedCast(x: PrivateIdentifier) = PrivateIdentifier x + // static member inline op_ErasedCast(x: StringLiteral) = StringLiteral x + + type [] [] MemberName = + | [] Identifier of Identifier + | [] PrivateIdentifier of PrivateIdentifier + // static member inline op_ErasedCast(x: Identifier) = Identifier x + // static member inline op_ErasedCast(x: PrivateIdentifier) = PrivateIdentifier x + + type [] [] DeclarationName = + | [] ArrayBindingPattern of ArrayBindingPattern + | [] ComputedPropertyName of ComputedPropertyName + | [] ElementAccessExpression of ElementAccessExpression + | [] Identifier of Identifier + | [] JsxNamespacedName of JsxNamespacedName + | [] NoSubstitutionTemplateLiteral of NoSubstitutionTemplateLiteral + | [] NumericLiteral of NumericLiteral + | [] ObjectBindingPattern of ObjectBindingPattern + | [] PrivateIdentifier of PrivateIdentifier + | [] PropertyAccessEntityNameExpression of PropertyAccessEntityNameExpression + | [] StringLiteral of StringLiteral + // static member inline op_ErasedCast(x: ArrayBindingPattern) = ArrayBindingPattern x + // static member inline op_ErasedCast(x: ComputedPropertyName) = ComputedPropertyName x + // static member inline op_ErasedCast(x: ElementAccessExpression) = ElementAccessExpression x + // static member inline op_ErasedCast(x: Identifier) = Identifier x + // static member inline op_ErasedCast(x: JsxNamespacedName) = JsxNamespacedName x + // static member inline op_ErasedCast(x: NoSubstitutionTemplateLiteral) = NoSubstitutionTemplateLiteral x + // static member inline op_ErasedCast(x: NumericLiteral) = NumericLiteral x + // static member inline op_ErasedCast(x: ObjectBindingPattern) = ObjectBindingPattern x + // static member inline op_ErasedCast(x: PrivateIdentifier) = PrivateIdentifier x + // static member inline op_ErasedCast(x: PropertyAccessEntityNameExpression) = PropertyAccessEntityNameExpression x + // static member inline op_ErasedCast(x: StringLiteral) = StringLiteral x type [] Declaration = inherit Node @@ -1845,10 +2201,12 @@ module Ts = type [] TypeParameterDeclaration = inherit NamedDeclaration + inherit JSDocContainer abstract kind: SyntaxKind abstract parent: U2 + abstract modifiers: Modifier[] option abstract name: Identifier - /// Note: Consider calling `getEffectiveConstraintOfTypeParameter` + /// Note: Consider calling getEffectiveConstraintOfTypeParameter abstract ``constraint``: TypeNode option abstract ``default``: TypeNode option abstract expression: Expression option with get, set @@ -1856,27 +2214,61 @@ module Ts = type [] SignatureDeclarationBase = inherit NamedDeclaration inherit JSDocContainer - abstract kind: SignatureDeclaration + abstract kind: obj abstract name: PropertyName option - abstract typeParameters: ResizeArray option - abstract parameters: ResizeArray + abstract typeParameters: TypeParameterDeclaration[] option + abstract parameters: ParameterDeclaration[] abstract ``type``: TypeNode option - type SignatureDeclaration = - obj + type [] [] SignatureDeclaration = + | [] ArrowFunction of ArrowFunction + | [] CallSignatureDeclaration of CallSignatureDeclaration + | [] ConstructSignatureDeclaration of ConstructSignatureDeclaration + | [] ConstructorDeclaration of ConstructorDeclaration + | [] ConstructorTypeNode of ConstructorTypeNode + | [] FunctionDeclaration of FunctionDeclaration + | [] FunctionExpression of FunctionExpression + | [] FunctionTypeNode of FunctionTypeNode + | [] GetAccessorDeclaration of GetAccessorDeclaration + | [] IndexSignatureDeclaration of IndexSignatureDeclaration + | [] JSDocFunctionType of JSDocFunctionType + | [] MethodDeclaration of MethodDeclaration + | [] MethodSignature of MethodSignature + | [] SetAccessorDeclaration of SetAccessorDeclaration + // static member inline op_ErasedCast(x: ArrowFunction) = ArrowFunction x + // static member inline op_ErasedCast(x: CallSignatureDeclaration) = CallSignatureDeclaration x + // static member inline op_ErasedCast(x: ConstructSignatureDeclaration) = ConstructSignatureDeclaration x + // static member inline op_ErasedCast(x: ConstructorDeclaration) = ConstructorDeclaration x + // static member inline op_ErasedCast(x: ConstructorTypeNode) = ConstructorTypeNode x + // static member inline op_ErasedCast(x: FunctionDeclaration) = FunctionDeclaration x + // static member inline op_ErasedCast(x: FunctionExpression) = FunctionExpression x + // static member inline op_ErasedCast(x: FunctionTypeNode) = FunctionTypeNode x + // static member inline op_ErasedCast(x: GetAccessorDeclaration) = GetAccessorDeclaration x + // static member inline op_ErasedCast(x: IndexSignatureDeclaration) = IndexSignatureDeclaration x + // static member inline op_ErasedCast(x: JSDocFunctionType) = JSDocFunctionType x + // static member inline op_ErasedCast(x: MethodDeclaration) = MethodDeclaration x + // static member inline op_ErasedCast(x: MethodSignature) = MethodSignature x + // static member inline op_ErasedCast(x: SetAccessorDeclaration) = SetAccessorDeclaration x type [] CallSignatureDeclaration = inherit SignatureDeclarationBase inherit TypeElement + inherit LocalsContainer abstract kind: SyntaxKind type [] ConstructSignatureDeclaration = inherit SignatureDeclarationBase inherit TypeElement + inherit LocalsContainer abstract kind: SyntaxKind - type BindingName = - U2 + type [] [] BindingName = + | [] ArrayBindingPattern of ArrayBindingPattern + | [] Identifier of Identifier + | [] ObjectBindingPattern of ObjectBindingPattern + // static member inline op_ErasedCast(x: ArrayBindingPattern) = ArrayBindingPattern x + // static member inline op_ErasedCast(x: Identifier) = Identifier x + // static member inline op_ErasedCast(x: ObjectBindingPattern) = ObjectBindingPattern x type [] VariableDeclaration = inherit NamedDeclaration @@ -1892,13 +2284,14 @@ module Ts = inherit Node abstract kind: SyntaxKind abstract parent: U4 - abstract declarations: ResizeArray + abstract declarations: VariableDeclaration[] type [] ParameterDeclaration = inherit NamedDeclaration inherit JSDocContainer abstract kind: SyntaxKind abstract parent: SignatureDeclaration + abstract modifiers: ModifierLike[] option abstract dotDotDotToken: DotDotDotToken option abstract name: BindingName abstract questionToken: QuestionToken option @@ -1907,6 +2300,7 @@ module Ts = type [] BindingElement = inherit NamedDeclaration + inherit FlowContainer abstract kind: SyntaxKind abstract parent: BindingPattern abstract propertyName: PropertyName option @@ -1918,29 +2312,47 @@ module Ts = inherit TypeElement inherit JSDocContainer abstract kind: SyntaxKind + abstract parent: U2 + abstract modifiers: Modifier[] option abstract name: PropertyName abstract questionToken: QuestionToken option abstract ``type``: TypeNode option - abstract initializer: Expression option with get, set type [] PropertyDeclaration = inherit ClassElement inherit JSDocContainer abstract kind: SyntaxKind abstract parent: ClassLikeDeclaration + abstract modifiers: ModifierLike[] option abstract name: PropertyName abstract questionToken: QuestionToken option abstract exclamationToken: ExclamationToken option abstract ``type``: TypeNode option abstract initializer: Expression option + type [] AutoAccessorPropertyDeclaration = + inherit PropertyDeclaration + abstract _autoAccessorBrand: obj option with get, set + type [] ObjectLiteralElement = inherit NamedDeclaration abstract _objectLiteralBrand: obj option with get, set abstract name: PropertyName option - type ObjectLiteralElementLike = - U5 + /// Unlike ObjectLiteralElement, excludes JSXAttribute and JSXSpreadAttribute. + type [] [] ObjectLiteralElementLike = + | [] GetAccessorDeclaration of GetAccessorDeclaration + | [] MethodDeclaration of MethodDeclaration + | [] PropertyAssignment of PropertyAssignment + | [] SetAccessorDeclaration of SetAccessorDeclaration + | [] ShorthandPropertyAssignment of ShorthandPropertyAssignment + | [] SpreadAssignment of SpreadAssignment + // static member inline op_ErasedCast(x: GetAccessorDeclaration) = GetAccessorDeclaration x + // static member inline op_ErasedCast(x: MethodDeclaration) = MethodDeclaration x + // static member inline op_ErasedCast(x: PropertyAssignment) = PropertyAssignment x + // static member inline op_ErasedCast(x: SetAccessorDeclaration) = SetAccessorDeclaration x + // static member inline op_ErasedCast(x: ShorthandPropertyAssignment) = ShorthandPropertyAssignment x + // static member inline op_ErasedCast(x: SpreadAssignment) = SpreadAssignment x type [] PropertyAssignment = inherit ObjectLiteralElement @@ -1948,8 +2360,6 @@ module Ts = abstract kind: SyntaxKind abstract parent: ObjectLiteralExpression abstract name: PropertyName - abstract questionToken: QuestionToken option - abstract exclamationToken: ExclamationToken option abstract initializer: Expression type [] ShorthandPropertyAssignment = @@ -1958,8 +2368,6 @@ module Ts = abstract kind: SyntaxKind abstract parent: ObjectLiteralExpression abstract name: Identifier - abstract questionToken: QuestionToken option - abstract exclamationToken: ExclamationToken option abstract equalsToken: EqualsToken option abstract objectAssignmentInitializer: Expression option @@ -1970,30 +2378,53 @@ module Ts = abstract parent: ObjectLiteralExpression abstract expression: Expression - type VariableLikeDeclaration = - obj - - type [] PropertyLikeDeclaration = - inherit NamedDeclaration - abstract name: PropertyName + type [] [] VariableLikeDeclaration = + | [] BindingElement of BindingElement + | [] EnumMember of EnumMember + | [] JSDocParameterTag of JSDocParameterTag + | [] JSDocPropertyTag of JSDocPropertyTag + | [] JsxAttribute of JsxAttribute + | [] ParameterDeclaration of ParameterDeclaration + | [] PropertyAssignment of PropertyAssignment + | [] PropertyDeclaration of PropertyDeclaration + | [] PropertySignature of PropertySignature + | [] ShorthandPropertyAssignment of ShorthandPropertyAssignment + | [] VariableDeclaration of VariableDeclaration + // static member inline op_ErasedCast(x: BindingElement) = BindingElement x + // static member inline op_ErasedCast(x: EnumMember) = EnumMember x + // static member inline op_ErasedCast(x: JSDocParameterTag) = JSDocParameterTag x + // static member inline op_ErasedCast(x: JSDocPropertyTag) = JSDocPropertyTag x + // static member inline op_ErasedCast(x: JsxAttribute) = JsxAttribute x + // static member inline op_ErasedCast(x: ParameterDeclaration) = ParameterDeclaration x + // static member inline op_ErasedCast(x: PropertyAssignment) = PropertyAssignment x + // static member inline op_ErasedCast(x: PropertyDeclaration) = PropertyDeclaration x + // static member inline op_ErasedCast(x: PropertySignature) = PropertySignature x + // static member inline op_ErasedCast(x: ShorthandPropertyAssignment) = ShorthandPropertyAssignment x + // static member inline op_ErasedCast(x: VariableDeclaration) = VariableDeclaration x type [] ObjectBindingPattern = inherit Node abstract kind: SyntaxKind abstract parent: U3 - abstract elements: ResizeArray + abstract elements: BindingElement[] type [] ArrayBindingPattern = inherit Node abstract kind: SyntaxKind abstract parent: U3 - abstract elements: ResizeArray + abstract elements: ArrayBindingElement[] - type BindingPattern = - U2 + type [] [] BindingPattern = + | [] ArrayBindingPattern of ArrayBindingPattern + | [] ObjectBindingPattern of ObjectBindingPattern + // static member inline op_ErasedCast(x: ArrayBindingPattern) = ArrayBindingPattern x + // static member inline op_ErasedCast(x: ObjectBindingPattern) = ObjectBindingPattern x - type ArrayBindingElement = - U2 + type [] [] ArrayBindingElement = + | [] BindingElement of BindingElement + | [] OmittedExpression of OmittedExpression + // static member inline op_ErasedCast(x: BindingElement) = BindingElement x + // static member inline op_ErasedCast(x: OmittedExpression) = OmittedExpression x /// Several node kinds share function-like features such as a signature, /// a name, and a body. These nodes should extend FunctionLikeDeclarationBase. @@ -2009,24 +2440,42 @@ module Ts = abstract exclamationToken: ExclamationToken option abstract body: U2 option - type FunctionLikeDeclaration = - U7 - + type [] [] FunctionLikeDeclaration = + | [] ArrowFunction of ArrowFunction + | [] ConstructorDeclaration of ConstructorDeclaration + | [] FunctionDeclaration of FunctionDeclaration + | [] FunctionExpression of FunctionExpression + | [] GetAccessorDeclaration of GetAccessorDeclaration + | [] MethodDeclaration of MethodDeclaration + | [] SetAccessorDeclaration of SetAccessorDeclaration + // static member inline op_ErasedCast(x: ArrowFunction) = ArrowFunction x + // static member inline op_ErasedCast(x: ConstructorDeclaration) = ConstructorDeclaration x + // static member inline op_ErasedCast(x: FunctionDeclaration) = FunctionDeclaration x + // static member inline op_ErasedCast(x: FunctionExpression) = FunctionExpression x + // static member inline op_ErasedCast(x: GetAccessorDeclaration) = GetAccessorDeclaration x + // static member inline op_ErasedCast(x: MethodDeclaration) = MethodDeclaration x + // static member inline op_ErasedCast(x: SetAccessorDeclaration) = SetAccessorDeclaration x + + [] type FunctionLike = SignatureDeclaration type [] FunctionDeclaration = inherit FunctionLikeDeclarationBase inherit DeclarationStatement + inherit LocalsContainer abstract kind: SyntaxKind + abstract modifiers: ModifierLike[] option abstract name: Identifier option abstract body: FunctionBody option type [] MethodSignature = inherit SignatureDeclarationBase inherit TypeElement + inherit LocalsContainer abstract kind: SyntaxKind - abstract parent: ObjectTypeDeclaration + abstract parent: U2 + abstract modifiers: Modifier[] option abstract name: PropertyName type [] MethodDeclaration = @@ -2034,8 +2483,11 @@ module Ts = inherit ClassElement inherit ObjectLiteralElement inherit JSDocContainer + inherit LocalsContainer + inherit FlowContainer abstract kind: SyntaxKind abstract parent: U2 + abstract modifiers: ModifierLike[] option abstract name: PropertyName abstract body: FunctionBody option @@ -2043,13 +2495,16 @@ module Ts = inherit FunctionLikeDeclarationBase inherit ClassElement inherit JSDocContainer + inherit LocalsContainer abstract kind: SyntaxKind abstract parent: ClassLikeDeclaration + abstract modifiers: ModifierLike[] option abstract body: FunctionBody option /// For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. type [] SemicolonClassElement = inherit ClassElement + inherit JSDocContainer abstract kind: SyntaxKind abstract parent: ClassLikeDeclaration @@ -2059,8 +2514,11 @@ module Ts = inherit TypeElement inherit ObjectLiteralElement inherit JSDocContainer + inherit LocalsContainer + inherit FlowContainer abstract kind: SyntaxKind abstract parent: U4 + abstract modifiers: ModifierLike[] option abstract name: PropertyName abstract body: FunctionBody option @@ -2070,25 +2528,34 @@ module Ts = inherit TypeElement inherit ObjectLiteralElement inherit JSDocContainer + inherit LocalsContainer + inherit FlowContainer abstract kind: SyntaxKind abstract parent: U4 + abstract modifiers: ModifierLike[] option abstract name: PropertyName abstract body: FunctionBody option - type AccessorDeclaration = - U2 + type [] [] AccessorDeclaration = + | [] GetAccessorDeclaration of GetAccessorDeclaration + | [] SetAccessorDeclaration of SetAccessorDeclaration + // static member inline op_ErasedCast(x: GetAccessorDeclaration) = GetAccessorDeclaration x + // static member inline op_ErasedCast(x: SetAccessorDeclaration) = SetAccessorDeclaration x type [] IndexSignatureDeclaration = inherit SignatureDeclarationBase inherit ClassElement inherit TypeElement + inherit LocalsContainer abstract kind: SyntaxKind abstract parent: ObjectTypeDeclaration + abstract modifiers: ModifierLike[] option abstract ``type``: TypeNode type [] ClassStaticBlockDeclaration = inherit ClassElement inherit JSDocContainer + inherit LocalsContainer abstract kind: SyntaxKind abstract parent: U2 abstract body: Block @@ -2098,26 +2565,37 @@ module Ts = abstract _typeNodeBrand: obj option with get, set type KeywordTypeNode = - KeywordTypeNode + KeywordTypeNode type [] KeywordTypeNode<'TKind> = inherit KeywordToken<'TKind> inherit TypeNode abstract kind: 'TKind + type [] ImportTypeAssertionContainer = + inherit Node + abstract kind: SyntaxKind + abstract parent: ImportTypeNode + abstract assertClause: AssertClause + abstract multiLine: bool option + type [] ImportTypeNode = inherit NodeWithTypeArguments abstract kind: SyntaxKind abstract isTypeOf: bool abstract argument: TypeNode + abstract assertions: ImportTypeAssertionContainer option abstract qualifier: EntityName option type [] ThisTypeNode = inherit TypeNode abstract kind: SyntaxKind - type FunctionOrConstructorTypeNode = - U2 + type [] [] FunctionOrConstructorTypeNode = + | [] ConstructorTypeNode of ConstructorTypeNode + | [] FunctionTypeNode of FunctionTypeNode + // static member inline op_ErasedCast(x: ConstructorTypeNode) = ConstructorTypeNode x + // static member inline op_ErasedCast(x: FunctionTypeNode) = FunctionTypeNode x type [] FunctionOrConstructorTypeNodeBase = inherit TypeNode @@ -2127,18 +2605,24 @@ module Ts = type [] FunctionTypeNode = inherit FunctionOrConstructorTypeNodeBase + inherit LocalsContainer abstract kind: SyntaxKind type [] ConstructorTypeNode = inherit FunctionOrConstructorTypeNodeBase + inherit LocalsContainer abstract kind: SyntaxKind + abstract modifiers: Modifier[] option type [] NodeWithTypeArguments = inherit TypeNode - abstract typeArguments: ResizeArray option + abstract typeArguments: TypeNode[] option - type TypeReferenceType = - U2 + type [] [] TypeReferenceType = + | [] ExpressionWithTypeArguments of ExpressionWithTypeArguments + | [] TypeReferenceNode of TypeReferenceNode + // static member inline op_ErasedCast(x: ExpressionWithTypeArguments) = ExpressionWithTypeArguments x + // static member inline op_ErasedCast(x: TypeReferenceNode) = TypeReferenceNode x type [] TypeReferenceNode = inherit NodeWithTypeArguments @@ -2149,12 +2633,12 @@ module Ts = inherit TypeNode abstract kind: SyntaxKind abstract parent: U2 - abstract assertsModifier: AssertsToken option + abstract assertsModifier: AssertsKeyword option abstract parameterName: U2 abstract ``type``: TypeNode option type [] TypeQueryNode = - inherit TypeNode + inherit NodeWithTypeArguments abstract kind: SyntaxKind abstract exprName: EntityName @@ -2162,7 +2646,7 @@ module Ts = inherit TypeNode inherit Declaration abstract kind: SyntaxKind - abstract members: ResizeArray + abstract members: TypeElement[] type [] ArrayTypeNode = inherit TypeNode @@ -2172,12 +2656,12 @@ module Ts = type [] TupleTypeNode = inherit TypeNode abstract kind: SyntaxKind - abstract elements: ResizeArray> + abstract elements: U2[] type [] NamedTupleMember = inherit TypeNode - inherit JSDocContainer inherit Declaration + inherit JSDocContainer abstract kind: SyntaxKind abstract dotDotDotToken: Token option abstract name: Identifier @@ -2194,21 +2678,25 @@ module Ts = abstract kind: SyntaxKind abstract ``type``: TypeNode - type UnionOrIntersectionTypeNode = - U2 + type [] [] UnionOrIntersectionTypeNode = + | [] IntersectionTypeNode of IntersectionTypeNode + | [] UnionTypeNode of UnionTypeNode + // static member inline op_ErasedCast(x: IntersectionTypeNode) = IntersectionTypeNode x + // static member inline op_ErasedCast(x: UnionTypeNode) = UnionTypeNode x type [] UnionTypeNode = inherit TypeNode abstract kind: SyntaxKind - abstract types: ResizeArray + abstract types: TypeNode[] type [] IntersectionTypeNode = inherit TypeNode abstract kind: SyntaxKind - abstract types: ResizeArray + abstract types: TypeNode[] type [] ConditionalTypeNode = inherit TypeNode + inherit LocalsContainer abstract kind: SyntaxKind abstract checkType: TypeNode abstract extendsType: TypeNode @@ -2240,14 +2728,15 @@ module Ts = type [] MappedTypeNode = inherit TypeNode inherit Declaration + inherit LocalsContainer abstract kind: SyntaxKind - abstract readonlyToken: U3 option + abstract readonlyToken: U3 option abstract typeParameter: TypeParameterDeclaration abstract nameType: TypeNode option abstract questionToken: U3 option abstract ``type``: TypeNode option /// Used only to produce grammar errors - abstract members: ResizeArray option + abstract members: TypeElement[] option type [] LiteralTypeNode = inherit TypeNode @@ -2259,17 +2748,29 @@ module Ts = inherit Declaration abstract kind: SyntaxKind - type StringLiteralLike = - U2 - - type PropertyNameLiteral = - U3 + type [] [] StringLiteralLike = + | [] NoSubstitutionTemplateLiteral of NoSubstitutionTemplateLiteral + | [] StringLiteral of StringLiteral + // static member inline op_ErasedCast(x: NoSubstitutionTemplateLiteral) = NoSubstitutionTemplateLiteral x + // static member inline op_ErasedCast(x: StringLiteral) = StringLiteral x + + type [] [] PropertyNameLiteral = + | [] Identifier of Identifier + | [] JsxNamespacedName of JsxNamespacedName + | [] NoSubstitutionTemplateLiteral of NoSubstitutionTemplateLiteral + | [] NumericLiteral of NumericLiteral + | [] StringLiteral of StringLiteral + // static member inline op_ErasedCast(x: Identifier) = Identifier x + // static member inline op_ErasedCast(x: JsxNamespacedName) = JsxNamespacedName x + // static member inline op_ErasedCast(x: NoSubstitutionTemplateLiteral) = NoSubstitutionTemplateLiteral x + // static member inline op_ErasedCast(x: NumericLiteral) = NumericLiteral x + // static member inline op_ErasedCast(x: StringLiteral) = StringLiteral x type [] TemplateLiteralTypeNode = inherit TypeNode abstract kind: SyntaxKind with get, set abstract head: TemplateHead - abstract templateSpans: ResizeArray + abstract templateSpans: TemplateLiteralTypeSpan[] type [] TemplateLiteralTypeSpan = inherit TypeNode @@ -2295,6 +2796,7 @@ module Ts = inherit Expression abstract _unaryExpressionBrand: obj option with get, set + /// Deprecated, please use UpdateExpression type IncrementExpression = UpdateExpression @@ -2302,6 +2804,12 @@ module Ts = inherit UnaryExpression abstract _updateExpressionBrand: obj option with get, set + /// + /// Original in TypeScript: + /// + /// SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken + /// + /// type PrefixUnaryOperator = SyntaxKind @@ -2311,6 +2819,12 @@ module Ts = abstract operator: PrefixUnaryOperator abstract operand: UnaryExpression + /// + /// Original in TypeScript: + /// + /// SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken + /// + /// type PostfixUnaryOperator = SyntaxKind @@ -2344,15 +2858,20 @@ module Ts = inherit PrimaryExpression abstract kind: SyntaxKind - type BooleanLiteral = - U2 + type [] [] BooleanLiteral = + | [] FalseLiteral of FalseLiteral + | [] TrueLiteral of TrueLiteral + // static member inline op_ErasedCast(x: FalseLiteral) = FalseLiteral x + // static member inline op_ErasedCast(x: TrueLiteral) = TrueLiteral x type [] ThisExpression = inherit PrimaryExpression + inherit FlowContainer abstract kind: SyntaxKind type [] SuperExpression = inherit PrimaryExpression + inherit FlowContainer abstract kind: SyntaxKind type [] ImportExpression = @@ -2392,63 +2911,183 @@ module Ts = abstract ``type``: Type abstract tupleNameSource: U2 option + /// + /// Original in TypeScript: + /// + /// SyntaxKind.AsteriskAsteriskToken + /// + /// type ExponentiationOperator = SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken + /// + /// type MultiplicativeOperator = SyntaxKind + /// + /// Original in TypeScript: + /// + /// ExponentiationOperator | MultiplicativeOperator + /// + /// type MultiplicativeOperatorOrHigher = - U2 + SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.PlusToken | SyntaxKind.MinusToken + /// + /// type AdditiveOperator = SyntaxKind + /// + /// Original in TypeScript: + /// + /// MultiplicativeOperatorOrHigher | AdditiveOperator + /// + /// type AdditiveOperatorOrHigher = - U2 + SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken + /// + /// type ShiftOperator = SyntaxKind + /// + /// Original in TypeScript: + /// + /// AdditiveOperatorOrHigher | ShiftOperator + /// + /// type ShiftOperatorOrHigher = - U2 + SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword + /// + /// type RelationalOperator = SyntaxKind + /// + /// Original in TypeScript: + /// + /// ShiftOperatorOrHigher | RelationalOperator + /// + /// type RelationalOperatorOrHigher = - U2 + SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken + /// + /// type EqualityOperator = SyntaxKind + /// + /// Original in TypeScript: + /// + /// RelationalOperatorOrHigher | EqualityOperator + /// + /// type EqualityOperatorOrHigher = - U2 + SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken + /// + /// type BitwiseOperator = SyntaxKind + /// + /// Original in TypeScript: + /// + /// EqualityOperatorOrHigher | BitwiseOperator + /// + /// type BitwiseOperatorOrHigher = - U2 + SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken + /// + /// type LogicalOperator = SyntaxKind + /// + /// Original in TypeScript: + /// + /// BitwiseOperatorOrHigher | LogicalOperator + /// + /// type LogicalOperatorOrHigher = - U2 + SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.BarBarEqualsToken | SyntaxKind.AmpersandAmpersandEqualsToken | SyntaxKind.QuestionQuestionEqualsToken + /// + /// type CompoundAssignmentOperator = SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.EqualsToken | CompoundAssignmentOperator + /// + /// type AssignmentOperator = - U2 + SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.QuestionQuestionToken | LogicalOperatorOrHigher | AssignmentOperator + /// + /// type AssignmentOperatorOrHigher = - U3 + SyntaxKind + /// + /// Original in TypeScript: + /// + /// AssignmentOperatorOrHigher | SyntaxKind.CommaToken + /// + /// type BinaryOperator = - U2 + SyntaxKind + /// + /// Original in TypeScript: + /// + /// SyntaxKind.AmpersandAmpersandEqualsToken | SyntaxKind.BarBarEqualsToken | SyntaxKind.QuestionQuestionEqualsToken + /// + /// type LogicalOrCoalescingAssignmentOperator = SyntaxKind @@ -2458,6 +3097,7 @@ module Ts = type [] BinaryExpression = inherit Expression inherit Declaration + inherit JSDocContainer abstract kind: SyntaxKind abstract left: Expression abstract operatorToken: BinaryOperatorToken @@ -2466,7 +3106,7 @@ module Ts = type AssignmentOperatorToken = Token - type [] AssignmentExpression<'TOperator> = + type [] AssignmentExpression<'TOperator > = inherit BinaryExpression abstract left: LeftHandSideExpression abstract operatorToken: 'TOperator @@ -2482,32 +3122,119 @@ module Ts = type DestructuringAssignment = U2 - type BindingOrAssignmentElement = - U4 - - type ObjectBindingOrAssignmentElement = - U4 - - type ArrayBindingOrAssignmentElement = - obj - - type BindingOrAssignmentElementRestIndicator = - U3 - - type BindingOrAssignmentElementTarget = - U5 - - type ObjectBindingOrAssignmentPattern = - U2 - - type ArrayBindingOrAssignmentPattern = - U2 - - type AssignmentPattern = - U2 - - type BindingOrAssignmentPattern = - U2 + type [] [] BindingOrAssignmentElement = + | [] ArrayLiteralExpression of ArrayLiteralExpression + | [] AssignmentExpression of AssignmentExpression + | [] BindingElement of BindingElement + | [] ElementAccessExpression of ElementAccessExpression + | [] Identifier of Identifier + | [] ObjectLiteralExpression of ObjectLiteralExpression + | [] OmittedExpression of OmittedExpression + | [] ParameterDeclaration of ParameterDeclaration + | [] PropertyAccessExpression of PropertyAccessExpression + | [] PropertyAssignment of PropertyAssignment + | [] ShorthandPropertyAssignment of ShorthandPropertyAssignment + | [] SpreadAssignment of SpreadAssignment + | [] SpreadElement of SpreadElement + | [] VariableDeclaration of VariableDeclaration + // static member inline op_ErasedCast(x: ArrayLiteralExpression) = ArrayLiteralExpression x + // static member inline op_ErasedCast(x: AssignmentExpression) = AssignmentExpression x + // static member inline op_ErasedCast(x: BindingElement) = BindingElement x + // static member inline op_ErasedCast(x: ElementAccessExpression) = ElementAccessExpression x + // static member inline op_ErasedCast(x: Identifier) = Identifier x + // static member inline op_ErasedCast(x: ObjectLiteralExpression) = ObjectLiteralExpression x + // static member inline op_ErasedCast(x: OmittedExpression) = OmittedExpression x + // static member inline op_ErasedCast(x: ParameterDeclaration) = ParameterDeclaration x + // static member inline op_ErasedCast(x: PropertyAccessExpression) = PropertyAccessExpression x + // static member inline op_ErasedCast(x: PropertyAssignment) = PropertyAssignment x + // static member inline op_ErasedCast(x: ShorthandPropertyAssignment) = ShorthandPropertyAssignment x + // static member inline op_ErasedCast(x: SpreadAssignment) = SpreadAssignment x + // static member inline op_ErasedCast(x: SpreadElement) = SpreadElement x + // static member inline op_ErasedCast(x: VariableDeclaration) = VariableDeclaration x + + type [] [] ObjectBindingOrAssignmentElement = + | [] BindingElement of BindingElement + | [] PropertyAssignment of PropertyAssignment + | [] ShorthandPropertyAssignment of ShorthandPropertyAssignment + | [] SpreadAssignment of SpreadAssignment + // static member inline op_ErasedCast(x: BindingElement) = BindingElement x + // static member inline op_ErasedCast(x: PropertyAssignment) = PropertyAssignment x + // static member inline op_ErasedCast(x: ShorthandPropertyAssignment) = ShorthandPropertyAssignment x + // static member inline op_ErasedCast(x: SpreadAssignment) = SpreadAssignment x + + type [] [] ArrayBindingOrAssignmentElement = + | [] ArrayLiteralExpression of ArrayLiteralExpression + | [] AssignmentExpression of AssignmentExpression + | [] BindingElement of BindingElement + | [] ElementAccessExpression of ElementAccessExpression + | [] Identifier of Identifier + | [] ObjectLiteralExpression of ObjectLiteralExpression + | [] OmittedExpression of OmittedExpression + | [] PropertyAccessExpression of PropertyAccessExpression + | [] SpreadElement of SpreadElement + // static member inline op_ErasedCast(x: ArrayLiteralExpression) = ArrayLiteralExpression x + // static member inline op_ErasedCast(x: AssignmentExpression) = AssignmentExpression x + // static member inline op_ErasedCast(x: BindingElement) = BindingElement x + // static member inline op_ErasedCast(x: ElementAccessExpression) = ElementAccessExpression x + // static member inline op_ErasedCast(x: Identifier) = Identifier x + // static member inline op_ErasedCast(x: ObjectLiteralExpression) = ObjectLiteralExpression x + // static member inline op_ErasedCast(x: OmittedExpression) = OmittedExpression x + // static member inline op_ErasedCast(x: PropertyAccessExpression) = PropertyAccessExpression x + // static member inline op_ErasedCast(x: SpreadElement) = SpreadElement x + + type [] [] BindingOrAssignmentElementRestIndicator = + | [] DotDotDotToken of DotDotDotToken + | [] SpreadAssignment of SpreadAssignment + | [] SpreadElement of SpreadElement + // static member inline op_ErasedCast(x: DotDotDotToken) = DotDotDotToken x + // static member inline op_ErasedCast(x: SpreadAssignment) = SpreadAssignment x + // static member inline op_ErasedCast(x: SpreadElement) = SpreadElement x + + type [] [] BindingOrAssignmentElementTarget = + | [] ArrayBindingPattern of ArrayBindingPattern + | [] ArrayLiteralExpression of ArrayLiteralExpression + | [] ElementAccessExpression of ElementAccessExpression + | [] Identifier of Identifier + | [] ObjectBindingPattern of ObjectBindingPattern + | [] ObjectLiteralExpression of ObjectLiteralExpression + | [] OmittedExpression of OmittedExpression + | [] PropertyAccessExpression of PropertyAccessExpression + // static member inline op_ErasedCast(x: ArrayBindingPattern) = ArrayBindingPattern x + // static member inline op_ErasedCast(x: ArrayLiteralExpression) = ArrayLiteralExpression x + // static member inline op_ErasedCast(x: ElementAccessExpression) = ElementAccessExpression x + // static member inline op_ErasedCast(x: Identifier) = Identifier x + // static member inline op_ErasedCast(x: ObjectBindingPattern) = ObjectBindingPattern x + // static member inline op_ErasedCast(x: ObjectLiteralExpression) = ObjectLiteralExpression x + // static member inline op_ErasedCast(x: OmittedExpression) = OmittedExpression x + // static member inline op_ErasedCast(x: PropertyAccessExpression) = PropertyAccessExpression x + + type [] [] ObjectBindingOrAssignmentPattern = + | [] ObjectBindingPattern of ObjectBindingPattern + | [] ObjectLiteralExpression of ObjectLiteralExpression + // static member inline op_ErasedCast(x: ObjectBindingPattern) = ObjectBindingPattern x + // static member inline op_ErasedCast(x: ObjectLiteralExpression) = ObjectLiteralExpression x + + type [] [] ArrayBindingOrAssignmentPattern = + | [] ArrayBindingPattern of ArrayBindingPattern + | [] ArrayLiteralExpression of ArrayLiteralExpression + // static member inline op_ErasedCast(x: ArrayBindingPattern) = ArrayBindingPattern x + // static member inline op_ErasedCast(x: ArrayLiteralExpression) = ArrayLiteralExpression x + + type [] [] AssignmentPattern = + | [] ArrayLiteralExpression of ArrayLiteralExpression + | [] ObjectLiteralExpression of ObjectLiteralExpression + // static member inline op_ErasedCast(x: ArrayLiteralExpression) = ArrayLiteralExpression x + // static member inline op_ErasedCast(x: ObjectLiteralExpression) = ObjectLiteralExpression x + + type [] [] BindingOrAssignmentPattern = + | [] ArrayBindingPattern of ArrayBindingPattern + | [] ArrayLiteralExpression of ArrayLiteralExpression + | [] ObjectBindingPattern of ObjectBindingPattern + | [] ObjectLiteralExpression of ObjectLiteralExpression + // static member inline op_ErasedCast(x: ArrayBindingPattern) = ArrayBindingPattern x + // static member inline op_ErasedCast(x: ArrayLiteralExpression) = ArrayLiteralExpression x + // static member inline op_ErasedCast(x: ObjectBindingPattern) = ObjectBindingPattern x + // static member inline op_ErasedCast(x: ObjectLiteralExpression) = ObjectLiteralExpression x type [] ConditionalExpression = inherit Expression @@ -2528,7 +3255,10 @@ module Ts = inherit PrimaryExpression inherit FunctionLikeDeclarationBase inherit JSDocContainer + inherit LocalsContainer + inherit FlowContainer abstract kind: SyntaxKind + abstract modifiers: Modifier[] option abstract name: Identifier option abstract body: FunctionBody @@ -2536,7 +3266,10 @@ module Ts = inherit Expression inherit FunctionLikeDeclarationBase inherit JSDocContainer + inherit LocalsContainer + inherit FlowContainer abstract kind: SyntaxKind + abstract modifiers: Modifier[] option abstract equalsGreaterThanToken: EqualsGreaterThanToken abstract body: ConciseBody abstract name: obj @@ -2583,8 +3316,19 @@ module Ts = inherit LiteralExpression abstract kind: SyntaxKind - type LiteralToken = - U6 + type [] [] LiteralToken = + | [] BigIntLiteral of BigIntLiteral + | [] JsxText of JsxText + | [] NoSubstitutionTemplateLiteral of NoSubstitutionTemplateLiteral + | [] NumericLiteral of NumericLiteral + | [] RegularExpressionLiteral of RegularExpressionLiteral + | [] StringLiteral of StringLiteral + // static member inline op_ErasedCast(x: BigIntLiteral) = BigIntLiteral x + // static member inline op_ErasedCast(x: JsxText) = JsxText x + // static member inline op_ErasedCast(x: NoSubstitutionTemplateLiteral) = NoSubstitutionTemplateLiteral x + // static member inline op_ErasedCast(x: NumericLiteral) = NumericLiteral x + // static member inline op_ErasedCast(x: RegularExpressionLiteral) = RegularExpressionLiteral x + // static member inline op_ErasedCast(x: StringLiteral) = StringLiteral x type [] TemplateHead = inherit TemplateLiteralLikeNode @@ -2601,20 +3345,35 @@ module Ts = abstract kind: SyntaxKind abstract parent: U2 - type PseudoLiteralToken = - U3 - - type TemplateLiteralToken = - U2 + type [] [] PseudoLiteralToken = + | [] TemplateHead of TemplateHead + | [] TemplateMiddle of TemplateMiddle + | [] TemplateTail of TemplateTail + // static member inline op_ErasedCast(x: TemplateHead) = TemplateHead x + // static member inline op_ErasedCast(x: TemplateMiddle) = TemplateMiddle x + // static member inline op_ErasedCast(x: TemplateTail) = TemplateTail x + + type [] [] TemplateLiteralToken = + | [] NoSubstitutionTemplateLiteral of NoSubstitutionTemplateLiteral + | [] TemplateHead of TemplateHead + | [] TemplateMiddle of TemplateMiddle + | [] TemplateTail of TemplateTail + // static member inline op_ErasedCast(x: NoSubstitutionTemplateLiteral) = NoSubstitutionTemplateLiteral x + // static member inline op_ErasedCast(x: TemplateHead) = TemplateHead x + // static member inline op_ErasedCast(x: TemplateMiddle) = TemplateMiddle x + // static member inline op_ErasedCast(x: TemplateTail) = TemplateTail x type [] TemplateExpression = inherit PrimaryExpression abstract kind: SyntaxKind abstract head: TemplateHead - abstract templateSpans: ResizeArray + abstract templateSpans: TemplateSpan[] - type TemplateLiteral = - U2 + type [] [] TemplateLiteral = + | [] NoSubstitutionTemplateLiteral of NoSubstitutionTemplateLiteral + | [] TemplateExpression of TemplateExpression + // static member inline op_ErasedCast(x: NoSubstitutionTemplateLiteral) = NoSubstitutionTemplateLiteral x + // static member inline op_ErasedCast(x: TemplateExpression) = TemplateExpression x type [] TemplateSpan = inherit Node @@ -2632,7 +3391,7 @@ module Ts = type [] ArrayLiteralExpression = inherit PrimaryExpression abstract kind: SyntaxKind - abstract elements: ResizeArray + abstract elements: Expression[] type [] SpreadElement = inherit Expression @@ -2644,27 +3403,41 @@ module Ts = /// ObjectLiteralExpression in that it contains array of properties; however, JSXAttributes' properties can only be /// JSXAttribute or JSXSpreadAttribute. ObjectLiteralExpression, on the other hand, can only have properties of type /// ObjectLiteralElement (e.g. PropertyAssignment, ShorthandPropertyAssignment etc.) - type [] ObjectLiteralExpressionBase<'T> = + type [] ObjectLiteralExpressionBase<'T > = inherit PrimaryExpression inherit Declaration - abstract properties: ResizeArray<'T> + abstract properties: 'T[] type [] ObjectLiteralExpression = inherit ObjectLiteralExpressionBase + inherit JSDocContainer abstract kind: SyntaxKind - type EntityNameExpression = - U2 + type [] [] EntityNameExpression = + | [] Identifier of Identifier + | [] PropertyAccessEntityNameExpression of PropertyAccessEntityNameExpression + // static member inline op_ErasedCast(x: Identifier) = Identifier x + // static member inline op_ErasedCast(x: PropertyAccessEntityNameExpression) = PropertyAccessEntityNameExpression x - type EntityNameOrEntityNameExpression = - U2 + type [] [] EntityNameOrEntityNameExpression = + | [] Identifier of Identifier + | [] PropertyAccessEntityNameExpression of PropertyAccessEntityNameExpression + | [] QualifiedName of QualifiedName + // static member inline op_ErasedCast(x: Identifier) = Identifier x + // static member inline op_ErasedCast(x: PropertyAccessEntityNameExpression) = PropertyAccessEntityNameExpression x + // static member inline op_ErasedCast(x: QualifiedName) = QualifiedName x - type AccessExpression = - U2 + type [] [] AccessExpression = + | [] ElementAccessExpression of ElementAccessExpression + | [] PropertyAccessExpression of PropertyAccessExpression + // static member inline op_ErasedCast(x: ElementAccessExpression) = ElementAccessExpression x + // static member inline op_ErasedCast(x: PropertyAccessExpression) = PropertyAccessExpression x type [] PropertyAccessExpression = inherit MemberExpression inherit NamedDeclaration + inherit JSDocContainer + inherit FlowContainer abstract kind: SyntaxKind abstract expression: LeftHandSideExpression abstract questionDotToken: QuestionDotToken option @@ -2688,6 +3461,9 @@ module Ts = type [] ElementAccessExpression = inherit MemberExpression + inherit Declaration + inherit JSDocContainer + inherit FlowContainer abstract kind: SyntaxKind abstract expression: LeftHandSideExpression abstract questionDotToken: QuestionDotToken option @@ -2701,8 +3477,11 @@ module Ts = inherit ElementAccessExpression abstract expression: SuperExpression - type SuperProperty = - U2 + type [] [] SuperProperty = + | [] SuperElementAccessExpression of SuperElementAccessExpression + | [] SuperPropertyAccessExpression of SuperPropertyAccessExpression + // static member inline op_ErasedCast(x: SuperElementAccessExpression) = SuperElementAccessExpression x + // static member inline op_ErasedCast(x: SuperPropertyAccessExpression) = SuperPropertyAccessExpression x type [] CallExpression = inherit LeftHandSideExpression @@ -2710,15 +3489,22 @@ module Ts = abstract kind: SyntaxKind abstract expression: LeftHandSideExpression abstract questionDotToken: QuestionDotToken option - abstract typeArguments: ResizeArray option - abstract arguments: ResizeArray + abstract typeArguments: TypeNode[] option + abstract arguments: Expression[] type [] CallChain = inherit CallExpression abstract _optionalChainBrand: obj option with get, set - type OptionalChain = - U4 + type [] [] OptionalChain = + | [] CallChain of CallChain + | [] ElementAccessChain of ElementAccessChain + | [] NonNullChain of NonNullChain + | [] PropertyAccessChain of PropertyAccessChain + // static member inline op_ErasedCast(x: CallChain) = CallChain x + // static member inline op_ErasedCast(x: ElementAccessChain) = ElementAccessChain x + // static member inline op_ErasedCast(x: NonNullChain) = NonNullChain x + // static member inline op_ErasedCast(x: PropertyAccessChain) = PropertyAccessChain x type [] SuperCall = inherit CallExpression @@ -2729,9 +3515,9 @@ module Ts = abstract expression: ImportExpression type [] ExpressionWithTypeArguments = + inherit MemberExpression inherit NodeWithTypeArguments abstract kind: SyntaxKind - abstract parent: U3 abstract expression: LeftHandSideExpression type [] NewExpression = @@ -2739,18 +3525,29 @@ module Ts = inherit Declaration abstract kind: SyntaxKind abstract expression: LeftHandSideExpression - abstract typeArguments: ResizeArray option - abstract arguments: ResizeArray option + abstract typeArguments: TypeNode[] option + abstract arguments: Expression[] option type [] TaggedTemplateExpression = inherit MemberExpression abstract kind: SyntaxKind abstract tag: LeftHandSideExpression - abstract typeArguments: ResizeArray option + abstract typeArguments: TypeNode[] option abstract template: TemplateLiteral - type CallLikeExpression = - U5 + type [] [] CallLikeExpression = + | [] CallExpression of CallExpression + | [] Decorator of Decorator + | [] JsxOpeningElement of JsxOpeningElement + | [] JsxSelfClosingElement of JsxSelfClosingElement + | [] NewExpression of NewExpression + | [] TaggedTemplateExpression of TaggedTemplateExpression + // static member inline op_ErasedCast(x: CallExpression) = CallExpression x + // static member inline op_ErasedCast(x: Decorator) = Decorator x + // static member inline op_ErasedCast(x: JsxOpeningElement) = JsxOpeningElement x + // static member inline op_ErasedCast(x: JsxSelfClosingElement) = JsxSelfClosingElement x + // static member inline op_ErasedCast(x: NewExpression) = NewExpression x + // static member inline op_ErasedCast(x: TaggedTemplateExpression) = TaggedTemplateExpression x type [] AsExpression = inherit Expression @@ -2764,8 +3561,17 @@ module Ts = abstract ``type``: TypeNode abstract expression: UnaryExpression - type AssertionExpression = - U2 + type [] SatisfiesExpression = + inherit Expression + abstract kind: SyntaxKind + abstract expression: Expression + abstract ``type``: TypeNode + + type [] [] AssertionExpression = + | [] AsExpression of AsExpression + | [] TypeAssertion of TypeAssertion + // static member inline op_ErasedCast(x: AsExpression) = AsExpression x + // static member inline op_ErasedCast(x: TypeAssertion) = TypeAssertion x type [] NonNullExpression = inherit LeftHandSideExpression @@ -2778,6 +3584,7 @@ module Ts = type [] MetaProperty = inherit PrimaryExpression + inherit FlowContainer abstract kind: SyntaxKind abstract keywordToken: SyntaxKind abstract name: Identifier @@ -2786,47 +3593,74 @@ module Ts = inherit PrimaryExpression abstract kind: SyntaxKind abstract openingElement: JsxOpeningElement - abstract children: ResizeArray + abstract children: JsxChild[] abstract closingElement: JsxClosingElement - type JsxOpeningLikeElement = - U2 - - type JsxAttributeLike = - U2 - - type JsxTagNameExpression = - U3 + type [] [] JsxOpeningLikeElement = + | [] JsxOpeningElement of JsxOpeningElement + | [] JsxSelfClosingElement of JsxSelfClosingElement + // static member inline op_ErasedCast(x: JsxOpeningElement) = JsxOpeningElement x + // static member inline op_ErasedCast(x: JsxSelfClosingElement) = JsxSelfClosingElement x + + type [] [] JsxAttributeLike = + | [] JsxAttribute of JsxAttribute + | [] JsxSpreadAttribute of JsxSpreadAttribute + // static member inline op_ErasedCast(x: JsxAttribute) = JsxAttribute x + // static member inline op_ErasedCast(x: JsxSpreadAttribute) = JsxSpreadAttribute x + + type [] [] JsxAttributeName = + | [] Identifier of Identifier + | [] JsxNamespacedName of JsxNamespacedName + // static member inline op_ErasedCast(x: Identifier) = Identifier x + // static member inline op_ErasedCast(x: JsxNamespacedName) = JsxNamespacedName x + + type [] [] JsxTagNameExpression = + | [] Identifier of Identifier + | [] JsxNamespacedName of JsxNamespacedName + | [] JsxTagNamePropertyAccess of JsxTagNamePropertyAccess + | [] ThisExpression of ThisExpression + // static member inline op_ErasedCast(x: Identifier) = Identifier x + // static member inline op_ErasedCast(x: JsxNamespacedName) = JsxNamespacedName x + // static member inline op_ErasedCast(x: JsxTagNamePropertyAccess) = JsxTagNamePropertyAccess x + // static member inline op_ErasedCast(x: ThisExpression) = ThisExpression x type [] JsxTagNamePropertyAccess = inherit PropertyAccessExpression - abstract expression: JsxTagNameExpression + abstract expression: U3 type [] JsxAttributes = - inherit ObjectLiteralExpressionBase + inherit PrimaryExpression + inherit Declaration + abstract properties: JsxAttributeLike[] abstract kind: SyntaxKind abstract parent: JsxOpeningLikeElement + type [] JsxNamespacedName = + inherit Node + abstract kind: SyntaxKind + abstract name: Identifier + abstract ``namespace``: Identifier + type [] JsxOpeningElement = inherit Expression abstract kind: SyntaxKind abstract parent: JsxElement abstract tagName: JsxTagNameExpression - abstract typeArguments: ResizeArray option + abstract typeArguments: TypeNode[] option abstract attributes: JsxAttributes type [] JsxSelfClosingElement = inherit PrimaryExpression abstract kind: SyntaxKind abstract tagName: JsxTagNameExpression - abstract typeArguments: ResizeArray option + abstract typeArguments: TypeNode[] option abstract attributes: JsxAttributes type [] JsxFragment = inherit PrimaryExpression abstract kind: SyntaxKind abstract openingFragment: JsxOpeningFragment - abstract children: ResizeArray + abstract children: JsxChild[] abstract closingFragment: JsxClosingFragment type [] JsxOpeningFragment = @@ -2840,11 +3674,23 @@ module Ts = abstract parent: JsxFragment type [] JsxAttribute = - inherit ObjectLiteralElement + inherit Declaration abstract kind: SyntaxKind abstract parent: JsxAttributes - abstract name: Identifier - abstract initializer: U2 option + abstract name: JsxAttributeName + abstract initializer: JsxAttributeValue option + + type [] [] JsxAttributeValue = + | [] JsxElement of JsxElement + | [] JsxExpression of JsxExpression + | [] JsxFragment of JsxFragment + | [] JsxSelfClosingElement of JsxSelfClosingElement + | [] StringLiteral of StringLiteral + // static member inline op_ErasedCast(x: JsxElement) = JsxElement x + // static member inline op_ErasedCast(x: JsxExpression) = JsxExpression x + // static member inline op_ErasedCast(x: JsxFragment) = JsxFragment x + // static member inline op_ErasedCast(x: JsxSelfClosingElement) = JsxSelfClosingElement x + // static member inline op_ErasedCast(x: StringLiteral) = StringLiteral x type [] JsxSpreadAttribute = inherit ObjectLiteralElement @@ -2871,8 +3717,17 @@ module Ts = abstract parent: U2 abstract containsOnlyTriviaWhiteSpaces: bool - type JsxChild = - U5 + type [] [] JsxChild = + | [] JsxElement of JsxElement + | [] JsxExpression of JsxExpression + | [] JsxFragment of JsxFragment + | [] JsxSelfClosingElement of JsxSelfClosingElement + | [] JsxText of JsxText + // static member inline op_ErasedCast(x: JsxElement) = JsxElement x + // static member inline op_ErasedCast(x: JsxExpression) = JsxExpression x + // static member inline op_ErasedCast(x: JsxFragment) = JsxFragment x + // static member inline op_ErasedCast(x: JsxSelfClosingElement) = JsxSelfClosingElement x + // static member inline op_ErasedCast(x: JsxText) = JsxText x type [] Statement = inherit Node @@ -2887,7 +3742,7 @@ module Ts = type [] CommaListExpression = inherit Expression abstract kind: SyntaxKind - abstract elements: ResizeArray + abstract elements: Expression[] type [] EmptyStatement = inherit Statement @@ -2895,33 +3750,49 @@ module Ts = type [] DebuggerStatement = inherit Statement + inherit FlowContainer abstract kind: SyntaxKind type [] MissingDeclaration = inherit DeclarationStatement + inherit PrimaryExpression abstract kind: SyntaxKind abstract name: Identifier option - type BlockLike = - U4 + type [] [] BlockLike = + | [] Block of Block + | [] CaseClause of CaseClause + | [] DefaultClause of DefaultClause + | [] ModuleBlock of ModuleBlock + | [] SourceFile of SourceFile + // static member inline op_ErasedCast(x: Block) = Block x + // static member inline op_ErasedCast(x: CaseClause) = CaseClause x + // static member inline op_ErasedCast(x: DefaultClause) = DefaultClause x + // static member inline op_ErasedCast(x: ModuleBlock) = ModuleBlock x + // static member inline op_ErasedCast(x: SourceFile) = SourceFile x type [] Block = inherit Statement + inherit LocalsContainer abstract kind: SyntaxKind - abstract statements: ResizeArray + abstract statements: Statement[] type [] VariableStatement = inherit Statement + inherit FlowContainer abstract kind: SyntaxKind + abstract modifiers: ModifierLike[] option abstract declarationList: VariableDeclarationList type [] ExpressionStatement = inherit Statement + inherit FlowContainer abstract kind: SyntaxKind abstract expression: Expression type [] IfStatement = inherit Statement + inherit FlowContainer abstract kind: SyntaxKind abstract expression: Expression abstract thenStatement: Statement @@ -2933,11 +3804,13 @@ module Ts = type [] DoStatement = inherit IterationStatement + inherit FlowContainer abstract kind: SyntaxKind abstract expression: Expression type [] WhileStatement = inherit IterationStatement + inherit FlowContainer abstract kind: SyntaxKind abstract expression: Expression @@ -2946,53 +3819,70 @@ module Ts = type [] ForStatement = inherit IterationStatement + inherit LocalsContainer + inherit FlowContainer abstract kind: SyntaxKind abstract initializer: ForInitializer option abstract condition: Expression option abstract incrementor: Expression option - type ForInOrOfStatement = - U2 + type [] [] ForInOrOfStatement = + | [] ForInStatement of ForInStatement + | [] ForOfStatement of ForOfStatement + // static member inline op_ErasedCast(x: ForInStatement) = ForInStatement x + // static member inline op_ErasedCast(x: ForOfStatement) = ForOfStatement x type [] ForInStatement = inherit IterationStatement + inherit LocalsContainer + inherit FlowContainer abstract kind: SyntaxKind abstract initializer: ForInitializer abstract expression: Expression type [] ForOfStatement = inherit IterationStatement + inherit LocalsContainer + inherit FlowContainer abstract kind: SyntaxKind - abstract awaitModifier: AwaitKeywordToken option + abstract awaitModifier: AwaitKeyword option abstract initializer: ForInitializer abstract expression: Expression type [] BreakStatement = inherit Statement + inherit FlowContainer abstract kind: SyntaxKind abstract label: Identifier option type [] ContinueStatement = inherit Statement + inherit FlowContainer abstract kind: SyntaxKind abstract label: Identifier option - type BreakOrContinueStatement = - U2 + type [] [] BreakOrContinueStatement = + | [] BreakStatement of BreakStatement + | [] ContinueStatement of ContinueStatement + // static member inline op_ErasedCast(x: BreakStatement) = BreakStatement x + // static member inline op_ErasedCast(x: ContinueStatement) = ContinueStatement x type [] ReturnStatement = inherit Statement + inherit FlowContainer abstract kind: SyntaxKind abstract expression: Expression option type [] WithStatement = inherit Statement + inherit FlowContainer abstract kind: SyntaxKind abstract expression: Expression abstract statement: Statement type [] SwitchStatement = inherit Statement + inherit FlowContainer abstract kind: SyntaxKind abstract expression: Expression abstract caseBlock: CaseBlock @@ -3000,39 +3890,47 @@ module Ts = type [] CaseBlock = inherit Node + inherit LocalsContainer abstract kind: SyntaxKind abstract parent: SwitchStatement - abstract clauses: ResizeArray + abstract clauses: CaseOrDefaultClause[] type [] CaseClause = inherit Node + inherit JSDocContainer abstract kind: SyntaxKind abstract parent: CaseBlock abstract expression: Expression - abstract statements: ResizeArray + abstract statements: Statement[] type [] DefaultClause = inherit Node abstract kind: SyntaxKind abstract parent: CaseBlock - abstract statements: ResizeArray + abstract statements: Statement[] - type CaseOrDefaultClause = - U2 + type [] [] CaseOrDefaultClause = + | [] CaseClause of CaseClause + | [] DefaultClause of DefaultClause + // static member inline op_ErasedCast(x: CaseClause) = CaseClause x + // static member inline op_ErasedCast(x: DefaultClause) = DefaultClause x type [] LabeledStatement = inherit Statement + inherit FlowContainer abstract kind: SyntaxKind abstract label: Identifier abstract statement: Statement type [] ThrowStatement = inherit Statement + inherit FlowContainer abstract kind: SyntaxKind abstract expression: Expression type [] TryStatement = inherit Statement + inherit FlowContainer abstract kind: SyntaxKind abstract tryBlock: Block abstract catchClause: CatchClause option @@ -3040,43 +3938,136 @@ module Ts = type [] CatchClause = inherit Node + inherit LocalsContainer abstract kind: SyntaxKind abstract parent: TryStatement abstract variableDeclaration: VariableDeclaration option abstract block: Block - type ObjectTypeDeclaration = - U3 - - type DeclarationWithTypeParameters = - U4 - - type DeclarationWithTypeParameterChildren = - U5 + type [] [] ObjectTypeDeclaration = + | [] ClassDeclaration of ClassDeclaration + | [] ClassExpression of ClassExpression + | [] InterfaceDeclaration of InterfaceDeclaration + | [] TypeLiteralNode of TypeLiteralNode + // static member inline op_ErasedCast(x: ClassDeclaration) = ClassDeclaration x + // static member inline op_ErasedCast(x: ClassExpression) = ClassExpression x + // static member inline op_ErasedCast(x: InterfaceDeclaration) = InterfaceDeclaration x + // static member inline op_ErasedCast(x: TypeLiteralNode) = TypeLiteralNode x + + type [] [] DeclarationWithTypeParameters = + | [] ArrowFunction of ArrowFunction + | [] CallSignatureDeclaration of CallSignatureDeclaration + | [] ClassDeclaration of ClassDeclaration + | [] ClassExpression of ClassExpression + | [] ConstructSignatureDeclaration of ConstructSignatureDeclaration + | [] ConstructorDeclaration of ConstructorDeclaration + | [] ConstructorTypeNode of ConstructorTypeNode + | [] FunctionDeclaration of FunctionDeclaration + | [] FunctionExpression of FunctionExpression + | [] FunctionTypeNode of FunctionTypeNode + | [] GetAccessorDeclaration of GetAccessorDeclaration + | [] IndexSignatureDeclaration of IndexSignatureDeclaration + | [] InterfaceDeclaration of InterfaceDeclaration + | [] JSDocCallbackTag of JSDocCallbackTag + | [] JSDocFunctionType of JSDocFunctionType + | [] JSDocSignature of JSDocSignature + | [] JSDocTemplateTag of JSDocTemplateTag + | [] JSDocTypedefTag of JSDocTypedefTag + | [] MethodDeclaration of MethodDeclaration + | [] MethodSignature of MethodSignature + | [] SetAccessorDeclaration of SetAccessorDeclaration + | [] TypeAliasDeclaration of TypeAliasDeclaration + // static member inline op_ErasedCast(x: ArrowFunction) = ArrowFunction x + // static member inline op_ErasedCast(x: CallSignatureDeclaration) = CallSignatureDeclaration x + // static member inline op_ErasedCast(x: ClassDeclaration) = ClassDeclaration x + // static member inline op_ErasedCast(x: ClassExpression) = ClassExpression x + // static member inline op_ErasedCast(x: ConstructSignatureDeclaration) = ConstructSignatureDeclaration x + // static member inline op_ErasedCast(x: ConstructorDeclaration) = ConstructorDeclaration x + // static member inline op_ErasedCast(x: ConstructorTypeNode) = ConstructorTypeNode x + // static member inline op_ErasedCast(x: FunctionDeclaration) = FunctionDeclaration x + // static member inline op_ErasedCast(x: FunctionExpression) = FunctionExpression x + // static member inline op_ErasedCast(x: FunctionTypeNode) = FunctionTypeNode x + // static member inline op_ErasedCast(x: GetAccessorDeclaration) = GetAccessorDeclaration x + // static member inline op_ErasedCast(x: IndexSignatureDeclaration) = IndexSignatureDeclaration x + // static member inline op_ErasedCast(x: InterfaceDeclaration) = InterfaceDeclaration x + // static member inline op_ErasedCast(x: JSDocCallbackTag) = JSDocCallbackTag x + // static member inline op_ErasedCast(x: JSDocFunctionType) = JSDocFunctionType x + // static member inline op_ErasedCast(x: JSDocSignature) = JSDocSignature x + // static member inline op_ErasedCast(x: JSDocTemplateTag) = JSDocTemplateTag x + // static member inline op_ErasedCast(x: JSDocTypedefTag) = JSDocTypedefTag x + // static member inline op_ErasedCast(x: MethodDeclaration) = MethodDeclaration x + // static member inline op_ErasedCast(x: MethodSignature) = MethodSignature x + // static member inline op_ErasedCast(x: SetAccessorDeclaration) = SetAccessorDeclaration x + // static member inline op_ErasedCast(x: TypeAliasDeclaration) = TypeAliasDeclaration x + + type [] [] DeclarationWithTypeParameterChildren = + | [] ArrowFunction of ArrowFunction + | [] CallSignatureDeclaration of CallSignatureDeclaration + | [] ClassDeclaration of ClassDeclaration + | [] ClassExpression of ClassExpression + | [] ConstructSignatureDeclaration of ConstructSignatureDeclaration + | [] ConstructorDeclaration of ConstructorDeclaration + | [] ConstructorTypeNode of ConstructorTypeNode + | [] FunctionDeclaration of FunctionDeclaration + | [] FunctionExpression of FunctionExpression + | [] FunctionTypeNode of FunctionTypeNode + | [] GetAccessorDeclaration of GetAccessorDeclaration + | [] IndexSignatureDeclaration of IndexSignatureDeclaration + | [] InterfaceDeclaration of InterfaceDeclaration + | [] JSDocFunctionType of JSDocFunctionType + | [] JSDocTemplateTag of JSDocTemplateTag + | [] MethodDeclaration of MethodDeclaration + | [] MethodSignature of MethodSignature + | [] SetAccessorDeclaration of SetAccessorDeclaration + | [] TypeAliasDeclaration of TypeAliasDeclaration + // static member inline op_ErasedCast(x: ArrowFunction) = ArrowFunction x + // static member inline op_ErasedCast(x: CallSignatureDeclaration) = CallSignatureDeclaration x + // static member inline op_ErasedCast(x: ClassDeclaration) = ClassDeclaration x + // static member inline op_ErasedCast(x: ClassExpression) = ClassExpression x + // static member inline op_ErasedCast(x: ConstructSignatureDeclaration) = ConstructSignatureDeclaration x + // static member inline op_ErasedCast(x: ConstructorDeclaration) = ConstructorDeclaration x + // static member inline op_ErasedCast(x: ConstructorTypeNode) = ConstructorTypeNode x + // static member inline op_ErasedCast(x: FunctionDeclaration) = FunctionDeclaration x + // static member inline op_ErasedCast(x: FunctionExpression) = FunctionExpression x + // static member inline op_ErasedCast(x: FunctionTypeNode) = FunctionTypeNode x + // static member inline op_ErasedCast(x: GetAccessorDeclaration) = GetAccessorDeclaration x + // static member inline op_ErasedCast(x: IndexSignatureDeclaration) = IndexSignatureDeclaration x + // static member inline op_ErasedCast(x: InterfaceDeclaration) = InterfaceDeclaration x + // static member inline op_ErasedCast(x: JSDocFunctionType) = JSDocFunctionType x + // static member inline op_ErasedCast(x: JSDocTemplateTag) = JSDocTemplateTag x + // static member inline op_ErasedCast(x: MethodDeclaration) = MethodDeclaration x + // static member inline op_ErasedCast(x: MethodSignature) = MethodSignature x + // static member inline op_ErasedCast(x: SetAccessorDeclaration) = SetAccessorDeclaration x + // static member inline op_ErasedCast(x: TypeAliasDeclaration) = TypeAliasDeclaration x type [] ClassLikeDeclarationBase = inherit NamedDeclaration inherit JSDocContainer abstract kind: SyntaxKind abstract name: Identifier option - abstract typeParameters: ResizeArray option - abstract heritageClauses: ResizeArray option - abstract members: ResizeArray + abstract typeParameters: TypeParameterDeclaration[] option + abstract heritageClauses: HeritageClause[] option + abstract members: ClassElement[] type [] ClassDeclaration = inherit ClassLikeDeclarationBase inherit DeclarationStatement abstract kind: SyntaxKind - /// May be undefined in `export default class { ... }`. + abstract modifiers: ModifierLike[] option + /// May be undefined in export default class { ... }. abstract name: Identifier option type [] ClassExpression = inherit ClassLikeDeclarationBase inherit PrimaryExpression abstract kind: SyntaxKind + abstract modifiers: ModifierLike[] option - type ClassLikeDeclaration = - U2 + type [] [] ClassLikeDeclaration = + | [] ClassDeclaration of ClassDeclaration + | [] ClassExpression of ClassExpression + // static member inline op_ErasedCast(x: ClassDeclaration) = ClassDeclaration x + // static member inline op_ErasedCast(x: ClassExpression) = ClassExpression x type [] ClassElement = inherit NamedDeclaration @@ -3093,24 +4084,27 @@ module Ts = inherit DeclarationStatement inherit JSDocContainer abstract kind: SyntaxKind + abstract modifiers: ModifierLike[] option abstract name: Identifier - abstract typeParameters: ResizeArray option - abstract heritageClauses: ResizeArray option - abstract members: ResizeArray + abstract typeParameters: TypeParameterDeclaration[] option + abstract heritageClauses: HeritageClause[] option + abstract members: TypeElement[] type [] HeritageClause = inherit Node abstract kind: SyntaxKind abstract parent: U2 abstract token: SyntaxKind - abstract types: ResizeArray + abstract types: ExpressionWithTypeArguments[] type [] TypeAliasDeclaration = inherit DeclarationStatement inherit JSDocContainer + inherit LocalsContainer abstract kind: SyntaxKind + abstract modifiers: ModifierLike[] option abstract name: Identifier - abstract typeParameters: ResizeArray option + abstract typeParameters: TypeParameterDeclaration[] option abstract ``type``: TypeNode type [] EnumMember = @@ -3125,33 +4119,50 @@ module Ts = inherit DeclarationStatement inherit JSDocContainer abstract kind: SyntaxKind + abstract modifiers: ModifierLike[] option abstract name: Identifier - abstract members: ResizeArray - - type ModuleName = - U2 - - type ModuleBody = - U2 + abstract members: EnumMember[] + + type [] [] ModuleName = + | [] Identifier of Identifier + | [] StringLiteral of StringLiteral + // static member inline op_ErasedCast(x: Identifier) = Identifier x + // static member inline op_ErasedCast(x: StringLiteral) = StringLiteral x + + type [] [] ModuleBody = + | [] Identifier of Identifier + | [] ModuleBlock of ModuleBlock + | [] ModuleDeclaration of U2 + // static member inline op_ErasedCast(x: Identifier) = Identifier x + // static member inline op_ErasedCast(x: ModuleBlock) = ModuleBlock x + // static member inline op_ErasedCast(x: U2) = ModuleDeclaration x type [] ModuleDeclaration = inherit DeclarationStatement inherit JSDocContainer + inherit LocalsContainer abstract kind: SyntaxKind abstract parent: U2 + abstract modifiers: ModifierLike[] option abstract name: ModuleName abstract body: U2 option - type NamespaceBody = - U2 + type [] [] NamespaceBody = + | [] ModuleBlock of ModuleBlock + | [] NamespaceDeclaration of NamespaceDeclaration + // static member inline op_ErasedCast(x: ModuleBlock) = ModuleBlock x + // static member inline op_ErasedCast(x: NamespaceDeclaration) = NamespaceDeclaration x type [] NamespaceDeclaration = inherit ModuleDeclaration abstract name: Identifier abstract body: NamespaceBody - type JSDocNamespaceBody = - U2 + type [] [] JSDocNamespaceBody = + | [] Identifier of Identifier + | [] JSDocNamespaceDeclaration of JSDocNamespaceDeclaration + // static member inline op_ErasedCast(x: Identifier) = Identifier x + // static member inline op_ErasedCast(x: JSDocNamespaceDeclaration) = JSDocNamespaceDeclaration x type [] JSDocNamespaceDeclaration = inherit ModuleDeclaration @@ -3163,10 +4174,15 @@ module Ts = inherit Statement abstract kind: SyntaxKind abstract parent: ModuleDeclaration - abstract statements: ResizeArray + abstract statements: Statement[] - type ModuleReference = - U2 + type [] [] ModuleReference = + | [] ExternalModuleReference of ExternalModuleReference + | [] Identifier of Identifier + | [] QualifiedName of QualifiedName + // static member inline op_ErasedCast(x: ExternalModuleReference) = ExternalModuleReference x + // static member inline op_ErasedCast(x: Identifier) = Identifier x + // static member inline op_ErasedCast(x: QualifiedName) = QualifiedName x /// One of: /// - import x = require("mod"); @@ -3176,6 +4192,7 @@ module Ts = inherit JSDocContainer abstract kind: SyntaxKind abstract parent: U2 + abstract modifiers: ModifierLike[] option abstract name: Identifier abstract isTypeOnly: bool abstract moduleReference: ModuleReference @@ -3190,16 +4207,23 @@ module Ts = inherit Statement abstract kind: SyntaxKind abstract parent: U2 + abstract modifiers: ModifierLike[] option abstract importClause: ImportClause option /// If this is not a StringLiteral it will be a grammar error. abstract moduleSpecifier: Expression abstract assertClause: AssertClause option - type NamedImportBindings = - U2 + type [] [] NamedImportBindings = + | [] NamedImports of NamedImports + | [] NamespaceImport of NamespaceImport + // static member inline op_ErasedCast(x: NamedImports) = NamedImports x + // static member inline op_ErasedCast(x: NamespaceImport) = NamespaceImport x - type NamedExportBindings = - U2 + type [] [] NamedExportBindings = + | [] NamedExports of NamedExports + | [] NamespaceExport of NamespaceExport + // static member inline op_ErasedCast(x: NamedExports) = NamedExports x + // static member inline op_ErasedCast(x: NamespaceExport) = NamespaceExport x type [] ImportClause = inherit NamedDeclaration @@ -3209,21 +4233,24 @@ module Ts = abstract name: Identifier option abstract namedBindings: NamedImportBindings option - type AssertionKey = - U2 + type [] [] AssertionKey = + | [] Identifier of Identifier + | [] StringLiteral of StringLiteral + // static member inline op_ErasedCast(x: Identifier) = Identifier x + // static member inline op_ErasedCast(x: StringLiteral) = StringLiteral x type [] AssertEntry = inherit Node abstract kind: SyntaxKind abstract parent: AssertClause abstract name: AssertionKey - abstract value: StringLiteral + abstract value: Expression type [] AssertClause = inherit Node abstract kind: SyntaxKind abstract parent: U2 - abstract elements: ResizeArray + abstract elements: AssertEntry[] abstract multiLine: bool option type [] NamespaceImport = @@ -3249,8 +4276,9 @@ module Ts = inherit JSDocContainer abstract kind: SyntaxKind abstract parent: U2 + abstract modifiers: ModifierLike[] option abstract isTypeOnly: bool - /// Will not be assigned in the case of `export * from "foo";` + /// Will not be assigned in the case of export * from "foo"; abstract exportClause: NamedExportBindings option /// If this is not a StringLiteral it will be a grammar error. abstract moduleSpecifier: Expression option @@ -3260,16 +4288,19 @@ module Ts = inherit Node abstract kind: SyntaxKind abstract parent: ImportClause - abstract elements: ResizeArray + abstract elements: ImportSpecifier[] type [] NamedExports = inherit Node abstract kind: SyntaxKind abstract parent: ExportDeclaration - abstract elements: ResizeArray + abstract elements: ExportSpecifier[] - type NamedImportsOrExports = - U2 + type [] [] NamedImportsOrExports = + | [] NamedExports of NamedExports + | [] NamedImports of NamedImports + // static member inline op_ErasedCast(x: NamedExports) = NamedExports x + // static member inline op_ErasedCast(x: NamedImports) = NamedImports x type [] ImportSpecifier = inherit NamedDeclaration @@ -3281,39 +4312,72 @@ module Ts = type [] ExportSpecifier = inherit NamedDeclaration + inherit JSDocContainer abstract kind: SyntaxKind abstract parent: NamedExports abstract isTypeOnly: bool abstract propertyName: Identifier option abstract name: Identifier - type ImportOrExportSpecifier = - U2 + type [] [] ImportOrExportSpecifier = + | [] ExportSpecifier of ExportSpecifier + | [] ImportSpecifier of ImportSpecifier + // static member inline op_ErasedCast(x: ExportSpecifier) = ExportSpecifier x + // static member inline op_ErasedCast(x: ImportSpecifier) = ImportSpecifier x + + type [] [] TypeOnlyCompatibleAliasDeclaration = + | [] ExportDeclaration of ExportDeclaration + | [] ExportSpecifier of ExportSpecifier + | [] ImportClause of ImportClause + | [] ImportEqualsDeclaration of ImportEqualsDeclaration + | [] ImportSpecifier of ImportSpecifier + | [] NamespaceExport of NamespaceExport + | [] NamespaceImport of NamespaceImport + // static member inline op_ErasedCast(x: ExportDeclaration) = ExportDeclaration x + // static member inline op_ErasedCast(x: ExportSpecifier) = ExportSpecifier x + // static member inline op_ErasedCast(x: ImportClause) = ImportClause x + // static member inline op_ErasedCast(x: ImportEqualsDeclaration) = ImportEqualsDeclaration x + // static member inline op_ErasedCast(x: ImportSpecifier) = ImportSpecifier x + // static member inline op_ErasedCast(x: NamespaceExport) = NamespaceExport x + // static member inline op_ErasedCast(x: NamespaceImport) = NamespaceImport x + + type TypeOnlyImportDeclaration = + obj - type TypeOnlyCompatibleAliasDeclaration = - U4 + type TypeOnlyExportDeclaration = + obj type TypeOnlyAliasDeclaration = - obj + U2 - /// This is either an `export =` or an `export default` declaration. - /// Unless `isExportEquals` is set, this node was parsed as an `export default`. + /// + /// This is either an export = or an export default declaration. + /// Unless isExportEquals is set, this node was parsed as an export default. + /// type [] ExportAssignment = inherit DeclarationStatement inherit JSDocContainer abstract kind: SyntaxKind abstract parent: SourceFile + abstract modifiers: ModifierLike[] option abstract isExportEquals: bool option abstract expression: Expression type [] FileReference = inherit TextRange abstract fileName: string with get, set + abstract resolutionMode: ResolutionMode option with get, set type [] CheckJsDirective = inherit TextRange abstract enabled: bool with get, set + /// + /// Original in TypeScript: + /// + /// SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia + /// + /// type CommentKind = SyntaxKind @@ -3325,8 +4389,8 @@ module Ts = type [] SynthesizedComment = inherit CommentRange abstract text: string with get, set - abstract pos: obj with get, set - abstract ``end``: obj with get, set + abstract pos: int with get, set + abstract ``end``: int with get, set abstract hasLeadingNewline: bool option with get, set type [] JSDocTypeExpression = @@ -3362,11 +4426,13 @@ module Ts = inherit JSDocType abstract kind: SyntaxKind abstract ``type``: TypeNode + abstract postfix: bool type [] JSDocNullableType = inherit JSDocType abstract kind: SyntaxKind abstract ``type``: TypeNode + abstract postfix: bool type [] JSDocOptionalType = inherit JSDocType @@ -3376,6 +4442,7 @@ module Ts = type [] JSDocFunctionType = inherit JSDocType inherit SignatureDeclarationBase + inherit LocalsContainer abstract kind: SyntaxKind type [] JSDocVariadicType = @@ -3388,21 +4455,28 @@ module Ts = abstract kind: SyntaxKind abstract ``type``: TypeNode - type JSDocTypeReferencingNode = - U4 + type [] [] JSDocTypeReferencingNode = + | [] JSDocNonNullableType of JSDocNonNullableType + | [] JSDocNullableType of JSDocNullableType + | [] JSDocOptionalType of JSDocOptionalType + | [] JSDocVariadicType of JSDocVariadicType + // static member inline op_ErasedCast(x: JSDocNonNullableType) = JSDocNonNullableType x + // static member inline op_ErasedCast(x: JSDocNullableType) = JSDocNullableType x + // static member inline op_ErasedCast(x: JSDocOptionalType) = JSDocOptionalType x + // static member inline op_ErasedCast(x: JSDocVariadicType) = JSDocVariadicType x type [] JSDoc = inherit Node abstract kind: SyntaxKind abstract parent: HasJSDoc - abstract tags: ResizeArray option - abstract comment: U2> option + abstract tags: JSDocTag[] option + abstract comment: U2 option type [] JSDocTag = inherit Node abstract parent: U2 abstract tagName: Identifier - abstract comment: U2> option + abstract comment: U2 option type [] JSDocLink = inherit Node @@ -3422,8 +4496,15 @@ module Ts = abstract name: U2 option abstract text: string with get, set - type JSDocComment = - U4 + type [] [] JSDocComment = + | [] JSDocLink of JSDocLink + | [] JSDocLinkCode of JSDocLinkCode + | [] JSDocLinkPlain of JSDocLinkPlain + | [] JSDocText of JSDocText + // static member inline op_ErasedCast(x: JSDocLink) = JSDocLink x + // static member inline op_ErasedCast(x: JSDocLinkCode) = JSDocLinkCode x + // static member inline op_ErasedCast(x: JSDocLinkPlain) = JSDocLinkPlain x + // static member inline op_ErasedCast(x: JSDocText) = JSDocText x type [] JSDocText = inherit Node @@ -3434,8 +4515,10 @@ module Ts = inherit JSDocTag abstract kind: SyntaxKind - /// Note that `@extends` is a synonym of `@augments`. + /// + /// Note that @extends is a synonym of @augments. /// Both tags are represented by this interface. + /// type [] JSDocAugmentsTag = inherit JSDocTag abstract kind: SyntaxKind @@ -3481,6 +4564,7 @@ module Ts = type [] JSDocEnumTag = inherit JSDocTag inherit Declaration + inherit LocalsContainer abstract kind: SyntaxKind abstract parent: JSDoc abstract typeExpression: JSDocTypeExpression @@ -3494,7 +4578,7 @@ module Ts = inherit JSDocTag abstract kind: SyntaxKind abstract ``constraint``: JSDocTypeExpression option - abstract typeParameters: ResizeArray + abstract typeParameters: TypeParameterDeclaration[] type [] JSDocSeeTag = inherit JSDocTag @@ -3514,6 +4598,7 @@ module Ts = type [] JSDocTypedefTag = inherit JSDocTag inherit NamedDeclaration + inherit LocalsContainer abstract kind: SyntaxKind abstract parent: JSDoc abstract fullName: U2 option @@ -3523,18 +4608,32 @@ module Ts = type [] JSDocCallbackTag = inherit JSDocTag inherit NamedDeclaration + inherit LocalsContainer abstract kind: SyntaxKind abstract parent: JSDoc abstract fullName: U2 option abstract name: Identifier option abstract typeExpression: JSDocSignature + type [] JSDocOverloadTag = + inherit JSDocTag + abstract kind: SyntaxKind + abstract parent: JSDoc + abstract typeExpression: JSDocSignature + + type [] JSDocThrowsTag = + inherit JSDocTag + abstract kind: SyntaxKind + abstract typeExpression: JSDocTypeExpression option + type [] JSDocSignature = inherit JSDocType inherit Declaration + inherit JSDocContainer + inherit LocalsContainer abstract kind: SyntaxKind - abstract typeParameters: ResizeArray option - abstract parameters: ResizeArray + abstract typeParameters: JSDocTemplateTag[] option + abstract parameters: JSDocParameterTag[] abstract ``type``: JSDocReturnTag option type [] JSDocPropertyLikeTag = @@ -3557,11 +4656,17 @@ module Ts = type [] JSDocTypeLiteral = inherit JSDocType + inherit Declaration abstract kind: SyntaxKind - abstract jsDocPropertyTags: ResizeArray option + abstract jsDocPropertyTags: JSDocPropertyLikeTag[] option /// If true, then this type literal represents an *array* of its type. abstract isArrayType: bool + type [] JSDocSatisfiesTag = + inherit JSDocTag + abstract kind: SyntaxKind + abstract typeExpression: JSDocTypeExpression + type [] FlowFlags = | Unreachable = 1 | Start = 2 @@ -3580,7 +4685,7 @@ module Ts = | Condition = 96 type FlowNode = - U8 + U8 type [] FlowNodeBase = abstract flags: FlowFlags with get, set @@ -3592,7 +4697,7 @@ module Ts = type [] FlowLabel = inherit FlowNodeBase - abstract antecedents: ResizeArray option with get, set + abstract antecedents: FlowNode[] option with get, set type [] FlowAssignment = inherit FlowNodeBase @@ -3624,64 +4729,87 @@ module Ts = type [] FlowReduceLabel = inherit FlowNodeBase abstract target: FlowLabel with get, set - abstract antecedents: ResizeArray with get, set + abstract antecedents: FlowNode[] with get, set abstract antecedent: FlowNode with get, set type FlowType = U2 type [] IncompleteType = - abstract flags: TypeFlags with get, set + abstract flags: U2 with get, set abstract ``type``: Type with get, set type [] AmdDependency = abstract path: string with get, set abstract name: string option with get, set + /// Subset of properties from SourceFile that are used in multiple utility functions + type [] SourceFileLike = + abstract text: string + abstract getLineAndCharacterOfPosition: pos: float -> LineAndCharacter + + /// + /// Original in TypeScript: + /// + /// ModuleKind.ESNext | ModuleKind.CommonJS | undefined + /// + /// + type ResolutionMode = + ModuleKind + type [] SourceFile = inherit Declaration + inherit LocalsContainer abstract kind: SyntaxKind - abstract statements: ResizeArray + abstract statements: Statement[] abstract endOfFileToken: Token abstract fileName: string with get, set abstract text: string with get, set - abstract amdDependencies: ResizeArray with get, set + abstract amdDependencies: AmdDependency[] with get, set abstract moduleName: string option with get, set - abstract referencedFiles: ResizeArray with get, set - abstract typeReferenceDirectives: ResizeArray with get, set - abstract libReferenceDirectives: ResizeArray with get, set + abstract referencedFiles: FileReference[] with get, set + abstract typeReferenceDirectives: FileReference[] with get, set + abstract libReferenceDirectives: FileReference[] with get, set abstract languageVariant: LanguageVariant with get, set abstract isDeclarationFile: bool with get, set /// lib.d.ts should have a reference comment like - /// + /// /// /// - /// + /// /// If any other file has this comment, it signals not to include lib.d.ts /// because this containing file is intended to act as a default library. abstract hasNoDefaultLib: bool with get, set abstract languageVersion: ScriptTarget with get, set - /// When `module` is `Node12` or `NodeNext`, this field controls whether the + /// + /// When module is Node16 or NodeNext, this field controls whether the /// source file in question is an ESNext-output-format file, or a CommonJS-output-format /// module. This is derived by the module resolver as it looks up the file, since /// it is derived from either the file extension of the module, or the containing - /// `package.json` context, and affects both checking and emit. - /// + /// package.json context, and affects both checking and emit. + /// /// It is _public_ so that (pre)transformers can set this field, - /// since it switches the builtin `node` module transform. Generally speaking, if unset, - /// the field is treated as though it is `ModuleKind.CommonJS`. - abstract impliedNodeFormat: ModuleKind option with get, set + /// since it switches the builtin node module transform. Generally speaking, if unset, + /// the field is treated as though it is ModuleKind.CommonJS. + /// + /// Note that this field is only set by the module resolution process when + /// moduleResolution is Node16 or NodeNext, which is implied by the module setting + /// of Node16 or NodeNext, respectively, but may be overriden (eg, by a moduleResolution + /// of node). If so, this field will be unset and source files will be considered to be + /// CommonJS-output-format by the node module transformer and type checker, regardless of extension or context. + /// + abstract impliedNodeFormat: ResolutionMode option with get, set abstract getLineAndCharacterOfPosition: pos: float -> LineAndCharacter abstract getLineEndOfPosition: pos: float -> float - abstract getLineStarts: unit -> ResizeArray + abstract getLineStarts: unit -> float[] abstract getPositionOfLineAndCharacter: line: float * character: float -> float abstract update: newText: string * textChangeRange: TextChangeRange -> SourceFile type [] Bundle = inherit Node abstract kind: SyntaxKind - abstract prepends: ResizeArray> - abstract sourceFiles: ResizeArray + abstract sourceFiles: SourceFile[] + [] type [] InputFiles = inherit Node abstract kind: SyntaxKind @@ -3694,52 +4822,74 @@ module Ts = abstract declarationMapPath: string option with get, set abstract declarationMapText: string option with get, set + [] type [] UnparsedSource = inherit Node abstract kind: SyntaxKind abstract fileName: string with get, set abstract text: string with get, set - abstract prologues: ResizeArray - abstract helpers: ResizeArray option with get, set - abstract referencedFiles: ResizeArray with get, set - abstract typeReferenceDirectives: ResizeArray option with get, set - abstract libReferenceDirectives: ResizeArray with get, set + abstract prologues: UnparsedPrologue[] + abstract helpers: UnscopedEmitHelper[] option with get, set + abstract referencedFiles: FileReference[] with get, set + abstract typeReferenceDirectives: FileReference[] option with get, set + abstract libReferenceDirectives: FileReference[] with get, set abstract hasNoDefaultLib: bool option with get, set abstract sourceMapPath: string option with get, set abstract sourceMapText: string option with get, set - abstract syntheticReferences: ResizeArray option - abstract texts: ResizeArray - - type UnparsedSourceText = - U2 - - type UnparsedNode = - U3 - + abstract syntheticReferences: UnparsedSyntheticReference[] option + abstract texts: UnparsedSourceText[] + + /// + type [] [] UnparsedSourceText = + | [] UnparsedTextLike of UnparsedTextLike + | [] UnparsedPrepend of UnparsedPrepend + | [] UnparsedTextLike' of UnparsedTextLike + // static member inline op_ErasedCast(x: UnparsedTextLike) = UnparsedTextLike x + // static member inline op_ErasedCast(x: UnparsedPrepend) = UnparsedPrepend x + // static member inline op_ErasedCast(x: UnparsedTextLike) = UnparsedTextLike' x + + /// + type [] [] UnparsedNode = + | [] UnparsedTextLike of UnparsedTextLike + | [] UnparsedPrepend of UnparsedPrepend + | [] UnparsedPrologue of UnparsedPrologue + | [] UnparsedSyntheticReference of UnparsedSyntheticReference + | [] UnparsedTextLike' of UnparsedTextLike + // static member inline op_ErasedCast(x: UnparsedTextLike) = UnparsedTextLike x + // static member inline op_ErasedCast(x: UnparsedPrepend) = UnparsedPrepend x + // static member inline op_ErasedCast(x: UnparsedPrologue) = UnparsedPrologue x + // static member inline op_ErasedCast(x: UnparsedSyntheticReference) = UnparsedSyntheticReference x + // static member inline op_ErasedCast(x: UnparsedTextLike) = UnparsedTextLike' x + + [] type [] UnparsedSection = inherit Node abstract kind: SyntaxKind abstract parent: UnparsedSource abstract data: string option + [] type [] UnparsedPrologue = inherit UnparsedSection abstract kind: SyntaxKind abstract parent: UnparsedSource abstract data: string + [] type [] UnparsedPrepend = inherit UnparsedSection abstract kind: SyntaxKind abstract parent: UnparsedSource abstract data: string - abstract texts: ResizeArray + abstract texts: UnparsedTextLike[] + [] type [] UnparsedTextLike = inherit UnparsedSection abstract kind: SyntaxKind abstract parent: UnparsedSource + [] type [] UnparsedSyntheticReference = inherit UnparsedSection abstract kind: SyntaxKind @@ -3747,11 +4897,11 @@ module Ts = type [] JsonSourceFile = inherit SourceFile - abstract statements: ResizeArray + abstract statements: JsonObjectExpressionStatement[] type [] TsConfigSourceFile = inherit JsonSourceFile - abstract extendedSourceFiles: ResizeArray option with get, set + abstract extendedSourceFiles: string[] option with get, set type [] JsonMinusNumericLiteral = inherit PrefixUnaryExpression @@ -3759,8 +4909,23 @@ module Ts = abstract operator: SyntaxKind abstract operand: NumericLiteral - type JsonObjectExpression = - U7 + type [] [] JsonObjectExpression = + | [] ArrayLiteralExpression of ArrayLiteralExpression + | [] FalseLiteral of FalseLiteral + | [] NullLiteral of NullLiteral + | [] NumericLiteral of NumericLiteral + | [] ObjectLiteralExpression of ObjectLiteralExpression + | [] JsonMinusNumericLiteral of JsonMinusNumericLiteral + | [] StringLiteral of StringLiteral + | [] TrueLiteral of TrueLiteral + // static member inline op_ErasedCast(x: ArrayLiteralExpression) = ArrayLiteralExpression x + // static member inline op_ErasedCast(x: FalseLiteral) = FalseLiteral x + // static member inline op_ErasedCast(x: NullLiteral) = NullLiteral x + // static member inline op_ErasedCast(x: NumericLiteral) = NumericLiteral x + // static member inline op_ErasedCast(x: ObjectLiteralExpression) = ObjectLiteralExpression x + // static member inline op_ErasedCast(x: JsonMinusNumericLiteral) = JsonMinusNumericLiteral x + // static member inline op_ErasedCast(x: StringLiteral) = StringLiteral x + // static member inline op_ErasedCast(x: TrueLiteral) = TrueLiteral x type [] JsonObjectExpressionStatement = inherit ExpressionStatement @@ -3774,52 +4939,59 @@ module Ts = type [] ParseConfigHost = abstract useCaseSensitiveFileNames: bool with get, set - abstract readDirectory: rootDir: string * extensions: ResizeArray * excludes: ResizeArray option * includes: ResizeArray * ?depth: float -> ResizeArray + abstract readDirectory: rootDir: string * extensions: string[] * excludes: string[] option * includes: string[] * ?depth: float -> string[] /// Gets a value indicating whether the specified path exists and is a file. /// The path to test. abstract fileExists: path: string -> bool abstract readFile: path: string -> string option abstract trace: s: string -> unit + /// Branded string for keeping track of when we've turned an ambiguous path + /// specified like "./blah" to an absolute path to an actual + /// tsconfig file, e.g. "/root/blah/tsconfig.json" type [] ResolvedConfigFileName = interface end + type [] WriteFileCallbackData = + interface end + type [] WriteFileCallback = - [] abstract Invoke: fileName: string * data: string * writeByteOrderMark: bool * ?onError: (string -> unit) * ?sourceFiles: ResizeArray -> unit + [] abstract Invoke: fileName: string * text: string * writeByteOrderMark: bool * ?onError: (string -> unit) * ?sourceFiles: SourceFile[] * ?data: WriteFileCallbackData -> unit type [] OperationCanceledException = interface end type [] OperationCanceledExceptionStatic = - [] abstract Create: unit -> OperationCanceledException + [] abstract Create: unit -> OperationCanceledException type [] CancellationToken = abstract isCancellationRequested: unit -> bool + /// OperationCanceledException if isCancellationRequested is true abstract throwIfCancellationRequested: unit -> unit type [] Program = inherit ScriptReferenceHost abstract getCurrentDirectory: unit -> string /// Get a list of root file names that were passed to a 'createProgram' - abstract getRootFileNames: unit -> ResizeArray + abstract getRootFileNames: unit -> string[] /// Get a list of files in the program - abstract getSourceFiles: unit -> ResizeArray + abstract getSourceFiles: unit -> SourceFile[] /// Emits the JavaScript and declaration files. If targetSourceFile is not specified, then /// the JavaScript and declaration files will be produced for all the files in this program. /// If targetSourceFile is specified, then only the JavaScript and declaration for that /// specific file will be generated. - /// + /// /// If writeFile is not specified then the writeFile callback from the compiler host will be /// used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter /// will be invoked when writing the JavaScript and declaration files. abstract emit: ?targetSourceFile: SourceFile * ?writeFile: WriteFileCallback * ?cancellationToken: CancellationToken * ?emitOnlyDtsFiles: bool * ?customTransformers: CustomTransformers -> EmitResult - abstract getOptionsDiagnostics: ?cancellationToken: CancellationToken -> ResizeArray - abstract getGlobalDiagnostics: ?cancellationToken: CancellationToken -> ResizeArray - abstract getSyntacticDiagnostics: ?sourceFile: SourceFile * ?cancellationToken: CancellationToken -> ResizeArray + abstract getOptionsDiagnostics: ?cancellationToken: CancellationToken -> Diagnostic[] + abstract getGlobalDiagnostics: ?cancellationToken: CancellationToken -> Diagnostic[] + abstract getSyntacticDiagnostics: ?sourceFile: SourceFile * ?cancellationToken: CancellationToken -> DiagnosticWithLocation[] /// The first time this is called, it will return global diagnostics (no location). - abstract getSemanticDiagnostics: ?sourceFile: SourceFile * ?cancellationToken: CancellationToken -> ResizeArray - abstract getDeclarationDiagnostics: ?sourceFile: SourceFile * ?cancellationToken: CancellationToken -> ResizeArray - abstract getConfigFileParsingDiagnostics: unit -> ResizeArray + abstract getSemanticDiagnostics: ?sourceFile: SourceFile * ?cancellationToken: CancellationToken -> Diagnostic[] + abstract getDeclarationDiagnostics: ?sourceFile: SourceFile * ?cancellationToken: CancellationToken -> DiagnosticWithLocation[] + abstract getConfigFileParsingDiagnostics: unit -> Diagnostic[] /// Gets a type checker that can be used to semantically analyze source files in the program. abstract getTypeChecker: unit -> TypeChecker abstract getNodeCount: unit -> float @@ -3827,25 +4999,19 @@ module Ts = abstract getSymbolCount: unit -> float abstract getTypeCount: unit -> float abstract getInstantiationCount: unit -> float - abstract getRelationCacheSizes: unit -> ProgramGetRelationCacheSizesReturn + abstract getRelationCacheSizes: unit -> {| assignable: float; identity: float; subtype: float; strictSubtype: float |} abstract isSourceFileFromExternalLibrary: file: SourceFile -> bool abstract isSourceFileDefaultLibrary: file: SourceFile -> bool - abstract getProjectReferences: unit -> ResizeArray option - abstract getResolvedProjectReferences: unit -> ResizeArray option - - type [] ProgramGetRelationCacheSizesReturn = - abstract assignable: float with get, set - abstract identity: float with get, set - abstract subtype: float with get, set - abstract strictSubtype: float with get, set + abstract getProjectReferences: unit -> ProjectReference[] option + abstract getResolvedProjectReferences: unit -> ResolvedProjectReference option[] option type [] ResolvedProjectReference = abstract commandLine: ParsedCommandLine with get, set abstract sourceFile: SourceFile with get, set - abstract references: ResizeArray option with get, set + abstract references: ResolvedProjectReference option[] option with get, set type [] CustomTransformerFactory = - [] abstract Invoke: context: TransformationContext -> CustomTransformer + [] abstract Invoke: context: TransformationContext -> CustomTransformer type [] CustomTransformer = abstract transformSourceFile: node: SourceFile -> SourceFile @@ -3853,11 +5019,11 @@ module Ts = type [] CustomTransformers = /// Custom transformers to evaluate before built-in .js transformations. - abstract before: ResizeArray, CustomTransformerFactory>> option with get, set + abstract before: U2, CustomTransformerFactory>[] option with get, set /// Custom transformers to evaluate after built-in .js transformations. - abstract after: ResizeArray, CustomTransformerFactory>> option with get, set + abstract after: U2, CustomTransformerFactory>[] option with get, set /// Custom transformers to evaluate after built-in .d.ts transformations. - abstract afterDeclarations: ResizeArray>, CustomTransformerFactory>> option with get, set + abstract afterDeclarations: U2>, CustomTransformerFactory>[] option with get, set type [] SourceMapSpan = /// Line number in the .js file. @@ -3873,37 +5039,39 @@ module Ts = /// .ts file (index into sources array) associated with this span abstract sourceIndex: float with get, set + /// Return code used by getEmitOutput function to indicate status of the function type [] ExitStatus = | Success = 0 | DiagnosticsPresent_OutputsSkipped = 1 | DiagnosticsPresent_OutputsGenerated = 2 | InvalidProject_OutputsSkipped = 3 | ProjectReferenceCycle_OutputsSkipped = 4 - | ProjectReferenceCycle_OutputsSkupped = 4 type [] EmitResult = abstract emitSkipped: bool with get, set /// Contains declaration emit diagnostics - abstract diagnostics: ResizeArray with get, set - abstract emittedFiles: ResizeArray option with get, set + abstract diagnostics: Diagnostic[] with get, set + abstract emittedFiles: string[] option with get, set type [] TypeChecker = abstract getTypeOfSymbolAtLocation: symbol: Symbol * node: Node -> Type + abstract getTypeOfSymbol: symbol: Symbol -> Type abstract getDeclaredTypeOfSymbol: symbol: Symbol -> Type - abstract getPropertiesOfType: ``type``: Type -> ResizeArray + abstract getPropertiesOfType: ``type``: Type -> Symbol[] abstract getPropertyOfType: ``type``: Type * propertyName: string -> Symbol option abstract getPrivateIdentifierPropertyOfType: leftType: Type * name: string * location: Node -> Symbol option abstract getIndexInfoOfType: ``type``: Type * kind: IndexKind -> IndexInfo option - abstract getIndexInfosOfType: ``type``: Type -> ResizeArray - abstract getSignaturesOfType: ``type``: Type * kind: SignatureKind -> ResizeArray + abstract getIndexInfosOfType: ``type``: Type -> IndexInfo[] + abstract getIndexInfosOfIndexSymbol: indexSymbol: Symbol -> IndexInfo[] + abstract getSignaturesOfType: ``type``: Type * kind: SignatureKind -> Signature[] abstract getIndexTypeOfType: ``type``: Type * kind: IndexKind -> Type option - abstract getBaseTypes: ``type``: InterfaceType -> ResizeArray + abstract getBaseTypes: ``type``: InterfaceType -> BaseType[] abstract getBaseTypeOfLiteralType: ``type``: Type -> Type abstract getWidenedType: ``type``: Type -> Type abstract getReturnTypeOfSignature: signature: Signature -> Type abstract getNullableType: ``type``: Type * flags: TypeFlags -> Type abstract getNonNullableType: ``type``: Type -> Type - abstract getTypeArguments: ``type``: TypeReference -> ResizeArray + abstract getTypeArguments: ``type``: TypeReference -> Type[] /// Note that the resulting nodes cannot be checked. abstract typeToTypeNode: ``type``: Type * enclosingDeclaration: Node option * flags: NodeBuilderFlags option -> TypeNode option /// Note that the resulting nodes cannot be checked. @@ -3915,24 +5083,26 @@ module Ts = /// Note that the resulting nodes cannot be checked. abstract symbolToExpression: symbol: Symbol * meaning: SymbolFlags * enclosingDeclaration: Node option * flags: NodeBuilderFlags option -> Expression option /// Note that the resulting nodes cannot be checked. - abstract symbolToTypeParameterDeclarations: symbol: Symbol * enclosingDeclaration: Node option * flags: NodeBuilderFlags option -> ResizeArray option + abstract symbolToTypeParameterDeclarations: symbol: Symbol * enclosingDeclaration: Node option * flags: NodeBuilderFlags option -> TypeParameterDeclaration[] option /// Note that the resulting nodes cannot be checked. abstract symbolToParameterDeclaration: symbol: Symbol * enclosingDeclaration: Node option * flags: NodeBuilderFlags option -> ParameterDeclaration option /// Note that the resulting nodes cannot be checked. abstract typeParameterToDeclaration: parameter: TypeParameter * enclosingDeclaration: Node option * flags: NodeBuilderFlags option -> TypeParameterDeclaration option - abstract getSymbolsInScope: location: Node * meaning: SymbolFlags -> ResizeArray + abstract getSymbolsInScope: location: Node * meaning: SymbolFlags -> Symbol[] abstract getSymbolAtLocation: node: Node -> Symbol option - abstract getSymbolsOfParameterPropertyDeclaration: parameter: ParameterDeclaration * parameterName: string -> ResizeArray + abstract getSymbolsOfParameterPropertyDeclaration: parameter: ParameterDeclaration * parameterName: string -> Symbol[] /// The function returns the value (local variable) symbol of an identifier in the short-hand property assignment. /// This is necessary as an identifier in short-hand property assignment can contains two meaning: property name and property value. abstract getShorthandAssignmentValueSymbol: location: Node option -> Symbol option abstract getExportSpecifierLocalTargetSymbol: location: U2 -> Symbol option + /// /// If a symbol is a local symbol with an associated exported symbol, returns the exported symbol. /// Otherwise returns its input. - /// For example, at `export type T = number;`: - /// - `getSymbolAtLocation` at the location `T` will return the exported symbol for `T`. - /// - But the result of `getSymbolsInScope` will contain the *local* symbol for `T`, not the exported symbol. - /// - Calling `getExportSymbolOfSymbol` on that local symbol will return the exported symbol. + /// For example, at export type T = number;: + /// - getSymbolAtLocation at the location T will return the exported symbol for T. + /// - But the result of getSymbolsInScope will contain the *local* symbol for T, not the exported symbol. + /// - Calling getExportSymbolOfSymbol on that local symbol will return the exported symbol. + /// abstract getExportSymbolOfSymbol: symbol: Symbol -> Symbol abstract getPropertySymbolOfDestructuringAssignment: location: Identifier -> Symbol option abstract getTypeOfAssignmentPattern: pattern: AssignmentPattern -> Type @@ -3943,14 +5113,16 @@ module Ts = abstract symbolToString: symbol: Symbol * ?enclosingDeclaration: Node * ?meaning: SymbolFlags * ?flags: SymbolFormatFlags -> string abstract typePredicateToString: predicate: TypePredicate * ?enclosingDeclaration: Node * ?flags: TypeFormatFlags -> string abstract getFullyQualifiedName: symbol: Symbol -> string - abstract getAugmentedPropertiesOfType: ``type``: Type -> ResizeArray - abstract getRootSymbols: symbol: Symbol -> ResizeArray + abstract getAugmentedPropertiesOfType: ``type``: Type -> Symbol[] + abstract getRootSymbols: symbol: Symbol -> Symbol[] abstract getSymbolOfExpando: node: Node * allowDeclaration: bool -> Symbol option abstract getContextualType: node: Expression -> Type option - /// returns unknownSignature in the case of an error. - /// returns undefined if the node is not valid. - /// Apparent number of arguments, passed in case of a possibly incomplete call. This should come from an ArgumentListInfo. See `signatureHelp.ts`. - abstract getResolvedSignature: node: CallLikeExpression * ?candidatesOutArray: ResizeArray * ?argumentCount: float -> Signature option + /// + /// returns unknownSignature in the case of an error. + /// returns undefined if the node is not valid. + /// + /// Apparent number of arguments, passed in case of a possibly incomplete call. This should come from an ArgumentListInfo. See signatureHelp.ts. + abstract getResolvedSignature: node: CallLikeExpression * ?candidatesOutArray: Signature[] * ?argumentCount: float -> Signature option abstract getSignatureFromDeclaration: declaration: SignatureDeclaration -> Signature option abstract isImplementationOfOverload: node: SignatureDeclaration -> bool option abstract isUndefinedSymbol: symbol: Symbol -> bool @@ -3962,14 +5134,59 @@ module Ts = abstract getAliasedSymbol: symbol: Symbol -> Symbol /// Follow a *single* alias to get the immediately aliased symbol. abstract getImmediateAliasedSymbol: symbol: Symbol -> Symbol option - abstract getExportsOfModule: moduleSymbol: Symbol -> ResizeArray - abstract getJsxIntrinsicTagNamesAt: location: Node -> ResizeArray + abstract getExportsOfModule: moduleSymbol: Symbol -> Symbol[] + abstract getJsxIntrinsicTagNamesAt: location: Node -> Symbol[] abstract isOptionalParameter: node: ParameterDeclaration -> bool - abstract getAmbientModules: unit -> ResizeArray + abstract getAmbientModules: unit -> Symbol[] abstract tryGetMemberInModuleExports: memberName: string * moduleSymbol: Symbol -> Symbol option abstract getApparentType: ``type``: Type -> Type abstract getBaseConstraintOfType: ``type``: Type -> Type option abstract getDefaultFromTypeParameter: ``type``: Type -> Type option + /// + /// Gets the intrinsic any type. There are multiple types that act as any used internally in the compiler, + /// so the type returned by this function should not be used in equality checks to determine if another type + /// is any. Instead, use type.flags & TypeFlags.Any. + /// + abstract getAnyType: unit -> Type + abstract getStringType: unit -> Type + abstract getStringLiteralType: value: string -> StringLiteralType + abstract getNumberType: unit -> Type + abstract getNumberLiteralType: value: float -> NumberLiteralType + abstract getBigIntType: unit -> Type + abstract getBooleanType: unit -> Type + abstract getFalseType: unit -> Type + abstract getTrueType: unit -> Type + abstract getVoidType: unit -> Type + /// + /// Gets the intrinsic undefined type. There are multiple types that act as undefined used internally in the compiler + /// depending on compiler options, so the type returned by this function should not be used in equality checks to determine + /// if another type is undefined. Instead, use type.flags & TypeFlags.Undefined. + /// + abstract getUndefinedType: unit -> Type + /// + /// Gets the intrinsic null type. There are multiple types that act as null used internally in the compiler, + /// so the type returned by this function should not be used in equality checks to determine if another type + /// is null. Instead, use type.flags & TypeFlags.Null. + /// + abstract getNullType: unit -> Type + abstract getESSymbolType: unit -> Type + /// + /// Gets the intrinsic never type. There are multiple types that act as never used internally in the compiler, + /// so the type returned by this function should not be used in equality checks to determine if another type + /// is never. Instead, use type.flags & TypeFlags.Never. + /// + abstract getNeverType: unit -> Type + /// + /// True if this type is the Array or ReadonlyArray type from lib.d.ts. + /// This function will _not_ return true if passed a type which + /// extends Array (for example, the TypeScript AST's NodeArray type). + /// + abstract isArrayType: ``type``: Type -> bool + /// True if this type is a tuple type. This function will _not_ return true if + /// passed a type which extends from a tuple. + abstract isTupleType: ``type``: Type -> bool + /// True if this type is assignable to ReadonlyArray<any>. + abstract isArrayLikeType: ``type``: Type -> bool abstract getTypePredicateOfSignature: signature: Signature -> TypePredicate option /// Depending on the operation performed, it may be appropriate to throw away the checker /// if the cancellation token is triggered. Typically, if it is used for error checking @@ -3995,10 +5212,9 @@ module Ts = | UseAliasDefinedOutsideCurrentScope = 16384 | UseSingleQuotesForStringLiteralType = 268435456 | NoTypeReduction = 536870912 - | NoUndefinedOptionalParameterType = 1073741824 + | OmitThisParameter = 33554432 | AllowThisInObjectLiteral = 32768 | AllowQualifiedNameInPlaceOfIdentifier = 65536 - | AllowQualifedNameInPlaceOfIdentifier = 65536 | AllowAnonymousIdentifier = 131072 | AllowEmptyUnionOrIntersection = 262144 | AllowEmptyTuple = 524288 @@ -4025,6 +5241,7 @@ module Ts = | UseAliasDefinedOutsideCurrentScope = 16384 | UseSingleQuotesForStringLiteralType = 268435456 | NoTypeReduction = 536870912 + | OmitThisParameter = 33554432 | AllowUniqueESSymbolType = 1048576 | AddUndefined = 131072 | WriteArrowStyleSignature = 262144 @@ -4032,8 +5249,7 @@ module Ts = | InElementType = 2097152 | InFirstTypeArgument = 4194304 | InTypeAlias = 8388608 - | WriteOwnNameForAnyLike = 0 - | NodeBuilderFlagsMask = 814775659 + | NodeBuilderFlagsMask = 848330091 type [] SymbolFormatFlags = | None = 0 @@ -4080,8 +5296,15 @@ module Ts = abstract parameterIndex: float with get, set abstract ``type``: Type option with get, set - type TypePredicate = - U4 + type [] [] TypePredicate = + | [] AssertsIdentifierTypePredicate of AssertsIdentifierTypePredicate + | [] AssertsThisTypePredicate of AssertsThisTypePredicate + | [] IdentifierTypePredicate of IdentifierTypePredicate + | [] ThisTypePredicate of ThisTypePredicate + // static member inline op_ErasedCast(x: AssertsIdentifierTypePredicate) = AssertsIdentifierTypePredicate x + // static member inline op_ErasedCast(x: AssertsThisTypePredicate) = AssertsThisTypePredicate x + // static member inline op_ErasedCast(x: IdentifierTypePredicate) = IdentifierTypePredicate x + // static member inline op_ErasedCast(x: ThisTypePredicate) = ThisTypePredicate x type [] SymbolFlags = | None = 0 @@ -4135,6 +5358,7 @@ module Ts = | MethodExcludes = 103359 | GetAccessorExcludes = 46015 | SetAccessorExcludes = 78783 + | AccessorExcludes = 13247 | TypeParameterExcludes = 526824 | TypeAliasExcludes = 788968 | AliasExcludes = 2097152 @@ -4147,7 +5371,7 @@ module Ts = type [] Symbol = abstract flags: SymbolFlags with get, set abstract escapedName: __String with get, set - abstract declarations: ResizeArray option with get, set + abstract declarations: Declaration[] option with get, set abstract valueDeclaration: Declaration option with get, set abstract members: SymbolTable option with get, set abstract exports: SymbolTable option with get, set @@ -4156,43 +5380,49 @@ module Ts = abstract getFlags: unit -> SymbolFlags abstract getEscapedName: unit -> __String abstract getName: unit -> string - abstract getDeclarations: unit -> ResizeArray option - abstract getDocumentationComment: typeChecker: TypeChecker option -> ResizeArray - abstract getJsDocTags: ?checker: TypeChecker -> ResizeArray + abstract getDeclarations: unit -> Declaration[] option + abstract getDocumentationComment: typeChecker: TypeChecker option -> SymbolDisplayPart[] + abstract getJsDocTags: ?checker: TypeChecker -> JSDocTagInfo[] type [] [] InternalSymbolName = - | [] Call - | [] Constructor - | [] New - | [] Index - | [] ExportStar - | [] Global - | [] Missing - | [] Type - | [] Object - | [] JSXAttributes - | [] Class - | [] Function - | [] Computed - | [] Resolving - | [] Call + | [] Constructor + | [] New + | [] Index + | [] ExportStar + | [] Global + | [] Missing + | [] Type + | [] Object + | [] JSXAttributes + | [] Class + | [] Function + | [] Computed + | [] Resolving + | [] ExportEquals | Default | This + /// This represents a string whose leading underscore have been escaped by adding extra leading underscores. + /// The shape of this brand is rather unique compared to others we've used. + /// Instead of just an intersection of a string and an object, it is that union-ed + /// with an intersection of void and an object. This makes it wholly incompatible + /// with a normal string (which is good, it cannot be misused on assignment or on usage), + /// while still being comparable with a normal string via === (also good) and castable from a string. type __String = U2 - /// ReadonlyMap where keys are `__String`s. - type [] ReadonlyUnderscoreEscapedMap<'T> = - inherit ReadonlyESMap<__String, 'T> + [ instead.")>] + type ReadonlyUnderscoreEscapedMap<'T> = + ReadonlyMap<__String, 'T> - /// Map where keys are `__String`s. - type [] UnderscoreEscapedMap<'T> = - inherit ESMap<__String, 'T> - inherit ReadonlyUnderscoreEscapedMap<'T> + [ instead.")>] + type UnderscoreEscapedMap<'T> = + Map<__String, 'T> + /// SymbolTable based on ES6 Map interface. type SymbolTable = - UnderscoreEscapedMap + Map<__String, Symbol> type [] TypeFlags = | Any = 1 @@ -4225,7 +5455,8 @@ module Ts = | TemplateLiteral = 134217728 | StringMapping = 268435456 | Literal = 2944 - | Unit = 109440 + | Unit = 109472 + | Freshable = 2976 | StringOrNumberLiteral = 384 | PossiblyFalsy = 117724 | StringLike = 402653316 @@ -4244,25 +5475,32 @@ module Ts = | StructuredOrInstantiable = 469499904 | Narrowable = 536624127 - type DestructuringPattern = - U3 + type [] [] DestructuringPattern = + | [] ArrayBindingPattern of ArrayBindingPattern + | [] ArrayLiteralExpression of ArrayLiteralExpression + | [] ObjectBindingPattern of ObjectBindingPattern + | [] ObjectLiteralExpression of ObjectLiteralExpression + // static member inline op_ErasedCast(x: ArrayBindingPattern) = ArrayBindingPattern x + // static member inline op_ErasedCast(x: ArrayLiteralExpression) = ArrayLiteralExpression x + // static member inline op_ErasedCast(x: ObjectBindingPattern) = ObjectBindingPattern x + // static member inline op_ErasedCast(x: ObjectLiteralExpression) = ObjectLiteralExpression x type [] Type = abstract flags: TypeFlags with get, set abstract symbol: Symbol with get, set abstract pattern: DestructuringPattern option with get, set abstract aliasSymbol: Symbol option with get, set - abstract aliasTypeArguments: ResizeArray option with get, set + abstract aliasTypeArguments: Type[] option with get, set abstract getFlags: unit -> TypeFlags abstract getSymbol: unit -> Symbol option - abstract getProperties: unit -> ResizeArray + abstract getProperties: unit -> Symbol[] abstract getProperty: propertyName: string -> Symbol option - abstract getApparentProperties: unit -> ResizeArray - abstract getCallSignatures: unit -> ResizeArray - abstract getConstructSignatures: unit -> ResizeArray + abstract getApparentProperties: unit -> Symbol[] + abstract getCallSignatures: unit -> Signature[] + abstract getConstructSignatures: unit -> Signature[] abstract getStringIndexType: unit -> Type option abstract getNumberIndexType: unit -> Type option - abstract getBaseTypes: unit -> ResizeArray option + abstract getBaseTypes: unit -> BaseType[] option abstract getNonNullableType: unit -> Type abstract getConstraint: unit -> Type option abstract getDefault: unit -> Type option @@ -4275,12 +5513,16 @@ module Ts = abstract isTypeParameter: unit -> bool abstract isClassOrInterface: unit -> bool abstract isClass: unit -> bool + abstract isIndexType: unit -> bool - type [] LiteralType = + type [] FreshableType = inherit Type + abstract freshType: FreshableType with get, set + abstract regularType: FreshableType with get, set + + type [] LiteralType = + inherit FreshableType abstract value: U3 with get, set - abstract freshType: LiteralType with get, set - abstract regularType: LiteralType with get, set type [] UniqueESSymbolType = inherit Type @@ -4300,9 +5542,10 @@ module Ts = abstract value: PseudoBigInt with get, set type [] EnumType = - inherit Type + inherit FreshableType type [] ObjectFlags = + | None = 0 | Class = 1 | Interface = 2 | Reference = 4 @@ -4315,13 +5558,13 @@ module Ts = | ObjectLiteralPatternWithComputedProperties = 512 | ReverseMapped = 1024 | JsxAttributes = 2048 - | MarkerType = 4096 - | JSLiteral = 8192 - | FreshLiteral = 16384 - | ArrayLiteral = 32768 + | JSLiteral = 4096 + | FreshLiteral = 8192 + | ArrayLiteral = 16384 | ClassOrInterface = 3 - | ContainsSpread = 4194304 - | ObjectRestType = 8388608 + | ContainsSpread = 2097152 + | ObjectRestType = 4194304 + | InstantiationExpressionType = 8388608 type [] ObjectType = inherit Type @@ -4330,9 +5573,9 @@ module Ts = /// Class and interface types (ObjectFlags.Class and ObjectFlags.Interface). type [] InterfaceType = inherit ObjectType - abstract typeParameters: ResizeArray option with get, set - abstract outerTypeParameters: ResizeArray option with get, set - abstract localTypeParameters: ResizeArray option with get, set + abstract typeParameters: TypeParameter[] option with get, set + abstract outerTypeParameters: TypeParameter[] option with get, set + abstract localTypeParameters: TypeParameter[] option with get, set abstract thisType: TypeParameter option with get, set type BaseType = @@ -4340,10 +5583,10 @@ module Ts = type [] InterfaceTypeWithDeclaredMembers = inherit InterfaceType - abstract declaredProperties: ResizeArray with get, set - abstract declaredCallSignatures: ResizeArray with get, set - abstract declaredConstructSignatures: ResizeArray with get, set - abstract declaredIndexInfos: ResizeArray with get, set + abstract declaredProperties: Symbol[] with get, set + abstract declaredCallSignatures: Signature[] with get, set + abstract declaredConstructSignatures: Signature[] with get, set + abstract declaredIndexInfos: IndexInfo[] with get, set /// Type references (ObjectFlags.Reference). When a class or interface has type parameters or /// a "this" type, references to the class or interface are made using type references. The @@ -4357,7 +5600,7 @@ module Ts = inherit ObjectType abstract target: GenericType with get, set abstract node: U3 option with get, set - abstract typeArguments: ResizeArray option with get, set + abstract typeArguments: Type[] option with get, set type [] DeferredTypeReference = inherit TypeReference @@ -4378,13 +5621,16 @@ module Ts = type [] TupleType = inherit GenericType - abstract elementFlags: ResizeArray with get, set + abstract elementFlags: ElementFlags[] with get, set + /// Number of required or variadic elements abstract minLength: float with get, set + /// Number of initial required or optional elements abstract fixedLength: float with get, set + /// True if tuple has any rest or variadic elements abstract hasRestElement: bool with get, set abstract combinedFlags: ElementFlags with get, set abstract readonly: bool with get, set - abstract labeledElementDeclarations: ResizeArray> option with get, set + abstract labeledElementDeclarations: U2[] option with get, set type [] TupleTypeReference = inherit TypeReference @@ -4392,7 +5638,7 @@ module Ts = type [] UnionOrIntersectionType = inherit Type - abstract types: ResizeArray with get, set + abstract types: Type[] with get, set type [] UnionType = inherit UnionOrIntersectionType @@ -4434,11 +5680,11 @@ module Ts = abstract checkType: Type with get, set abstract extendsType: Type with get, set abstract isDistributive: bool with get, set - abstract inferTypeParameters: ResizeArray option with get, set - abstract outerTypeParameters: ResizeArray option with get, set - abstract instantiations: Map option with get, set + abstract inferTypeParameters: TypeParameter[] option with get, set + abstract outerTypeParameters: TypeParameter[] option with get, set + abstract instantiations: Map option with get, set abstract aliasSymbol: Symbol option with get, set - abstract aliasTypeArguments: ResizeArray option with get, set + abstract aliasTypeArguments: Type[] option with get, set type [] ConditionalType = inherit InstantiableType @@ -4450,8 +5696,8 @@ module Ts = type [] TemplateLiteralType = inherit InstantiableType - abstract texts: ResizeArray with get, set - abstract types: ResizeArray with get, set + abstract texts: string[] with get, set + abstract types: Type[] with get, set type [] StringMappingType = inherit InstantiableType @@ -4462,7 +5708,7 @@ module Ts = inherit InstantiableType abstract objectFlags: ObjectFlags with get, set abstract baseType: Type with get, set - abstract substitute: Type with get, set + abstract ``constraint``: Type with get, set type [] SignatureKind = | Call = 0 @@ -4470,14 +5716,15 @@ module Ts = type [] Signature = abstract declaration: U2 option with get, set - abstract typeParameters: ResizeArray option with get, set - abstract parameters: ResizeArray with get, set + abstract typeParameters: TypeParameter[] option with get, set + abstract parameters: Symbol[] with get, set abstract getDeclaration: unit -> SignatureDeclaration - abstract getTypeParameters: unit -> ResizeArray option - abstract getParameters: unit -> ResizeArray + abstract getTypeParameters: unit -> TypeParameter[] option + abstract getParameters: unit -> Symbol[] + abstract getTypeParameterAtPosition: pos: float -> Type abstract getReturnType: unit -> Type - abstract getDocumentationComment: typeChecker: TypeChecker option -> ResizeArray - abstract getJsDocTags: unit -> ResizeArray + abstract getDocumentationComment: typeChecker: TypeChecker option -> SymbolDisplayPart[] + abstract getJsDocTags: unit -> JSDocTagInfo[] type [] IndexKind = | String = 0 @@ -4490,6 +5737,7 @@ module Ts = abstract declaration: IndexSignatureDeclaration option with get, set type [] InferencePriority = + | None = 0 | NakedTypeVariable = 1 | SpeculativeTuple = 2 | SubstituteSource = 4 @@ -4505,9 +5753,6 @@ module Ts = | PriorityImpliesCombination = 416 | Circularity = -1 - type JsFileExtensionInfo = - FileExtensionInfo - type [] FileExtensionInfo = abstract extension: string with get, set abstract isMixedContent: bool with get, set @@ -4529,15 +5774,15 @@ module Ts = abstract messageText: string with get, set abstract category: DiagnosticCategory with get, set abstract code: float with get, set - abstract next: ResizeArray option with get, set + abstract next: DiagnosticMessageChain[] option with get, set type [] Diagnostic = inherit DiagnosticRelatedInformation - /// May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. + /// May store more in future. For now, this will simply be true to indicate when a diagnostic is an unused-identifier diagnostic. abstract reportsUnnecessary: DiagnosticMessageReportsUnnecessary option with get, set abstract reportsDeprecated: DiagnosticMessageReportsUnnecessary option with get, set abstract source: string option with get, set - abstract relatedInformation: ResizeArray option with get, set + abstract relatedInformation: DiagnosticRelatedInformation[] option with get, set type [] DiagnosticRelatedInformation = abstract category: DiagnosticCategory with get, set @@ -4561,9 +5806,23 @@ module Ts = type [] ModuleResolutionKind = | Classic = 1 + /// + /// NodeJs was renamed to Node10 to better reflect the version of Node that it targets. + /// Use the new name or consider switching to a modern module resolution target. + /// | NodeJs = 2 - | Node12 = 3 + | Node10 = 2 + | Node16 = 3 | NodeNext = 99 + | Bundler = 100 + + type [] ModuleDetectionKind = + /// Files with imports, exports and/or import.meta are considered modules + | Legacy = 1 + /// Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node16+ + | Auto = 2 + /// Consider all non-declaration files modules, regardless of present syntax + | Force = 3 type [] PluginImport = abstract name: string with get, set @@ -4599,10 +5858,12 @@ module Ts = | FixedChunkSize = 3 type CompilerOptionsValue = - U8>, ResizeArray, MapLike>, ResizeArray, ResizeArray> option + U8[], string[], MapLike, PluginImport[], ProjectReference[]> option type [] CompilerOptions = + abstract allowImportingTsExtensions: bool option with get, set abstract allowJs: bool option with get, set + abstract allowArbitraryExtensions: bool option with get, set abstract allowSyntheticDefaultImports: bool option with get, set abstract allowUmdGlobalAccess: bool option with get, set abstract allowUnreachableCode: bool option with get, set @@ -4611,6 +5872,7 @@ module Ts = abstract baseUrl: string option with get, set abstract charset: string option with get, set abstract checkJs: bool option with get, set + abstract customConditions: string[] option with get, set abstract declaration: bool option with get, set abstract declarationMap: bool option with get, set abstract emitDeclarationOnly: bool option with get, set @@ -4625,6 +5887,7 @@ module Ts = abstract exactOptionalPropertyTypes: bool option with get, set abstract experimentalDecorators: bool option with get, set abstract forceConsistentCasingInFileNames: bool option with get, set + abstract ignoreDeprecations: string option with get, set abstract importHelpers: bool option with get, set abstract importsNotUsedAsValues: ImportsNotUsedAsValues option with get, set abstract inlineSourceMap: bool option with get, set @@ -4632,12 +5895,14 @@ module Ts = abstract isolatedModules: bool option with get, set abstract jsx: JsxEmit option with get, set abstract keyofStringsOnly: bool option with get, set - abstract lib: ResizeArray option with get, set + abstract lib: string[] option with get, set abstract locale: string option with get, set abstract mapRoot: string option with get, set abstract maxNodeModuleJsDepth: float option with get, set abstract ``module``: ModuleKind option with get, set abstract moduleResolution: ModuleResolutionKind option with get, set + abstract moduleSuffixes: string[] option with get, set + abstract moduleDetection: ModuleDetectionKind option with get, set abstract newLine: NewLineKind option with get, set abstract noEmit: bool option with get, set abstract noEmitHelpers: bool option with get, set @@ -4659,7 +5924,7 @@ module Ts = abstract out: string option with get, set abstract outDir: string option with get, set abstract outFile: string option with get, set - abstract paths: MapLike> option with get, set + abstract paths: MapLike option with get, set abstract preserveConstEnums: bool option with get, set abstract noImplicitOverride: bool option with get, set abstract preserveSymlinks: bool option with get, set @@ -4673,8 +5938,10 @@ module Ts = abstract incremental: bool option with get, set abstract tsBuildInfoFile: string option with get, set abstract removeComments: bool option with get, set + abstract resolvePackageJsonExports: bool option with get, set + abstract resolvePackageJsonImports: bool option with get, set abstract rootDir: string option with get, set - abstract rootDirs: ResizeArray option with get, set + abstract rootDirs: string[] option with get, set abstract skipLibCheck: bool option with get, set abstract skipDefaultLibCheck: bool option with get, set abstract sourceMap: bool option with get, set @@ -4691,29 +5958,29 @@ module Ts = abstract traceResolution: bool option with get, set abstract useUnknownInCatchVariables: bool option with get, set abstract resolveJsonModule: bool option with get, set - abstract types: ResizeArray option with get, set + abstract types: string[] option with get, set /// Paths used to compute primary types search locations - abstract typeRoots: ResizeArray option with get, set + abstract typeRoots: string[] option with get, set + abstract verbatimModuleSyntax: bool option with get, set abstract esModuleInterop: bool option with get, set abstract useDefineForClassFields: bool option with get, set - [] abstract Item: option: string -> U2 option with get, set + [] abstract Item: option: string -> U2 option with get, set type [] WatchOptions = abstract watchFile: WatchFileKind option with get, set abstract watchDirectory: WatchDirectoryKind option with get, set abstract fallbackPolling: PollingWatchKind option with get, set abstract synchronousWatchDirectory: bool option with get, set - abstract excludeDirectories: ResizeArray option with get, set - abstract excludeFiles: ResizeArray option with get, set - [] abstract Item: option: string -> CompilerOptionsValue option with get, set + abstract excludeDirectories: string[] option with get, set + abstract excludeFiles: string[] option with get, set + [] abstract Item: option: string -> CompilerOptionsValue option with get, set type [] TypeAcquisition = - abstract enableAutoDiscovery: bool option with get, set abstract enable: bool option with get, set - abstract ``include``: ResizeArray option with get, set - abstract exclude: ResizeArray option with get, set + abstract ``include``: string[] option with get, set + abstract exclude: string[] option with get, set abstract disableFilenameBasedTypeAcquisition: bool option with get, set - [] abstract Item: option: string -> CompilerOptionsValue option with get, set + [] abstract Item: option: string -> CompilerOptionsValue option with get, set type [] ModuleKind = | None = 0 @@ -4725,7 +5992,7 @@ module Ts = | ES2020 = 6 | ES2022 = 7 | ESNext = 99 - | Node12 = 100 + | Node16 = 100 | NodeNext = 199 type [] JsxEmit = @@ -4758,6 +6025,8 @@ module Ts = | TSX = 4 | External = 5 | JSON = 6 + /// Used on extensions that doesn't define the ScriptKind but the content defines it. + /// Deferred extensions are going to be included in all project contexts. | Deferred = 7 type [] ScriptTarget = @@ -4770,6 +6039,7 @@ module Ts = | ES2019 = 6 | ES2020 = 7 | ES2021 = 8 + | ES2022 = 9 | ESNext = 99 | JSON = 100 | Latest = 99 @@ -4782,11 +6052,11 @@ module Ts = type [] ParsedCommandLine = abstract options: CompilerOptions with get, set abstract typeAcquisition: TypeAcquisition option with get, set - abstract fileNames: ResizeArray with get, set - abstract projectReferences: ResizeArray option with get, set + abstract fileNames: string[] with get, set + abstract projectReferences: ProjectReference[] option with get, set abstract watchOptions: WatchOptions option with get, set abstract raw: obj option with get, set - abstract errors: ResizeArray with get, set + abstract errors: Diagnostic[] with get, set abstract wildcardDirectories: MapLike option with get, set abstract compileOnSave: bool option with get, set @@ -4795,51 +6065,69 @@ module Ts = | Recursive = 1 type [] CreateProgramOptions = - abstract rootNames: ResizeArray with get, set + abstract rootNames: string[] with get, set abstract options: CompilerOptions with get, set - abstract projectReferences: ResizeArray option with get, set + abstract projectReferences: ProjectReference[] option with get, set abstract host: CompilerHost option with get, set abstract oldProgram: Program option with get, set - abstract configFileParsingDiagnostics: ResizeArray option with get, set + abstract configFileParsingDiagnostics: Diagnostic[] option with get, set type [] ModuleResolutionHost = abstract fileExists: fileName: string -> bool abstract readFile: fileName: string -> string option abstract trace: s: string -> unit abstract directoryExists: directoryName: string -> bool - /// Resolve a symbolic link. + /// Resolve a symbolic link. + /// abstract realpath: path: string -> string abstract getCurrentDirectory: unit -> string - abstract getDirectories: path: string -> ResizeArray + abstract getDirectories: path: string -> string[] abstract useCaseSensitiveFileNames: U2 bool)> option with get, set + /// Used by services to specify the minimum host area required to set up source files under any compilation settings + type [] MinimalResolutionCacheHost = + inherit ModuleResolutionHost + abstract getCompilationSettings: unit -> CompilerOptions + abstract getCompilerHost: unit -> CompilerHost option + + /// /// Represents the result of module resolution. /// Module resolution will pick up tsx/jsx/js files even if '--jsx' and '--allowJs' are turned off. /// The Program will then filter results based on these flags. - /// - /// Prefer to return a `ResolvedModuleFull` so that the file type does not have to be inferred. + /// + /// Prefer to return a ResolvedModuleFull so that the file type does not have to be inferred. + /// type [] ResolvedModule = /// Path of the file the module was resolved to. abstract resolvedFileName: string with get, set - /// True if `resolvedFileName` comes from `node_modules`. + /// True if resolvedFileName comes from node_modules. abstract isExternalLibraryImport: bool option with get, set - - /// ResolvedModule with an explicitly provided `extension` property. - /// Prefer this over `ResolvedModule`. - /// If changing this, remember to change `moduleResolutionIsEqualTo`. + /// True if the original module reference used a .ts extension to refer directly to a .ts file, + /// which should produce an error during checking if emit is enabled. + abstract resolvedUsingTsExtension: bool option with get, set + + /// + /// ResolvedModule with an explicitly provided extension property. + /// Prefer this over ResolvedModule. + /// If changing this, remember to change moduleResolutionIsEqualTo. + /// type [] ResolvedModuleFull = inherit ResolvedModule /// Extension of resolvedFileName. This must match what's at the end of resolvedFileName. /// This is optional for backwards-compatibility, but will be added if not provided. - abstract extension: Extension with get, set + abstract extension: string with get, set abstract packageId: PackageId option with get, set + /// /// Unique identifier with a package name and version. - /// If changing this, remember to change `packageIdIsEqual`. + /// If changing this, remember to change packageIdIsEqual. + /// type [] PackageId = + /// /// Name of the package. - /// Should not include `@types`. + /// Should not include @types. /// If accessing a non-index file, this should include its name e.g. "foo/bar". + /// abstract name: string with get, set /// Name of a submodule within this package. /// May be "". @@ -4848,19 +6136,19 @@ module Ts = abstract version: string with get, set type [] [] Extension = - | [] Ts - | [] Tsx - | [] Dts - | [] Js - | [] Jsx - | [] Json - | [] TsBuildInfo - | [] Mjs - | [] Mts - | [] Dmts - | [] Cjs - | [] Cts - | [] Dcts + | [] Ts + | [] Tsx + | [] Dts + | [] Js + | [] Jsx + | [] Json + | [] TsBuildInfo + | [] Mjs + | [] Mts + | [] Dmts + | [] Cjs + | [] Cts + | [] Dcts type [] ResolvedModuleWithFailedLookupLocations = abstract resolvedModule: ResolvedModuleFull option @@ -4869,17 +6157,16 @@ module Ts = abstract primary: bool with get, set abstract resolvedFileName: string option with get, set abstract packageId: PackageId option with get, set - /// True if `resolvedFileName` comes from `node_modules`. + /// True if resolvedFileName comes from node_modules. abstract isExternalLibraryImport: bool option with get, set type [] ResolvedTypeReferenceDirectiveWithFailedLookupLocations = abstract resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective option - abstract failedLookupLocations: ResizeArray type [] CompilerHost = inherit ModuleResolutionHost - abstract getSourceFile: fileName: string * languageVersion: ScriptTarget * ?onError: (string -> unit) * ?shouldCreateNewSourceFile: bool -> SourceFile option - abstract getSourceFileByPath: fileName: string * path: Path * languageVersion: ScriptTarget * ?onError: (string -> unit) * ?shouldCreateNewSourceFile: bool -> SourceFile option + abstract getSourceFile: fileName: string * languageVersionOrOptions: U2 * ?onError: (string -> unit) * ?shouldCreateNewSourceFile: bool -> SourceFile option + abstract getSourceFileByPath: fileName: string * path: Path * languageVersionOrOptions: U2 * ?onError: (string -> unit) * ?shouldCreateNewSourceFile: bool -> SourceFile option abstract getCancellationToken: unit -> CancellationToken abstract getDefaultLibFileName: options: CompilerOptions -> string abstract getDefaultLibLocation: unit -> string @@ -4888,13 +6175,14 @@ module Ts = abstract getCanonicalFileName: fileName: string -> string abstract useCaseSensitiveFileNames: unit -> bool abstract getNewLine: unit -> string - abstract readDirectory: rootDir: string * extensions: ResizeArray * excludes: ResizeArray option * includes: ResizeArray * ?depth: float -> ResizeArray - abstract resolveModuleNames: moduleNames: ResizeArray * containingFile: string * reusedNames: ResizeArray option * redirectedReference: ResolvedProjectReference option * options: CompilerOptions * ?containingSourceFile: SourceFile -> ResizeArray - /// Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it + abstract readDirectory: rootDir: string * extensions: string[] * excludes: string[] option * includes: string[] * ?depth: float -> string[] + /// Returns the module resolution cache used by a provided resolveModuleNames implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it abstract getModuleResolutionCache: unit -> ModuleResolutionCache option - /// This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files - abstract resolveTypeReferenceDirectives: typeReferenceDirectiveNames: ResizeArray * containingFile: string * redirectedReference: ResolvedProjectReference option * options: CompilerOptions -> ResizeArray + abstract resolveModuleNameLiterals: moduleLiterals: StringLiteralLike[] * containingFile: string * redirectedReference: ResolvedProjectReference option * options: CompilerOptions * containingSourceFile: SourceFile * reusedNames: StringLiteralLike[] option -> ResolvedModuleWithFailedLookupLocations[] + abstract resolveTypeReferenceDirectiveReferences: typeDirectiveReferences: 'T[] * containingFile: string * redirectedReference: ResolvedProjectReference option * options: CompilerOptions * containingSourceFile: SourceFile option * reusedNames: 'T[] option -> ResolvedTypeReferenceDirectiveWithFailedLookupLocations[] abstract getEnvironmentVariable: name: string -> string option + /// If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives + abstract hasInvalidatedResolutions: filePath: Path -> bool abstract createHash: data: string -> string abstract getParsedCommandLine: fileName: string -> ParsedCommandLine option @@ -4905,37 +6193,37 @@ module Ts = type [] SourceMapSource = abstract fileName: string with get, set abstract text: string with get, set - abstract skipTrivia: (float -> float) option with get, set + abstract skipTrivia: pos: float -> float abstract getLineAndCharacterOfPosition: pos: float -> LineAndCharacter type [] EmitFlags = | None = 0 | SingleLine = 1 - | AdviseOnEmitNode = 2 - | NoSubstitution = 4 - | CapturesThis = 8 - | NoLeadingSourceMap = 16 - | NoTrailingSourceMap = 32 - | NoSourceMap = 48 - | NoNestedSourceMaps = 64 - | NoTokenLeadingSourceMaps = 128 - | NoTokenTrailingSourceMaps = 256 - | NoTokenSourceMaps = 384 - | NoLeadingComments = 512 - | NoTrailingComments = 1024 - | NoComments = 1536 - | NoNestedComments = 2048 - | HelperName = 4096 - | ExportName = 8192 - | LocalName = 16384 - | InternalName = 32768 - | Indented = 65536 - | NoIndentation = 131072 - | AsyncFunctionBody = 262144 - | ReuseTempVariableScope = 524288 - | CustomPrologue = 1048576 - | NoHoisting = 2097152 - | HasEndOfDeclarationMarker = 4194304 + | MultiLine = 2 + | AdviseOnEmitNode = 4 + | NoSubstitution = 8 + | CapturesThis = 16 + | NoLeadingSourceMap = 32 + | NoTrailingSourceMap = 64 + | NoSourceMap = 96 + | NoNestedSourceMaps = 128 + | NoTokenLeadingSourceMaps = 256 + | NoTokenTrailingSourceMaps = 512 + | NoTokenSourceMaps = 768 + | NoLeadingComments = 1024 + | NoTrailingComments = 2048 + | NoComments = 3072 + | NoNestedComments = 4096 + | HelperName = 8192 + | ExportName = 16384 + | LocalName = 32768 + | InternalName = 65536 + | Indented = 131072 + | NoIndentation = 262144 + | AsyncFunctionBody = 524288 + | ReuseTempVariableScope = 1048576 + | CustomPrologue = 2097152 + | NoHoisting = 4194304 | Iterator = 8388608 | NoAsciiEscaping = 16777216 @@ -4944,22 +6232,25 @@ module Ts = abstract scoped: bool abstract text: U2 string)> abstract priority: float option - abstract dependencies: ResizeArray option + abstract dependencies: EmitHelper[] option type [] ScopedEmitHelper = inherit EmitHelperBase - abstract scoped: obj + abstract scoped: bool type [] UnscopedEmitHelper = inherit EmitHelperBase - abstract scoped: obj + abstract scoped: bool abstract text: string - type EmitHelper = - U2 + type [] [] EmitHelper = + | [] UnscopedEmitHelper of UnscopedEmitHelper + | [] ScopedEmitHelper of ScopedEmitHelper + // static member inline op_ErasedCast(x: UnscopedEmitHelper) = UnscopedEmitHelper x + // static member inline op_ErasedCast(x: ScopedEmitHelper) = ScopedEmitHelper x type [] EmitHelperUniqueNameCallback = - [] abstract Invoke: name: string -> string + [] abstract Invoke: name: string -> string type [] EmitHint = | SourceFile = 0 @@ -4990,31 +6281,39 @@ module Ts = | Function type [] NodeFactory = - abstract createNodeArray: ?elements: ResizeArray<'T> * ?hasTrailingComma: bool -> ResizeArray<'T> + abstract createNodeArray: ?elements: 'T[] * ?hasTrailingComma: bool -> 'T[] abstract createNumericLiteral: value: U2 * ?numericLiteralFlags: TokenFlags -> NumericLiteral abstract createBigIntLiteral: value: U2 -> BigIntLiteral abstract createStringLiteral: text: string * ?isSingleQuote: bool -> StringLiteral - abstract createStringLiteralFromNode: sourceNode: PropertyNameLiteral * ?isSingleQuote: bool -> StringLiteral + abstract createStringLiteralFromNode: sourceNode: U2 * ?isSingleQuote: bool -> StringLiteral abstract createRegularExpressionLiteral: text: string -> RegularExpressionLiteral abstract createIdentifier: text: string -> Identifier /// Create a unique temporary variable. - /// An optional callback used to record the temporary variable name. This - /// should usually be a reference to `hoistVariableDeclaration` from a `TransformationContext`, but - /// can be `undefined` if you plan to record the temporary variable manually. - /// When `true`, reserves the temporary variable name in all nested scopes + /// + /// An optional callback used to record the temporary variable name. This + /// should usually be a reference to hoistVariableDeclaration from a TransformationContext, but + /// can be undefined if you plan to record the temporary variable manually. + /// + /// + /// When true, reserves the temporary variable name in all nested scopes /// during emit so that the variable can be referenced in a nested function body. This is an alternative to - /// setting `EmitFlags.ReuseTempVariableScope` on the nested function itself. + /// setting EmitFlags.ReuseTempVariableScope on the nested function itself. + /// abstract createTempVariable: recordTempVariable: (Identifier -> unit) option * ?reservedInNestedScopes: bool -> Identifier /// Create a unique temporary variable for use in a loop. - /// When `true`, reserves the temporary variable name in all nested scopes + /// + /// When true, reserves the temporary variable name in all nested scopes /// during emit so that the variable can be referenced in a nested function body. This is an alternative to - /// setting `EmitFlags.ReuseTempVariableScope` on the nested function itself. + /// setting EmitFlags.ReuseTempVariableScope on the nested function itself. + /// abstract createLoopVariable: ?reservedInNestedScopes: bool -> Identifier /// Create a unique name based on the supplied text. abstract createUniqueName: text: string * ?flags: GeneratedIdentifierFlags -> Identifier /// Create a unique name generated for a node. abstract getGeneratedNameForNode: node: Node option * ?flags: GeneratedIdentifierFlags -> Identifier abstract createPrivateIdentifier: text: string -> PrivateIdentifier + abstract createUniquePrivateName: ?text: string -> PrivateIdentifier + abstract getGeneratedPrivateNameForNode: node: Node -> PrivateIdentifier abstract createToken: token: SyntaxKind -> SuperExpression abstract createToken: token: 'TKind -> PunctuationToken<'TKind> abstract createSuper: unit -> SuperExpression @@ -5023,76 +6322,74 @@ module Ts = abstract createTrue: unit -> TrueLiteral abstract createFalse: unit -> FalseLiteral abstract createModifier: kind: 'T -> ModifierToken<'T> - abstract createModifiersFromModifierFlags: flags: ModifierFlags -> ResizeArray + abstract createModifiersFromModifierFlags: flags: ModifierFlags -> Modifier[] option abstract createQualifiedName: left: EntityName * right: U2 -> QualifiedName abstract updateQualifiedName: node: QualifiedName * left: EntityName * right: Identifier -> QualifiedName abstract createComputedPropertyName: expression: Expression -> ComputedPropertyName abstract updateComputedPropertyName: node: ComputedPropertyName * expression: Expression -> ComputedPropertyName - abstract createTypeParameterDeclaration: name: U2 * ?``constraint``: TypeNode * ?defaultType: TypeNode -> TypeParameterDeclaration - abstract updateTypeParameterDeclaration: node: TypeParameterDeclaration * name: Identifier * ``constraint``: TypeNode option * defaultType: TypeNode option -> TypeParameterDeclaration - abstract createParameterDeclaration: decorators: ResizeArray option * modifiers: ResizeArray option * dotDotDotToken: DotDotDotToken option * name: U2 * ?questionToken: QuestionToken * ?``type``: TypeNode * ?initializer: Expression -> ParameterDeclaration - abstract updateParameterDeclaration: node: ParameterDeclaration * decorators: ResizeArray option * modifiers: ResizeArray option * dotDotDotToken: DotDotDotToken option * name: U2 * questionToken: QuestionToken option * ``type``: TypeNode option * initializer: Expression option -> ParameterDeclaration + abstract createTypeParameterDeclaration: modifiers: Modifier[] option * name: U2 * ?``constraint``: TypeNode * ?defaultType: TypeNode -> TypeParameterDeclaration + abstract updateTypeParameterDeclaration: node: TypeParameterDeclaration * modifiers: Modifier[] option * name: Identifier * ``constraint``: TypeNode option * defaultType: TypeNode option -> TypeParameterDeclaration + abstract createParameterDeclaration: modifiers: ModifierLike[] option * dotDotDotToken: DotDotDotToken option * name: U2 * ?questionToken: QuestionToken * ?``type``: TypeNode * ?initializer: Expression -> ParameterDeclaration + abstract updateParameterDeclaration: node: ParameterDeclaration * modifiers: ModifierLike[] option * dotDotDotToken: DotDotDotToken option * name: U2 * questionToken: QuestionToken option * ``type``: TypeNode option * initializer: Expression option -> ParameterDeclaration abstract createDecorator: expression: Expression -> Decorator abstract updateDecorator: node: Decorator * expression: Expression -> Decorator - abstract createPropertySignature: modifiers: ResizeArray option * name: U2 * questionToken: QuestionToken option * ``type``: TypeNode option -> PropertySignature - abstract updatePropertySignature: node: PropertySignature * modifiers: ResizeArray option * name: PropertyName * questionToken: QuestionToken option * ``type``: TypeNode option -> PropertySignature - abstract createPropertyDeclaration: decorators: ResizeArray option * modifiers: ResizeArray option * name: U2 * questionOrExclamationToken: U2 option * ``type``: TypeNode option * initializer: Expression option -> PropertyDeclaration - abstract updatePropertyDeclaration: node: PropertyDeclaration * decorators: ResizeArray option * modifiers: ResizeArray option * name: U2 * questionOrExclamationToken: U2 option * ``type``: TypeNode option * initializer: Expression option -> PropertyDeclaration - abstract createMethodSignature: modifiers: ResizeArray option * name: U2 * questionToken: QuestionToken option * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode option -> MethodSignature - abstract updateMethodSignature: node: MethodSignature * modifiers: ResizeArray option * name: PropertyName * questionToken: QuestionToken option * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode option -> MethodSignature - abstract createMethodDeclaration: decorators: ResizeArray option * modifiers: ResizeArray option * asteriskToken: AsteriskToken option * name: U2 * questionToken: QuestionToken option * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode option * body: Block option -> MethodDeclaration - abstract updateMethodDeclaration: node: MethodDeclaration * decorators: ResizeArray option * modifiers: ResizeArray option * asteriskToken: AsteriskToken option * name: PropertyName * questionToken: QuestionToken option * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode option * body: Block option -> MethodDeclaration - abstract createConstructorDeclaration: decorators: ResizeArray option * modifiers: ResizeArray option * parameters: ResizeArray * body: Block option -> ConstructorDeclaration - abstract updateConstructorDeclaration: node: ConstructorDeclaration * decorators: ResizeArray option * modifiers: ResizeArray option * parameters: ResizeArray * body: Block option -> ConstructorDeclaration - abstract createGetAccessorDeclaration: decorators: ResizeArray option * modifiers: ResizeArray option * name: U2 * parameters: ResizeArray * ``type``: TypeNode option * body: Block option -> GetAccessorDeclaration - abstract updateGetAccessorDeclaration: node: GetAccessorDeclaration * decorators: ResizeArray option * modifiers: ResizeArray option * name: PropertyName * parameters: ResizeArray * ``type``: TypeNode option * body: Block option -> GetAccessorDeclaration - abstract createSetAccessorDeclaration: decorators: ResizeArray option * modifiers: ResizeArray option * name: U2 * parameters: ResizeArray * body: Block option -> SetAccessorDeclaration - abstract updateSetAccessorDeclaration: node: SetAccessorDeclaration * decorators: ResizeArray option * modifiers: ResizeArray option * name: PropertyName * parameters: ResizeArray * body: Block option -> SetAccessorDeclaration - abstract createCallSignature: typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode option -> CallSignatureDeclaration - abstract updateCallSignature: node: CallSignatureDeclaration * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode option -> CallSignatureDeclaration - abstract createConstructSignature: typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode option -> ConstructSignatureDeclaration - abstract updateConstructSignature: node: ConstructSignatureDeclaration * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode option -> ConstructSignatureDeclaration - abstract createIndexSignature: decorators: ResizeArray option * modifiers: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode -> IndexSignatureDeclaration - abstract updateIndexSignature: node: IndexSignatureDeclaration * decorators: ResizeArray option * modifiers: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode -> IndexSignatureDeclaration + abstract createPropertySignature: modifiers: Modifier[] option * name: U2 * questionToken: QuestionToken option * ``type``: TypeNode option -> PropertySignature + abstract updatePropertySignature: node: PropertySignature * modifiers: Modifier[] option * name: PropertyName * questionToken: QuestionToken option * ``type``: TypeNode option -> PropertySignature + abstract createPropertyDeclaration: modifiers: ModifierLike[] option * name: U2 * questionOrExclamationToken: U2 option * ``type``: TypeNode option * initializer: Expression option -> PropertyDeclaration + abstract updatePropertyDeclaration: node: PropertyDeclaration * modifiers: ModifierLike[] option * name: U2 * questionOrExclamationToken: U2 option * ``type``: TypeNode option * initializer: Expression option -> PropertyDeclaration + abstract createMethodSignature: modifiers: Modifier[] option * name: U2 * questionToken: QuestionToken option * typeParameters: TypeParameterDeclaration[] option * parameters: ParameterDeclaration[] * ``type``: TypeNode option -> MethodSignature + abstract updateMethodSignature: node: MethodSignature * modifiers: Modifier[] option * name: PropertyName * questionToken: QuestionToken option * typeParameters: TypeParameterDeclaration[] option * parameters: ParameterDeclaration[] * ``type``: TypeNode option -> MethodSignature + abstract createMethodDeclaration: modifiers: ModifierLike[] option * asteriskToken: AsteriskToken option * name: U2 * questionToken: QuestionToken option * typeParameters: TypeParameterDeclaration[] option * parameters: ParameterDeclaration[] * ``type``: TypeNode option * body: Block option -> MethodDeclaration + abstract updateMethodDeclaration: node: MethodDeclaration * modifiers: ModifierLike[] option * asteriskToken: AsteriskToken option * name: PropertyName * questionToken: QuestionToken option * typeParameters: TypeParameterDeclaration[] option * parameters: ParameterDeclaration[] * ``type``: TypeNode option * body: Block option -> MethodDeclaration + abstract createConstructorDeclaration: modifiers: ModifierLike[] option * parameters: ParameterDeclaration[] * body: Block option -> ConstructorDeclaration + abstract updateConstructorDeclaration: node: ConstructorDeclaration * modifiers: ModifierLike[] option * parameters: ParameterDeclaration[] * body: Block option -> ConstructorDeclaration + abstract createGetAccessorDeclaration: modifiers: ModifierLike[] option * name: U2 * parameters: ParameterDeclaration[] * ``type``: TypeNode option * body: Block option -> GetAccessorDeclaration + abstract updateGetAccessorDeclaration: node: GetAccessorDeclaration * modifiers: ModifierLike[] option * name: PropertyName * parameters: ParameterDeclaration[] * ``type``: TypeNode option * body: Block option -> GetAccessorDeclaration + abstract createSetAccessorDeclaration: modifiers: ModifierLike[] option * name: U2 * parameters: ParameterDeclaration[] * body: Block option -> SetAccessorDeclaration + abstract updateSetAccessorDeclaration: node: SetAccessorDeclaration * modifiers: ModifierLike[] option * name: PropertyName * parameters: ParameterDeclaration[] * body: Block option -> SetAccessorDeclaration + abstract createCallSignature: typeParameters: TypeParameterDeclaration[] option * parameters: ParameterDeclaration[] * ``type``: TypeNode option -> CallSignatureDeclaration + abstract updateCallSignature: node: CallSignatureDeclaration * typeParameters: TypeParameterDeclaration[] option * parameters: ParameterDeclaration[] * ``type``: TypeNode option -> CallSignatureDeclaration + abstract createConstructSignature: typeParameters: TypeParameterDeclaration[] option * parameters: ParameterDeclaration[] * ``type``: TypeNode option -> ConstructSignatureDeclaration + abstract updateConstructSignature: node: ConstructSignatureDeclaration * typeParameters: TypeParameterDeclaration[] option * parameters: ParameterDeclaration[] * ``type``: TypeNode option -> ConstructSignatureDeclaration + abstract createIndexSignature: modifiers: ModifierLike[] option * parameters: ParameterDeclaration[] * ``type``: TypeNode -> IndexSignatureDeclaration + abstract updateIndexSignature: node: IndexSignatureDeclaration * modifiers: ModifierLike[] option * parameters: ParameterDeclaration[] * ``type``: TypeNode -> IndexSignatureDeclaration abstract createTemplateLiteralTypeSpan: ``type``: TypeNode * literal: U2 -> TemplateLiteralTypeSpan abstract updateTemplateLiteralTypeSpan: node: TemplateLiteralTypeSpan * ``type``: TypeNode * literal: U2 -> TemplateLiteralTypeSpan - abstract createClassStaticBlockDeclaration: decorators: ResizeArray option * modifiers: ResizeArray option * body: Block -> ClassStaticBlockDeclaration - abstract updateClassStaticBlockDeclaration: node: ClassStaticBlockDeclaration * decorators: ResizeArray option * modifiers: ResizeArray option * body: Block -> ClassStaticBlockDeclaration + abstract createClassStaticBlockDeclaration: body: Block -> ClassStaticBlockDeclaration + abstract updateClassStaticBlockDeclaration: node: ClassStaticBlockDeclaration * body: Block -> ClassStaticBlockDeclaration abstract createKeywordTypeNode: kind: 'TKind -> KeywordTypeNode<'TKind> abstract createTypePredicateNode: assertsModifier: AssertsKeyword option * parameterName: U3 * ``type``: TypeNode option -> TypePredicateNode abstract updateTypePredicateNode: node: TypePredicateNode * assertsModifier: AssertsKeyword option * parameterName: U2 * ``type``: TypeNode option -> TypePredicateNode - abstract createTypeReferenceNode: typeName: U2 * ?typeArguments: ResizeArray -> TypeReferenceNode - abstract updateTypeReferenceNode: node: TypeReferenceNode * typeName: EntityName * typeArguments: ResizeArray option -> TypeReferenceNode - abstract createFunctionTypeNode: typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode -> FunctionTypeNode - abstract updateFunctionTypeNode: node: FunctionTypeNode * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode -> FunctionTypeNode - abstract createConstructorTypeNode: modifiers: ResizeArray option * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode -> ConstructorTypeNode - abstract createConstructorTypeNode: typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode -> ConstructorTypeNode - abstract updateConstructorTypeNode: node: ConstructorTypeNode * modifiers: ResizeArray option * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode -> ConstructorTypeNode - abstract updateConstructorTypeNode: node: ConstructorTypeNode * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode -> ConstructorTypeNode - abstract createTypeQueryNode: exprName: EntityName -> TypeQueryNode - abstract updateTypeQueryNode: node: TypeQueryNode * exprName: EntityName -> TypeQueryNode - abstract createTypeLiteralNode: members: ResizeArray option -> TypeLiteralNode - abstract updateTypeLiteralNode: node: TypeLiteralNode * members: ResizeArray -> TypeLiteralNode + abstract createTypeReferenceNode: typeName: U2 * ?typeArguments: TypeNode[] -> TypeReferenceNode + abstract updateTypeReferenceNode: node: TypeReferenceNode * typeName: EntityName * typeArguments: TypeNode[] option -> TypeReferenceNode + abstract createFunctionTypeNode: typeParameters: TypeParameterDeclaration[] option * parameters: ParameterDeclaration[] * ``type``: TypeNode -> FunctionTypeNode + abstract updateFunctionTypeNode: node: FunctionTypeNode * typeParameters: TypeParameterDeclaration[] option * parameters: ParameterDeclaration[] * ``type``: TypeNode -> FunctionTypeNode + abstract createConstructorTypeNode: modifiers: Modifier[] option * typeParameters: TypeParameterDeclaration[] option * parameters: ParameterDeclaration[] * ``type``: TypeNode -> ConstructorTypeNode + abstract updateConstructorTypeNode: node: ConstructorTypeNode * modifiers: Modifier[] option * typeParameters: TypeParameterDeclaration[] option * parameters: ParameterDeclaration[] * ``type``: TypeNode -> ConstructorTypeNode + abstract createTypeQueryNode: exprName: EntityName * ?typeArguments: TypeNode[] -> TypeQueryNode + abstract updateTypeQueryNode: node: TypeQueryNode * exprName: EntityName * ?typeArguments: TypeNode[] -> TypeQueryNode + abstract createTypeLiteralNode: members: TypeElement[] option -> TypeLiteralNode + abstract updateTypeLiteralNode: node: TypeLiteralNode * members: TypeElement[] -> TypeLiteralNode abstract createArrayTypeNode: elementType: TypeNode -> ArrayTypeNode abstract updateArrayTypeNode: node: ArrayTypeNode * elementType: TypeNode -> ArrayTypeNode - abstract createTupleTypeNode: elements: ResizeArray> -> TupleTypeNode - abstract updateTupleTypeNode: node: TupleTypeNode * elements: ResizeArray> -> TupleTypeNode + abstract createTupleTypeNode: elements: U2[] -> TupleTypeNode + abstract updateTupleTypeNode: node: TupleTypeNode * elements: U2[] -> TupleTypeNode abstract createNamedTupleMember: dotDotDotToken: DotDotDotToken option * name: Identifier * questionToken: QuestionToken option * ``type``: TypeNode -> NamedTupleMember abstract updateNamedTupleMember: node: NamedTupleMember * dotDotDotToken: DotDotDotToken option * name: Identifier * questionToken: QuestionToken option * ``type``: TypeNode -> NamedTupleMember abstract createOptionalTypeNode: ``type``: TypeNode -> OptionalTypeNode abstract updateOptionalTypeNode: node: OptionalTypeNode * ``type``: TypeNode -> OptionalTypeNode abstract createRestTypeNode: ``type``: TypeNode -> RestTypeNode abstract updateRestTypeNode: node: RestTypeNode * ``type``: TypeNode -> RestTypeNode - abstract createUnionTypeNode: types: ResizeArray -> UnionTypeNode - abstract updateUnionTypeNode: node: UnionTypeNode * types: ResizeArray -> UnionTypeNode - abstract createIntersectionTypeNode: types: ResizeArray -> IntersectionTypeNode - abstract updateIntersectionTypeNode: node: IntersectionTypeNode * types: ResizeArray -> IntersectionTypeNode + abstract createUnionTypeNode: types: TypeNode[] -> UnionTypeNode + abstract updateUnionTypeNode: node: UnionTypeNode * types: TypeNode[] -> UnionTypeNode + abstract createIntersectionTypeNode: types: TypeNode[] -> IntersectionTypeNode + abstract updateIntersectionTypeNode: node: IntersectionTypeNode * types: TypeNode[] -> IntersectionTypeNode abstract createConditionalTypeNode: checkType: TypeNode * extendsType: TypeNode * trueType: TypeNode * falseType: TypeNode -> ConditionalTypeNode abstract updateConditionalTypeNode: node: ConditionalTypeNode * checkType: TypeNode * extendsType: TypeNode * trueType: TypeNode * falseType: TypeNode -> ConditionalTypeNode abstract createInferTypeNode: typeParameter: TypeParameterDeclaration -> InferTypeNode abstract updateInferTypeNode: node: InferTypeNode * typeParameter: TypeParameterDeclaration -> InferTypeNode - abstract createImportTypeNode: argument: TypeNode * ?qualifier: EntityName * ?typeArguments: ResizeArray * ?isTypeOf: bool -> ImportTypeNode - abstract updateImportTypeNode: node: ImportTypeNode * argument: TypeNode * qualifier: EntityName option * typeArguments: ResizeArray option * ?isTypeOf: bool -> ImportTypeNode + abstract createImportTypeNode: argument: TypeNode * ?assertions: ImportTypeAssertionContainer * ?qualifier: EntityName * ?typeArguments: TypeNode[] * ?isTypeOf: bool -> ImportTypeNode + abstract updateImportTypeNode: node: ImportTypeNode * argument: TypeNode * assertions: ImportTypeAssertionContainer option * qualifier: EntityName option * typeArguments: TypeNode[] option * ?isTypeOf: bool -> ImportTypeNode abstract createParenthesizedType: ``type``: TypeNode -> ParenthesizedTypeNode abstract updateParenthesizedType: node: ParenthesizedTypeNode * ``type``: TypeNode -> ParenthesizedTypeNode abstract createThisTypeNode: unit -> ThisTypeNode @@ -5100,22 +6397,22 @@ module Ts = abstract updateTypeOperatorNode: node: TypeOperatorNode * ``type``: TypeNode -> TypeOperatorNode abstract createIndexedAccessTypeNode: objectType: TypeNode * indexType: TypeNode -> IndexedAccessTypeNode abstract updateIndexedAccessTypeNode: node: IndexedAccessTypeNode * objectType: TypeNode * indexType: TypeNode -> IndexedAccessTypeNode - abstract createMappedTypeNode: readonlyToken: U3 option * typeParameter: TypeParameterDeclaration * nameType: TypeNode option * questionToken: U3 option * ``type``: TypeNode option * members: ResizeArray option -> MappedTypeNode - abstract updateMappedTypeNode: node: MappedTypeNode * readonlyToken: U3 option * typeParameter: TypeParameterDeclaration * nameType: TypeNode option * questionToken: U3 option * ``type``: TypeNode option * members: ResizeArray option -> MappedTypeNode - abstract createLiteralTypeNode: literal: LiteralTypeNode -> LiteralTypeNode - abstract updateLiteralTypeNode: node: LiteralTypeNode * literal: LiteralTypeNode -> LiteralTypeNode - abstract createTemplateLiteralType: head: TemplateHead * templateSpans: ResizeArray -> TemplateLiteralTypeNode - abstract updateTemplateLiteralType: node: TemplateLiteralTypeNode * head: TemplateHead * templateSpans: ResizeArray -> TemplateLiteralTypeNode - abstract createObjectBindingPattern: elements: ResizeArray -> ObjectBindingPattern - abstract updateObjectBindingPattern: node: ObjectBindingPattern * elements: ResizeArray -> ObjectBindingPattern - abstract createArrayBindingPattern: elements: ResizeArray -> ArrayBindingPattern - abstract updateArrayBindingPattern: node: ArrayBindingPattern * elements: ResizeArray -> ArrayBindingPattern + abstract createMappedTypeNode: readonlyToken: U3 option * typeParameter: TypeParameterDeclaration * nameType: TypeNode option * questionToken: U3 option * ``type``: TypeNode option * members: TypeElement[] option -> MappedTypeNode + abstract updateMappedTypeNode: node: MappedTypeNode * readonlyToken: U3 option * typeParameter: TypeParameterDeclaration * nameType: TypeNode option * questionToken: U3 option * ``type``: TypeNode option * members: TypeElement[] option -> MappedTypeNode + abstract createLiteralTypeNode: literal: obj -> LiteralTypeNode + abstract updateLiteralTypeNode: node: LiteralTypeNode * literal: obj -> LiteralTypeNode + abstract createTemplateLiteralType: head: TemplateHead * templateSpans: TemplateLiteralTypeSpan[] -> TemplateLiteralTypeNode + abstract updateTemplateLiteralType: node: TemplateLiteralTypeNode * head: TemplateHead * templateSpans: TemplateLiteralTypeSpan[] -> TemplateLiteralTypeNode + abstract createObjectBindingPattern: elements: BindingElement[] -> ObjectBindingPattern + abstract updateObjectBindingPattern: node: ObjectBindingPattern * elements: BindingElement[] -> ObjectBindingPattern + abstract createArrayBindingPattern: elements: ArrayBindingElement[] -> ArrayBindingPattern + abstract updateArrayBindingPattern: node: ArrayBindingPattern * elements: ArrayBindingElement[] -> ArrayBindingPattern abstract createBindingElement: dotDotDotToken: DotDotDotToken option * propertyName: U2 option * name: U2 * ?initializer: Expression -> BindingElement abstract updateBindingElement: node: BindingElement * dotDotDotToken: DotDotDotToken option * propertyName: PropertyName option * name: BindingName * initializer: Expression option -> BindingElement - abstract createArrayLiteralExpression: ?elements: ResizeArray * ?multiLine: bool -> ArrayLiteralExpression - abstract updateArrayLiteralExpression: node: ArrayLiteralExpression * elements: ResizeArray -> ArrayLiteralExpression - abstract createObjectLiteralExpression: ?properties: ResizeArray * ?multiLine: bool -> ObjectLiteralExpression - abstract updateObjectLiteralExpression: node: ObjectLiteralExpression * properties: ResizeArray -> ObjectLiteralExpression + abstract createArrayLiteralExpression: ?elements: Expression[] * ?multiLine: bool -> ArrayLiteralExpression + abstract updateArrayLiteralExpression: node: ArrayLiteralExpression * elements: Expression[] -> ArrayLiteralExpression + abstract createObjectLiteralExpression: ?properties: ObjectLiteralElementLike[] * ?multiLine: bool -> ObjectLiteralExpression + abstract updateObjectLiteralExpression: node: ObjectLiteralExpression * properties: ObjectLiteralElementLike[] -> ObjectLiteralExpression abstract createPropertyAccessExpression: expression: Expression * name: U2 -> PropertyAccessExpression abstract updatePropertyAccessExpression: node: PropertyAccessExpression * expression: Expression * name: MemberName -> PropertyAccessExpression abstract createPropertyAccessChain: expression: Expression * questionDotToken: QuestionDotToken option * name: U2 -> PropertyAccessChain @@ -5124,22 +6421,22 @@ module Ts = abstract updateElementAccessExpression: node: ElementAccessExpression * expression: Expression * argumentExpression: Expression -> ElementAccessExpression abstract createElementAccessChain: expression: Expression * questionDotToken: QuestionDotToken option * index: U2 -> ElementAccessChain abstract updateElementAccessChain: node: ElementAccessChain * expression: Expression * questionDotToken: QuestionDotToken option * argumentExpression: Expression -> ElementAccessChain - abstract createCallExpression: expression: Expression * typeArguments: ResizeArray option * argumentsArray: ResizeArray option -> CallExpression - abstract updateCallExpression: node: CallExpression * expression: Expression * typeArguments: ResizeArray option * argumentsArray: ResizeArray -> CallExpression - abstract createCallChain: expression: Expression * questionDotToken: QuestionDotToken option * typeArguments: ResizeArray option * argumentsArray: ResizeArray option -> CallChain - abstract updateCallChain: node: CallChain * expression: Expression * questionDotToken: QuestionDotToken option * typeArguments: ResizeArray option * argumentsArray: ResizeArray -> CallChain - abstract createNewExpression: expression: Expression * typeArguments: ResizeArray option * argumentsArray: ResizeArray option -> NewExpression - abstract updateNewExpression: node: NewExpression * expression: Expression * typeArguments: ResizeArray option * argumentsArray: ResizeArray option -> NewExpression - abstract createTaggedTemplateExpression: tag: Expression * typeArguments: ResizeArray option * template: TemplateLiteral -> TaggedTemplateExpression - abstract updateTaggedTemplateExpression: node: TaggedTemplateExpression * tag: Expression * typeArguments: ResizeArray option * template: TemplateLiteral -> TaggedTemplateExpression + abstract createCallExpression: expression: Expression * typeArguments: TypeNode[] option * argumentsArray: Expression[] option -> CallExpression + abstract updateCallExpression: node: CallExpression * expression: Expression * typeArguments: TypeNode[] option * argumentsArray: Expression[] -> CallExpression + abstract createCallChain: expression: Expression * questionDotToken: QuestionDotToken option * typeArguments: TypeNode[] option * argumentsArray: Expression[] option -> CallChain + abstract updateCallChain: node: CallChain * expression: Expression * questionDotToken: QuestionDotToken option * typeArguments: TypeNode[] option * argumentsArray: Expression[] -> CallChain + abstract createNewExpression: expression: Expression * typeArguments: TypeNode[] option * argumentsArray: Expression[] option -> NewExpression + abstract updateNewExpression: node: NewExpression * expression: Expression * typeArguments: TypeNode[] option * argumentsArray: Expression[] option -> NewExpression + abstract createTaggedTemplateExpression: tag: Expression * typeArguments: TypeNode[] option * template: TemplateLiteral -> TaggedTemplateExpression + abstract updateTaggedTemplateExpression: node: TaggedTemplateExpression * tag: Expression * typeArguments: TypeNode[] option * template: TemplateLiteral -> TaggedTemplateExpression abstract createTypeAssertion: ``type``: TypeNode * expression: Expression -> TypeAssertion abstract updateTypeAssertion: node: TypeAssertion * ``type``: TypeNode * expression: Expression -> TypeAssertion abstract createParenthesizedExpression: expression: Expression -> ParenthesizedExpression abstract updateParenthesizedExpression: node: ParenthesizedExpression * expression: Expression -> ParenthesizedExpression - abstract createFunctionExpression: modifiers: ResizeArray option * asteriskToken: AsteriskToken option * name: U2 option * typeParameters: ResizeArray option * parameters: ResizeArray option * ``type``: TypeNode option * body: Block -> FunctionExpression - abstract updateFunctionExpression: node: FunctionExpression * modifiers: ResizeArray option * asteriskToken: AsteriskToken option * name: Identifier option * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode option * body: Block -> FunctionExpression - abstract createArrowFunction: modifiers: ResizeArray option * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode option * equalsGreaterThanToken: EqualsGreaterThanToken option * body: ConciseBody -> ArrowFunction - abstract updateArrowFunction: node: ArrowFunction * modifiers: ResizeArray option * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode option * equalsGreaterThanToken: EqualsGreaterThanToken * body: ConciseBody -> ArrowFunction + abstract createFunctionExpression: modifiers: Modifier[] option * asteriskToken: AsteriskToken option * name: U2 option * typeParameters: TypeParameterDeclaration[] option * parameters: ParameterDeclaration[] option * ``type``: TypeNode option * body: Block -> FunctionExpression + abstract updateFunctionExpression: node: FunctionExpression * modifiers: Modifier[] option * asteriskToken: AsteriskToken option * name: Identifier option * typeParameters: TypeParameterDeclaration[] option * parameters: ParameterDeclaration[] * ``type``: TypeNode option * body: Block -> FunctionExpression + abstract createArrowFunction: modifiers: Modifier[] option * typeParameters: TypeParameterDeclaration[] option * parameters: ParameterDeclaration[] * ``type``: TypeNode option * equalsGreaterThanToken: EqualsGreaterThanToken option * body: ConciseBody -> ArrowFunction + abstract updateArrowFunction: node: ArrowFunction * modifiers: Modifier[] option * typeParameters: TypeParameterDeclaration[] option * parameters: ParameterDeclaration[] * ``type``: TypeNode option * equalsGreaterThanToken: EqualsGreaterThanToken * body: ConciseBody -> ArrowFunction abstract createDeleteExpression: expression: Expression -> DeleteExpression abstract updateDeleteExpression: node: DeleteExpression * expression: Expression -> DeleteExpression abstract createTypeOfExpression: expression: Expression -> TypeOfExpression @@ -5156,8 +6453,8 @@ module Ts = abstract updateBinaryExpression: node: BinaryExpression * left: Expression * operator: U2 * right: Expression -> BinaryExpression abstract createConditionalExpression: condition: Expression * questionToken: QuestionToken option * whenTrue: Expression * colonToken: ColonToken option * whenFalse: Expression -> ConditionalExpression abstract updateConditionalExpression: node: ConditionalExpression * condition: Expression * questionToken: QuestionToken * whenTrue: Expression * colonToken: ColonToken * whenFalse: Expression -> ConditionalExpression - abstract createTemplateExpression: head: TemplateHead * templateSpans: ResizeArray -> TemplateExpression - abstract updateTemplateExpression: node: TemplateExpression * head: TemplateHead * templateSpans: ResizeArray -> TemplateExpression + abstract createTemplateExpression: head: TemplateHead * templateSpans: TemplateSpan[] -> TemplateExpression + abstract updateTemplateExpression: node: TemplateExpression * head: TemplateHead * templateSpans: TemplateSpan[] -> TemplateExpression abstract createTemplateHead: text: string * ?rawText: string * ?templateFlags: TokenFlags -> TemplateHead abstract createTemplateHead: text: string option * rawText: string * ?templateFlags: TokenFlags -> TemplateHead abstract createTemplateMiddle: text: string * ?rawText: string * ?templateFlags: TokenFlags -> TemplateMiddle @@ -5171,26 +6468,28 @@ module Ts = abstract updateYieldExpression: node: YieldExpression * asteriskToken: AsteriskToken option * expression: Expression option -> YieldExpression abstract createSpreadElement: expression: Expression -> SpreadElement abstract updateSpreadElement: node: SpreadElement * expression: Expression -> SpreadElement - abstract createClassExpression: decorators: ResizeArray option * modifiers: ResizeArray option * name: U2 option * typeParameters: ResizeArray option * heritageClauses: ResizeArray option * members: ResizeArray -> ClassExpression - abstract updateClassExpression: node: ClassExpression * decorators: ResizeArray option * modifiers: ResizeArray option * name: Identifier option * typeParameters: ResizeArray option * heritageClauses: ResizeArray option * members: ResizeArray -> ClassExpression + abstract createClassExpression: modifiers: ModifierLike[] option * name: U2 option * typeParameters: TypeParameterDeclaration[] option * heritageClauses: HeritageClause[] option * members: ClassElement[] -> ClassExpression + abstract updateClassExpression: node: ClassExpression * modifiers: ModifierLike[] option * name: Identifier option * typeParameters: TypeParameterDeclaration[] option * heritageClauses: HeritageClause[] option * members: ClassElement[] -> ClassExpression abstract createOmittedExpression: unit -> OmittedExpression - abstract createExpressionWithTypeArguments: expression: Expression * typeArguments: ResizeArray option -> ExpressionWithTypeArguments - abstract updateExpressionWithTypeArguments: node: ExpressionWithTypeArguments * expression: Expression * typeArguments: ResizeArray option -> ExpressionWithTypeArguments + abstract createExpressionWithTypeArguments: expression: Expression * typeArguments: TypeNode[] option -> ExpressionWithTypeArguments + abstract updateExpressionWithTypeArguments: node: ExpressionWithTypeArguments * expression: Expression * typeArguments: TypeNode[] option -> ExpressionWithTypeArguments abstract createAsExpression: expression: Expression * ``type``: TypeNode -> AsExpression abstract updateAsExpression: node: AsExpression * expression: Expression * ``type``: TypeNode -> AsExpression abstract createNonNullExpression: expression: Expression -> NonNullExpression abstract updateNonNullExpression: node: NonNullExpression * expression: Expression -> NonNullExpression abstract createNonNullChain: expression: Expression -> NonNullChain abstract updateNonNullChain: node: NonNullChain * expression: Expression -> NonNullChain - abstract createMetaProperty: keywordToken: MetaProperty * name: Identifier -> MetaProperty + abstract createMetaProperty: keywordToken: obj * name: Identifier -> MetaProperty abstract updateMetaProperty: node: MetaProperty * name: Identifier -> MetaProperty + abstract createSatisfiesExpression: expression: Expression * ``type``: TypeNode -> SatisfiesExpression + abstract updateSatisfiesExpression: node: SatisfiesExpression * expression: Expression * ``type``: TypeNode -> SatisfiesExpression abstract createTemplateSpan: expression: Expression * literal: U2 -> TemplateSpan abstract updateTemplateSpan: node: TemplateSpan * expression: Expression * literal: U2 -> TemplateSpan abstract createSemicolonClassElement: unit -> SemicolonClassElement - abstract createBlock: statements: ResizeArray * ?multiLine: bool -> Block - abstract updateBlock: node: Block * statements: ResizeArray -> Block - abstract createVariableStatement: modifiers: ResizeArray option * declarationList: U2> -> VariableStatement - abstract updateVariableStatement: node: VariableStatement * modifiers: ResizeArray option * declarationList: VariableDeclarationList -> VariableStatement + abstract createBlock: statements: Statement[] * ?multiLine: bool -> Block + abstract updateBlock: node: Block * statements: Statement[] -> Block + abstract createVariableStatement: modifiers: ModifierLike[] option * declarationList: U2 -> VariableStatement + abstract updateVariableStatement: node: VariableStatement * modifiers: ModifierLike[] option * declarationList: VariableDeclarationList -> VariableStatement abstract createEmptyStatement: unit -> EmptyStatement abstract createExpressionStatement: expression: Expression -> ExpressionStatement abstract updateExpressionStatement: node: ExpressionStatement * expression: Expression -> ExpressionStatement @@ -5225,64 +6524,66 @@ module Ts = abstract createDebuggerStatement: unit -> DebuggerStatement abstract createVariableDeclaration: name: U2 * ?exclamationToken: ExclamationToken * ?``type``: TypeNode * ?initializer: Expression -> VariableDeclaration abstract updateVariableDeclaration: node: VariableDeclaration * name: BindingName * exclamationToken: ExclamationToken option * ``type``: TypeNode option * initializer: Expression option -> VariableDeclaration - abstract createVariableDeclarationList: declarations: ResizeArray * ?flags: NodeFlags -> VariableDeclarationList - abstract updateVariableDeclarationList: node: VariableDeclarationList * declarations: ResizeArray -> VariableDeclarationList - abstract createFunctionDeclaration: decorators: ResizeArray option * modifiers: ResizeArray option * asteriskToken: AsteriskToken option * name: U2 option * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode option * body: Block option -> FunctionDeclaration - abstract updateFunctionDeclaration: node: FunctionDeclaration * decorators: ResizeArray option * modifiers: ResizeArray option * asteriskToken: AsteriskToken option * name: Identifier option * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode option * body: Block option -> FunctionDeclaration - abstract createClassDeclaration: decorators: ResizeArray option * modifiers: ResizeArray option * name: U2 option * typeParameters: ResizeArray option * heritageClauses: ResizeArray option * members: ResizeArray -> ClassDeclaration - abstract updateClassDeclaration: node: ClassDeclaration * decorators: ResizeArray option * modifiers: ResizeArray option * name: Identifier option * typeParameters: ResizeArray option * heritageClauses: ResizeArray option * members: ResizeArray -> ClassDeclaration - abstract createInterfaceDeclaration: decorators: ResizeArray option * modifiers: ResizeArray option * name: U2 * typeParameters: ResizeArray option * heritageClauses: ResizeArray option * members: ResizeArray -> InterfaceDeclaration - abstract updateInterfaceDeclaration: node: InterfaceDeclaration * decorators: ResizeArray option * modifiers: ResizeArray option * name: Identifier * typeParameters: ResizeArray option * heritageClauses: ResizeArray option * members: ResizeArray -> InterfaceDeclaration - abstract createTypeAliasDeclaration: decorators: ResizeArray option * modifiers: ResizeArray option * name: U2 * typeParameters: ResizeArray option * ``type``: TypeNode -> TypeAliasDeclaration - abstract updateTypeAliasDeclaration: node: TypeAliasDeclaration * decorators: ResizeArray option * modifiers: ResizeArray option * name: Identifier * typeParameters: ResizeArray option * ``type``: TypeNode -> TypeAliasDeclaration - abstract createEnumDeclaration: decorators: ResizeArray option * modifiers: ResizeArray option * name: U2 * members: ResizeArray -> EnumDeclaration - abstract updateEnumDeclaration: node: EnumDeclaration * decorators: ResizeArray option * modifiers: ResizeArray option * name: Identifier * members: ResizeArray -> EnumDeclaration - abstract createModuleDeclaration: decorators: ResizeArray option * modifiers: ResizeArray option * name: ModuleName * body: ModuleBody option * ?flags: NodeFlags -> ModuleDeclaration - abstract updateModuleDeclaration: node: ModuleDeclaration * decorators: ResizeArray option * modifiers: ResizeArray option * name: ModuleName * body: ModuleBody option -> ModuleDeclaration - abstract createModuleBlock: statements: ResizeArray -> ModuleBlock - abstract updateModuleBlock: node: ModuleBlock * statements: ResizeArray -> ModuleBlock - abstract createCaseBlock: clauses: ResizeArray -> CaseBlock - abstract updateCaseBlock: node: CaseBlock * clauses: ResizeArray -> CaseBlock + abstract createVariableDeclarationList: declarations: VariableDeclaration[] * ?flags: NodeFlags -> VariableDeclarationList + abstract updateVariableDeclarationList: node: VariableDeclarationList * declarations: VariableDeclaration[] -> VariableDeclarationList + abstract createFunctionDeclaration: modifiers: ModifierLike[] option * asteriskToken: AsteriskToken option * name: U2 option * typeParameters: TypeParameterDeclaration[] option * parameters: ParameterDeclaration[] * ``type``: TypeNode option * body: Block option -> FunctionDeclaration + abstract updateFunctionDeclaration: node: FunctionDeclaration * modifiers: ModifierLike[] option * asteriskToken: AsteriskToken option * name: Identifier option * typeParameters: TypeParameterDeclaration[] option * parameters: ParameterDeclaration[] * ``type``: TypeNode option * body: Block option -> FunctionDeclaration + abstract createClassDeclaration: modifiers: ModifierLike[] option * name: U2 option * typeParameters: TypeParameterDeclaration[] option * heritageClauses: HeritageClause[] option * members: ClassElement[] -> ClassDeclaration + abstract updateClassDeclaration: node: ClassDeclaration * modifiers: ModifierLike[] option * name: Identifier option * typeParameters: TypeParameterDeclaration[] option * heritageClauses: HeritageClause[] option * members: ClassElement[] -> ClassDeclaration + abstract createInterfaceDeclaration: modifiers: ModifierLike[] option * name: U2 * typeParameters: TypeParameterDeclaration[] option * heritageClauses: HeritageClause[] option * members: TypeElement[] -> InterfaceDeclaration + abstract updateInterfaceDeclaration: node: InterfaceDeclaration * modifiers: ModifierLike[] option * name: Identifier * typeParameters: TypeParameterDeclaration[] option * heritageClauses: HeritageClause[] option * members: TypeElement[] -> InterfaceDeclaration + abstract createTypeAliasDeclaration: modifiers: ModifierLike[] option * name: U2 * typeParameters: TypeParameterDeclaration[] option * ``type``: TypeNode -> TypeAliasDeclaration + abstract updateTypeAliasDeclaration: node: TypeAliasDeclaration * modifiers: ModifierLike[] option * name: Identifier * typeParameters: TypeParameterDeclaration[] option * ``type``: TypeNode -> TypeAliasDeclaration + abstract createEnumDeclaration: modifiers: ModifierLike[] option * name: U2 * members: EnumMember[] -> EnumDeclaration + abstract updateEnumDeclaration: node: EnumDeclaration * modifiers: ModifierLike[] option * name: Identifier * members: EnumMember[] -> EnumDeclaration + abstract createModuleDeclaration: modifiers: ModifierLike[] option * name: ModuleName * body: ModuleBody option * ?flags: NodeFlags -> ModuleDeclaration + abstract updateModuleDeclaration: node: ModuleDeclaration * modifiers: ModifierLike[] option * name: ModuleName * body: ModuleBody option -> ModuleDeclaration + abstract createModuleBlock: statements: Statement[] -> ModuleBlock + abstract updateModuleBlock: node: ModuleBlock * statements: Statement[] -> ModuleBlock + abstract createCaseBlock: clauses: CaseOrDefaultClause[] -> CaseBlock + abstract updateCaseBlock: node: CaseBlock * clauses: CaseOrDefaultClause[] -> CaseBlock abstract createNamespaceExportDeclaration: name: U2 -> NamespaceExportDeclaration abstract updateNamespaceExportDeclaration: node: NamespaceExportDeclaration * name: Identifier -> NamespaceExportDeclaration - abstract createImportEqualsDeclaration: decorators: ResizeArray option * modifiers: ResizeArray option * isTypeOnly: bool * name: U2 * moduleReference: ModuleReference -> ImportEqualsDeclaration - abstract updateImportEqualsDeclaration: node: ImportEqualsDeclaration * decorators: ResizeArray option * modifiers: ResizeArray option * isTypeOnly: bool * name: Identifier * moduleReference: ModuleReference -> ImportEqualsDeclaration - abstract createImportDeclaration: decorators: ResizeArray option * modifiers: ResizeArray option * importClause: ImportClause option * moduleSpecifier: Expression * ?assertClause: AssertClause -> ImportDeclaration - abstract updateImportDeclaration: node: ImportDeclaration * decorators: ResizeArray option * modifiers: ResizeArray option * importClause: ImportClause option * moduleSpecifier: Expression * assertClause: AssertClause option -> ImportDeclaration + abstract createImportEqualsDeclaration: modifiers: ModifierLike[] option * isTypeOnly: bool * name: U2 * moduleReference: ModuleReference -> ImportEqualsDeclaration + abstract updateImportEqualsDeclaration: node: ImportEqualsDeclaration * modifiers: ModifierLike[] option * isTypeOnly: bool * name: Identifier * moduleReference: ModuleReference -> ImportEqualsDeclaration + abstract createImportDeclaration: modifiers: ModifierLike[] option * importClause: ImportClause option * moduleSpecifier: Expression * ?assertClause: AssertClause -> ImportDeclaration + abstract updateImportDeclaration: node: ImportDeclaration * modifiers: ModifierLike[] option * importClause: ImportClause option * moduleSpecifier: Expression * assertClause: AssertClause option -> ImportDeclaration abstract createImportClause: isTypeOnly: bool * name: Identifier option * namedBindings: NamedImportBindings option -> ImportClause abstract updateImportClause: node: ImportClause * isTypeOnly: bool * name: Identifier option * namedBindings: NamedImportBindings option -> ImportClause - abstract createAssertClause: elements: ResizeArray * ?multiLine: bool -> AssertClause - abstract updateAssertClause: node: AssertClause * elements: ResizeArray * ?multiLine: bool -> AssertClause - abstract createAssertEntry: name: AssertionKey * value: StringLiteral -> AssertEntry - abstract updateAssertEntry: node: AssertEntry * name: AssertionKey * value: StringLiteral -> AssertEntry + abstract createAssertClause: elements: AssertEntry[] * ?multiLine: bool -> AssertClause + abstract updateAssertClause: node: AssertClause * elements: AssertEntry[] * ?multiLine: bool -> AssertClause + abstract createAssertEntry: name: AssertionKey * value: Expression -> AssertEntry + abstract updateAssertEntry: node: AssertEntry * name: AssertionKey * value: Expression -> AssertEntry + abstract createImportTypeAssertionContainer: clause: AssertClause * ?multiLine: bool -> ImportTypeAssertionContainer + abstract updateImportTypeAssertionContainer: node: ImportTypeAssertionContainer * clause: AssertClause * ?multiLine: bool -> ImportTypeAssertionContainer abstract createNamespaceImport: name: Identifier -> NamespaceImport abstract updateNamespaceImport: node: NamespaceImport * name: Identifier -> NamespaceImport abstract createNamespaceExport: name: Identifier -> NamespaceExport abstract updateNamespaceExport: node: NamespaceExport * name: Identifier -> NamespaceExport - abstract createNamedImports: elements: ResizeArray -> NamedImports - abstract updateNamedImports: node: NamedImports * elements: ResizeArray -> NamedImports + abstract createNamedImports: elements: ImportSpecifier[] -> NamedImports + abstract updateNamedImports: node: NamedImports * elements: ImportSpecifier[] -> NamedImports abstract createImportSpecifier: isTypeOnly: bool * propertyName: Identifier option * name: Identifier -> ImportSpecifier abstract updateImportSpecifier: node: ImportSpecifier * isTypeOnly: bool * propertyName: Identifier option * name: Identifier -> ImportSpecifier - abstract createExportAssignment: decorators: ResizeArray option * modifiers: ResizeArray option * isExportEquals: bool option * expression: Expression -> ExportAssignment - abstract updateExportAssignment: node: ExportAssignment * decorators: ResizeArray option * modifiers: ResizeArray option * expression: Expression -> ExportAssignment - abstract createExportDeclaration: decorators: ResizeArray option * modifiers: ResizeArray option * isTypeOnly: bool * exportClause: NamedExportBindings option * ?moduleSpecifier: Expression * ?assertClause: AssertClause -> ExportDeclaration - abstract updateExportDeclaration: node: ExportDeclaration * decorators: ResizeArray option * modifiers: ResizeArray option * isTypeOnly: bool * exportClause: NamedExportBindings option * moduleSpecifier: Expression option * assertClause: AssertClause option -> ExportDeclaration - abstract createNamedExports: elements: ResizeArray -> NamedExports - abstract updateNamedExports: node: NamedExports * elements: ResizeArray -> NamedExports + abstract createExportAssignment: modifiers: ModifierLike[] option * isExportEquals: bool option * expression: Expression -> ExportAssignment + abstract updateExportAssignment: node: ExportAssignment * modifiers: ModifierLike[] option * expression: Expression -> ExportAssignment + abstract createExportDeclaration: modifiers: ModifierLike[] option * isTypeOnly: bool * exportClause: NamedExportBindings option * ?moduleSpecifier: Expression * ?assertClause: AssertClause -> ExportDeclaration + abstract updateExportDeclaration: node: ExportDeclaration * modifiers: ModifierLike[] option * isTypeOnly: bool * exportClause: NamedExportBindings option * moduleSpecifier: Expression option * assertClause: AssertClause option -> ExportDeclaration + abstract createNamedExports: elements: ExportSpecifier[] -> NamedExports + abstract updateNamedExports: node: NamedExports * elements: ExportSpecifier[] -> NamedExports abstract createExportSpecifier: isTypeOnly: bool * propertyName: U2 option * name: U2 -> ExportSpecifier abstract updateExportSpecifier: node: ExportSpecifier * isTypeOnly: bool * propertyName: Identifier option * name: Identifier -> ExportSpecifier abstract createExternalModuleReference: expression: Expression -> ExternalModuleReference abstract updateExternalModuleReference: node: ExternalModuleReference * expression: Expression -> ExternalModuleReference abstract createJSDocAllType: unit -> JSDocAllType abstract createJSDocUnknownType: unit -> JSDocUnknownType - abstract createJSDocNonNullableType: ``type``: TypeNode -> JSDocNonNullableType + abstract createJSDocNonNullableType: ``type``: TypeNode * ?postfix: bool -> JSDocNonNullableType abstract updateJSDocNonNullableType: node: JSDocNonNullableType * ``type``: TypeNode -> JSDocNonNullableType - abstract createJSDocNullableType: ``type``: TypeNode -> JSDocNullableType + abstract createJSDocNullableType: ``type``: TypeNode * ?postfix: bool -> JSDocNullableType abstract updateJSDocNullableType: node: JSDocNullableType * ``type``: TypeNode -> JSDocNullableType abstract createJSDocOptionalType: ``type``: TypeNode -> JSDocOptionalType abstract updateJSDocOptionalType: node: JSDocOptionalType * ``type``: TypeNode -> JSDocOptionalType - abstract createJSDocFunctionType: parameters: ResizeArray * ``type``: TypeNode option -> JSDocFunctionType - abstract updateJSDocFunctionType: node: JSDocFunctionType * parameters: ResizeArray * ``type``: TypeNode option -> JSDocFunctionType + abstract createJSDocFunctionType: parameters: ParameterDeclaration[] * ``type``: TypeNode option -> JSDocFunctionType + abstract updateJSDocFunctionType: node: JSDocFunctionType * parameters: ParameterDeclaration[] * ``type``: TypeNode option -> JSDocFunctionType abstract createJSDocVariadicType: ``type``: TypeNode -> JSDocVariadicType abstract updateJSDocVariadicType: node: JSDocVariadicType * ``type``: TypeNode -> JSDocVariadicType abstract createJSDocNamepathType: ``type``: TypeNode -> JSDocNamepathType @@ -5299,84 +6600,92 @@ module Ts = abstract updateJSDocLinkCode: node: JSDocLinkCode * name: U2 option * text: string -> JSDocLinkCode abstract createJSDocLinkPlain: name: U2 option * text: string -> JSDocLinkPlain abstract updateJSDocLinkPlain: node: JSDocLinkPlain * name: U2 option * text: string -> JSDocLinkPlain - abstract createJSDocTypeLiteral: ?jsDocPropertyTags: ResizeArray * ?isArrayType: bool -> JSDocTypeLiteral - abstract updateJSDocTypeLiteral: node: JSDocTypeLiteral * jsDocPropertyTags: ResizeArray option * isArrayType: bool option -> JSDocTypeLiteral - abstract createJSDocSignature: typeParameters: ResizeArray option * parameters: ResizeArray * ?``type``: JSDocReturnTag -> JSDocSignature - abstract updateJSDocSignature: node: JSDocSignature * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: JSDocReturnTag option -> JSDocSignature - abstract createJSDocTemplateTag: tagName: Identifier option * ``constraint``: JSDocTypeExpression option * typeParameters: ResizeArray * ?comment: U2> -> JSDocTemplateTag - abstract updateJSDocTemplateTag: node: JSDocTemplateTag * tagName: Identifier option * ``constraint``: JSDocTypeExpression option * typeParameters: ResizeArray * comment: U2> option -> JSDocTemplateTag - abstract createJSDocTypedefTag: tagName: Identifier option * ?typeExpression: U2 * ?fullName: U2 * ?comment: U2> -> JSDocTypedefTag - abstract updateJSDocTypedefTag: node: JSDocTypedefTag * tagName: Identifier option * typeExpression: U2 option * fullName: U2 option * comment: U2> option -> JSDocTypedefTag - abstract createJSDocParameterTag: tagName: Identifier option * name: EntityName * isBracketed: bool * ?typeExpression: JSDocTypeExpression * ?isNameFirst: bool * ?comment: U2> -> JSDocParameterTag - abstract updateJSDocParameterTag: node: JSDocParameterTag * tagName: Identifier option * name: EntityName * isBracketed: bool * typeExpression: JSDocTypeExpression option * isNameFirst: bool * comment: U2> option -> JSDocParameterTag - abstract createJSDocPropertyTag: tagName: Identifier option * name: EntityName * isBracketed: bool * ?typeExpression: JSDocTypeExpression * ?isNameFirst: bool * ?comment: U2> -> JSDocPropertyTag - abstract updateJSDocPropertyTag: node: JSDocPropertyTag * tagName: Identifier option * name: EntityName * isBracketed: bool * typeExpression: JSDocTypeExpression option * isNameFirst: bool * comment: U2> option -> JSDocPropertyTag - abstract createJSDocTypeTag: tagName: Identifier option * typeExpression: JSDocTypeExpression * ?comment: U2> -> JSDocTypeTag - abstract updateJSDocTypeTag: node: JSDocTypeTag * tagName: Identifier option * typeExpression: JSDocTypeExpression * comment: U2> option -> JSDocTypeTag - abstract createJSDocSeeTag: tagName: Identifier option * nameExpression: JSDocNameReference option * ?comment: U2> -> JSDocSeeTag - abstract updateJSDocSeeTag: node: JSDocSeeTag * tagName: Identifier option * nameExpression: JSDocNameReference option * ?comment: U2> -> JSDocSeeTag - abstract createJSDocReturnTag: tagName: Identifier option * ?typeExpression: JSDocTypeExpression * ?comment: U2> -> JSDocReturnTag - abstract updateJSDocReturnTag: node: JSDocReturnTag * tagName: Identifier option * typeExpression: JSDocTypeExpression option * comment: U2> option -> JSDocReturnTag - abstract createJSDocThisTag: tagName: Identifier option * typeExpression: JSDocTypeExpression * ?comment: U2> -> JSDocThisTag - abstract updateJSDocThisTag: node: JSDocThisTag * tagName: Identifier option * typeExpression: JSDocTypeExpression option * comment: U2> option -> JSDocThisTag - abstract createJSDocEnumTag: tagName: Identifier option * typeExpression: JSDocTypeExpression * ?comment: U2> -> JSDocEnumTag - abstract updateJSDocEnumTag: node: JSDocEnumTag * tagName: Identifier option * typeExpression: JSDocTypeExpression * comment: U2> option -> JSDocEnumTag - abstract createJSDocCallbackTag: tagName: Identifier option * typeExpression: JSDocSignature * ?fullName: U2 * ?comment: U2> -> JSDocCallbackTag - abstract updateJSDocCallbackTag: node: JSDocCallbackTag * tagName: Identifier option * typeExpression: JSDocSignature * fullName: U2 option * comment: U2> option -> JSDocCallbackTag - abstract createJSDocAugmentsTag: tagName: Identifier option * className: JSDocAugmentsTag * ?comment: U2> -> JSDocAugmentsTag - abstract updateJSDocAugmentsTag: node: JSDocAugmentsTag * tagName: Identifier option * className: JSDocAugmentsTag * comment: U2> option -> JSDocAugmentsTag - abstract createJSDocImplementsTag: tagName: Identifier option * className: JSDocImplementsTag * ?comment: U2> -> JSDocImplementsTag - abstract updateJSDocImplementsTag: node: JSDocImplementsTag * tagName: Identifier option * className: JSDocImplementsTag * comment: U2> option -> JSDocImplementsTag - abstract createJSDocAuthorTag: tagName: Identifier option * ?comment: U2> -> JSDocAuthorTag - abstract updateJSDocAuthorTag: node: JSDocAuthorTag * tagName: Identifier option * comment: U2> option -> JSDocAuthorTag - abstract createJSDocClassTag: tagName: Identifier option * ?comment: U2> -> JSDocClassTag - abstract updateJSDocClassTag: node: JSDocClassTag * tagName: Identifier option * comment: U2> option -> JSDocClassTag - abstract createJSDocPublicTag: tagName: Identifier option * ?comment: U2> -> JSDocPublicTag - abstract updateJSDocPublicTag: node: JSDocPublicTag * tagName: Identifier option * comment: U2> option -> JSDocPublicTag - abstract createJSDocPrivateTag: tagName: Identifier option * ?comment: U2> -> JSDocPrivateTag - abstract updateJSDocPrivateTag: node: JSDocPrivateTag * tagName: Identifier option * comment: U2> option -> JSDocPrivateTag - abstract createJSDocProtectedTag: tagName: Identifier option * ?comment: U2> -> JSDocProtectedTag - abstract updateJSDocProtectedTag: node: JSDocProtectedTag * tagName: Identifier option * comment: U2> option -> JSDocProtectedTag - abstract createJSDocReadonlyTag: tagName: Identifier option * ?comment: U2> -> JSDocReadonlyTag - abstract updateJSDocReadonlyTag: node: JSDocReadonlyTag * tagName: Identifier option * comment: U2> option -> JSDocReadonlyTag - abstract createJSDocUnknownTag: tagName: Identifier * ?comment: U2> -> JSDocUnknownTag - abstract updateJSDocUnknownTag: node: JSDocUnknownTag * tagName: Identifier * comment: U2> option -> JSDocUnknownTag - abstract createJSDocDeprecatedTag: tagName: Identifier * ?comment: U2> -> JSDocDeprecatedTag - abstract updateJSDocDeprecatedTag: node: JSDocDeprecatedTag * tagName: Identifier * ?comment: U2> -> JSDocDeprecatedTag - abstract createJSDocOverrideTag: tagName: Identifier * ?comment: U2> -> JSDocOverrideTag - abstract updateJSDocOverrideTag: node: JSDocOverrideTag * tagName: Identifier * ?comment: U2> -> JSDocOverrideTag + abstract createJSDocTypeLiteral: ?jsDocPropertyTags: JSDocPropertyLikeTag[] * ?isArrayType: bool -> JSDocTypeLiteral + abstract updateJSDocTypeLiteral: node: JSDocTypeLiteral * jsDocPropertyTags: JSDocPropertyLikeTag[] option * isArrayType: bool option -> JSDocTypeLiteral + abstract createJSDocSignature: typeParameters: JSDocTemplateTag[] option * parameters: JSDocParameterTag[] * ?``type``: JSDocReturnTag -> JSDocSignature + abstract updateJSDocSignature: node: JSDocSignature * typeParameters: JSDocTemplateTag[] option * parameters: JSDocParameterTag[] * ``type``: JSDocReturnTag option -> JSDocSignature + abstract createJSDocTemplateTag: tagName: Identifier option * ``constraint``: JSDocTypeExpression option * typeParameters: TypeParameterDeclaration[] * ?comment: U2 -> JSDocTemplateTag + abstract updateJSDocTemplateTag: node: JSDocTemplateTag * tagName: Identifier option * ``constraint``: JSDocTypeExpression option * typeParameters: TypeParameterDeclaration[] * comment: U2 option -> JSDocTemplateTag + abstract createJSDocTypedefTag: tagName: Identifier option * ?typeExpression: U2 * ?fullName: U2 * ?comment: U2 -> JSDocTypedefTag + abstract updateJSDocTypedefTag: node: JSDocTypedefTag * tagName: Identifier option * typeExpression: U2 option * fullName: U2 option * comment: U2 option -> JSDocTypedefTag + abstract createJSDocParameterTag: tagName: Identifier option * name: EntityName * isBracketed: bool * ?typeExpression: JSDocTypeExpression * ?isNameFirst: bool * ?comment: U2 -> JSDocParameterTag + abstract updateJSDocParameterTag: node: JSDocParameterTag * tagName: Identifier option * name: EntityName * isBracketed: bool * typeExpression: JSDocTypeExpression option * isNameFirst: bool * comment: U2 option -> JSDocParameterTag + abstract createJSDocPropertyTag: tagName: Identifier option * name: EntityName * isBracketed: bool * ?typeExpression: JSDocTypeExpression * ?isNameFirst: bool * ?comment: U2 -> JSDocPropertyTag + abstract updateJSDocPropertyTag: node: JSDocPropertyTag * tagName: Identifier option * name: EntityName * isBracketed: bool * typeExpression: JSDocTypeExpression option * isNameFirst: bool * comment: U2 option -> JSDocPropertyTag + abstract createJSDocTypeTag: tagName: Identifier option * typeExpression: JSDocTypeExpression * ?comment: U2 -> JSDocTypeTag + abstract updateJSDocTypeTag: node: JSDocTypeTag * tagName: Identifier option * typeExpression: JSDocTypeExpression * comment: U2 option -> JSDocTypeTag + abstract createJSDocSeeTag: tagName: Identifier option * nameExpression: JSDocNameReference option * ?comment: U2 -> JSDocSeeTag + abstract updateJSDocSeeTag: node: JSDocSeeTag * tagName: Identifier option * nameExpression: JSDocNameReference option * ?comment: U2 -> JSDocSeeTag + abstract createJSDocReturnTag: tagName: Identifier option * ?typeExpression: JSDocTypeExpression * ?comment: U2 -> JSDocReturnTag + abstract updateJSDocReturnTag: node: JSDocReturnTag * tagName: Identifier option * typeExpression: JSDocTypeExpression option * comment: U2 option -> JSDocReturnTag + abstract createJSDocThisTag: tagName: Identifier option * typeExpression: JSDocTypeExpression * ?comment: U2 -> JSDocThisTag + abstract updateJSDocThisTag: node: JSDocThisTag * tagName: Identifier option * typeExpression: JSDocTypeExpression option * comment: U2 option -> JSDocThisTag + abstract createJSDocEnumTag: tagName: Identifier option * typeExpression: JSDocTypeExpression * ?comment: U2 -> JSDocEnumTag + abstract updateJSDocEnumTag: node: JSDocEnumTag * tagName: Identifier option * typeExpression: JSDocTypeExpression * comment: U2 option -> JSDocEnumTag + abstract createJSDocCallbackTag: tagName: Identifier option * typeExpression: JSDocSignature * ?fullName: U2 * ?comment: U2 -> JSDocCallbackTag + abstract updateJSDocCallbackTag: node: JSDocCallbackTag * tagName: Identifier option * typeExpression: JSDocSignature * fullName: U2 option * comment: U2 option -> JSDocCallbackTag + abstract createJSDocOverloadTag: tagName: Identifier option * typeExpression: JSDocSignature * ?comment: U2 -> JSDocOverloadTag + abstract updateJSDocOverloadTag: node: JSDocOverloadTag * tagName: Identifier option * typeExpression: JSDocSignature * comment: U2 option -> JSDocOverloadTag + abstract createJSDocAugmentsTag: tagName: Identifier option * className: obj * ?comment: U2 -> JSDocAugmentsTag + abstract updateJSDocAugmentsTag: node: JSDocAugmentsTag * tagName: Identifier option * className: obj * comment: U2 option -> JSDocAugmentsTag + abstract createJSDocImplementsTag: tagName: Identifier option * className: obj * ?comment: U2 -> JSDocImplementsTag + abstract updateJSDocImplementsTag: node: JSDocImplementsTag * tagName: Identifier option * className: obj * comment: U2 option -> JSDocImplementsTag + abstract createJSDocAuthorTag: tagName: Identifier option * ?comment: U2 -> JSDocAuthorTag + abstract updateJSDocAuthorTag: node: JSDocAuthorTag * tagName: Identifier option * comment: U2 option -> JSDocAuthorTag + abstract createJSDocClassTag: tagName: Identifier option * ?comment: U2 -> JSDocClassTag + abstract updateJSDocClassTag: node: JSDocClassTag * tagName: Identifier option * comment: U2 option -> JSDocClassTag + abstract createJSDocPublicTag: tagName: Identifier option * ?comment: U2 -> JSDocPublicTag + abstract updateJSDocPublicTag: node: JSDocPublicTag * tagName: Identifier option * comment: U2 option -> JSDocPublicTag + abstract createJSDocPrivateTag: tagName: Identifier option * ?comment: U2 -> JSDocPrivateTag + abstract updateJSDocPrivateTag: node: JSDocPrivateTag * tagName: Identifier option * comment: U2 option -> JSDocPrivateTag + abstract createJSDocProtectedTag: tagName: Identifier option * ?comment: U2 -> JSDocProtectedTag + abstract updateJSDocProtectedTag: node: JSDocProtectedTag * tagName: Identifier option * comment: U2 option -> JSDocProtectedTag + abstract createJSDocReadonlyTag: tagName: Identifier option * ?comment: U2 -> JSDocReadonlyTag + abstract updateJSDocReadonlyTag: node: JSDocReadonlyTag * tagName: Identifier option * comment: U2 option -> JSDocReadonlyTag + abstract createJSDocUnknownTag: tagName: Identifier * ?comment: U2 -> JSDocUnknownTag + abstract updateJSDocUnknownTag: node: JSDocUnknownTag * tagName: Identifier * comment: U2 option -> JSDocUnknownTag + abstract createJSDocDeprecatedTag: tagName: Identifier option * ?comment: U2 -> JSDocDeprecatedTag + abstract updateJSDocDeprecatedTag: node: JSDocDeprecatedTag * tagName: Identifier option * ?comment: U2 -> JSDocDeprecatedTag + abstract createJSDocOverrideTag: tagName: Identifier option * ?comment: U2 -> JSDocOverrideTag + abstract updateJSDocOverrideTag: node: JSDocOverrideTag * tagName: Identifier option * ?comment: U2 -> JSDocOverrideTag + abstract createJSDocThrowsTag: tagName: Identifier * typeExpression: JSDocTypeExpression option * ?comment: U2 -> JSDocThrowsTag + abstract updateJSDocThrowsTag: node: JSDocThrowsTag * tagName: Identifier option * typeExpression: JSDocTypeExpression option * ?comment: U2 -> JSDocThrowsTag + abstract createJSDocSatisfiesTag: tagName: Identifier option * typeExpression: JSDocTypeExpression * ?comment: U2 -> JSDocSatisfiesTag + abstract updateJSDocSatisfiesTag: node: JSDocSatisfiesTag * tagName: Identifier option * typeExpression: JSDocTypeExpression * comment: U2 option -> JSDocSatisfiesTag abstract createJSDocText: text: string -> JSDocText abstract updateJSDocText: node: JSDocText * text: string -> JSDocText - abstract createJSDocComment: ?comment: U2> * ?tags: ResizeArray -> JSDoc - abstract updateJSDocComment: node: JSDoc * comment: U2> option * tags: ResizeArray option -> JSDoc - abstract createJsxElement: openingElement: JsxOpeningElement * children: ResizeArray * closingElement: JsxClosingElement -> JsxElement - abstract updateJsxElement: node: JsxElement * openingElement: JsxOpeningElement * children: ResizeArray * closingElement: JsxClosingElement -> JsxElement - abstract createJsxSelfClosingElement: tagName: JsxTagNameExpression * typeArguments: ResizeArray option * attributes: JsxAttributes -> JsxSelfClosingElement - abstract updateJsxSelfClosingElement: node: JsxSelfClosingElement * tagName: JsxTagNameExpression * typeArguments: ResizeArray option * attributes: JsxAttributes -> JsxSelfClosingElement - abstract createJsxOpeningElement: tagName: JsxTagNameExpression * typeArguments: ResizeArray option * attributes: JsxAttributes -> JsxOpeningElement - abstract updateJsxOpeningElement: node: JsxOpeningElement * tagName: JsxTagNameExpression * typeArguments: ResizeArray option * attributes: JsxAttributes -> JsxOpeningElement + abstract createJSDocComment: ?comment: U2 * ?tags: JSDocTag[] -> JSDoc + abstract updateJSDocComment: node: JSDoc * comment: U2 option * tags: JSDocTag[] option -> JSDoc + abstract createJsxElement: openingElement: JsxOpeningElement * children: JsxChild[] * closingElement: JsxClosingElement -> JsxElement + abstract updateJsxElement: node: JsxElement * openingElement: JsxOpeningElement * children: JsxChild[] * closingElement: JsxClosingElement -> JsxElement + abstract createJsxSelfClosingElement: tagName: JsxTagNameExpression * typeArguments: TypeNode[] option * attributes: JsxAttributes -> JsxSelfClosingElement + abstract updateJsxSelfClosingElement: node: JsxSelfClosingElement * tagName: JsxTagNameExpression * typeArguments: TypeNode[] option * attributes: JsxAttributes -> JsxSelfClosingElement + abstract createJsxOpeningElement: tagName: JsxTagNameExpression * typeArguments: TypeNode[] option * attributes: JsxAttributes -> JsxOpeningElement + abstract updateJsxOpeningElement: node: JsxOpeningElement * tagName: JsxTagNameExpression * typeArguments: TypeNode[] option * attributes: JsxAttributes -> JsxOpeningElement abstract createJsxClosingElement: tagName: JsxTagNameExpression -> JsxClosingElement abstract updateJsxClosingElement: node: JsxClosingElement * tagName: JsxTagNameExpression -> JsxClosingElement - abstract createJsxFragment: openingFragment: JsxOpeningFragment * children: ResizeArray * closingFragment: JsxClosingFragment -> JsxFragment + abstract createJsxFragment: openingFragment: JsxOpeningFragment * children: JsxChild[] * closingFragment: JsxClosingFragment -> JsxFragment abstract createJsxText: text: string * ?containsOnlyTriviaWhiteSpaces: bool -> JsxText abstract updateJsxText: node: JsxText * text: string * ?containsOnlyTriviaWhiteSpaces: bool -> JsxText abstract createJsxOpeningFragment: unit -> JsxOpeningFragment abstract createJsxJsxClosingFragment: unit -> JsxClosingFragment - abstract updateJsxFragment: node: JsxFragment * openingFragment: JsxOpeningFragment * children: ResizeArray * closingFragment: JsxClosingFragment -> JsxFragment - abstract createJsxAttribute: name: Identifier * initializer: U2 option -> JsxAttribute - abstract updateJsxAttribute: node: JsxAttribute * name: Identifier * initializer: U2 option -> JsxAttribute - abstract createJsxAttributes: properties: ResizeArray -> JsxAttributes - abstract updateJsxAttributes: node: JsxAttributes * properties: ResizeArray -> JsxAttributes + abstract updateJsxFragment: node: JsxFragment * openingFragment: JsxOpeningFragment * children: JsxChild[] * closingFragment: JsxClosingFragment -> JsxFragment + abstract createJsxAttribute: name: JsxAttributeName * initializer: JsxAttributeValue option -> JsxAttribute + abstract updateJsxAttribute: node: JsxAttribute * name: JsxAttributeName * initializer: JsxAttributeValue option -> JsxAttribute + abstract createJsxAttributes: properties: JsxAttributeLike[] -> JsxAttributes + abstract updateJsxAttributes: node: JsxAttributes * properties: JsxAttributeLike[] -> JsxAttributes abstract createJsxSpreadAttribute: expression: Expression -> JsxSpreadAttribute abstract updateJsxSpreadAttribute: node: JsxSpreadAttribute * expression: Expression -> JsxSpreadAttribute abstract createJsxExpression: dotDotDotToken: DotDotDotToken option * expression: Expression option -> JsxExpression abstract updateJsxExpression: node: JsxExpression * expression: Expression option -> JsxExpression - abstract createCaseClause: expression: Expression * statements: ResizeArray -> CaseClause - abstract updateCaseClause: node: CaseClause * expression: Expression * statements: ResizeArray -> CaseClause - abstract createDefaultClause: statements: ResizeArray -> DefaultClause - abstract updateDefaultClause: node: DefaultClause * statements: ResizeArray -> DefaultClause - abstract createHeritageClause: token: HeritageClause * types: ResizeArray -> HeritageClause - abstract updateHeritageClause: node: HeritageClause * types: ResizeArray -> HeritageClause + abstract createJsxNamespacedName: ``namespace``: Identifier * name: Identifier -> JsxNamespacedName + abstract updateJsxNamespacedName: node: JsxNamespacedName * ``namespace``: Identifier * name: Identifier -> JsxNamespacedName + abstract createCaseClause: expression: Expression * statements: Statement[] -> CaseClause + abstract updateCaseClause: node: CaseClause * expression: Expression * statements: Statement[] -> CaseClause + abstract createDefaultClause: statements: Statement[] -> DefaultClause + abstract updateDefaultClause: node: DefaultClause * statements: Statement[] -> DefaultClause + abstract createHeritageClause: token: obj * types: ExpressionWithTypeArguments[] -> HeritageClause + abstract updateHeritageClause: node: HeritageClause * types: ExpressionWithTypeArguments[] -> HeritageClause abstract createCatchClause: variableDeclaration: U3 option * block: Block -> CatchClause abstract updateCatchClause: node: CatchClause * variableDeclaration: VariableDeclaration option * block: Block -> CatchClause abstract createPropertyAssignment: name: U2 * initializer: Expression -> PropertyAssignment @@ -5387,15 +6696,15 @@ module Ts = abstract updateSpreadAssignment: node: SpreadAssignment * expression: Expression -> SpreadAssignment abstract createEnumMember: name: U2 * ?initializer: Expression -> EnumMember abstract updateEnumMember: node: EnumMember * name: PropertyName * initializer: Expression option -> EnumMember - abstract createSourceFile: statements: ResizeArray * endOfFileToken: EndOfFileToken * flags: NodeFlags -> SourceFile - abstract updateSourceFile: node: SourceFile * statements: ResizeArray * ?isDeclarationFile: bool * ?referencedFiles: ResizeArray * ?typeReferences: ResizeArray * ?hasNoDefaultLib: bool * ?libReferences: ResizeArray -> SourceFile + abstract createSourceFile: statements: Statement[] * endOfFileToken: EndOfFileToken * flags: NodeFlags -> SourceFile + abstract updateSourceFile: node: SourceFile * statements: Statement[] * ?isDeclarationFile: bool * ?referencedFiles: FileReference[] * ?typeReferences: FileReference[] * ?hasNoDefaultLib: bool * ?libReferences: FileReference[] -> SourceFile abstract createNotEmittedStatement: original: Node -> NotEmittedStatement abstract createPartiallyEmittedExpression: expression: Expression * ?original: Node -> PartiallyEmittedExpression abstract updatePartiallyEmittedExpression: node: PartiallyEmittedExpression * expression: Expression -> PartiallyEmittedExpression - abstract createCommaListExpression: elements: ResizeArray -> CommaListExpression - abstract updateCommaListExpression: node: CommaListExpression * elements: ResizeArray -> CommaListExpression - abstract createBundle: sourceFiles: ResizeArray * ?prepends: ResizeArray> -> Bundle - abstract updateBundle: node: Bundle * sourceFiles: ResizeArray * ?prepends: ResizeArray> -> Bundle + abstract createCommaListExpression: elements: Expression[] -> CommaListExpression + abstract updateCommaListExpression: node: CommaListExpression * elements: Expression[] -> CommaListExpression + abstract createBundle: sourceFiles: SourceFile[] -> Bundle + abstract updateBundle: node: Bundle * sourceFiles: SourceFile[] -> Bundle abstract createComma: left: Expression * right: Expression -> BinaryExpression abstract createAssignment: left: U2 * right: Expression -> DestructuringAssignment abstract createAssignment: left: Expression * right: Expression -> AssignmentExpression @@ -5429,10 +6738,10 @@ module Ts = abstract createLogicalNot: operand: Expression -> PrefixUnaryExpression abstract createPostfixIncrement: operand: Expression -> PostfixUnaryExpression abstract createPostfixDecrement: operand: Expression -> PostfixUnaryExpression - abstract createImmediatelyInvokedFunctionExpression: statements: ResizeArray -> CallExpression - abstract createImmediatelyInvokedFunctionExpression: statements: ResizeArray * param: ParameterDeclaration * paramValue: Expression -> CallExpression - abstract createImmediatelyInvokedArrowFunction: statements: ResizeArray -> CallExpression - abstract createImmediatelyInvokedArrowFunction: statements: ResizeArray * param: ParameterDeclaration * paramValue: Expression -> CallExpression + abstract createImmediatelyInvokedFunctionExpression: statements: Statement[] -> CallExpression + abstract createImmediatelyInvokedFunctionExpression: statements: Statement[] * param: ParameterDeclaration * paramValue: Expression -> CallExpression + abstract createImmediatelyInvokedArrowFunction: statements: Statement[] -> CallExpression + abstract createImmediatelyInvokedArrowFunction: statements: Statement[] * param: ParameterDeclaration * paramValue: Expression -> CallExpression abstract createVoidZero: unit -> VoidExpression abstract createExportDefault: expression: Expression -> ExportAssignment abstract createExternalModuleExport: exportName: Identifier -> ExportDeclaration @@ -5449,7 +6758,7 @@ module Ts = /// Resumes a suspended lexical environment, usually before visiting a function body. abstract resumeLexicalEnvironment: unit -> unit /// Ends a lexical environment, returning any declarations. - abstract endLexicalEnvironment: unit -> ResizeArray option + abstract endLexicalEnvironment: unit -> Statement[] option /// Hoists a function declaration to the containing scope. abstract hoistFunctionDeclaration: node: FunctionDeclaration -> unit /// Hoists a variable declaration to the containing scope. @@ -5460,35 +6769,39 @@ module Ts = /// Records a request for a non-scoped emit helper in the current context. abstract requestEmitHelper: helper: EmitHelper -> unit /// Gets and resets the requested non-scoped emit helpers. - abstract readEmitHelpers: unit -> ResizeArray option + abstract readEmitHelpers: unit -> EmitHelper[] option /// Enables expression substitutions in the pretty printer for the provided SyntaxKind. abstract enableSubstitution: kind: SyntaxKind -> unit /// Determines whether expression substitutions are enabled for the provided node. abstract isSubstitutionEnabled: node: Node -> bool + /// /// Hook used by transformers to substitute expressions just before they /// are emitted by the pretty printer. - /// - /// NOTE: Transformation hooks should only be modified during `Transformer` initialization, - /// before returning the `NodeTransformer` callback. - abstract onSubstituteNode: (EmitHint -> Node -> Node) with get, set + /// + /// NOTE: Transformation hooks should only be modified during Transformer initialization, + /// before returning the NodeTransformer callback. + /// + abstract onSubstituteNode: hint: EmitHint * node: Node -> Node /// Enables before/after emit notifications in the pretty printer for the provided /// SyntaxKind. abstract enableEmitNotification: kind: SyntaxKind -> unit /// Determines whether before/after emit notifications should be raised in the pretty /// printer when it emits a node. abstract isEmitNotificationEnabled: node: Node -> bool + /// /// Hook used to allow transformers to capture state before or after /// the printer emits a node. - /// - /// NOTE: Transformation hooks should only be modified during `Transformer` initialization, - /// before returning the `NodeTransformer` callback. - abstract onEmitNode: (EmitHint -> Node -> (EmitHint -> Node -> unit) -> unit) with get, set + /// + /// NOTE: Transformation hooks should only be modified during Transformer initialization, + /// before returning the NodeTransformer callback. + /// + abstract onEmitNode: hint: EmitHint * node: Node * emitCallback: (EmitHint -> Node -> unit) -> unit - type [] TransformationResult<'T> = + type [] TransformationResult<'T > = /// Gets the transformed source files. - abstract transformed: ResizeArray<'T> with get, set + abstract transformed: 'T[] with get, set /// Gets diagnostics for the transformation. - abstract diagnostics: ResizeArray option with get, set + abstract diagnostics: DiagnosticWithLocation[] option with get, set /// Gets a substitute for a node, if one is available; otherwise, returns the original node. /// A hint as to the intended usage of the node. /// The node to substitute. @@ -5504,41 +6817,90 @@ module Ts = /// Clean up EmitNode entries on any parse-tree nodes. abstract dispose: unit -> unit - type [] TransformerFactory<'T> = - [] abstract Invoke: context: TransformationContext -> Transformer<'T> - - type [] Transformer<'T> = - [] abstract Invoke: node: 'T -> 'T - - type [] Visitor = - [] abstract Invoke: node: Node -> VisitResult - + /// + /// A function that is used to initialize and return a Transformer callback, which in turn + /// will be used to transform one or more nodes. + /// + type [] TransformerFactory<'T > = + /// + /// A function that is used to initialize and return a Transformer callback, which in turn + /// will be used to transform one or more nodes. + /// + [] abstract Invoke: context: TransformationContext -> Transformer<'T> + + /// A function that transforms a node. + type [] Transformer<'T > = + /// A function that transforms a node. + [] abstract Invoke: node: 'T -> 'T + + /// A function that accepts and possibly transforms a node. + type Visitor = + Visitor + + /// A function that accepts and possibly transforms a node. + type Visitor<'TIn > = + Visitor<'TIn, 'TIn option> + + /// A function that accepts and possibly transforms a node. + type [] Visitor<'TIn, 'TOut > = + /// A function that accepts and possibly transforms a node. + [] abstract Invoke: node: 'TIn -> VisitResult<'TOut> + + /// + /// A function that walks a node using the given visitor, lifting node arrays into single nodes, + /// returning an node which satisfies the test. + /// + /// - If the input node is undefined, then the output is undefined. + /// - If the visitor returns undefined, then the output is undefined. + /// - If the output node is not undefined, then it will satisfy the test function. + /// - In order to obtain a return type that is more specific than Node, a test + /// function _must_ be provided, and that function must be a type predicate. + /// + /// For the canonical implementation of this type, @see {visitNode}. + /// type [] NodeVisitor = - [] abstract Invoke: nodes: 'T * visitor: Visitor option * ?test: (Node -> bool) * ?lift: (ResizeArray -> 'T) -> 'T - [] abstract Invoke: nodes: 'T option * visitor: Visitor option * ?test: (Node -> bool) * ?lift: (ResizeArray -> 'T) -> 'T option - + [] abstract Invoke: node: 'TIn * visitor: Visitor<'TIn, 'TVisited> * test: (Node -> bool) * ?lift: (Node[] -> Node) -> U2<'TOut, obj> + [] abstract Invoke: node: 'TIn * visitor: Visitor<'TIn, 'TVisited> * ?test: (Node -> bool) * ?lift: (Node[] -> Node) -> U2 + + /// + /// A function that walks a node array using the given visitor, returning an array whose contents satisfy the test. + /// + /// - If the input node array is undefined, the output is undefined. + /// - If the visitor can return undefined, the node it visits in the array will be reused. + /// - If the output node array is not undefined, then its contents will satisfy the test. + /// - In order to obtain a return type that is more specific than NodeArray<Node>, a test + /// function _must_ be provided, and that function must be a type predicate. + /// + /// For the canonical implementation of this type, @see {visitNodes}. + /// type [] NodesVisitor = - [] abstract Invoke: nodes: ResizeArray<'T> * visitor: Visitor option * ?test: (Node -> bool) * ?start: float * ?count: float -> ResizeArray<'T> - [] abstract Invoke: nodes: ResizeArray<'T> option * visitor: Visitor option * ?test: (Node -> bool) * ?start: float * ?count: float -> ResizeArray<'T> option + [] abstract Invoke: nodes: 'TInArray * visitor: Visitor<'TIn, Node option> * test: (Node -> bool) * ?start: float * ?count: float -> U2<'TOut[], obj> + [] abstract Invoke: nodes: 'TInArray * visitor: Visitor<'TIn, Node option> * ?test: (Node -> bool) * ?start: float * ?count: float -> U2 type VisitResult<'T> = - U2<'T, ResizeArray<'T>> option + U2<'T, Node[]> type [] Printer = /// Print a node and its subtree as-is, without any emit transformations. - /// A value indicating the purpose of a node. This is primarily used to - /// distinguish between an `Identifier` used in an expression position, versus an - /// `Identifier` used as an `IdentifierName` as part of a declaration. For most nodes you - /// should just pass `Unspecified`. - /// The node to print. The node and its subtree are printed as-is, without any - /// emit transformations. - /// A source file that provides context for the node. The source text of + /// + /// A value indicating the purpose of a node. This is primarily used to + /// distinguish between an Identifier used in an expression position, versus an + /// Identifier used as an IdentifierName as part of a declaration. For most nodes you + /// should just pass Unspecified. + /// + /// + /// The node to print. The node and its subtree are printed as-is, without any + /// emit transformations. + /// + /// + /// A source file that provides context for the node. The source text of /// the file is used to emit the original source content for literals and identifiers, while /// the identifiers of the source file are used when generating unique names to avoid - /// collisions. + /// collisions. + /// abstract printNode: hint: EmitHint * node: Node * sourceFile: SourceFile -> string /// Prints a list of nodes using the given format flags - abstract printList: format: ListFormat * list: ResizeArray<'T> * sourceFile: SourceFile -> string + abstract printList: format: ListFormat * list: 'T[] * sourceFile: SourceFile -> string /// Prints a source file as-is, without any emit transformations. abstract printFile: sourceFile: SourceFile -> string /// Prints a bundle of source files as-is, without any emit transformations. @@ -5548,21 +6910,46 @@ module Ts = /// A hook used by the Printer when generating unique names to avoid collisions with /// globally defined names that exist outside of the current source file. abstract hasGlobalName: name: string -> bool - /// A hook used by the Printer to provide notifications prior to emitting a node. A - /// compatible implementation **must** invoke `emitCallback` with the provided `hint` and - /// `node` values. + /// + /// A hook used by the Printer to provide notifications prior to emitting a node. A + /// compatible implementation **must** invoke emitCallback with the provided hint and + /// node values. + /// /// A hint indicating the intended purpose of the node. /// The node to emit. /// A callback that, when invoked, will emit the node. + /// + /// + /// var printer = createPrinter(printerOptions, { + /// onEmitNode(hint, node, emitCallback) { + /// // set up or track state prior to emitting the node... + /// emitCallback(hint, node); + /// // restore state after emitting the node... + /// } + /// }); + /// + /// abstract onEmitNode: hint: EmitHint * node: Node * emitCallback: (EmitHint -> Node -> unit) -> unit /// A hook used to check if an emit notification is required for a node. /// The node to emit. abstract isEmitNotificationEnabled: node: Node -> bool - /// A hook used by the Printer to perform just-in-time substitution of a node. This is + /// + /// A hook used by the Printer to perform just-in-time substitution of a node. This is /// primarily used by node transformations that need to substitute one node for another, - /// such as replacing `myExportedVar` with `exports.myExportedVar`. + /// such as replacing myExportedVar with exports.myExportedVar. + /// /// A hint indicating the intended purpose of the node. /// The node to emit. + /// + /// + /// var printer = createPrinter(printerOptions, { + /// substituteNode(hint, node) { + /// // perform substitution if necessary... + /// return node; + /// } + /// }); + /// + /// abstract substituteNode: hint: EmitHint * node: Node -> Node type [] PrinterOptions = @@ -5572,7 +6959,6 @@ module Ts = abstract noEmitHelpers: bool option with get, set type [] GetEffectiveTypeRootsHost = - abstract directoryExists: directoryName: string -> bool abstract getCurrentDirectory: unit -> string type [] TextSpan = @@ -5586,7 +6972,7 @@ module Ts = type [] SyntaxList = inherit Node abstract kind: SyntaxKind with get, set - abstract _children: ResizeArray with get, set + abstract _children: Node[] with get, set type [] ListFormat = | None = 0 @@ -5618,7 +7004,7 @@ module Ts = | NoSpaceIfEmpty = 524288 | SingleElement = 1048576 | SpaceAfterList = 2097152 - | Modifiers = 262656 + | Modifiers = 2359808 | HeritageClauses = 512 | SingleLineTypeLiteralMembers = 768 | MultiLineTypeLiteralMembers = 32897 @@ -5667,15 +7053,33 @@ module Ts = abstract includeAutomaticOptionalChainCompletions: bool option abstract includeCompletionsWithInsertText: bool option abstract includeCompletionsWithClassMemberSnippets: bool option + abstract includeCompletionsWithObjectLiteralMethodSnippets: bool option + abstract useLabelDetailsInCompletionEntries: bool option abstract allowIncompleteCompletions: bool option abstract importModuleSpecifierPreference: UserPreferencesImportModuleSpecifierPreference option - /// Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" + /// Determines whether we import foo/index.ts as "foo", "foo/index", or "foo/index.js" abstract importModuleSpecifierEnding: UserPreferencesImportModuleSpecifierEnding option abstract allowTextChangesInNewFiles: bool option abstract providePrefixAndSuffixTextForRename: bool option abstract includePackageJsonAutoImports: UserPreferencesIncludePackageJsonAutoImports option abstract provideRefactorNotApplicableReason: bool option abstract jsxAttributeCompletionStyle: UserPreferencesJsxAttributeCompletionStyle option + abstract includeInlayParameterNameHints: UserPreferencesIncludeInlayParameterNameHints option + abstract includeInlayParameterNameHintsWhenArgumentMatchesName: bool option + abstract includeInlayFunctionParameterTypeHints: bool option + abstract includeInlayVariableTypeHints: bool option + abstract includeInlayVariableTypeHintsWhenTypeMatchesName: bool option + abstract includeInlayPropertyDeclarationTypeHints: bool option + abstract includeInlayFunctionLikeReturnTypeHints: bool option + abstract includeInlayEnumMemberValueHints: bool option + abstract allowRenameOfImportPath: bool option + abstract autoImportFileExcludePatterns: string[] option + abstract organizeImportsIgnoreCase: U2 option + abstract organizeImportsCollation: UserPreferencesOrganizeImportsCollation option + abstract organizeImportsLocale: string option + abstract organizeImportsNumericCollation: bool option + abstract organizeImportsAccentCollation: bool option + abstract organizeImportsCaseFirst: UserPreferencesOrganizeImportsCaseFirst option /// Represents a bigint literal value without requiring bigint support type [] PseudoBigInt = @@ -5688,13 +7092,25 @@ module Ts = | Deleted = 2 type [] FileWatcherCallback = - [] abstract Invoke: fileName: string * eventKind: FileWatcherEventKind -> unit + [] abstract Invoke: fileName: string * eventKind: FileWatcherEventKind * ?modifiedTime: DateTime -> unit type [] DirectoryWatcherCallback = - [] abstract Invoke: fileName: string -> unit + [] abstract Invoke: fileName: string -> unit + + type [] [] BufferEncoding = + | Ascii + | Utf8 + | [] ``utf-8`` + | Utf16le + | Ucs2 + | [] ``ucs-2`` + | Base64 + | Latin1 + | Binary + | Hex type [] System = - abstract args: ResizeArray with get, set + abstract args: string[] with get, set abstract newLine: string with get, set abstract useCaseSensitiveFileNames: bool with get, set abstract write: s: string -> unit @@ -5711,19 +7127,19 @@ module Ts = abstract createDirectory: path: string -> unit abstract getExecutingFilePath: unit -> string abstract getCurrentDirectory: unit -> string - abstract getDirectories: path: string -> ResizeArray - abstract readDirectory: path: string * ?extensions: ResizeArray * ?exclude: ResizeArray * ?``include``: ResizeArray * ?depth: float -> ResizeArray + abstract getDirectories: path: string -> string[] + abstract readDirectory: path: string * ?extensions: string[] * ?exclude: string[] * ?``include``: string[] * ?depth: float -> string[] abstract getModifiedTime: path: string -> DateTime option abstract setModifiedTime: path: string * time: DateTime -> unit abstract deleteFile: path: string -> unit - /// A good implementation is node.js' `crypto.createHash`. (https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm) + /// A good implementation is node.js' crypto.createHash. ( abstract createHash: data: string -> string - /// This must be cryptographically secure. Only implement this method using `crypto.createHash("sha256")`. + /// This must be cryptographically secure. Only implement this method using crypto.createHash("sha256"). abstract createSHA256Hash: data: string -> string abstract getMemoryUsage: unit -> float abstract exit: ?exitCode: float -> unit abstract realpath: path: string -> string - abstract setTimeout: callback: (ResizeArray -> unit) * ms: float * [] args: ResizeArray -> obj option + abstract setTimeout: callback: (obj option[] -> unit) * ms: float * [] args: obj option[] -> obj option abstract clearTimeout: timeoutId: obj option -> unit abstract clearScreen: unit -> unit abstract base64decode: input: string -> string @@ -5733,13 +7149,13 @@ module Ts = abstract close: unit -> unit type [] ErrorCallback = - [] abstract Invoke: message: DiagnosticMessage * length: float -> unit + [] abstract Invoke: message: DiagnosticMessage * length: float * ?arg0: obj -> unit type [] Scanner = - abstract getStartPos: unit -> float abstract getToken: unit -> SyntaxKind - abstract getTextPos: unit -> float - abstract getTokenPos: unit -> float + abstract getTokenFullStart: unit -> float + abstract getTokenStart: unit -> float + abstract getTokenEnd: unit -> float abstract getTokenText: unit -> string abstract getTokenValue: unit -> string abstract hasUnicodeEscape: unit -> bool @@ -5752,7 +7168,6 @@ module Ts = abstract reScanSlashToken: unit -> SyntaxKind abstract reScanAsteriskEqualsToken: unit -> SyntaxKind abstract reScanTemplateToken: isTaggedTemplate: bool -> SyntaxKind - abstract reScanTemplateHeadOrNoSubstitutionTemplate: unit -> SyntaxKind abstract scanJsxIdentifier: unit -> SyntaxKind abstract scanJsxAttributeValue: unit -> SyntaxKind abstract reScanJsxAttributeValue: unit -> SyntaxKind @@ -5769,7 +7184,7 @@ module Ts = abstract setOnError: onError: ErrorCallback option -> unit abstract setScriptTarget: scriptTarget: ScriptTarget -> unit abstract setLanguageVariant: variant: LanguageVariant -> unit - abstract setTextPos: textPos: float -> unit + abstract resetTokenState: pos: float -> unit abstract lookAhead: callback: (unit -> 'T) -> 'T abstract scanRange: start: float * length: float * callback: (unit -> 'T) -> 'T abstract tryScan: callback: (unit -> 'T) -> 'T @@ -5777,8 +7192,23 @@ module Ts = type [] ParameterPropertyDeclaration = interface end + type [] CreateSourceFileOptions = + abstract languageVersion: ScriptTarget with get, set + /// + /// Controls the format the file is detected as - this can be derived from only the path + /// and files on disk, but needs to be done with a module resolution cache in scope to be performant. + /// This is usually undefined for compilations that do not have moduleResolution values of node16 or nodenext. + /// + abstract impliedNodeFormat: ResolutionMode option with get, set + /// + /// Controls how module-y-ness is set for the given file. Usually the result of calling + /// getSetExternalModuleIndicator on a valid CompilerOptions object. If not present, the default + /// check specified by isFileProbablyExternalModule will be used to set the field. + /// + abstract setExternalModuleIndicator: file: SourceFile -> unit + type [] DiagnosticReporter = - [] abstract Invoke: diagnostic: Diagnostic -> unit + [] abstract Invoke: diagnostic: Diagnostic -> unit /// Reports config file diagnostics type [] ConfigFileDiagnosticsReporter = @@ -5797,7 +7227,7 @@ module Ts = abstract watchOptions: WatchOptions option with get, set abstract typeAcquisition: TypeAcquisition option with get, set /// Note that the case of the config path has not yet been normalized, as no files have been imported into the project yet - abstract extendedConfigPath: string option with get, set + abstract extendedConfigPath: U2 option with get, set type [] ExtendedConfigCacheEntry = abstract extendedResult: TsConfigSourceFile with get, set @@ -5805,25 +7235,39 @@ module Ts = type [] TypeReferenceDirectiveResolutionCache = inherit PerDirectoryResolutionCache + inherit NonRelativeNameResolutionCache inherit PackageJsonInfoCache type [] ModeAwareCache<'T> = - abstract get: key: string * mode: ModuleKind option -> 'T option - abstract set: key: string * mode: ModuleKind option * value: 'T -> ModeAwareCache<'T> - abstract delete: key: string * mode: ModuleKind option -> ModeAwareCache<'T> - abstract has: key: string * mode: ModuleKind option -> bool - abstract forEach: cb: ('T -> string -> ModuleKind option -> unit) -> unit + abstract get: key: string * mode: ResolutionMode -> 'T option + abstract set: key: string * mode: ResolutionMode * value: 'T -> ModeAwareCache<'T> + abstract delete: key: string * mode: ResolutionMode -> ModeAwareCache<'T> + abstract has: key: string * mode: ResolutionMode -> bool + abstract forEach: cb: ('T -> string -> ResolutionMode -> unit) -> unit abstract size: unit -> float /// Cached resolutions per containing directory. /// This assumes that any module id will have the same resolution for sibling files located in the same folder. type [] PerDirectoryResolutionCache<'T> = + abstract getFromDirectoryCache: name: string * mode: ResolutionMode * directoryName: string * redirectedReference: ResolvedProjectReference option -> 'T option abstract getOrCreateCacheForDirectory: directoryName: string * ?redirectedReference: ResolvedProjectReference -> ModeAwareCache<'T> abstract clear: unit -> unit /// Updates with the current compilerOptions the cache will operate with. /// This updates the redirects map as well if needed so module resolutions are cached if they can across the projects abstract update: options: CompilerOptions -> unit + type [] NonRelativeNameResolutionCache<'T> = + abstract getFromNonRelativeNameCache: nonRelativeName: string * mode: ResolutionMode * directoryName: string * redirectedReference: ResolvedProjectReference option -> 'T option + abstract getOrCreateCacheForNonRelativeName: nonRelativeName: string * mode: ResolutionMode * ?redirectedReference: ResolvedProjectReference -> PerNonRelativeNameCache<'T> + abstract clear: unit -> unit + /// Updates with the current compilerOptions the cache will operate with. + /// This updates the redirects map as well if needed so module resolutions are cached if they can across the projects + abstract update: options: CompilerOptions -> unit + + type [] PerNonRelativeNameCache<'T> = + abstract get: directory: string -> 'T option + abstract set: directory: string * result: 'T -> unit + type [] ModuleResolutionCache = inherit PerDirectoryResolutionCache inherit NonRelativeModuleNameResolutionCache @@ -5833,26 +7277,22 @@ module Ts = /// Stored map from non-relative module name to a table: directory -> result of module lookup in this directory /// We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. type [] NonRelativeModuleNameResolutionCache = + inherit NonRelativeNameResolutionCache inherit PackageJsonInfoCache - abstract getOrCreateCacheForModuleName: nonRelativeModuleName: string * mode: ModuleKind option * ?redirectedReference: ResolvedProjectReference -> PerModuleNameCache type [] PackageJsonInfoCache = abstract clear: unit -> unit - type [] PerModuleNameCache = - abstract get: directory: string -> ResolvedModuleWithFailedLookupLocations option - abstract set: directory: string * result: ResolvedModuleWithFailedLookupLocations -> unit + type PerModuleNameCache = + PerNonRelativeNameCache type [] FormatDiagnosticsHost = abstract getCurrentDirectory: unit -> string abstract getCanonicalFileName: fileName: string -> string abstract getNewLine: unit -> string - type [] ResolveProjectReferencePathHost = - abstract fileExists: fileName: string -> bool - type [] EmitOutput = - abstract outputFiles: ResizeArray with get, set + abstract outputFiles: OutputFile[] with get, set abstract emitSkipped: bool with get, set type [] OutputFile = @@ -5861,13 +7301,11 @@ module Ts = abstract text: string with get, set type AffectedFileResult<'T> = - U2<'T, U2> option + {| result: 'T; affected: U2 |} option type [] BuilderProgramHost = - /// return true if file names are treated with case sensitivity - abstract useCaseSensitiveFileNames: unit -> bool /// If provided this would be used this hash instead of actual file shape text for detecting changes - abstract createHash: (string -> string) option with get, set + abstract createHash: data: string -> string /// When emit or emitNextAffectedFile are called without writeFile, /// this callback if present would be used to write files abstract writeFile: WriteFileCallback option with get, set @@ -5881,33 +7319,33 @@ module Ts = /// Get the source file in the program with file name abstract getSourceFile: fileName: string -> SourceFile option /// Get a list of files in the program - abstract getSourceFiles: unit -> ResizeArray + abstract getSourceFiles: unit -> SourceFile[] /// Get the diagnostics for compiler options - abstract getOptionsDiagnostics: ?cancellationToken: CancellationToken -> ResizeArray + abstract getOptionsDiagnostics: ?cancellationToken: CancellationToken -> Diagnostic[] /// Get the diagnostics that dont belong to any file - abstract getGlobalDiagnostics: ?cancellationToken: CancellationToken -> ResizeArray + abstract getGlobalDiagnostics: ?cancellationToken: CancellationToken -> Diagnostic[] /// Get the diagnostics from config file parsing - abstract getConfigFileParsingDiagnostics: unit -> ResizeArray + abstract getConfigFileParsingDiagnostics: unit -> Diagnostic[] /// Get the syntax diagnostics, for all source files if source file is not supplied - abstract getSyntacticDiagnostics: ?sourceFile: SourceFile * ?cancellationToken: CancellationToken -> ResizeArray + abstract getSyntacticDiagnostics: ?sourceFile: SourceFile * ?cancellationToken: CancellationToken -> Diagnostic[] /// Get the declaration diagnostics, for all source files if source file is not supplied - abstract getDeclarationDiagnostics: ?sourceFile: SourceFile * ?cancellationToken: CancellationToken -> ResizeArray + abstract getDeclarationDiagnostics: ?sourceFile: SourceFile * ?cancellationToken: CancellationToken -> DiagnosticWithLocation[] /// Get all the dependencies of the file - abstract getAllDependencies: sourceFile: SourceFile -> ResizeArray + abstract getAllDependencies: sourceFile: SourceFile -> string[] /// Gets the semantic diagnostics from the program corresponding to this state of file (if provided) or whole program /// The semantic diagnostics are cached and managed here /// Note that it is assumed that when asked about semantic diagnostics through this API, /// the file has been taken out of affected files so it is safe to use cache or get from program and cache the diagnostics /// In case of SemanticDiagnosticsBuilderProgram if the source file is not provided, /// it will iterate through all the affected files, to ensure that cache stays valid and yet provide a way to get all semantic diagnostics - abstract getSemanticDiagnostics: ?sourceFile: SourceFile * ?cancellationToken: CancellationToken -> ResizeArray + abstract getSemanticDiagnostics: ?sourceFile: SourceFile * ?cancellationToken: CancellationToken -> Diagnostic[] /// Emits the JavaScript and declaration files. /// When targetSource file is specified, emits the files corresponding to that source file, /// otherwise for the whole program. /// In case of EmitAndSemanticDiagnosticsBuilderProgram, when targetSourceFile is specified, /// it is assumed that that file is handled from affected file list. If targetSourceFile is not specified, /// it will only emit all the affected files instead of whole program - /// + /// /// The first of writeFile if provided, writeFile of BuilderProgramHost if provided, writeFile of compiler host /// in that order would be used to write the files abstract emit: ?targetSourceFile: SourceFile * ?writeFile: WriteFileCallback * ?cancellationToken: CancellationToken * ?emitOnlyDtsFiles: bool * ?customTransformers: CustomTransformers -> EmitResult @@ -5919,7 +7357,7 @@ module Ts = inherit BuilderProgram /// Gets the semantic diagnostics from the program for the next affected file and caches it /// Returns undefined if the iteration is complete - abstract getSemanticDiagnosticsOfNextAffectedFile: ?cancellationToken: CancellationToken * ?ignoreSourceFile: (SourceFile -> bool) -> AffectedFileResult> + abstract getSemanticDiagnosticsOfNextAffectedFile: ?cancellationToken: CancellationToken * ?ignoreSourceFile: (SourceFile -> bool) -> AffectedFileResult /// The builder that can handle the changes in program and iterate through changed file to emit the files /// The semantic diagnostics are cached per file and managed by clearing for the changed/affected files @@ -5935,34 +7373,36 @@ module Ts = abstract getCurrentDirectory: unit -> string abstract readFile: fileName: string -> string option - type [] IncrementalProgramOptions<'T> = - abstract rootNames: ResizeArray with get, set + type [] IncrementalProgramOptions<'T > = + abstract rootNames: string[] with get, set abstract options: CompilerOptions with get, set - abstract configFileParsingDiagnostics: ResizeArray option with get, set - abstract projectReferences: ResizeArray option with get, set + abstract configFileParsingDiagnostics: Diagnostic[] option with get, set + abstract projectReferences: ProjectReference[] option with get, set abstract host: CompilerHost option with get, set abstract createProgram: CreateProgram<'T> option with get, set type [] WatchStatusReporter = - [] abstract Invoke: diagnostic: Diagnostic * newLine: string * options: CompilerOptions * ?errorCount: float -> unit + [] abstract Invoke: diagnostic: Diagnostic * newLine: string * options: CompilerOptions * ?errorCount: float -> unit - type [] CreateProgram<'T> = - [] abstract Invoke: rootNames: ResizeArray option * options: CompilerOptions option * ?host: CompilerHost * ?oldProgram: 'T * ?configFileParsingDiagnostics: ResizeArray * ?projectReferences: ResizeArray -> 'T + /// Create the program with rootNames and options, if they are undefined, oldProgram and new configFile diagnostics create new program + type [] CreateProgram<'T > = + /// Create the program with rootNames and options, if they are undefined, oldProgram and new configFile diagnostics create new program + [] abstract Invoke: rootNames: string[] option * options: CompilerOptions option * ?host: CompilerHost * ?oldProgram: 'T * ?configFileParsingDiagnostics: Diagnostic[] * ?projectReferences: ProjectReference[] -> 'T /// Host that has watch functionality used in --watch mode type [] WatchHost = /// If provided, called with Diagnostic message that informs about change in watch status abstract onWatchStatusChange: diagnostic: Diagnostic * newLine: string * options: CompilerOptions * ?errorCount: float -> unit /// Used to watch changes in source files, missing files needed to update the program or config file - abstract watchFile: path: string * callback: FileWatcherCallback * ?pollingInterval: float * ?options: CompilerOptions -> FileWatcher + abstract watchFile: path: string * callback: FileWatcherCallback * ?pollingInterval: float * ?options: WatchOptions -> FileWatcher /// Used to watch resolved module's failed lookup locations, config file specs, type roots where auto type reference directives are added - abstract watchDirectory: path: string * callback: DirectoryWatcherCallback * ?recursive: bool * ?options: CompilerOptions -> FileWatcher + abstract watchDirectory: path: string * callback: DirectoryWatcherCallback * ?recursive: bool * ?options: WatchOptions -> FileWatcher /// If provided, will be used to set delayed compilation, so that multiple changes in short span are compiled together - abstract setTimeout: callback: (ResizeArray -> unit) * ms: float * [] args: ResizeArray -> obj option + abstract setTimeout: callback: (obj option[] -> unit) * ms: float * [] args: obj option[] -> obj option /// If provided, will be used to reset existing delayed compilation abstract clearTimeout: timeoutId: obj option -> unit - type [] ProgramHost<'T> = + type [] ProgramHost<'T > = /// Used to create the program when need for program creation or recreation detected abstract createProgram: CreateProgram<'T> with get, set abstract useCaseSensitiveFileNames: unit -> bool @@ -5980,21 +7420,23 @@ module Ts = /// If provided, used for module resolution as well as to handle directory structure abstract directoryExists: path: string -> bool /// If provided, used in resolutions as well as handling directory structure - abstract getDirectories: path: string -> ResizeArray + abstract getDirectories: path: string -> string[] /// If provided, used to cache and handle directory structure modifications - abstract readDirectory: path: string * ?extensions: ResizeArray * ?exclude: ResizeArray * ?``include``: ResizeArray * ?depth: float -> ResizeArray + abstract readDirectory: path: string * ?extensions: string[] * ?exclude: string[] * ?``include``: string[] * ?depth: float -> string[] /// Symbol links resolution abstract realpath: path: string -> string /// If provided would be used to write log about compilation abstract trace: s: string -> unit /// If provided is used to get the environment variable abstract getEnvironmentVariable: name: string -> string option - /// If provided, used to resolve the module names, otherwise typescript's default module resolution - abstract resolveModuleNames: moduleNames: ResizeArray * containingFile: string * reusedNames: ResizeArray option * redirectedReference: ResolvedProjectReference option * options: CompilerOptions * ?containingSourceFile: SourceFile -> ResizeArray - /// If provided, used to resolve type reference directives, otherwise typescript's default resolution - abstract resolveTypeReferenceDirectives: typeReferenceDirectiveNames: ResizeArray * containingFile: string * redirectedReference: ResolvedProjectReference option * options: CompilerOptions -> ResizeArray + abstract resolveModuleNameLiterals: moduleLiterals: StringLiteralLike[] * containingFile: string * redirectedReference: ResolvedProjectReference option * options: CompilerOptions * containingSourceFile: SourceFile * reusedNames: StringLiteralLike[] option -> ResolvedModuleWithFailedLookupLocations[] + abstract resolveTypeReferenceDirectiveReferences: typeDirectiveReferences: 'T[] * containingFile: string * redirectedReference: ResolvedProjectReference option * options: CompilerOptions * containingSourceFile: SourceFile option * reusedNames: 'T[] option -> ResolvedTypeReferenceDirectiveWithFailedLookupLocations[] + /// If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives + abstract hasInvalidatedResolutions: filePath: Path -> bool + /// Returns the module resolution cache used by a provided resolveModuleNames implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it + abstract getModuleResolutionCache: unit -> ModuleResolutionCache option - type [] WatchCompilerHost<'T> = + type [] WatchCompilerHost<'T > = inherit ProgramHost<'T> inherit WatchHost /// Instead of using output d.ts file from project reference, use its source file @@ -6005,18 +7447,18 @@ module Ts = abstract afterProgramCreate: program: 'T -> unit /// Host to create watch with root files and options - type [] WatchCompilerHostOfFilesAndCompilerOptions<'T> = + type [] WatchCompilerHostOfFilesAndCompilerOptions<'T > = inherit WatchCompilerHost<'T> /// root files to use to generate program - abstract rootFiles: ResizeArray with get, set + abstract rootFiles: string[] with get, set /// Compiler options abstract options: CompilerOptions with get, set abstract watchOptions: WatchOptions option with get, set /// Project References - abstract projectReferences: ResizeArray option with get, set + abstract projectReferences: ProjectReference[] option with get, set /// Host to create watch with config file - type [] WatchCompilerHostOfConfigFile<'T> = + type [] WatchCompilerHostOfConfigFile<'T > = inherit WatchCompilerHost<'T> inherit ConfigFileDiagnosticsReporter /// Name of the config file to compile @@ -6024,10 +7466,10 @@ module Ts = /// Options to extend abstract optionsToExtend: CompilerOptions option with get, set abstract watchOptionsToExtend: WatchOptions option with get, set - abstract extraFileExtensions: ResizeArray option with get, set + abstract extraFileExtensions: FileExtensionInfo[] option with get, set /// Used to generate source file names from the config file and its include, exclude, files rules /// and also to cache the directory stucture - abstract readDirectory: path: string * ?extensions: ResizeArray * ?exclude: ResizeArray * ?``include``: ResizeArray * ?depth: float -> ResizeArray + abstract readDirectory: path: string * ?extensions: string[] * ?exclude: string[] * ?``include``: string[] * ?depth: float -> string[] type [] Watch<'T> = /// Synchronize with host and get updated program @@ -6043,7 +7485,7 @@ module Ts = type [] WatchOfFilesAndCompilerOptions<'T> = inherit Watch<'T> /// Updates the root files in the program, only if this is not config file compilation - abstract updateRootFileNames: fileNames: ResizeArray -> unit + abstract updateRootFileNames: fileNames: string[] -> unit type [] BuildOptions = abstract dry: bool option with get, set @@ -6051,19 +7493,28 @@ module Ts = abstract verbose: bool option with get, set abstract incremental: bool option with get, set abstract assumeChangesOnlyAffectDirectDependencies: bool option with get, set + abstract declaration: bool option with get, set + abstract declarationMap: bool option with get, set + abstract emitDeclarationOnly: bool option with get, set + abstract sourceMap: bool option with get, set + abstract inlineSourceMap: bool option with get, set abstract traceResolution: bool option with get, set - [] abstract Item: option: string -> CompilerOptionsValue option with get, set + [] abstract Item: option: string -> CompilerOptionsValue option with get, set type [] ReportEmitErrorSummary = - [] abstract Invoke: errorCount: float -> unit + [] abstract Invoke: errorCount: float * filesInError: ReportFileInError option[] -> unit + + type [] ReportFileInError = + abstract fileName: string with get, set + abstract line: float with get, set - type [] SolutionBuilderHostBase<'T> = + type [] SolutionBuilderHostBase<'T > = inherit ProgramHost<'T> abstract createDirectory: path: string -> unit /// Should provide create directory and writeFile if done of invalidatedProjects is not invoked with /// writeFileCallback abstract writeFile: path: string * data: string * ?writeByteOrderMark: bool -> unit - abstract getCustomTransformers: (string -> CustomTransformers option) option with get, set + abstract getCustomTransformers: project: string -> CustomTransformers option abstract getModifiedTime: fileName: string -> DateTime option abstract setModifiedTime: fileName: string * date: DateTime -> unit abstract deleteFile: fileName: string -> unit @@ -6072,15 +7523,15 @@ module Ts = abstract reportSolutionBuilderStatus: DiagnosticReporter with get, set abstract afterProgramEmitAndDiagnostics: program: 'T -> unit - type [] SolutionBuilderHost<'T> = + type [] SolutionBuilderHost<'T > = inherit SolutionBuilderHostBase<'T> abstract reportErrorSummary: ReportEmitErrorSummary option with get, set - type [] SolutionBuilderWithWatchHost<'T> = + type [] SolutionBuilderWithWatchHost<'T > = inherit SolutionBuilderHostBase<'T> inherit WatchHost - type [] SolutionBuilder<'T> = + type [] SolutionBuilder<'T > = abstract build: ?project: string * ?cancellationToken: CancellationToken * ?writeFile: WriteFileCallback * ?getCustomTransformers: (string -> CustomTransformers) -> ExitStatus abstract clean: ?project: string -> ExitStatus abstract buildReferences: project: string * ?cancellationToken: CancellationToken * ?writeFile: WriteFileCallback * ?getCustomTransformers: (string -> CustomTransformers) -> ExitStatus @@ -6089,6 +7540,7 @@ module Ts = type [] InvalidatedProjectKind = | Build = 0 + /// | UpdateBundle = 1 | UpdateOutputFileStamps = 2 @@ -6105,29 +7557,43 @@ module Ts = abstract kind: InvalidatedProjectKind abstract updateOutputFileStatmps: unit -> unit - type [] BuildInvalidedProject<'T> = + type [] BuildInvalidedProject<'T > = inherit InvalidatedProjectBase abstract kind: InvalidatedProjectKind abstract getBuilderProgram: unit -> 'T option abstract getProgram: unit -> Program option abstract getSourceFile: fileName: string -> SourceFile option - abstract getSourceFiles: unit -> ResizeArray - abstract getOptionsDiagnostics: ?cancellationToken: CancellationToken -> ResizeArray - abstract getGlobalDiagnostics: ?cancellationToken: CancellationToken -> ResizeArray - abstract getConfigFileParsingDiagnostics: unit -> ResizeArray - abstract getSyntacticDiagnostics: ?sourceFile: SourceFile * ?cancellationToken: CancellationToken -> ResizeArray - abstract getAllDependencies: sourceFile: SourceFile -> ResizeArray - abstract getSemanticDiagnostics: ?sourceFile: SourceFile * ?cancellationToken: CancellationToken -> ResizeArray - abstract getSemanticDiagnosticsOfNextAffectedFile: ?cancellationToken: CancellationToken * ?ignoreSourceFile: (SourceFile -> bool) -> AffectedFileResult> + abstract getSourceFiles: unit -> SourceFile[] + abstract getOptionsDiagnostics: ?cancellationToken: CancellationToken -> Diagnostic[] + abstract getGlobalDiagnostics: ?cancellationToken: CancellationToken -> Diagnostic[] + abstract getConfigFileParsingDiagnostics: unit -> Diagnostic[] + abstract getSyntacticDiagnostics: ?sourceFile: SourceFile * ?cancellationToken: CancellationToken -> Diagnostic[] + abstract getAllDependencies: sourceFile: SourceFile -> string[] + abstract getSemanticDiagnostics: ?sourceFile: SourceFile * ?cancellationToken: CancellationToken -> Diagnostic[] + abstract getSemanticDiagnosticsOfNextAffectedFile: ?cancellationToken: CancellationToken * ?ignoreSourceFile: (SourceFile -> bool) -> AffectedFileResult abstract emit: ?targetSourceFile: SourceFile * ?writeFile: WriteFileCallback * ?cancellationToken: CancellationToken * ?emitOnlyDtsFiles: bool * ?customTransformers: CustomTransformers -> EmitResult option - type [] UpdateBundleProject<'T> = + [] + type [] UpdateBundleProject<'T > = inherit InvalidatedProjectBase abstract kind: InvalidatedProjectKind abstract emit: ?writeFile: WriteFileCallback * ?customTransformers: CustomTransformers -> U2> option - type InvalidatedProject<'T> = - U3, UpdateBundleProject<'T>> + type [] [] InvalidatedProject<'T > = + | [] BuildInvalidedProject of BuildInvalidedProject<'T> + | [] UpdateBundleProject of UpdateBundleProject<'T> + | [] UpdateOutputFileStampsProject of UpdateOutputFileStampsProject + // static member inline op_ErasedCast(x: BuildInvalidedProject<'T>) = BuildInvalidedProject x + // static member inline op_ErasedCast(x: UpdateBundleProject<'T>) = UpdateBundleProject x + // static member inline op_ErasedCast(x: UpdateOutputFileStampsProject) = UpdateOutputFileStampsProject x + + module JsTyping = + + type [] TypingResolutionHost = + abstract directoryExists: path: string -> bool + abstract fileExists: fileName: string -> bool + abstract readFile: path: string * ?encoding: string -> string option + abstract readDirectory: rootDir: string * extensions: string[] * excludes: string[] option * includes: string[] option * ?depth: float -> string[] module Server = @@ -6152,18 +7618,20 @@ module Ts = type EventInitializationFailed = string + type ActionWatchTypingLocations = + string + type [] TypingInstallerResponse = - abstract kind: U7 + abstract kind: U8 type [] TypingInstallerRequestWithProjectName = abstract projectName: string type [] DiscoverTypings = inherit TypingInstallerRequestWithProjectName - abstract fileNames: ResizeArray + abstract fileNames: string[] abstract projectRootPath: Path abstract compilerOptions: CompilerOptions - abstract watchOptions: WatchOptions option abstract typeAcquisition: TypeAcquisition abstract unresolvedImports: SortedReadonlyArray abstract cachePath: string option @@ -6208,7 +7676,7 @@ module Ts = abstract kind: U2 abstract eventId: float abstract typingsInstallerVersion: string - abstract packagesToInstall: ResizeArray + abstract packagesToInstall: string[] type [] BeginInstallTypes = inherit InstallTypes @@ -6219,16 +7687,26 @@ module Ts = abstract kind: EventEndInstallTypes abstract installSuccess: bool + type [] InstallTypingHost = + inherit JsTyping.TypingResolutionHost + abstract useCaseSensitiveFileNames: bool with get, set + abstract writeFile: path: string * content: string -> unit + abstract createDirectory: path: string -> unit + abstract getCurrentDirectory: unit -> string + type [] SetTypings = inherit ProjectResponse abstract typeAcquisition: TypeAcquisition abstract compilerOptions: CompilerOptions - abstract typings: ResizeArray + abstract typings: string[] abstract unresolvedImports: SortedReadonlyArray abstract kind: ActionSet - type [] SourceFileLike = - abstract getLineAndCharacterOfPosition: pos: float -> LineAndCharacter + type [] WatchTypingLocations = + inherit ProjectResponse + /// if files is undefined, retain same set of watchers + abstract files: string[] option + abstract kind: ActionWatchTypingLocations /// Represents an immutable snapshot of a script at a specified time.Once acquired, the /// snapshot is observably immutable. i.e. the same calls with the same parameters will return @@ -6253,11 +7731,11 @@ module Ts = abstract fromString: text: string -> IScriptSnapshot type [] PreProcessedFileInfo = - abstract referencedFiles: ResizeArray with get, set - abstract typeReferenceDirectives: ResizeArray with get, set - abstract libReferenceDirectives: ResizeArray with get, set - abstract importedFiles: ResizeArray with get, set - abstract ambientExternalModules: ResizeArray option with get, set + abstract referencedFiles: FileReference[] with get, set + abstract typeReferenceDirectives: FileReference[] with get, set + abstract libReferenceDirectives: FileReference[] with get, set + abstract importedFiles: FileReference[] with get, set + abstract ambientExternalModules: string[] option with get, set abstract isLibFile: bool with get, set type [] HostCancellationToken = @@ -6283,14 +7761,15 @@ module Ts = type [] LanguageServiceHost = inherit GetEffectiveTypeRootsHost + inherit MinimalResolutionCacheHost abstract getCompilationSettings: unit -> CompilerOptions abstract getNewLine: unit -> string abstract getProjectVersion: unit -> string - abstract getScriptFileNames: unit -> ResizeArray + abstract getScriptFileNames: unit -> string[] abstract getScriptKind: fileName: string -> ScriptKind abstract getScriptVersion: fileName: string -> string abstract getScriptSnapshot: fileName: string -> IScriptSnapshot option - abstract getProjectReferences: unit -> ResizeArray option + abstract getProjectReferences: unit -> ProjectReference[] option abstract getLocalizedDiagnosticMessages: unit -> obj option abstract getCancellationToken: unit -> HostCancellationToken abstract getCurrentDirectory: unit -> string @@ -6299,15 +7778,16 @@ module Ts = abstract trace: s: string -> unit abstract error: s: string -> unit abstract useCaseSensitiveFileNames: unit -> bool - abstract readDirectory: path: string * ?extensions: ResizeArray * ?exclude: ResizeArray * ?``include``: ResizeArray * ?depth: float -> ResizeArray - abstract readFile: path: string * ?encoding: string -> string option + abstract readDirectory: path: string * ?extensions: string[] * ?exclude: string[] * ?``include``: string[] * ?depth: float -> string[] + /// Resolve a symbolic link. abstract realpath: path: string -> string + abstract readFile: path: string * ?encoding: string -> string option abstract fileExists: path: string -> bool abstract getTypeRootsVersion: unit -> float - abstract resolveModuleNames: moduleNames: ResizeArray * containingFile: string * reusedNames: ResizeArray option * redirectedReference: ResolvedProjectReference option * options: CompilerOptions * ?containingSourceFile: SourceFile -> ResizeArray - abstract getResolvedModuleWithFailedLookupLocationsFromCache: modulename: string * containingFile: string * ?resolutionMode: ModuleKind -> ResolvedModuleWithFailedLookupLocations option - abstract resolveTypeReferenceDirectives: typeDirectiveNames: ResizeArray * containingFile: string * redirectedReference: ResolvedProjectReference option * options: CompilerOptions -> ResizeArray - abstract getDirectories: directoryName: string -> ResizeArray + abstract getResolvedModuleWithFailedLookupLocationsFromCache: modulename: string * containingFile: string * ?resolutionMode: ResolutionMode -> ResolvedModuleWithFailedLookupLocations option + abstract resolveModuleNameLiterals: moduleLiterals: StringLiteralLike[] * containingFile: string * redirectedReference: ResolvedProjectReference option * options: CompilerOptions * containingSourceFile: SourceFile * reusedNames: StringLiteralLike[] option -> ResolvedModuleWithFailedLookupLocations[] + abstract resolveTypeReferenceDirectiveReferences: typeDirectiveReferences: 'T[] * containingFile: string * redirectedReference: ResolvedProjectReference option * options: CompilerOptions * containingSourceFile: SourceFile option * reusedNames: 'T[] option -> ResolvedTypeReferenceDirectiveWithFailedLookupLocations[] + abstract getDirectories: directoryName: string -> string[] /// Gets a set of custom transformers to use during emit. abstract getCustomTransformers: unit -> CustomTransformers option abstract isKnownTypesPackageName: name: string -> bool @@ -6320,132 +7800,152 @@ module Ts = type [] [] SemanticClassificationFormat = | Original - | [] TwentyTwenty + | [] TwentyTwenty type [] LanguageService = /// This is used as a part of restarting the language service. abstract cleanupSemanticCache: unit -> unit - /// Gets errors indicating invalid syntax in a file. - /// + /// + /// Gets errors indicating invalid syntax in a file. + /// /// In English, "this cdeo have, erorrs" is syntactically invalid because it has typos, /// grammatical errors, and misplaced punctuation. Likewise, examples of syntax - /// errors in TypeScript are missing parentheses in an `if` statement, mismatched + /// errors in TypeScript are missing parentheses in an if statement, mismatched /// curly braces, and using a reserved keyword as a variable name. - /// + /// /// These diagnostics are inexpensive to compute and don't require knowledge of /// other files. Note that a non-empty result increases the likelihood of false positives - /// from `getSemanticDiagnostics`. - /// + /// from getSemanticDiagnostics. + /// /// While these represent the majority of syntax-related diagnostics, there are some - /// that require the type system, which will be present in `getSemanticDiagnostics`. + /// that require the type system, which will be present in getSemanticDiagnostics. + /// /// A path to the file you want syntactic diagnostics for - abstract getSyntacticDiagnostics: fileName: string -> ResizeArray - /// Gets warnings or errors indicating type system issues in a given file. + abstract getSyntacticDiagnostics: fileName: string -> DiagnosticWithLocation[] + /// + /// Gets warnings or errors indicating type system issues in a given file. /// Requesting semantic diagnostics may start up the type system and /// run deferred work, so the first call may take longer than subsequent calls. - /// + /// /// Unlike the other get*Diagnostics functions, these diagnostics can potentially not /// include a reference to a source file. Specifically, the first time this is called, /// it will return global diagnostics with no associated location. - /// + /// /// To contrast the differences between semantic and syntactic diagnostics, consider the /// sentence: "The sun is green." is syntactically correct; those are real English words with - /// correct sentence structure. However, it is semantically invalid, because it is not true. + /// correct sentence structure. However, it is semantically invalid, because it is not true. + /// /// A path to the file you want semantic diagnostics for - abstract getSemanticDiagnostics: fileName: string -> ResizeArray - /// Gets suggestion diagnostics for a specific file. These diagnostics tend to + abstract getSemanticDiagnostics: fileName: string -> Diagnostic[] + /// + /// Gets suggestion diagnostics for a specific file. These diagnostics tend to /// proactively suggest refactors, as opposed to diagnostics that indicate - /// potentially incorrect runtime behavior. + /// potentially incorrect runtime behavior. + /// /// A path to the file you want semantic diagnostics for - abstract getSuggestionDiagnostics: fileName: string -> ResizeArray + abstract getSuggestionDiagnostics: fileName: string -> DiagnosticWithLocation[] /// Gets global diagnostics related to the program configuration and compiler options. - abstract getCompilerOptionsDiagnostics: unit -> ResizeArray - abstract getSyntacticClassifications: fileName: string * span: TextSpan -> ResizeArray - abstract getSyntacticClassifications: fileName: string * span: TextSpan * format: SemanticClassificationFormat -> U2, ResizeArray> - abstract getSemanticClassifications: fileName: string * span: TextSpan -> ResizeArray - abstract getSemanticClassifications: fileName: string * span: TextSpan * format: SemanticClassificationFormat -> U2, ResizeArray> + abstract getCompilerOptionsDiagnostics: unit -> Diagnostic[] + abstract getSyntacticClassifications: fileName: string * span: TextSpan * format: SemanticClassificationFormat -> U2 + abstract getSemanticClassifications: fileName: string * span: TextSpan * format: SemanticClassificationFormat -> U2 /// Encoded as triples of [start, length, ClassificationType]. abstract getEncodedSyntacticClassifications: fileName: string * span: TextSpan -> Classifications - /// Gets semantic highlights information for a particular file. Has two formats, an older - /// version used by VS and a format used by VS Code. + /// + /// Gets semantic highlights information for a particular file. Has two formats, an older + /// version used by VS and a format used by VS Code. + /// /// The path to the file + /// A text span to return results within /// Which format to use, defaults to "original" + /// a number array encoded as triples of [start, length, ClassificationType, ...]. abstract getEncodedSemanticClassifications: fileName: string * span: TextSpan * ?format: SemanticClassificationFormat -> Classifications /// Gets completion entries at a particular position in a file. /// The path to the file /// A zero-based index of the character where you want the entries - /// An object describing how the request was triggered and what kinds - /// of code actions can be returned with the completions. - abstract getCompletionsAtPosition: fileName: string * position: float * options: GetCompletionsAtPositionOptions option -> WithMetadata option - /// Gets the extended details for a completion entry retrieved from `getCompletionsAtPosition`. + /// + /// An object describing how the request was triggered and what kinds + /// of code actions can be returned with the completions. + /// + /// settings needed for calling formatting functions. + abstract getCompletionsAtPosition: fileName: string * position: float * options: GetCompletionsAtPositionOptions option * ?formattingSettings: FormatCodeSettings -> WithMetadata option + /// Gets the extended details for a completion entry retrieved from getCompletionsAtPosition. /// The path to the file /// A zero based index of the character where you want the entries - /// The `name` from an existing completion which came from `getCompletionsAtPosition` + /// The name from an existing completion which came from getCompletionsAtPosition /// How should code samples in the completions be formatted, can be undefined for backwards compatibility - /// `source` property from the completion entry + /// source property from the completion entry /// User settings, can be undefined for backwards compatibility - /// `data` property from the completion entry + /// data property from the completion entry abstract getCompletionEntryDetails: fileName: string * position: float * entryName: string * formatOptions: U2 option * source: string option * preferences: UserPreferences option * data: CompletionEntryData option -> CompletionEntryDetails option abstract getCompletionEntrySymbol: fileName: string * position: float * name: string * source: string option -> Symbol option - /// Gets semantic information about the identifier at a particular position in a - /// file. Quick info is what you typically see when you hover in an editor. + /// + /// Gets semantic information about the identifier at a particular position in a + /// file. Quick info is what you typically see when you hover in an editor. + /// /// The path to the file /// A zero-based index of the character where you want the quick info abstract getQuickInfoAtPosition: fileName: string * position: float -> QuickInfo option abstract getNameOrDottedNameSpan: fileName: string * startPos: float * endPos: float -> TextSpan option abstract getBreakpointStatementAtPosition: fileName: string * position: float -> TextSpan option abstract getSignatureHelpItems: fileName: string * position: float * options: SignatureHelpItemsOptions option -> SignatureHelpItems option - abstract getRenameInfo: fileName: string * position: float * ?options: RenameInfoOptions -> RenameInfo - abstract findRenameLocations: fileName: string * position: float * findInStrings: bool * findInComments: bool * ?providePrefixAndSuffixTextForRename: bool -> ResizeArray option + abstract getRenameInfo: fileName: string * position: float * preferences: UserPreferences -> RenameInfo + abstract findRenameLocations: fileName: string * position: float * findInStrings: bool * findInComments: bool * preferences: UserPreferences -> RenameLocation[] option abstract getSmartSelectionRange: fileName: string * position: float -> SelectionRange - abstract getDefinitionAtPosition: fileName: string * position: float -> ResizeArray option + abstract getDefinitionAtPosition: fileName: string * position: float -> DefinitionInfo[] option abstract getDefinitionAndBoundSpan: fileName: string * position: float -> DefinitionInfoAndBoundSpan option - abstract getTypeDefinitionAtPosition: fileName: string * position: float -> ResizeArray option - abstract getImplementationAtPosition: fileName: string * position: float -> ResizeArray option - abstract getReferencesAtPosition: fileName: string * position: float -> ResizeArray option - abstract findReferences: fileName: string * position: float -> ResizeArray option - abstract getDocumentHighlights: fileName: string * position: float * filesToSearch: ResizeArray -> ResizeArray option - abstract getFileReferences: fileName: string -> ResizeArray - abstract getOccurrencesAtPosition: fileName: string * position: float -> ResizeArray option - abstract getNavigateToItems: searchValue: string * ?maxResultCount: float * ?fileName: string * ?excludeDtsFiles: bool -> ResizeArray - abstract getNavigationBarItems: fileName: string -> ResizeArray + abstract getTypeDefinitionAtPosition: fileName: string * position: float -> DefinitionInfo[] option + abstract getImplementationAtPosition: fileName: string * position: float -> ImplementationLocation[] option + abstract getReferencesAtPosition: fileName: string * position: float -> ReferenceEntry[] option + abstract findReferences: fileName: string * position: float -> ReferencedSymbol[] option + abstract getDocumentHighlights: fileName: string * position: float * filesToSearch: string[] -> DocumentHighlights[] option + abstract getFileReferences: fileName: string -> ReferenceEntry[] + abstract getNavigateToItems: searchValue: string * ?maxResultCount: float * ?fileName: string * ?excludeDtsFiles: bool -> NavigateToItem[] + abstract getNavigationBarItems: fileName: string -> NavigationBarItem[] abstract getNavigationTree: fileName: string -> NavigationTree - abstract prepareCallHierarchy: fileName: string * position: float -> U2> option - abstract provideCallHierarchyIncomingCalls: fileName: string * position: float -> ResizeArray - abstract provideCallHierarchyOutgoingCalls: fileName: string * position: float -> ResizeArray - abstract provideInlayHints: fileName: string * span: TextSpan * preferences: UserPreferences option -> ResizeArray - abstract getOutliningSpans: fileName: string -> ResizeArray - abstract getTodoComments: fileName: string * descriptors: ResizeArray -> ResizeArray - abstract getBraceMatchingAtPosition: fileName: string * position: float -> ResizeArray + abstract prepareCallHierarchy: fileName: string * position: float -> U2 option + abstract provideCallHierarchyIncomingCalls: fileName: string * position: float -> CallHierarchyIncomingCall[] + abstract provideCallHierarchyOutgoingCalls: fileName: string * position: float -> CallHierarchyOutgoingCall[] + abstract provideInlayHints: fileName: string * span: TextSpan * preferences: UserPreferences option -> InlayHint[] + abstract getOutliningSpans: fileName: string -> OutliningSpan[] + abstract getTodoComments: fileName: string * descriptors: TodoCommentDescriptor[] -> TodoComment[] + abstract getBraceMatchingAtPosition: fileName: string * position: float -> TextSpan[] abstract getIndentationAtPosition: fileName: string * position: float * options: U2 -> float - abstract getFormattingEditsForRange: fileName: string * start: float * ``end``: float * options: U2 -> ResizeArray - abstract getFormattingEditsForDocument: fileName: string * options: U2 -> ResizeArray - abstract getFormattingEditsAfterKeystroke: fileName: string * position: float * key: string * options: U2 -> ResizeArray - abstract getDocCommentTemplateAtPosition: fileName: string * position: float * ?options: DocCommentTemplateOptions -> TextInsertion option + abstract getFormattingEditsForRange: fileName: string * start: float * ``end``: float * options: U2 -> TextChange[] + abstract getFormattingEditsForDocument: fileName: string * options: U2 -> TextChange[] + abstract getFormattingEditsAfterKeystroke: fileName: string * position: float * key: string * options: U2 -> TextChange[] + abstract getDocCommentTemplateAtPosition: fileName: string * position: float * ?options: DocCommentTemplateOptions * ?formatOptions: FormatCodeSettings -> TextInsertion option abstract isValidBraceCompletionAtPosition: fileName: string * position: float * openingBrace: float -> bool - /// This will return a defined result if the position is after the `>` of the opening tag, or somewhere in the text, of a JSXElement with no closing tag. - /// Editors should call this after `>` is typed. + /// + /// This will return a defined result if the position is after the > of the opening tag, or somewhere in the text, of a JSXElement with no closing tag. + /// Editors should call this after > is typed. + /// abstract getJsxClosingTagAtPosition: fileName: string * position: float -> JsxClosingTagInfo option + abstract getLinkedEditingRangeAtPosition: fileName: string * position: float -> LinkedEditingInfo option abstract getSpanOfEnclosingComment: fileName: string * position: float * onlyMultiLine: bool -> TextSpan option abstract toLineColumnOffset: fileName: string * position: float -> LineAndCharacter - abstract getCodeFixesAtPosition: fileName: string * start: float * ``end``: float * errorCodes: ResizeArray * formatOptions: FormatCodeSettings * preferences: UserPreferences -> ResizeArray + abstract getCodeFixesAtPosition: fileName: string * start: float * ``end``: float * errorCodes: float[] * formatOptions: FormatCodeSettings * preferences: UserPreferences -> CodeFixAction[] abstract getCombinedCodeFix: scope: CombinedCodeFixScope * fixId: LanguageServiceGetCombinedCodeFixFixId * formatOptions: FormatCodeSettings * preferences: UserPreferences -> CombinedCodeActions abstract applyCodeActionCommand: action: CodeActionCommand * ?formatSettings: FormatCodeSettings -> Promise - abstract applyCodeActionCommand: action: ResizeArray * ?formatSettings: FormatCodeSettings -> Promise> - abstract applyCodeActionCommand: action: U2> * ?formatSettings: FormatCodeSettings -> Promise>> - abstract applyCodeActionCommand: fileName: string * action: CodeActionCommand -> Promise - abstract applyCodeActionCommand: fileName: string * action: ResizeArray -> Promise> - abstract applyCodeActionCommand: fileName: string * action: U2> -> Promise>> - abstract getApplicableRefactors: fileName: string * positionOrRange: U2 * preferences: UserPreferences option * ?triggerReason: RefactorTriggerReason * ?kind: string -> ResizeArray - abstract getEditsForRefactor: fileName: string * formatOptions: FormatCodeSettings * positionOrRange: U2 * refactorName: string * actionName: string * preferences: UserPreferences option -> RefactorEditInfo option - abstract organizeImports: args: OrganizeImportsArgs * formatOptions: FormatCodeSettings * preferences: UserPreferences option -> ResizeArray - abstract getEditsForFileRename: oldFilePath: string * newFilePath: string * formatOptions: FormatCodeSettings * preferences: UserPreferences option -> ResizeArray + abstract applyCodeActionCommand: action: CodeActionCommand[] * ?formatSettings: FormatCodeSettings -> Promise + abstract applyCodeActionCommand: action: U2 * ?formatSettings: FormatCodeSettings -> Promise> + /// + /// Include refactor actions that require additional arguments to be + /// passed when calling getEditsForRefactor. When true, clients should inspect the isInteractive + /// property of each returned RefactorActionInfo and ensure they are able to collect the appropriate + /// arguments for any interactive action before offering it. + /// + abstract getApplicableRefactors: fileName: string * positionOrRange: U2 * preferences: UserPreferences option * ?triggerReason: RefactorTriggerReason * ?kind: string * ?includeInteractiveActions: bool -> ApplicableRefactorInfo[] + abstract getEditsForRefactor: fileName: string * formatOptions: FormatCodeSettings * positionOrRange: U2 * refactorName: string * actionName: string * preferences: UserPreferences option * ?interactiveRefactorArguments: InteractiveRefactorArguments -> RefactorEditInfo option + abstract getMoveToRefactoringFileSuggestions: fileName: string * positionOrRange: U2 * preferences: UserPreferences option * ?triggerReason: RefactorTriggerReason * ?kind: string -> {| newFileName: string; files: string[] |} + abstract organizeImports: args: OrganizeImportsArgs * formatOptions: FormatCodeSettings * preferences: UserPreferences option -> FileTextChanges[] + abstract getEditsForFileRename: oldFilePath: string * newFilePath: string * formatOptions: FormatCodeSettings * preferences: UserPreferences option -> FileTextChanges[] abstract getEmitOutput: fileName: string * ?emitOnlyDtsFiles: bool * ?forceDtsEmit: bool -> EmitOutput abstract getProgram: unit -> Program option - abstract toggleLineComment: fileName: string * textRange: TextRange -> ResizeArray - abstract toggleMultilineComment: fileName: string * textRange: TextRange -> ResizeArray - abstract commentSelection: fileName: string * textRange: TextRange -> ResizeArray - abstract uncommentSelection: fileName: string * textRange: TextRange -> ResizeArray + abstract toggleLineComment: fileName: string * textRange: TextRange -> TextChange[] + abstract toggleMultilineComment: fileName: string * textRange: TextRange -> TextChange[] + abstract commentSelection: fileName: string * textRange: TextRange -> TextChange[] + abstract uncommentSelection: fileName: string * textRange: TextRange -> TextChange[] + abstract getSupportedCodeFixes: ?fileName: string -> string[] abstract dispose: unit -> unit type [] LanguageServiceGetCombinedCodeFixFixId = @@ -6454,28 +7954,40 @@ module Ts = type [] JsxClosingTagInfo = abstract newText: string + type [] LinkedEditingInfo = + abstract ranges: TextSpan[] + abstract wordPattern: string option with get, set + type [] CombinedCodeFixScope = abstract ``type``: string with get, set abstract fileName: string with get, set + type [] [] OrganizeImportsMode = + | [] All + | [] SortAndCombine + | [] RemoveUnused + type [] OrganizeImportsArgs = inherit CombinedCodeFixScope - abstract skipDestructiveCodeActions: bool option with get, set + abstract mode: OrganizeImportsMode option with get, set type [] [] CompletionsTriggerCharacter = - | [] Dot - | [] DoubleQuote - | [] SingleQuote - | [] BackQuote - | [] Slash - | [] At - | [] LessThan - | [] Sharp - | [] Empty + | [] DOT + | [] QUOTATION + | [] ``'`` + | [] BACKTICK + | [] SLASH + | [] AT + | [] ``<`` + | [] ``#`` + | [] Empty type [] CompletionTriggerKind = + /// Completion was triggered by typing an identifier, manual invocation (e.g Ctrl+Space) or via API. | Invoked = 1 + /// Completion was triggered by a trigger character. | TriggerCharacter = 2 + /// Completion was re-triggered as the current completion list is incomplete. | TriggerForIncompleteCompletions = 3 type [] GetCompletionsAtPositionOptions = @@ -6484,23 +7996,18 @@ module Ts = /// (as opposed to when the user explicitly requested them) this should be set. abstract triggerCharacter: CompletionsTriggerCharacter option with get, set abstract triggerKind: CompletionTriggerKind option with get, set - abstract includeExternalModuleExports: bool option with get, set - abstract includeInsertTextCompletions: bool option with get, set - - type [] InlayHintsOptions = - inherit UserPreferences - abstract includeInlayParameterNameHints: InlayHintsOptionsIncludeInlayParameterNameHints option - abstract includeInlayParameterNameHintsWhenArgumentMatchesName: bool option - abstract includeInlayFunctionParameterTypeHints: bool option - abstract includeInlayVariableTypeHints: bool option - abstract includeInlayPropertyDeclarationTypeHints: bool option - abstract includeInlayFunctionLikeReturnTypeHints: bool option - abstract includeInlayEnumMemberValueHints: bool option + /// + /// Include a symbol property on each completion entry object. + /// Symbols reference cyclic data structures and sometimes an entire TypeChecker instance, + /// so use caution when serializing or retaining completion entries retrieved with this option. + /// + /// false + abstract includeSymbol: bool option with get, set type [] [] SignatureHelpTriggerCharacter = - | [] Comma - | [] LeftParen - | [] LessThan + | [] ``,`` + | [] ``(`` + | [] ``<`` type SignatureHelpRetriggerCharacter = U2 @@ -6508,8 +8015,13 @@ module Ts = type [] SignatureHelpItemsOptions = abstract triggerReason: SignatureHelpTriggerReason option with get, set - type SignatureHelpTriggerReason = - U3 + type [] [] SignatureHelpTriggerReason = + | [] SignatureHelpCharacterTypedReason of SignatureHelpCharacterTypedReason + | [] SignatureHelpInvokedReason of SignatureHelpInvokedReason + | [] SignatureHelpRetriggeredReason of SignatureHelpRetriggeredReason + // static member inline op_ErasedCast(x: SignatureHelpCharacterTypedReason) = SignatureHelpCharacterTypedReason x + // static member inline op_ErasedCast(x: SignatureHelpInvokedReason) = SignatureHelpInvokedReason x + // static member inline op_ErasedCast(x: SignatureHelpRetriggeredReason) = SignatureHelpRetriggeredReason x /// Signals that the user manually requested signature help. /// The language service will unconditionally attempt to provide a result. @@ -6524,10 +8036,12 @@ module Ts = /// Character that was responsible for triggering signature help. abstract triggerCharacter: SignatureHelpTriggerCharacter with get, set + /// /// Signals that this signature help request came from typing a character or moving the cursor. /// This should only occur if a signature help session was already active and the editor needs to see if it should adjust. /// The language service will unconditionally attempt to provide a result. - /// `triggerCharacter` can be `undefined` for a retrigger caused by a cursor move. + /// triggerCharacter can be undefined for a retrigger caused by a cursor move. + /// type [] SignatureHelpRetriggeredReason = abstract kind: string with get, set /// Character that was responsible for triggering signature help. @@ -6537,7 +8051,7 @@ module Ts = abstract successMessage: string with get, set type [] Classifications = - abstract spans: ResizeArray with get, set + abstract spans: float[] with get, set abstract endOfLineState: EndOfLineState with get, set type [] ClassifiedSpan = @@ -6548,16 +8062,18 @@ module Ts = abstract textSpan: TextSpan with get, set abstract classificationType: float with get, set + /// /// Navigation bar interface designed for visual studio's dual-column layout. /// This does not form a proper tree. /// The navbar is returned as a list of top-level items, each of which has a list of child items. - /// Child items always have an empty array for their `childItems`. + /// Child items always have an empty array for their childItems. + /// type [] NavigationBarItem = abstract text: string with get, set abstract kind: ScriptElementKind with get, set abstract kindModifiers: string with get, set - abstract spans: ResizeArray with get, set - abstract childItems: ResizeArray with get, set + abstract spans: TextSpan[] with get, set + abstract childItems: NavigationBarItem[] with get, set abstract indent: float with get, set abstract bolded: bool with get, set abstract grayed: bool with get, set @@ -6572,10 +8088,10 @@ module Ts = abstract kindModifiers: string with get, set /// Spans of the nodes that generated this declaration. /// There will be more than one if this is the result of merging. - abstract spans: ResizeArray with get, set + abstract spans: TextSpan[] with get, set abstract nameSpan: TextSpan option with get, set /// Present if non-empty - abstract childItems: ResizeArray option with get, set + abstract childItems: NavigationTree[] option with get, set type [] CallHierarchyItem = abstract name: string with get, set @@ -6588,16 +8104,16 @@ module Ts = type [] CallHierarchyIncomingCall = abstract from: CallHierarchyItem with get, set - abstract fromSpans: ResizeArray with get, set + abstract fromSpans: TextSpan[] with get, set type [] CallHierarchyOutgoingCall = abstract ``to``: CallHierarchyItem with get, set - abstract fromSpans: ResizeArray with get, set + abstract fromSpans: TextSpan[] with get, set type [] [] InlayHintKind = - | [] Type - | [] Parameter - | [] Enum + | [] Type + | [] Parameter + | [] Enum type [] InlayHint = abstract text: string with get, set @@ -6621,17 +8137,19 @@ module Ts = type [] FileTextChanges = abstract fileName: string with get, set - abstract textChanges: ResizeArray with get, set + abstract textChanges: TextChange[] with get, set abstract isNewFile: bool option with get, set type [] CodeAction = /// Description of the code action to display in the UI of the editor abstract description: string with get, set /// Text changes to apply to each file as part of the code action - abstract changes: ResizeArray with get, set - /// If the user accepts the code fix, the editor should send the action back in a `applyAction` request. + abstract changes: FileTextChanges[] with get, set + /// + /// If the user accepts the code fix, the editor should send the action back in a applyAction request. /// This allows the language service to have side effects (e.g. installing dependencies) upon a code fix. - abstract commands: ResizeArray option with get, set + /// + abstract commands: CodeActionCommand[] option with get, set type [] CodeFixAction = inherit CodeAction @@ -6643,8 +8161,8 @@ module Ts = abstract fixAllDescription: string option with get, set type [] CombinedCodeActions = - abstract changes: ResizeArray with get, set - abstract commands: ResizeArray option with get, set + abstract changes: FileTextChanges[] with get, set + abstract commands: CodeActionCommand[] option with get, set type CodeActionCommand = InstallPackageAction @@ -6662,10 +8180,10 @@ module Ts = /// Inlineable refactorings can have their actions hoisted out to the top level /// of a context menu. Non-inlineanable refactorings should always be shown inside /// their parent grouping. - /// + /// /// If not specified, this value is assumed to be 'true' abstract inlineable: bool option with get, set - abstract actions: ResizeArray with get, set + abstract actions: RefactorActionInfo[] with get, set /// Represents a single refactoring action - for example, the "Extract Method..." refactor might /// offer several actions, each corresponding to a surround class or closure to extract into. @@ -6681,14 +8199,20 @@ module Ts = abstract notApplicableReason: string option with get, set /// The hierarchical dotted name of the refactor action. abstract kind: string option with get, set + /// + /// Indicates that the action requires additional arguments to be passed + /// when calling getEditsForRefactor. + /// + abstract isInteractive: bool option with get, set /// A set of edits to make in response to a refactor action, plus an optional /// location where renaming should be invoked from type [] RefactorEditInfo = - abstract edits: ResizeArray with get, set + abstract edits: FileTextChanges[] with get, set abstract renameFilename: string option with get, set abstract renameLocation: float option with get, set - abstract commands: ResizeArray option with get, set + abstract commands: CodeActionCommand[] option with get, set + abstract notApplicableReason: string option with get, set type [] [] RefactorTriggerReason = | Implicit @@ -6719,13 +8243,12 @@ module Ts = type [] ReferenceEntry = inherit DocumentSpan abstract isWriteAccess: bool with get, set - abstract isDefinition: bool with get, set - abstract isInString: obj option with get, set + abstract isInString: bool option with get, set type [] ImplementationLocation = inherit DocumentSpan abstract kind: ScriptElementKind with get, set - abstract displayParts: ResizeArray with get, set + abstract displayParts: SymbolDisplayPart[] with get, set type [] [] HighlightSpanKind = | None @@ -6735,7 +8258,7 @@ module Ts = type [] HighlightSpan = abstract fileName: string option with get, set - abstract isInString: obj option with get, set + abstract isInString: bool option with get, set abstract textSpan: TextSpan with get, set abstract contextSpan: TextSpan option with get, set abstract kind: HighlightSpanKind with get, set @@ -6761,6 +8284,7 @@ module Ts = | Insert | Remove + [] type [] EditorOptions = abstract BaseIndentSize: float option with get, set abstract IndentSize: float with get, set @@ -6778,6 +8302,7 @@ module Ts = abstract indentStyle: IndentStyle option with get, set abstract trimTrailingWhitespace: bool option with get, set + [] type [] FormatCodeOptions = inherit EditorOptions abstract InsertSpaceAfterCommaDelimiter: bool with get, set @@ -6818,6 +8343,7 @@ module Ts = abstract insertSpaceBeforeTypeAnnotation: bool option abstract indentMultiLineObjectLiteralBeginningOnBlankLine: bool option abstract semicolons: SemicolonPreference option + abstract indentSwitchCase: bool option type [] DefinitionInfo = inherit DocumentSpan @@ -6828,16 +8354,20 @@ module Ts = abstract unverified: bool option with get, set type [] DefinitionInfoAndBoundSpan = - abstract definitions: ResizeArray option with get, set + abstract definitions: DefinitionInfo[] option with get, set abstract textSpan: TextSpan with get, set type [] ReferencedSymbolDefinitionInfo = inherit DefinitionInfo - abstract displayParts: ResizeArray with get, set + abstract displayParts: SymbolDisplayPart[] with get, set type [] ReferencedSymbol = abstract definition: ReferencedSymbolDefinitionInfo with get, set - abstract references: ResizeArray with get, set + abstract references: ReferencedSymbolEntry[] with get, set + + type [] ReferencedSymbolEntry = + inherit ReferenceEntry + abstract isDefinition: bool option with get, set type [] SymbolDisplayPartKind = | AliasName = 0 @@ -6876,23 +8406,28 @@ module Ts = type [] JSDocTagInfo = abstract name: string with get, set - abstract text: ResizeArray option with get, set + abstract text: SymbolDisplayPart[] option with get, set type [] QuickInfo = abstract kind: ScriptElementKind with get, set abstract kindModifiers: string with get, set abstract textSpan: TextSpan with get, set - abstract displayParts: ResizeArray option with get, set - abstract documentation: ResizeArray option with get, set - abstract tags: ResizeArray option with get, set + abstract displayParts: SymbolDisplayPart[] option with get, set + abstract documentation: SymbolDisplayPart[] option with get, set + abstract tags: JSDocTagInfo[] option with get, set - type RenameInfo = - U2 + type [] [] RenameInfo = + | [] RenameInfoFailure of RenameInfoFailure + | [] RenameInfoSuccess of RenameInfoSuccess + // static member inline op_ErasedCast(x: RenameInfoFailure) = RenameInfoFailure x + // static member inline op_ErasedCast(x: RenameInfoSuccess) = RenameInfoSuccess x type [] RenameInfoSuccess = - abstract canRename: obj with get, set + abstract canRename: bool with get, set + /// /// File or directory to rename. - /// If set, `getEditsForFileRename` should be called instead of `findRenameLocations`. + /// If set, getEditsForFileRename should be called instead of findRenameLocations. + /// abstract fileToRename: string option with get, set abstract displayName: string with get, set abstract fullDisplayName: string with get, set @@ -6901,19 +8436,23 @@ module Ts = abstract triggerSpan: TextSpan with get, set type [] RenameInfoFailure = - abstract canRename: obj with get, set + abstract canRename: bool with get, set abstract localizedErrorMessage: string with get, set + [] type [] RenameInfoOptions = abstract allowRenameOfImportPath: bool option type [] DocCommentTemplateOptions = abstract generateReturnInDocTemplate: bool option + type [] InteractiveRefactorArguments = + abstract targetFile: string with get, set + type [] SignatureHelpParameter = abstract name: string with get, set - abstract documentation: ResizeArray with get, set - abstract displayParts: ResizeArray with get, set + abstract documentation: SymbolDisplayPart[] with get, set + abstract displayParts: SymbolDisplayPart[] with get, set abstract isOptional: bool with get, set abstract isRest: bool option with get, set @@ -6928,50 +8467,63 @@ module Ts = /// questions like 'what parameter is the user currently contained within?'. type [] SignatureHelpItem = abstract isVariadic: bool with get, set - abstract prefixDisplayParts: ResizeArray with get, set - abstract suffixDisplayParts: ResizeArray with get, set - abstract separatorDisplayParts: ResizeArray with get, set - abstract parameters: ResizeArray with get, set - abstract documentation: ResizeArray with get, set - abstract tags: ResizeArray with get, set + abstract prefixDisplayParts: SymbolDisplayPart[] with get, set + abstract suffixDisplayParts: SymbolDisplayPart[] with get, set + abstract separatorDisplayParts: SymbolDisplayPart[] with get, set + abstract parameters: SignatureHelpParameter[] with get, set + abstract documentation: SymbolDisplayPart[] with get, set + abstract tags: JSDocTagInfo[] with get, set /// Represents a set of signature help items, and the preferred item that should be selected. type [] SignatureHelpItems = - abstract items: ResizeArray with get, set + abstract items: SignatureHelpItem[] with get, set abstract applicableSpan: TextSpan with get, set abstract selectedItemIndex: float with get, set abstract argumentIndex: float with get, set abstract argumentCount: float with get, set + type [] CompletionInfoFlags = + | None = 0 + | MayIncludeAutoImports = 1 + | IsImportStatementCompletion = 2 + | IsContinuation = 4 + | ResolvedModuleSpecifiers = 8 + | ResolvedModuleSpecifiersBeyondLimit = 16 + | MayIncludeMethodSnippets = 32 + type [] CompletionInfo = - /// Not true for all global completions. This will be true if the enclosing scope matches a few syntax kinds. See `isSnippetScope`. + /// For performance telemetry. + abstract flags: CompletionInfoFlags option with get, set + /// Not true for all global completions. This will be true if the enclosing scope matches a few syntax kinds. See isSnippetScope. abstract isGlobalCompletion: bool with get, set abstract isMemberCompletion: bool with get, set - /// In the absence of `CompletionEntry["replacementSpan"], the editor may choose whether to use - /// this span or its default one. If `CompletionEntry["replacementSpan"]` is defined, that span + /// + /// In the absence of CompletionEntry["replacementSpan"], the editor may choose whether to use + /// this span or its default one. If CompletionEntry["replacementSpan"] is defined, that span /// must be used to commit that completion entry. + /// abstract optionalReplacementSpan: TextSpan option with get, set /// true when the current location also allows for a new identifier abstract isNewIdentifierLocation: bool with get, set /// Indicates to client to continue requesting completions on subsequent keystrokes. - abstract isIncomplete: obj option with get, set - abstract entries: ResizeArray with get, set + abstract isIncomplete: bool option with get, set + abstract entries: CompletionEntry[] with get, set type [] CompletionEntryDataAutoImport = /// The name of the property or export in the module's symbol table. Differs from the completion name /// in the case of InternalSymbolName.ExportEquals and InternalSymbolName.Default. abstract exportName: string with get, set + abstract exportMapKey: string option with get, set abstract moduleSpecifier: string option with get, set /// The file name declaring the export's module symbol, if it was an external module abstract fileName: string option with get, set /// The module name (with quotes stripped) of the export's module symbol, if it was an ambient module abstract ambientModuleName: string option with get, set /// True if the export was found in the package.json AutoImportProvider - abstract isPackageJsonImport: obj option with get, set + abstract isPackageJsonImport: bool option with get, set type [] CompletionEntryDataUnresolved = inherit CompletionEntryDataAutoImport - /// The key in the `ExportMapCache` where the completion entry's `SymbolExportInfo[]` is found abstract exportMapKey: string with get, set type [] CompletionEntryDataResolved = @@ -6987,36 +8539,48 @@ module Ts = abstract kindModifiers: string option with get, set abstract sortText: string with get, set abstract insertText: string option with get, set - abstract isSnippet: obj option with get, set + abstract isSnippet: bool option with get, set /// An optional span that indicates the text to be replaced by this completion item. /// If present, this span should be used instead of the default one. /// It will be set if the required span differs from the one generated by the default replacement behavior. abstract replacementSpan: TextSpan option with get, set - abstract hasAction: obj option with get, set + abstract hasAction: bool option with get, set abstract source: string option with get, set - abstract sourceDisplay: ResizeArray option with get, set - abstract isRecommended: obj option with get, set - abstract isFromUncheckedFile: obj option with get, set - abstract isPackageJsonImport: obj option with get, set - abstract isImportStatementCompletion: obj option with get, set - /// A property to be sent back to TS Server in the CompletionDetailsRequest, along with `name`, + abstract sourceDisplay: SymbolDisplayPart[] option with get, set + abstract labelDetails: CompletionEntryLabelDetails option with get, set + abstract isRecommended: bool option with get, set + abstract isFromUncheckedFile: bool option with get, set + abstract isPackageJsonImport: bool option with get, set + abstract isImportStatementCompletion: bool option with get, set + /// + /// For API purposes. + /// Included for non-string completions only when includeSymbol: true option is passed to getCompletionsAtPosition. + /// + /// Get declaration of completion: symbol.valueDeclaration + abstract symbol: Symbol option with get, set + /// + /// A property to be sent back to TS Server in the CompletionDetailsRequest, along with name, /// that allows TS Server to look up the symbol represented by the completion item, disambiguating /// items with the same name. Currently only defined for auto-import completions, but the type is - /// `unknown` in the protocol, so it can be changed as needed to support other kinds of completions. + /// unknown in the protocol, so it can be changed as needed to support other kinds of completions. /// The presence of this property should generally not be used to assume that this completion entry /// is an auto-import. + /// abstract data: CompletionEntryData option with get, set + type [] CompletionEntryLabelDetails = + abstract detail: string option with get, set + abstract description: string option with get, set + type [] CompletionEntryDetails = abstract name: string with get, set abstract kind: ScriptElementKind with get, set abstract kindModifiers: string with get, set - abstract displayParts: ResizeArray with get, set - abstract documentation: ResizeArray option with get, set - abstract tags: ResizeArray option with get, set - abstract codeActions: ResizeArray option with get, set - abstract source: ResizeArray option with get, set - abstract sourceDisplay: ResizeArray option with get, set + abstract displayParts: SymbolDisplayPart[] with get, set + abstract documentation: SymbolDisplayPart[] option with get, set + abstract tags: JSDocTagInfo[] option with get, set + abstract codeActions: CodeAction[] option with get, set + abstract sourceDisplay: SymbolDisplayPart[] option with get, set type [] OutliningSpan = /// The span of the document to actually collapse. @@ -7032,9 +8596,13 @@ module Ts = abstract kind: OutliningSpanKind with get, set type [] [] OutliningSpanKind = + /// Single or multi-line comments | Comment + /// Sections marked by '// #region' and '// #endregion' comments | Region + /// Declarations and expressions | Code + /// Contiguous blocks of import declarations | Imports type [] OutputFileType = @@ -7065,120 +8633,135 @@ module Ts = type [] ClassificationResult = abstract finalLexState: EndOfLineState with get, set - abstract entries: ResizeArray with get, set + abstract entries: ClassificationInfo[] with get, set type [] ClassificationInfo = abstract length: float with get, set abstract classification: TokenClass with get, set type [] Classifier = - /// Gives lexical classifications of tokens on a line without any syntactic context. - /// For instance, a token consisting of the text 'string' can be either an identifier - /// named 'string' or the keyword 'string', however, because this classifier is not aware, - /// it relies on certain heuristics to give acceptable results. For classifications where - /// speed trumps accuracy, this function is preferable; however, for true accuracy, the - /// syntactic classifier is ideal. In fact, in certain editing scenarios, combining the - /// lexical, syntactic, and semantic classifiers may issue the best user experience. - /// The text of a line to classify. - /// The state of the lexical classifier at the end of the previous line. - /// Whether the client is *not* using a syntactic classifier. - /// If there is no syntactic classifier (syntacticClassifierAbsent=true), - /// certain heuristics may be used in its place; however, if there is a - /// syntactic classifier (syntacticClassifierAbsent=false), certain - /// classifications which may be incorrectly categorized will be given - /// back as Identifiers in order to allow the syntactic classifier to - /// subsume the classification. - abstract getClassificationsForLine: text: string * lexState: EndOfLineState * syntacticClassifierAbsent: bool -> ClassificationResult abstract getEncodedLexicalClassifications: text: string * endOfLineState: EndOfLineState * syntacticClassifierAbsent: bool -> Classifications type [] [] ScriptElementKind = - | [] Unknown + | [] Unknown | Warning + /// predefined type (void) or keyword (class) | Keyword - | [] ScriptElement - | [] ModuleElement - | [] ClassElement - | [] LocalClassElement - | [] InterfaceElement - | [] TypeElement - | [] EnumElement - | [] EnumMemberElement - | [] VariableElement - | [] LocalVariableElement - | [] FunctionElement - | [] LocalFunctionElement - | [] MemberFunctionElement - | [] MemberGetAccessorElement - | [] MemberSetAccessorElement - | [] MemberVariableElement - | [] ConstructorImplementationElement - | [] CallSignatureElement - | [] IndexSignatureElement - | [] ConstructSignatureElement - | [] ParameterElement - | [] TypeParameterElement - | [] PrimitiveType + /// top level script node + | [] ScriptElement + /// module foo {} + | [] ModuleElement + /// class X {} + | [] ClassElement + /// var x = class X {} + | [] LocalClassElement + /// interface Y {} + | [] InterfaceElement + /// type T = ... + | [] TypeElement + /// enum E + | [] EnumElement + | [] EnumMemberElement + /// Inside module and script only + /// const v = .. + | [] VariableElement + /// Inside function + | [] LocalVariableElement + /// Inside module and script only + /// function f() { } + | [] FunctionElement + /// Inside function + | [] LocalFunctionElement + /// class X { [public|private]* foo() {} } + | [] MemberFunctionElement + /// class X { [public|private]* [get|set] foo:number; } + | [] MemberGetAccessorElement + | [] MemberSetAccessorElement + /// class X { [public|private]* foo:number; } + /// interface Y { foo:number; } + | [] MemberVariableElement + /// class X { [public|private]* accessor foo: number; } + | [] MemberAccessorVariableElement + /// class X { constructor() { } } + /// class X { static { } } + | [] ConstructorImplementationElement + /// interface Y { ():number; } + | [] CallSignatureElement + /// interface Y { []:number; } + | [] IndexSignatureElement + /// interface Y { new():Y; } + | [] ConstructSignatureElement + /// function foo(*Y*: string) + | [] ParameterElement + | [] TypeParameterElement + | [] PrimitiveType | Label | Alias - | [] ConstElement - | [] LetElement + | [] ConstElement + | [] LetElement | Directory - | [] ExternalModuleName - | [] JsxAttribute + | [] ExternalModuleName + /// <JsxTagName attribute1 attribute2={0} /> + /// + | [] JsxAttribute + /// String literal | String + /// Jsdoc @link: in {@link C link text}, the before and after text "and "" | Link - | [] LinkName - | [] LinkText + /// Jsdoc @link: in {@link C link text}, the entity name "C" + | [] LinkName + /// Jsdoc @link: in {@link C link text}, the link text "link text" + | [] LinkText type [] [] ScriptElementKindModifier = - | [] None - | [] PublicMemberModifier - | [] PrivateMemberModifier - | [] ProtectedMemberModifier - | [] ExportedModifier - | [] AmbientModifier - | [] StaticModifier - | [] AbstractModifier - | [] OptionalModifier - | [] DeprecatedModifier - | [] DtsModifier - | [] TsModifier - | [] TsxModifier - | [] JsModifier - | [] JsxModifier - | [] JsonModifier - | [] DmtsModifier - | [] MtsModifier - | [] MjsModifier - | [] DctsModifier - | [] CtsModifier - | [] CjsModifier + | [] None + | [] PublicMemberModifier + | [] PrivateMemberModifier + | [] ProtectedMemberModifier + | [] ExportedModifier + | [] AmbientModifier + | [] StaticModifier + | [] AbstractModifier + | [] OptionalModifier + | [] DeprecatedModifier + | [] DtsModifier + | [] TsModifier + | [] TsxModifier + | [] JsModifier + | [] JsxModifier + | [] JsonModifier + | [] DmtsModifier + | [] MtsModifier + | [] MjsModifier + | [] DctsModifier + | [] CtsModifier + | [] CjsModifier type [] [] ClassificationTypeNames = | Comment | Identifier | Keyword - | [] NumericLiteral - | [] BigintLiteral + | [] NumericLiteral + | [] BigintLiteral | Operator - | [] StringLiteral - | [] WhiteSpace + | [] StringLiteral + | [] WhiteSpace | Text | Punctuation - | [] ClassName - | [] EnumName - | [] InterfaceName - | [] ModuleName - | [] TypeParameterName - | [] TypeAliasName - | [] ParameterName - | [] DocCommentTagName - | [] JsxOpenTagName - | [] JsxCloseTagName - | [] JsxSelfClosingTagName - | [] JsxAttribute - | [] JsxText - | [] JsxAttributeStringLiteralValue + | [] ClassName + | [] EnumName + | [] InterfaceName + | [] ModuleName + | [] TypeParameterName + | [] TypeAliasName + | [] ParameterName + | [] DocCommentTagName + | [] JsxOpenTagName + | [] JsxCloseTagName + | [] JsxSelfClosingTagName + | [] JsxAttribute + | [] JsxText + | [] JsxAttributeStringLiteralValue type [] ClassificationType = | Comment = 1 @@ -7213,11 +8796,11 @@ module Ts = abstract cancellationToken: CancellationToken with get, set abstract host: LanguageServiceHost with get, set abstract span: TextSpan with get, set - abstract preferences: InlayHintsOptions with get, set + abstract preferences: UserPreferences with get, set type [] DocumentHighlights = abstract fileName: string with get, set - abstract highlightSpans: ResizeArray with get, set + abstract highlightSpans: HighlightSpan[] with get, set /// The document registry represents a store of SourceFile objects that can be shared between /// multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST) @@ -7226,49 +8809,68 @@ module Ts = /// the same DocumentRegistry instance between different instances of LanguageService allow /// for more efficient memory utilization since all projects will share at least the library /// file (lib.d.ts). - /// + /// /// A more advanced use of the document registry is to serialize sourceFile objects to disk /// and re-hydrate them when needed. - /// + /// /// To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it /// to all subsequent createLanguageService calls. type [] DocumentRegistry = - /// Request a stored SourceFile with a given fileName and compilationSettings. + /// + /// Request a stored SourceFile with a given fileName and compilationSettings. /// The first call to acquire will call createLanguageServiceSourceFile to generate - /// the SourceFile if was not found in the registry. + /// the SourceFile if was not found in the registry. + /// /// The name of the file requested - /// Some compilation settings like target affects the + /// + /// Some compilation settings like target affects the /// shape of a the resulting SourceFile. This allows the DocumentRegistry to store - /// multiple copies of the same file for different compilation settings. - /// Text of the file. Only used if the file was not found - /// in the registry and a new one was created. - /// Current version of the file. Only used if the file was not found - /// in the registry and a new one was created. - abstract acquireDocument: fileName: string * compilationSettings: CompilerOptions * scriptSnapshot: IScriptSnapshot * version: string * ?scriptKind: ScriptKind -> SourceFile - abstract acquireDocumentWithKey: fileName: string * path: Path * compilationSettings: CompilerOptions * key: DocumentRegistryBucketKey * scriptSnapshot: IScriptSnapshot * version: string * ?scriptKind: ScriptKind -> SourceFile - /// Request an updated version of an already existing SourceFile with a given fileName + /// multiple copies of the same file for different compilation settings. A minimal + /// resolution cache is needed to fully define a source file's shape when + /// the compilation settings include module: node16+, so providing a cache host + /// object should be preferred. A common host is a language service ConfiguredProject. + /// + /// + /// Text of the file. Only used if the file was not found + /// in the registry and a new one was created. + /// + /// + /// Current version of the file. Only used if the file was not found + /// in the registry and a new one was created. + /// + abstract acquireDocument: fileName: string * compilationSettingsOrHost: U2 * scriptSnapshot: IScriptSnapshot * version: string * ?scriptKind: ScriptKind * ?sourceFileOptions: U2 -> SourceFile + abstract acquireDocumentWithKey: fileName: string * path: Path * compilationSettingsOrHost: U2 * key: DocumentRegistryBucketKey * scriptSnapshot: IScriptSnapshot * version: string * ?scriptKind: ScriptKind * ?sourceFileOptions: U2 -> SourceFile + /// + /// Request an updated version of an already existing SourceFile with a given fileName /// and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile - /// to get an updated SourceFile. + /// to get an updated SourceFile. + /// /// The name of the file requested - /// Some compilation settings like target affects the + /// + /// Some compilation settings like target affects the /// shape of a the resulting SourceFile. This allows the DocumentRegistry to store - /// multiple copies of the same file for different compilation settings. + /// multiple copies of the same file for different compilation settings. A minimal + /// resolution cache is needed to fully define a source file's shape when + /// the compilation settings include module: node16+, so providing a cache host + /// object should be preferred. A common host is a language service ConfiguredProject. + /// /// Text of the file. /// Current version of the file. - abstract updateDocument: fileName: string * compilationSettings: CompilerOptions * scriptSnapshot: IScriptSnapshot * version: string * ?scriptKind: ScriptKind -> SourceFile - abstract updateDocumentWithKey: fileName: string * path: Path * compilationSettings: CompilerOptions * key: DocumentRegistryBucketKey * scriptSnapshot: IScriptSnapshot * version: string * ?scriptKind: ScriptKind -> SourceFile + abstract updateDocument: fileName: string * compilationSettingsOrHost: U2 * scriptSnapshot: IScriptSnapshot * version: string * ?scriptKind: ScriptKind * ?sourceFileOptions: U2 -> SourceFile + abstract updateDocumentWithKey: fileName: string * path: Path * compilationSettingsOrHost: U2 * key: DocumentRegistryBucketKey * scriptSnapshot: IScriptSnapshot * version: string * ?scriptKind: ScriptKind * ?sourceFileOptions: U2 -> SourceFile abstract getKeyForCompilationSettings: settings: CompilerOptions -> DocumentRegistryBucketKey - abstract releaseDocument: fileName: string * compilationSettings: CompilerOptions -> unit - /// Informs the DocumentRegistry that a file is not needed any longer. - /// + /// + /// Informs the DocumentRegistry that a file is not needed any longer. + /// /// Note: It is not allowed to call release on a SourceFile that was not acquired from - /// this registry originally. + /// this registry originally. + /// /// The name of the file to be released /// The compilation settings used to acquire the file /// The script kind of the file to be released - abstract releaseDocument: fileName: string * compilationSettings: CompilerOptions * scriptKind: ScriptKind -> unit - abstract releaseDocumentWithKey: path: Path * key: DocumentRegistryBucketKey -> unit - abstract releaseDocumentWithKey: path: Path * key: DocumentRegistryBucketKey * scriptKind: ScriptKind -> unit + /// The implied source file format of the file to be released + abstract releaseDocument: fileName: string * compilationSettings: CompilerOptions * scriptKind: ScriptKind * impliedNodeFormat: ResolutionMode -> unit + abstract releaseDocumentWithKey: path: Path * key: DocumentRegistryBucketKey * scriptKind: ScriptKind * impliedNodeFormat: ResolutionMode -> unit abstract reportStats: unit -> string type [] DocumentRegistryBucketKey = @@ -7284,83 +8886,9 @@ module Ts = type [] TranspileOutput = abstract outputText: string with get, set - abstract diagnostics: ResizeArray option with get, set + abstract diagnostics: Diagnostic[] option with get, set abstract sourceMapText: string option with get, set - type [] IExportsCreateStringLiteral = - [] abstract Invoke: text: string * ?isSingleQuote: bool -> StringLiteral - [] abstract Invoke: text: string * ?isSingleQuote: bool * ?hasExtendedUnicodeEscape: bool -> StringLiteral - - type [] IExportsCreateTemplateHead = - [] abstract Invoke: text: string * ?rawText: string * ?templateFlags: TokenFlags -> TemplateHead - [] abstract Invoke: text: string option * rawText: string * ?templateFlags: TokenFlags -> TemplateHead - - type [] IExportsCreateTemplateMiddle = - [] abstract Invoke: text: string * ?rawText: string * ?templateFlags: TokenFlags -> TemplateMiddle - [] abstract Invoke: text: string option * rawText: string * ?templateFlags: TokenFlags -> TemplateMiddle - - type [] IExportsCreateTemplateTail = - [] abstract Invoke: text: string * ?rawText: string * ?templateFlags: TokenFlags -> TemplateTail - [] abstract Invoke: text: string option * rawText: string * ?templateFlags: TokenFlags -> TemplateTail - - type [] IExportsCreateNoSubstitutionTemplateLiteral = - [] abstract Invoke: text: string * ?rawText: string -> NoSubstitutionTemplateLiteral - [] abstract Invoke: text: string option * rawText: string -> NoSubstitutionTemplateLiteral - - type [] IExportsCreateImmediatelyInvokedFunctionExpression = - [] abstract Invoke: statements: ResizeArray -> CallExpression - [] abstract Invoke: statements: ResizeArray * param: ParameterDeclaration * paramValue: Expression -> CallExpression - - type [] IExportsCreateLiteral = - [] abstract Invoke: value: U5 -> StringLiteral - [] abstract Invoke: value: U2 -> NumericLiteral - [] abstract Invoke: value: bool -> BooleanLiteral - [] abstract Invoke: value: U4 -> PrimaryExpression - - type [] IExportsCreateTypeOperatorNode = - [] abstract Invoke: ``type``: TypeNode -> TypeOperatorNode - [] abstract Invoke: operator: SyntaxKind * ``type``: TypeNode -> TypeOperatorNode - - type [] IExportsCreateTaggedTemplate = - [] abstract Invoke: tag: Expression * template: TemplateLiteral -> TaggedTemplateExpression - [] abstract Invoke: tag: Expression * typeArguments: ResizeArray option * template: TemplateLiteral -> TaggedTemplateExpression - - type [] IExportsUpdateTaggedTemplate = - [] abstract Invoke: node: TaggedTemplateExpression * tag: Expression * template: TemplateLiteral -> TaggedTemplateExpression - [] abstract Invoke: node: TaggedTemplateExpression * tag: Expression * typeArguments: ResizeArray option * template: TemplateLiteral -> TaggedTemplateExpression - - type [] IExportsCreateConditional = - [] abstract Invoke: condition: Expression * whenTrue: Expression * whenFalse: Expression -> ConditionalExpression - [] abstract Invoke: condition: Expression * questionToken: QuestionToken * whenTrue: Expression * colonToken: ColonToken * whenFalse: Expression -> ConditionalExpression - - type [] IExportsCreateYield = - [] abstract Invoke: ?expression: Expression -> YieldExpression - [] abstract Invoke: asteriskToken: AsteriskToken option * expression: Expression -> YieldExpression - - type [] IExportsCreateArrowFunction = - [] abstract Invoke: modifiers: ResizeArray option * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode option * equalsGreaterThanToken: EqualsGreaterThanToken option * body: ConciseBody -> ArrowFunction - [] abstract Invoke: modifiers: ResizeArray option * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode option * body: ConciseBody -> ArrowFunction - - type [] IExportsUpdateArrowFunction = - [] abstract Invoke: node: ArrowFunction * modifiers: ResizeArray option * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode option * equalsGreaterThanToken: EqualsGreaterThanToken * body: ConciseBody -> ArrowFunction - [] abstract Invoke: node: ArrowFunction * modifiers: ResizeArray option * typeParameters: ResizeArray option * parameters: ResizeArray * ``type``: TypeNode option * body: ConciseBody -> ArrowFunction - - type [] IExportsCreateVariableDeclaration = - [] abstract Invoke: name: U2 * ?``type``: TypeNode * ?initializer: Expression -> VariableDeclaration - [] abstract Invoke: name: U2 * exclamationToken: ExclamationToken option * ``type``: TypeNode option * initializer: Expression option -> VariableDeclaration - - type [] IExportsUpdateVariableDeclaration = - [] abstract Invoke: node: VariableDeclaration * name: BindingName * ``type``: TypeNode option * initializer: Expression option -> VariableDeclaration - [] abstract Invoke: node: VariableDeclaration * name: BindingName * exclamationToken: ExclamationToken option * ``type``: TypeNode option * initializer: Expression option -> VariableDeclaration - - type [] IteratorNext<'T> = - abstract value: 'T with get, set - abstract ``done``: obj option with get, set - - type [] IteratorNext2 = - abstract value: obj with get, set - abstract ``done``: obj with get, set - type [] DiagnosticMessageReportsUnnecessary = interface end @@ -7371,9 +8899,9 @@ module Ts = type [] [] UserPreferencesImportModuleSpecifierPreference = | Shortest - | [] ProjectRelative + | [] ProjectRelative | Relative - | [] NonRelative + | [] NonRelative type [] [] UserPreferencesImportModuleSpecifierEnding = | Auto @@ -7391,15 +8919,23 @@ module Ts = | Braces | None - type [] [] PerformanceEventKind = - | [] UpdateGraph - | [] CreatePackageJsonAutoImportProvider - - type [] [] InlayHintsOptionsIncludeInlayParameterNameHints = + type [] [] UserPreferencesIncludeInlayParameterNameHints = | None | Literals | All + type [] [] UserPreferencesOrganizeImportsCollation = + | Ordinal + | Unicode + + type [] [] UserPreferencesOrganizeImportsCaseFirst = + | Upper + | Lower + + type [] [] PerformanceEventKind = + | [] UpdateGraph + | [] CreatePackageJsonAutoImportProvider + type [] [] NavigateToItemMatchKind = | Exact | Prefix diff --git a/lib/DataTypes/Graph.fs b/lib/DataTypes/Graph.fs index 54e0da7f..db138e40 100644 --- a/lib/DataTypes/Graph.fs +++ b/lib/DataTypes/Graph.fs @@ -117,7 +117,49 @@ module Graph = ordering.[group] <- order; ordering ) (Array.zeroCreate (List.length groups)) - xs - |> List.groupBy (fun s -> Map.find s cmps) - |> List.sortBy (fun (i, _) -> sortedGroups.[i]) - |> List.map (snd >> List.sort) + let result = + xs + |> List.groupBy (fun s -> Map.find s cmps) + |> List.sortBy (fun (i, _) -> sortedGroups.[i]) + |> List.map snd +#if DEBUG + assert (Set.ofList xs = Set.ofList (List.concat result)) +#endif + result + +type DependencyTrie<'k when 'k: comparison> = Trie<'k, 'k list list> + +module DependencyTrie = + open Ts2Ml.Extensions + + let ofTrie (getReferences: 'v -> WeakTrie<'k>) (trie: Trie<'k, 'v>) : DependencyTrie<'k> = + let refTrieMap = new MutableMap<'k list, WeakTrie<'k>>() + let rec getRefTrie nsRev (x: Trie<'k, 'v>) = + match refTrieMap.TryGetValue(nsRev) with + | true, wt -> wt + | false, _ -> + let wtCurrent = + x.value + |> Option.map getReferences + |? WeakTrie.empty + let wt = + x.children + |> Map.fold (fun state k child -> WeakTrie.union state (getRefTrie (k :: nsRev) child)) wtCurrent + |> WeakTrie.remove (List.rev nsRev) + refTrieMap[nsRev] <- wt + wt + let getDeps nsRev (x: Trie<'k, 'v>) : ('k * 'k) list = + x.children + |> Map.fold (fun state k child -> + let refs = + getRefTrie (k :: nsRev) child + |> WeakTrie.getSubTrie (List.rev nsRev) |? WeakTrie.empty + |> WeakTrie.ofDepth 1 |> WeakTrie.toList + |> List.choose (function [x] -> Some (k, x) | _ -> None (* should be impossible *)) + refs :: state) [] + |> List.rev |> List.concat + let rec go nsRev (x: Trie<'k, 'v>) : DependencyTrie<'k> = + let g = getDeps nsRev x |> Graph.ofEdges + let scc = Graph.stronglyConnectedComponents g (x.children |> Map.toList |> List.map fst) + { value = Some scc; children = x.children |> Map.map (fun k child -> go (k :: nsRev) child) } + go [] trie diff --git a/lib/DataTypes/Text.fs b/lib/DataTypes/Text.fs index 9571cf99..8feef23d 100644 --- a/lib/DataTypes/Text.fs +++ b/lib/DataTypes/Text.fs @@ -103,3 +103,11 @@ module Text = | Indent x -> isMultiLine x | Concat (x, y) -> isMultiLine x || isMultiLine y | Empty | Str _ -> false + + /// Get the length of a text. Indents are ignored. + let rec length = function + | Empty -> 0 + | Newline -> 1 + | Str s -> s.Length + | Concat (x, y) -> length x + length y + | Indent x -> length x diff --git a/lib/DataTypes/Trie.fs b/lib/DataTypes/Trie.fs index 0f51cd5c..07681abe 100644 --- a/lib/DataTypes/Trie.fs +++ b/lib/DataTypes/Trie.fs @@ -7,10 +7,6 @@ type Trie<'k, 'v when 'k: comparison> = { type Trie<'k when 'k: comparison> = Trie<'k, unit> -type WeakTrie<'k when 'k: comparison> = { - children: Map<'k, WeakTrie<'k>> -} - module Trie = let empty<'k, 'v when 'k: comparison> : Trie<'k, 'v> = { value = None; children = Map.empty } @@ -165,6 +161,10 @@ module Trie = let toMap (t: Trie<'k, 'v>) : Map<'k list, 'v> = t |> fold (fun state ks v -> Map.add ks v state) Map.empty let ofMap (xs: Map<'k list, 'v>) : Trie<'k, 'v> = xs |> Map.fold (fun state ks v -> add ks v state) empty +type WeakTrie<'k when 'k: comparison> = { + children: Map<'k, WeakTrie<'k>> +} + module WeakTrie = let empty<'k when 'k: comparison> : WeakTrie<'k> = { children = Map.empty } diff --git a/lib/Extensions.fs b/lib/Extensions.fs index 5f8fc0ee..7d1aa9c7 100644 --- a/lib/Extensions.fs +++ b/lib/Extensions.fs @@ -1,6 +1,17 @@ [] module Ts2Ml.Extensions +let inline (|?) (xo: 'a option) (y: 'a) : 'a = Option.defaultValue y xo + +/// Use when a certain code path is impossible or unreachable. +let impossible fmt = + Printf.ksprintf (fun msg -> failwith ("impossible: " + msg)) fmt + +/// Repeatedly apply `f` until the same result is obtained. +let rec repeatUntilEquilibrium<'a when 'a: equality> (f: 'a -> 'a) a = + let a' = f a + if (a = a') then a' else repeatUntilEquilibrium f a' + open System module Enum = @@ -42,7 +53,7 @@ module String = let escape (s: string) = s .Replace("\\", "\\\\") - .Replace("'", "\\'").Replace("\"", "\\\"") + .Replace("\"", "\\\"") .Replace("\b", "\\b").Replace("\n", "\\n").Replace("\r", "\\r") .Replace("\t", "\\t") @@ -51,12 +62,18 @@ module String = state.Replace(e, "\\" + e) ) s + open Fable.Core + [] + let normalize (_: string) : string = jsNative + module Option = let iterNone f = function | Some x -> Some x | None -> f (); None module Result = + let ofOption opt = + match opt with Some x -> Ok x | None -> Error (Unchecked.defaultof<_>) let toOption result = match result with Ok x -> Some x | Error _ -> None @@ -69,10 +86,25 @@ module List = ) ([], []) List.rev xs1, List.rev xs2 + let splitChoice3 (xs: Choice<'t1, 't2, 't3> list) : 't1 list * 't2 list * 't3 list = + let xs1, xs2, xs3 = + xs |> List.fold (fun (xs1, xs2, xs3) -> function + | Choice1Of3 x -> x :: xs1, xs2, xs3 + | Choice2Of3 x -> xs1, x :: xs2, xs3 + | Choice3Of3 x -> xs1, xs2, x :: xs3) ([], [], []) + List.rev xs1, List.rev xs2, List.rev xs3 + module Map = let addNoOverwrite k v m = m |> Map.change k (function None -> Some v | Some v -> Some v) + let mergeWith f m1 m2 = + m2 |> Map.fold (fun m1 k v2 -> + match m1 |> Map.tryFind k with + | None -> m1 |> Map.add k v2 + | Some v1 -> m1 |> Map.add k (f v1 v2) + ) m1 + type MutableMap<'k, 'v> = Collections.Generic.Dictionary<'k, 'v> type MutableSet<'v> = Collections.Generic.HashSet<'v> @@ -193,6 +225,11 @@ module Path = if Node.path.isAbsolute(path) then path |> normalizeSlashes else Node.path.resolve(path) |> normalizeSlashes + let relativeToCwd (path: string) = + if Node.path.isAbsolute(path) then + Node.path.relative(Node.``process``.cwd(), path) |> normalizeSlashes + else path |> normalizeSlashes + let diff (fromPath: Absolute) (toPath: Absolute) : string = let fromPath = if Node.fs.lstatSync(!^fromPath).isDirectory() then fromPath diff --git a/lib/JsHelper.fs b/lib/JsHelper.fs index af5b9d31..456c1f94 100644 --- a/lib/JsHelper.fs +++ b/lib/JsHelper.fs @@ -21,7 +21,7 @@ let getPackageJsonPath (exampleFilePath: string) = match rest with | userName :: packageName :: _ when userName.StartsWith("@") -> [userName; packageName] | packageName :: _ -> [packageName] - | _ -> failwith "impossible_getPackageJsonPath_root" + | _ -> impossible "getPackageJsonPath_root" let path = prefix @ packageName @ ["package.json"] |> String.concat Path.separator @@ -156,14 +156,17 @@ let inferPackageInfoFromFileName (sourceFile: Path.Absolute) : {| name: string; | _ -> None let inline stripExtension path = - path |> String.replace ".ts" "" |> String.replace ".d" "" + let stripEnd ext cont (path: string) = + if path.EndsWith(ext) then path.Substring(0, path.Length - ext.Length) + else cont path + stripEnd ".d.ts" (stripEnd ".ts" id) path let getJsModuleName (info: Syntax.PackageInfo option) (sourceFile: Path.Absolute) = let getSubmodule rest = match List.rev rest with | "index.d.ts" :: name :: _ -> name | name :: _ -> stripExtension name - | [] -> failwith "impossible" + | [] -> impossible "getJsModuleName_getSubmodule" match info with | Some info -> if info.indexFile |> Option.exists ((=) sourceFile) then diff --git a/lib/Naming.fs b/lib/Naming.fs index 3878d151..4fcbe77d 100644 --- a/lib/Naming.fs +++ b/lib/Naming.fs @@ -127,29 +127,12 @@ let toCase (case: Case) (str: string) = | _, _ -> wordsToCase case words module Keywords = - let keywords = - Set.ofList [ - "and"; "as"; "assert"; "asr"; "begin"; "class"; - "constraint"; "do"; "done"; "downto"; "else"; "end"; - "exception"; "external"; "false"; "for"; "fun"; "function"; - "functor"; "if"; "in"; "include"; "inherit"; "initializer"; - "land"; "lazy"; "let"; "lor"; "lsl"; "lsr"; - "lxor"; "match"; "method"; "mod"; "module"; "mutable"; - "new"; "nonrec"; "object"; "of"; "open"; "or"; - "private"; "rec"; "sig"; "struct"; "then"; "to"; - "true"; "try"; "type"; "val"; "virtual"; "when"; - "while"; "with" - ] - let esKeywords = Set.ofList [ "Readonly"; "Partial"; "Pick"; "HTMLDialogElement"; "HTMLWebViewElement" ] - let primitives = Set.ofList [ "string"; "obj"; "unit"; "float"; "bool"; "int" ] - let basicTypes = Set.ofList [ "list"; "array"; "option" ] - let removeQuotesAndTrim (s: string) = if String.IsNullOrEmpty s then "" else @@ -157,3 +140,14 @@ let removeQuotesAndTrim (s: string) = if (c = '\"' || c = ''') then s.Trim(c).Trim() else s.Trim() + +let isValidJSIdentifier (s: string) = + if String.IsNullOrEmpty s then false + else + let cs = s.ToCharArray() + if cs[0] |> Char.IsDigit then false + else + cs |> Array.forall (fun c -> + Char.IsLetterOrDigit(c) + || c = '_' || c = '$' + ) diff --git a/lib/Parser.fs b/lib/Parser.fs index 0664a968..401f921d 100644 --- a/lib/Parser.fs +++ b/lib/Parser.fs @@ -12,6 +12,7 @@ open TypeScript type Node = Ts.Node type TypeChecker = Ts.TypeChecker type Kind = Ts.SyntaxKind +type ModuleName = Ts.ModuleName type ParserContext = inherit IContext @@ -30,16 +31,21 @@ module private ParserImpl = let ppLocation (n: Node) = let src = n.getSourceFile() let pos = src.getLineAndCharacterOfPosition (n.getStart()) - sprintf "line %i, col %i of %s" (int pos.line + 1) (int pos.character + 1) src.fileName + sprintf "line %i, col %i of %s" (int pos.line + 1) (int pos.character + 1) (Path.relativeToCwd src.fileName) let ppLine (n: Node) = let src = n.getSourceFile() - let pos = src.getLineAndCharacterOfPosition (n.getStart()) - let startPos = int <| src.getPositionOfLineAndCharacter(pos.line, 0.) - let endPos = int <| src.getLineEndOfPosition(n.getEnd()) - let lines = - src.text.Substring(startPos, endPos - startPos) |> String.toLines - lines |> Array.map (sprintf "> %s") |> String.concat System.Environment.NewLine + let startPos = src.getLineAndCharacterOfPosition(n.getStart()) + let endPos = src.getLineAndCharacterOfPosition(n.getEnd()) + let text = src.text + Codeframe.Codeframe.CreateColumns( + text, + int startPos.line + 1, + int startPos.character + 1, + int endPos.line + 1, + int endPos.character + 1, + linesAbove=0, linesBelow=0 + ) let nodeWarn (ctx: ParserContext) (node: Node) format = Printf.kprintf (fun s -> @@ -51,12 +57,15 @@ module private ParserImpl = ctx.logger.errorf "%s at %s\n%s" s (Node.ppLocation node) (Node.ppLine node) ) format - let hasModifier (kind: Ts.SyntaxKind) (modifiers: Ts.ModifiersArray option) = - match modifiers with - | None -> false - | Some mds -> mds |> Seq.exists (fun md -> md.kind = kind) + let modifiers (n: Ts.Node) : Ts.ModifierLike[] option = + if ts.canHaveModifiers(n) then + Some !!(ts.getModifiers(!!n)) + else None - let getAccessibility (modifiersOpt: Ts.ModifiersArray option) : Accessibility option = + let hasModifier (kind: Ts.SyntaxKind) (modifiers: Ts.ModifierLike[] option) = + modifiers |> Option.exists (Array.exists (fun md -> (!!md : Ts.Token<_>).kind = kind)) + + let getAccessibility (modifiersOpt: Ts.ModifierLike[] option) : Accessibility option = if modifiersOpt |> hasModifier Kind.PublicKeyword then Some Public else if modifiersOpt |> hasModifier Kind.ProtectedKeyword then @@ -66,7 +75,7 @@ module private ParserImpl = else None - let getExported (modifiersOpt: Ts.ModifiersArray option) : Exported = + let getExported (modifiersOpt: Ts.ModifierLike[] option) : Exported = if modifiersOpt |> hasModifier Kind.DeclareKeyword then Exported.Declared else if modifiersOpt |> hasModifier Kind.ExportKeyword |> not then @@ -76,36 +85,25 @@ module private ParserImpl = else Exported.Yes - let isReadOnly (m: Ts.ModifiersArray option) : bool = + let isReadOnly (m: Ts.ModifierLike[] option) : bool = m |> hasModifier Kind.ReadonlyKeyword let getText (x: 'a) : string = (!!x : Ts.Node).getText() |> removeQuotesAndTrim - let getPropertyName (pn: Ts.PropertyName) : string option = - let node : Node = !!pn - match node.kind with - | Kind.Identifier -> Some (!!pn : Ts.Identifier).text - | Kind.PrivateIdentifier -> Some (!!pn : Ts.PrivateIdentifier).text - | Kind.StringLiteral -> Some (!!pn : Ts.StringLiteral).text - | Kind.NumericLiteral -> Some (!!pn : Ts.NumericLiteral).text - | _ -> None - - let getPropertyExpression (pn: Ts.PropertyName) : Ts.Expression option = - let node : Node = !!pn - match node.kind with - | Kind.ComputedPropertyName -> Some (!!pn : Ts.ComputedPropertyName).expression - | _ -> None - - let getBindingName ctx (bn: Ts.BindingName): string option = - let syntaxNode : Node = !! bn - match syntaxNode.kind with - | Kind.Identifier -> - let id : Ts.Identifier = !! bn - Some id.text - | Kind.ObjectBindingPattern - | Kind.ArrayBindingPattern -> None - | _ -> nodeError ctx syntaxNode "unknown Binding Name kind: %s" (Enum.pp syntaxNode.kind) + let getPropertyName (pn: Ts.PropertyName) : Result = + match pn with + | Ts.PropertyName.Identifier i -> Ok i.text + | Ts.PropertyName.PrivateIdentifier i -> Ok i.text + | Ts.PropertyName.StringLiteral s -> Ok s.text + | Ts.PropertyName.NumericLiteral n -> Ok n.text + | Ts.PropertyName.ComputedPropertyName c -> Error c.expression + + let getBindingName (bn: Ts.BindingName): string option = + match bn with + | Ts.BindingName.Identifier i -> Some i.text + | Ts.BindingName.ObjectBindingPattern _ + | Ts.BindingName.ArrayBindingPattern _ -> None let rec extractNestedName (node: Node) = seq { @@ -124,7 +122,7 @@ module private ParserImpl = match ctx.checker.getSymbolAtLocation i with | None -> None | Some s -> - let inline check (superset: Ts.SymbolFlags) (subset: Ts.SymbolFlags) = int (subset &&& superset) > 0 + let check (superset: Ts.SymbolFlags) (subset: Ts.SymbolFlags) = int (subset &&& superset) > 0 let rec go (symbol: Ts.Symbol) = let flags = symbol.getFlags() if flags = Ts.SymbolFlags.Alias then @@ -148,37 +146,46 @@ module private ParserImpl = ] |> Some go s - let normalizeQualifiedName (fileNames: string list) (s: string) = - s - |> String.split "." - |> List.ofArray - |> function - | x :: xs when x.StartsWith("\"") -> - let basenames = fileNames |> List.map JsHelper.stripExtension - if basenames |> List.exists (fun basename -> x.EndsWith(basename + "\"")) then xs - else x.Trim('"') :: xs - | xs -> xs - - let getFullName (ctx: ParserContext) (nd: Node) = - match ctx.checker.getSymbolAtLocation nd with - | None -> None - | Some s -> - let source = ctx.currentSource.fileName - let fullName = - ctx.checker.getFullyQualifiedName s |> normalizeQualifiedName [source] - Some { source = source; name = fullName } + type Source = {| + file: Path.Absolute + moduleName: string option + |} + + let getSource (d: Ts.Declaration) : Source = + let sourceFile = d.getSourceFile() + let rec findAmbientModule (n: Ts.Node) = + if isNullOrUndefined n then None + else + match n.kind with + | Kind.SourceFile -> None + | Kind.ModuleDeclaration -> + let md = n :?> Ts.ModuleDeclaration + match md.name with + | ModuleName.StringLiteral s -> Some s.text + | ModuleName.Identifier _ -> findAmbientModule n.parent + | _ -> findAmbientModule n.parent + let ambientModuleName = findAmbientModule d + {| file = Path.absolute sourceFile.fileName; moduleName = ambientModuleName |} + + let makeFullName (fn: string list) (s: Source) = + let name = + match s.moduleName, fn with + | Some m, x :: _ when x = $"\"{m}\"" -> fn + | Some m, _ -> $"\"{m}\"" :: fn + | None, x :: fn when x.StartsWith("\"") -> fn + | None, _ -> fn + { source = s.file; name = name } let getFullNames (ctx: ParserContext) (nd: Node) = let getSources (s: Ts.Symbol) = s.declarations - |> Option.toList - |> List.collect (fun decs -> - decs |> Seq.map (fun dec -> dec.getSourceFile()) |> List.ofSeq) - |> List.map (fun x -> x.fileName) - |> List.distinct + |> Option.toArray + |> Array.collect (Array.map getSource) + |> Array.distinctBy (fun x -> x.file) + |> List.ofArray let getRootAndAliasedSymbols (s: Ts.Symbol) = - let roots = ctx.checker.getRootSymbols(s) + let roots = ctx.checker.getRootSymbols(s) |> ResizeArray try let s = ctx.checker.getAliasedSymbol(s) if not (ctx.checker.isUnknownSymbol s || ctx.checker.isUndefinedSymbol s) then @@ -194,10 +201,11 @@ module private ParserImpl = let sources = getSources s let fullName = ctx.checker.getFullyQualifiedName s - |> normalizeQualifiedName sources + |> String.split "." + |> List.ofArray let newItems = sources - |> List.map (fun source -> { source = source; name = fullName }) + |> List.map (makeFullName fullName) |> Set.ofList if Set.isSubset newItems acc then acc else @@ -215,7 +223,7 @@ module private ParserImpl = let kind = getKindFromName ctx nd let loc = Node.location nd let fullName = getFullNames ctx nd - { name = name; kind = kind; fullName = fullName; loc = loc; parent = parent } + { name = name; kind = kind; fullName = fullName; loc = loc; parent = parent; misc = IdentMiscData.Empty } match nd.kind with | Kind.Identifier | Kind.PrivateIdentifier -> let i = nd :?> Ts.Identifier @@ -237,16 +245,35 @@ module private ParserImpl = else readIdent ctx nd |> Choice1Of2 + type DeclarationWithTypeParameters = + inherit Ts.Node + abstract typeParameters: Ts.TypeParameterDeclaration[] option with get + + let getArityOfIdentType (ctx: ParserContext) (nd: Ts.Node) (i: Ident) : Ident = + match ctx.checker.getSymbolAtLocation nd with + | None -> i + | Some symbol -> + let arity = + symbol.declarations + |> Option.toArray + |> Array.concat + |> Array.fold (fun maxArity decl -> + match (decl :?> DeclarationWithTypeParameters).typeParameters with + | Some tps when tps.Length > maxArity -> tps.Length + | _ -> maxArity + ) 0 + { i with misc = { i.misc with maxArity = Some arity } } + let sanitizeCommentText str : string list = str |> String.toLines |> List.ofArray - let readCommentText (comment: U2>) : string list = + let readCommentText (comment: U2) : string list = let str = if JS.typeof comment = "string" then box comment :?> string else - let texts = box comment :?> ResizeArray // TODO: do not ignore links - texts |> Seq.map (fun x -> x.text) |> String.concat "" + let texts = box comment :?> Ts.JSDocText[] // TODO: do not ignore links + texts |> Array.map (fun x -> x.text) |> String.concat "" sanitizeCommentText str let readNonJSDocComments (ctx: ParserContext) (node: Node) : Comment list = @@ -256,13 +283,13 @@ module private ParserImpl = | None -> [] | Some ranges -> ranges - |> Seq.map (fun range -> + |> Array.map (fun range -> fullText.[int range.pos .. int range.``end``] |> sanitizeCommentText |> Summary) - |> Seq.toList + |> Array.toList let readJSDocTag (tag: Ts.JSDocTag) : Comment = - let text = tag.comment |> Option.map readCommentText |> Option.defaultValue [] + let text = tag.comment |> Option.map readCommentText |? [] match tag.kind with | Kind.JSDocParameterTag -> let tag = tag :?> Ts.JSDocParameterTag @@ -280,18 +307,18 @@ module private ParserImpl = | tagName -> Other (tagName, text, tag) - let readJSDocComments (docComment: ResizeArray) (tags: Ts.JSDocTag seq) : Comment list = + let readJSDocComments (docComment: Ts.SymbolDisplayPart[]) (tags: Ts.JSDocTag[]) : Comment list = let desc = let text = docComment - |> List.ofSeq + |> List.ofArray |> List.collect (fun sdp -> sdp.text |> sanitizeCommentText) if List.isEmpty text then [] else [Description text] let tags = tags - |> Seq.map readJSDocTag - |> List.ofSeq + |> Array.map readJSDocTag + |> List.ofArray desc @ tags let readCommentsForNamedDeclaration (ctx: ParserContext) (nd: Ts.NamedDeclaration) : Comment list = @@ -313,7 +340,7 @@ module private ParserImpl = | Kind.MethodDeclaration | Kind.Constructor | Kind.GetAccessor | Kind.SetAccessor | Kind.FunctionExpression | Kind.ArrowFunction -> try - match ctx.checker.getSignatureFromDeclaration nd with + match ctx.checker.getSignatureFromDeclaration !!nd with | None -> fallback () | Some signature -> @@ -360,22 +387,22 @@ module private ParserImpl = | Kind.ArrayType -> let t = t :?> Ts.ArrayTypeNode let elem = readTypeNode typrm ctx t.elementType - if isReadOnly t.modifiers then + if isReadOnly (modifiers t) then App (APrim ReadonlyArray, [elem], Node.location t) else App (APrim Array, [elem], Node.location t) | Kind.TupleType -> let t = t :?> Ts.TupleTypeNode - readTupleTypeNode typrm ctx t (isReadOnly t.modifiers) + readTupleTypeNode typrm ctx t (t |> modifiers |> isReadOnly) // complex types | Kind.IntrinsicKeyword -> Intrinsic | Kind.ThisType -> PolymorphicThis | Kind.UnionType -> let t = t :?> Ts.UnionTypeNode - Union { types = t.types |> Seq.map (readTypeNode typrm ctx) |> List.ofSeq } + Union { types = t.types |> Array.map (readTypeNode typrm ctx) |> List.ofArray } | Kind.IntersectionType -> let t = t :?> Ts.IntersectionTypeNode - Intersection { types = t.types |> Seq.map (readTypeNode typrm ctx) |> List.ofSeq } + Intersection { types = t.types |> Array.map (readTypeNode typrm ctx) |> List.ofArray } | Kind.ParenthesizedType -> readTypeNode typrm ctx ((t :?> Ts.ParenthesizedTypeNode).``type``) // ident, possibly tyapp @@ -387,12 +414,14 @@ module private ParserImpl = match t.kind with | Kind.TypeReference -> !!(t :?> Ts.TypeReferenceNode).typeName | Kind.ExpressionWithTypeArguments -> !!(t :?> Ts.ExpressionWithTypeArguments).expression - | _ -> failwith "impossible" + | _ -> impossible "readTypeNode_TypeReference" + let arity = getArityOfIdentType ctx lhs match readIdentOrTypeVar ctx typrm lhs with | Choice1Of2 lt -> + let lt = lt |> getArityOfIdentType ctx lhs match t.typeArguments with | None -> Ident lt - | Some args -> App (AIdent lt, args |> Seq.map (readTypeNode typrm ctx) |> List.ofSeq, Node.location t) + | Some args -> App (AIdent lt, args |> Array.map (readTypeNode typrm ctx) |> List.ofArray, Node.location t) | Choice2Of2 x -> TypeVar x | Kind.FunctionType -> let t = t :?> Ts.FunctionTypeNode @@ -418,9 +447,9 @@ module private ParserImpl = // anonymous interface | Kind.TypeLiteral -> let t = t :?> Ts.TypeLiteralNode - if t.members.Count = 0 then Prim Object // treat {} as just object + if t.members.Length = 0 then Prim Object // treat {} as just object else - let members = t.members |> List.ofSeq |> List.map (readNamedDeclaration typrm ctx) + let members = t.members |> List.ofArray |> List.map (readNamedDeclaration typrm ctx) let temp = { name = Anonymous; isInterface = true; isExported = Exported.No comments = []; implements = []; typeParams = []; accessibility = Public @@ -488,16 +517,16 @@ module private ParserImpl = {| value = readTypeNode typrm ctx x.``type``; name = Some x.name.text |} | _ -> {| value = readTypeNode typrm ctx (xNode :?> Ts.TypeNode); name = None |} - Tuple { types = Seq.map f tuple.elements |> List.ofSeq; isReadOnly = isReadOnly } + Tuple { types = Array.map f tuple.elements |> List.ofArray; isReadOnly = isReadOnly } - and readParameters<'retType> (typrm: Set) (ctx: ParserContext) (ps: Ts.ParameterDeclaration seq) (parent: Ts.Node) (retType: 'retType) : FuncType<'retType> = + and readParameters<'retType> (typrm: Set) (ctx: ParserContext) (ps: Ts.ParameterDeclaration[]) (parent: Ts.Node) (retType: 'retType) : FuncType<'retType> = let isVariadic = - ps |> Seq.exists (fun p -> p.dotDotDotToken |> Option.isSome) + ps |> Array.exists (fun p -> p.dotDotDotToken |> Option.isSome) let args = ps - |> Seq.mapi (fun i p -> + |> Array.mapi (fun i p -> let isOptional = p.questionToken |> Option.isSome - let nameOpt = p.name |> getBindingName ctx + let nameOpt = p.name |> getBindingName let ty = match p.``type`` with | Some t -> readTypeNode typrm ctx t @@ -515,12 +544,13 @@ module private ParserImpl = assert (not isOptional); Choice2Of2 ty ) - |> Seq.toList + |> Array.toList { args = args; isVariadic = isVariadic; returnType = retType; loc = Node.location parent } and readMemberAttribute (ctx: ParserContext) (nd: Ts.NamedDeclaration) : MemberAttribute = - let accessibility = getAccessibility nd.modifiers |> Option.defaultValue Public - let isStatic = hasModifier Kind.StaticKeyword nd.modifiers + let modifiers = modifiers nd + let accessibility = getAccessibility modifiers |? Public + let isStatic = hasModifier Kind.StaticKeyword modifiers let comments = readCommentsForNamedDeclaration ctx nd { accessibility = accessibility; isStatic = isStatic; comments = comments; loc = Node.location nd } @@ -552,7 +582,7 @@ module private ParserImpl = match ty with | Choice1Of2 t -> { args = []; isVariadic = false; returnType = t; loc = Node.location nd } | Choice2Of2 ft -> ft - attr, SymbolIndexer (symbolName, ft, if isReadOnly nd.modifiers then ReadOnly else Mutable) + attr, SymbolIndexer (symbolName, ft, if isReadOnly (modifiers nd) then ReadOnly else Mutable) | _ -> fail () | _ -> fail () @@ -566,22 +596,19 @@ module private ParserImpl = | Some t -> readTypeNode typrm ctx t | None -> UnknownType None match getPropertyName nd.name with - | Some name -> + | Ok name -> match ty with | UnknownType None -> nodeWarn ctx nd "type not specified for field '%s'" (getText nd.name) | _ -> () let isOptional = nd.questionToken |> Option.isSome let fl = { name = name; isOptional = isOptional; value = ty } - attr, Field (fl, (if isReadOnly nd.modifiers then ReadOnly else Mutable)) - | None -> - match getPropertyExpression nd.name with - | Some expr -> readSymbolIndexer expr (Choice1Of2 ty) fail - | None -> fail () + attr, Field (fl, (if isReadOnly !!nd.modifiers then ReadOnly else Mutable)) + | Error expr -> readSymbolIndexer expr (Choice1Of2 ty) fail | Kind.PropertyDeclaration -> let nd = nd :?> Ts.PropertyDeclaration match getPropertyName nd.name with - | Some name -> + | Ok name -> let ty = match nd.``type`` with | Some t -> readTypeNode typrm ctx t @@ -593,8 +620,8 @@ module private ParserImpl = | _ -> () let isOptional = nd.questionToken |> Option.isSome let fl = { name = name; isOptional = isOptional; value = ty } - attr, Field (fl, (if isReadOnly nd.modifiers then ReadOnly else Mutable)) - | None -> nodeWarn ctx nd "unsupported property name '%s' in PropertyDeclaration" (getText nd.name); (attr, UnknownMember (Some (getText nd))) + attr, Field (fl, (if isReadOnly (modifiers nd) then ReadOnly else Mutable)) + | Error _ -> nodeWarn ctx nd "unsupported property name '%s' in PropertyDeclaration" (getText nd.name); (attr, UnknownMember (Some (getText nd))) | Kind.CallSignature -> let nd = nd :?> Ts.CallSignatureDeclaration let localTyprm, ty = extractType nd @@ -607,13 +634,10 @@ module private ParserImpl = let localTyprm, retTy = extractType sdb let typrm = Set.union typrm (localTyprm |> List.map (fun x -> x.name) |> Set.ofList) let func = readParameters typrm ctx sdb.parameters sdb retTy - match sdb.name |> Option.bind getPropertyName with - | Some name -> + match sdb.name |> Result.ofOption |> Result.bind getPropertyName with + | Ok name -> attr, Method (name, func, localTyprm) - | None -> - match sdb.name |> Option.bind getPropertyExpression with - | Some expr -> readSymbolIndexer expr (Choice2Of2 func) fail - | None -> fail () + | Error expr -> readSymbolIndexer expr (Choice2Of2 func) fail | Kind.IndexSignature -> let nd = nd :?> Ts.IndexSignatureDeclaration let localTyprm, ty = extractType nd @@ -639,17 +663,17 @@ module private ParserImpl = | Kind.GetAccessor -> let nd = nd :?> Ts.GetAccessorDeclaration match getPropertyName nd.name with - | Some name -> + | Ok name -> let localTyprm, ty = extractType nd if not (List.isEmpty localTyprm) then nodeWarn ctx nd "getter with type argument is not supported" let isOptional = nd.questionToken |> Option.isSome let fl = { name = name; isOptional = isOptional; value = ty } attr, Getter fl - | None -> nodeWarn ctx nd "unsupported property name '%s' in GetAccessor" (getText nd.name); (attr, UnknownMember (Some (getText nd))) + | Error _ -> nodeWarn ctx nd "unsupported property name '%s' in GetAccessor" (getText nd.name); (attr, UnknownMember (Some (getText nd))) | Kind.SetAccessor -> let nd = nd :?> Ts.SetAccessorDeclaration match getPropertyName nd.name with - | Some name -> + | Ok name -> let localTyprm, retTy = extractType nd assert (match retTy with UnknownType _ -> true | _ -> false) if not (List.isEmpty localTyprm) then nodeWarn ctx nd "setter with type argument is not supported" @@ -659,34 +683,35 @@ module private ParserImpl = | Choice1Of2 named -> attr, Setter { named with name = name } | Choice2Of2 ty -> - attr, Setter { name = name; isOptional = false; value = ty } + let isOptional = nd.questionToken |> Option.isSome + attr, Setter { name = name; isOptional = isOptional; value = ty } | _ -> nodeWarn ctx nd "invalid setter for '%s'" (getText nd.name) attr, UnknownMember (Some (getText nd)) - | None -> nodeWarn ctx nd "unsupported property name '%s' in SetAccessor" (getText nd.name); (attr, UnknownMember (Some (getText nd))) + | Error _ -> nodeWarn ctx nd "unsupported property name '%s' in SetAccessor" (getText nd.name); (attr, UnknownMember (Some (getText nd))) | _ -> nodeWarn ctx nd "unsupported NamedDeclaration kind: '%s'" (Enum.pp nd.kind) attr, UnknownMember (Some (getText nd)) - and readTypeParameters (typrm: Set) (ctx: ParserContext) (tps: Ts.TypeParameterDeclaration ResizeArray option) : TypeParam list = + and readTypeParameters (typrm: Set) (ctx: ParserContext) (tps: Ts.TypeParameterDeclaration[] option) : TypeParam list = match tps with | None -> [] | Some tps -> - let names = tps |> Seq.map (fun tp -> tp.name.text) |> Set.ofSeq |> Set.union typrm + let names = tps |> Array.map (fun tp -> tp.name.text) |> Set.ofArray |> Set.union typrm tps - |> Seq.map (fun tp -> + |> Array.map (fun tp -> let dt = tp.``default`` |> Option.map (readTypeNode names ctx) let et = tp.``constraint`` |> Option.map (readTypeNode names ctx) { name = tp.name.text; extends = et; defaultType = dt } ) - |> Seq.toList + |> Array.toList - let readInherits (typrm: Set) (ctx: ParserContext) (hcs: Ts.HeritageClause ResizeArray option) : Type list = + let readInherits (typrm: Set) (ctx: ParserContext) (hcs: Ts.HeritageClause[] option) : Type list = match hcs with | None -> [] | Some hcs -> - hcs |> Seq.collect (fun hc -> hc.types |> Seq.map (readTypeNode typrm ctx)) - |> Seq.toList + hcs |> Array.collect (fun hc -> hc.types |> Array.map (readTypeNode typrm ctx)) + |> Array.toList let readInterface (ctx: ParserContext) (i: Ts.InterfaceDeclaration) : Class = let name = i.name.getText() @@ -695,35 +720,36 @@ module private ParserImpl = { comments = readCommentsForNamedDeclaration ctx i name = Name name - accessibility = getAccessibility i.modifiers |> Option.defaultValue Public + accessibility = getAccessibility i.modifiers |? Public typeParams = typrms implements = readInherits typrmsSet ctx i.heritageClauses isInterface = true isExported = getExported i.modifiers - members = i.members |> List.ofSeq |> List.map (readNamedDeclaration typrmsSet ctx) + members = i.members |> Array.map (readNamedDeclaration typrmsSet ctx) |> List.ofArray loc = Node.location i } let readClass (ctx: ParserContext) (i: Ts.ClassDeclaration) : Class = let typrms = readTypeParameters Set.empty ctx i.typeParameters let typrmsSet = typrms |> List.map (fun tp -> tp.name) |> Set.ofList + let modifiers = modifiers i { comments = readCommentsForNamedDeclaration ctx i - name = i.name |> Option.map (fun id -> Name id.text) |> Option.defaultValue ExportDefaultUnnamedClass - accessibility = getAccessibility i.modifiers |> Option.defaultValue Public + name = i.name |> Option.map (fun id -> Name id.text) |? ExportDefaultUnnamedClass + accessibility = getAccessibility modifiers |? Public typeParams = typrms implements = readInherits typrmsSet ctx i.heritageClauses isInterface = false - isExported = getExported i.modifiers - members = i.members |> List.ofSeq |> List.map (readNamedDeclaration typrmsSet ctx) + isExported = getExported modifiers + members = i.members |> Array.map (readNamedDeclaration typrmsSet ctx) |> List.ofArray loc = Node.location i } let readEnumCase (ctx: ParserContext) (em: Ts.EnumMember) : EnumCase option = match getPropertyName em.name with - | Some name -> + | Ok name -> let value = - let inline fallback () = + let fallback () = match ctx.checker.getConstantValue(!^em) with | None -> None | Some (U2.Case1 str) -> Some (LString str) @@ -740,13 +766,13 @@ module private ParserImpl = nodeWarn ctx ep "enum value '%s' for case '%s' not supported" (ep.getText()) name) let comments = readCommentsForNamedDeclaration ctx em Some { comments = comments; loc = Node.location em; name = name; value = value } - | None -> nodeWarn ctx em "unsupported enum case name '%s'" (getText em.name); None + | Error _ -> nodeWarn ctx em "unsupported enum case name '%s'" (getText em.name); None let readEnum (ctx: ParserContext) (ed: Ts.EnumDeclaration) : Enum = { name = ed.name.text comments = readCommentsForNamedDeclaration ctx ed - cases = ed.members |> List.ofSeq |> List.choose (readEnumCase ctx) + cases = ed.members |> Array.choose (readEnumCase ctx) |> List.ofArray isExported = getExported ed.modifiers loc = Node.location ed } @@ -758,9 +784,9 @@ module private ParserImpl = { name = a.name.text; typeParams = typrm; target = ty; comments = comments; isExported = getExported a.modifiers; loc = Node.location a } let readVariable (ctx: ParserContext) (v: Ts.VariableStatement) : Statement list = - v.declarationList.declarations |> List.ofSeq |> List.map (fun vd -> + v.declarationList.declarations |> Array.map (fun vd -> let comments = readCommentsForNamedDeclaration ctx vd - match getBindingName ctx vd.name with + match getBindingName vd.name with | None -> nodeWarn ctx vd "name is not defined for variable" UnknownStatement {| origText = Some (vd.getText()); loc = Node.location vd; comments = comments |} @@ -783,10 +809,11 @@ module private ParserImpl = nodeWarn ctx vd "type missing for variable '%s'" name UnknownType None let isConst = (int vd.flags) ||| (int Ts.NodeFlags.Const) <> 0 - let isExported = getExported vd.modifiers - let accessibility = getAccessibility vd.modifiers + let modifiers = modifiers vd + let isExported = getExported modifiers + let accessibility = getAccessibility modifiers Variable { comments = comments; loc = Node.location vd; name = name; typ = ty; isConst = isConst; isExported = isExported; accessibility = accessibility } - ) + ) |> List.ofArray let readFunction (ctx: ParserContext) (f: Ts.FunctionDeclaration) : Function option = match f.name with @@ -839,12 +866,12 @@ module private ParserImpl = let nes = bindings |> box :?> Ts.NamedExports let clauses = nes.elements - |> Seq.map (fun x -> - let inline ident (name: Ts.Identifier) = readIdent ctx name + |> Array.map (fun x -> + let ident (name: Ts.Identifier) = readIdent ctx name match x.propertyName with | None -> ES6ReExport {| target = ident x.name; renameAs = None |} | Some propertyName -> ES6ReExport {| target = ident propertyName; renameAs = Some x.name.text |}) - |> Seq.toList + |> List.ofArray Some clauses | _ -> nodeWarn ctx e "invalid syntax kind '%s' for an export declaration" (Enum.pp kind); None clauses |> Option.map (fun clauses -> @@ -863,12 +890,12 @@ module private ParserImpl = let nes = bindings |> box :?> Ts.NamedExports let clauses = nes.elements - |> Seq.map (fun x -> - let inline ident (name: Ts.Identifier) = readIdent ctx name + |> Array.map (fun x -> + let ident (name: Ts.Identifier) = readIdent ctx name match x.propertyName with | None -> ES6Export {| target = ident x.name; renameAs = None |} | Some propertyName -> ES6Export {| target = ident propertyName; renameAs = Some x.name.text |}) - |> Seq.toList + |> List.ofArray Some [Export { clauses = clauses; loc = Node.location nes; comments = comments; origText = e.getText() }] | _ -> nodeWarn ctx e "invalid syntax kind '%s' for an export declaration" (Enum.pp kind); None | _, _ -> nodeWarn ctx e "this kind of export statement is not supported."; None @@ -878,20 +905,18 @@ module private ParserImpl = let readImportEqualsDeclaration (ctx: ParserContext) (i: Ts.ImportEqualsDeclaration) : Statement option = let comments = readCommentsForNamedDeclaration ctx i - let moduleReference = !!i.moduleReference : Ts.Node - match moduleReference.kind with - | Kind.Identifier | Kind.QualifiedName -> - let kind = getKindFromName ctx moduleReference + match i.moduleReference with + | Ts.ModuleReference.Identifier _ | Ts.ModuleReference.QualifiedName _ -> + let kind = getKindFromName ctx !!i.moduleReference Import { comments = comments; loc = Node.location i; isTypeOnly = i.isTypeOnly; isExported = getExported i.modifiers; - clauses = [LocalImport {| name = i.name.text; kind = kind; target = readIdent ctx moduleReference |}] + clauses = [LocalImport {| name = i.name.text; kind = kind; target = readIdent ctx !!i.moduleReference |}] origText = i.getText() } |> Some - | Kind.ExternalModuleReference -> - let m : Ts.ExternalModuleReference = !!i.moduleReference + | Ts.ModuleReference.ExternalModuleReference m -> match (!!m.expression : Ts.Node).kind with | Kind.StringLiteral -> let moduleSpecifier = (!!m.expression : Ts.StringLiteral).text @@ -906,8 +931,6 @@ module private ParserImpl = } |> Some | kind -> nodeWarn ctx i "invalid kind '%s' for module specifier" (Enum.pp kind); None - | kind -> - nodeWarn ctx i "invalid kind '%s' for import" (Enum.pp kind); None let readImportDeclaration (ctx: ParserContext) (i: Ts.ImportDeclaration) : Statement option = match i.importClause with @@ -917,28 +940,26 @@ module private ParserImpl = | Kind.StringLiteral -> let comments = readCommentsForNamedDeclaration ctx c let moduleSpecifier = (!!i.moduleSpecifier : Ts.StringLiteral).text - let inline create clauses = + let create clauses = Some (Import { comments = comments; loc = Node.location i; isTypeOnly = c.isTypeOnly; isExported = getExported i.modifiers; clauses = clauses; origText = i.getText() }) match c.name, c.namedBindings with | None, None -> create [ES6WildcardImport moduleSpecifier] - | None, Some b when (!!b : Ts.Node).kind = Kind.NamespaceImport -> - let n = (!!b : Ts.NamespaceImport) + | None, Some (Ts.NamedImportBindings.NamespaceImport n) -> let kind = getKindFromName ctx n.name create [NamespaceImport {| name = n.name.text; kind = kind; isES6Import = true; specifier = moduleSpecifier |}] - | _, Some b when (!!b : Ts.Node).kind = Kind.NamedImports -> - let n = (!!b : Ts.NamedImports) + | _, Some (Ts.NamedImportBindings.NamedImports n) -> let spec = {| specifier = moduleSpecifier |} let defaultImport = c.name |> Option.map (fun i -> ES6DefaultImport {| spec with name = i.text; kind = getKindFromName ctx i |}) let bindings = n.elements - |> Seq.toList - |> List.map (fun e -> + |> Array.map (fun e -> let kind = getKindFromName ctx e.name let name, renameAs = match e.propertyName with | Some i -> i.text, Some e.name.text | None -> e.name.text, None ES6Import {| spec with name = name; kind = kind; renameAs = renameAs |}) + |> List.ofArray create (Option.toList defaultImport @ bindings) | Some i, None -> create [ES6DefaultImport {| name = i.text; kind = getKindFromName ctx i; specifier = moduleSpecifier |}] @@ -951,11 +972,11 @@ module private ParserImpl = let desc = doc.comment |> Option.map (readCommentText >> Description >> List.singleton) - |> Option.defaultValue [] + |? [] let tags = doc.tags - |> Option.map (Seq.map readJSDocTag >> List.ofSeq) - |> Option.defaultValue [] + |> Option.map (Array.map readJSDocTag >> List.ofArray) + |? [] desc @ tags let readJSDoc (ctx: ParserContext) (doc: Ts.JSDoc) : Statement option = @@ -964,27 +985,16 @@ module private ParserImpl = | xs -> FloatingComment {| comments = xs; loc = Node.location doc |} |> Some let rec readModule (ctx: ParserContext) (md: Ts.ModuleDeclaration) : Statement = - let name = - match (!!md.name : Ts.Node).kind with - | Kind.GlobalKeyword -> None - | Kind.Identifier -> - match (!!md.name : Ts.Identifier).text with - | "global" -> None - | name -> Some name - | Kind.StringLiteral -> (!!md.name : Ts.StringLiteral).text |> Some - | _ -> nodeError ctx !!md.name "unsupported module name '%s'" (getText md.name) let check kind = - md.getChildren() |> Seq.exists (fun nd -> nd.kind = kind) - let isNamespace = check Kind.NamespaceKeyword - let isExported = getExported md.modifiers - let statements = + md.getChildren() |> Array.exists (fun nd -> nd.kind = kind) + let statements ctx = md.getChildren() - |> Seq.toList + |> Array.toList |> List.collect (fun nd -> match nd.kind with | Kind.ModuleBlock -> let mb = nd :?> Ts.ModuleBlock - mb.statements |> List.ofSeq |> List.collect (readStatement ctx) + mb.statements |> List.ofArray |> List.collect (readStatement ctx) | Kind.NamespaceKeyword | Kind.ExportKeyword | Kind.Identifier | Kind.DeclareKeyword | Kind.StringLiteral | Kind.DotToken | Kind.SyntaxList | Kind.ModuleKeyword -> [] | Kind.JSDocComment -> [] @@ -995,14 +1005,20 @@ module private ParserImpl = []) let comments = md.getChildren() - |> Seq.filter (fun nd -> nd.kind = Kind.JSDocComment) - |> List.ofSeq + |> Array.filter (fun nd -> nd.kind = Kind.JSDocComment) + |> List.ofArray |> List.collect (fun nd -> nd :?> Ts.JSDoc |> readJSDocImpl ctx) - match name with - | Some name -> - Module { isExported = isExported; isNamespace = isNamespace; name = name; statements = statements; comments = comments; loc = Node.location md } - | None -> - Global { isExported = isExported; isNamespace = isNamespace; name = (); statements = statements; comments = comments; loc = Node.location md } + let loc = Node.location md + match md.name with + | ModuleName.Identifier i -> + if i.text = "global" then + Global { name = (); isExported = (); statements = statements ctx; comments = comments; loc = loc } + else + let isExported = getExported md.modifiers + Namespace { name = i.text; isExported = isExported; statements = statements ctx; comments = comments; loc = loc } + | ModuleName.StringLiteral s -> + let orig = $"\"{s.text}\"" + AmbientModule { name = { orig = orig; unquoted = s.text }; isExported = (); statements = statements ctx; comments = comments; loc = loc } and readStatement (ctx: ParserContext) (stmt: Ts.Statement) : Statement list = let onError () = @@ -1033,13 +1049,13 @@ module private ParserImpl = module Node = Node.Api /// works on NodeJS only. -let private getAllLocalReferences (ctx: #IContext<#IOptions>) (sourceFiles: Ts.SourceFile seq) = +let private getAllLocalReferences (ctx: #IContext<#IOptions>) (sourceFiles: Ts.SourceFile[]) = let sourceFilesMap = new MutableMap<_, _>() for sourceFile in sourceFiles do sourceFilesMap.Add(Path.absolute sourceFile.fileName, sourceFile) let createSourceFile path = - ts.createSourceFile(path, Node.fs.readFileSync(path, "utf-8"), Ts.ScriptTarget.Latest, setParentNodes=true, scriptKind=Ts.ScriptKind.TS) + ts.createSourceFile(path, Node.fs.readFileSync(path, "utf-8"), !^Ts.ScriptTarget.Latest, setParentNodes=true, scriptKind=Ts.ScriptKind.TS) let tryAdd (from: Ts.SourceFile) path = let path = Path.absolute path @@ -1097,8 +1113,7 @@ let private getAllLocalReferences (ctx: #IContext<#IOptions>) (sourceFiles: Ts.S open DataTypes -let createDependencyGraph (sourceFiles: Ts.SourceFile seq) = - let sourceFiles = Array.ofSeq sourceFiles +let createDependencyGraph (sourceFiles: Ts.SourceFile[]) = let files = sourceFiles |> Array.map (fun sf -> sf.fileName, sf) |> Map.ofArray let mutable graph = Graph.empty @@ -1116,7 +1131,7 @@ let createDependencyGraph (sourceFiles: Ts.SourceFile seq) = |> Option.iter (fun target -> graph <- graph |> Graph.add sourceFile.fileName target.fileName) - let go (sourceFile: Ts.SourceFile) (ns: Ts.Node seq) = + let go (sourceFile: Ts.SourceFile) (ns: Ts.Node[]) = for n in ns do match n.kind with | Ts.SyntaxKind.ImportEqualsDeclaration -> @@ -1129,22 +1144,22 @@ let createDependencyGraph (sourceFiles: Ts.SourceFile seq) = n.moduleSpecifier |> handleModuleSpecifier sourceFile | _ -> () - ns |> Seq.collect (fun n -> n.getChildren(sourceFile)) + ns |> Array.collect (fun n -> n.getChildren(sourceFile)) let goSourceFile (sourceFile: Ts.SourceFile) = - let mutable nodes : Ts.Node seq = !!sourceFile.statements - while not (nodes |> Seq.isEmpty) do + let mutable nodes : Ts.Node[] = !!sourceFile.statements + while not (nodes |> Array.isEmpty) do nodes <- go sourceFile nodes for source in sourceFiles do goSourceFile source graph -let assertFileExistsAndHasCorrectExtension (fileName: string) = +let assertFileExistsAndHasCorrectExtension (ctx: #IContext<#IOptions>) (fileName: string) = assertNode () if not <| Node.fs.existsSync(!^fileName) then - failwithf "file '%s' does not exist" fileName - if fileName.EndsWith(".d.ts") |> not then - failwithf "file '%s' is not a TypeScript declaration file" fileName + ctx.logger.errorf "file '%s' does not exist" fileName + if fileName.EndsWith(".ts") |> not then + ctx.logger.errorf "file '%s' is not a TypeScript file" fileName fileName let createContextFromFiles (ctx: #IContext<#IOptions>) compilerOptions (fileNames: string[]) : ParserContext = @@ -1154,14 +1169,14 @@ let createContextFromFiles (ctx: #IContext<#IOptions>) compilerOptions (fileName if not ctx.options.followRelativeReferences then fileNames |> Array.map Path.absolute - |> Array.map assertFileExistsAndHasCorrectExtension + |> Array.map (assertFileExistsAndHasCorrectExtension ctx) else fileNames - |> Seq.map Path.absolute - |> Seq.map assertFileExistsAndHasCorrectExtension - |> Seq.map (fun a -> a, Node.fs.readFileSync(a, "utf-8")) - |> Seq.map (fun (a, i) -> - ts.createSourceFile (a, i, Ts.ScriptTarget.Latest, setParentNodes=true, scriptKind=Ts.ScriptKind.TS)) + |> Array.map Path.absolute + |> Array.map (assertFileExistsAndHasCorrectExtension ctx) + |> Array.map (fun a -> a, Node.fs.readFileSync(a, "utf-8")) + |> Array.map (fun (a, i) -> + ts.createSourceFile (a, i, !^Ts.ScriptTarget.Latest, setParentNodes=true, scriptKind=Ts.ScriptKind.TS)) |> fun srcs -> ctx.logger.tracef "* following relative references..." getAllLocalReferences ctx srcs |> fst @@ -1173,12 +1188,13 @@ let createContextFromFiles (ctx: #IContext<#IOptions>) compilerOptions (fileName checker = program.getTypeChecker() fileNames = fileNames currentSource = (null : Ts.SourceFile) + currentAmbientModule = (None : string option) |} let createContextFromString (ctx: #IContext<#IOptions>) compilerOptions (files: {| fileName: string; text: string |} seq) : ParserContext = let sourceFiles = files - |> Seq.map (fun x -> ts.createSourceFile (x.fileName, x.text, Ts.ScriptTarget.Latest, setParentNodes=true, scriptKind=Ts.ScriptKind.TS)) + |> Seq.map (fun x -> ts.createSourceFile (x.fileName, x.text, !^Ts.ScriptTarget.Latest, setParentNodes=true, scriptKind=Ts.ScriptKind.TS)) |> Seq.toArray let program = TypeScriptHelper.createProgramForBrowser sourceFiles compilerOptions !!{| @@ -1188,34 +1204,35 @@ let createContextFromString (ctx: #IContext<#IOptions>) compilerOptions (files: checker = program.getTypeChecker() fileNames = files |> Seq.map (fun x -> x.fileName) |> Seq.toArray currentSource = (null : Ts.SourceFile) + currentAmbientModule = (None : string option) |} let parse (ctx: ParserContext) : Input = let srcs = let targets = ctx.fileNames |> Set.ofArray ctx.program.getSourceFiles() - |> Seq.filter (fun sf -> targets |> Set.contains sf.fileName) + |> Array.filter (fun sf -> targets |> Set.contains sf.fileName) let sources = srcs - |> Seq.map (fun src -> + |> Array.map (fun src -> ctx.logger.tracef "* parsing %s..." src.fileName let references = - Seq.concat [ - src.referencedFiles |> Seq.map (fun x -> FileReference x.fileName) - src.typeReferenceDirectives |> Seq.map (fun x -> TypeReference x.fileName) - src.libReferenceDirectives |> Seq.map (fun x -> LibReference x.fileName) - ] |> Seq.toList + Array.concat [ + src.referencedFiles |> Array.map (fun x -> FileReference x.fileName) + src.typeReferenceDirectives |> Array.map (fun x -> TypeReference x.fileName) + src.libReferenceDirectives |> Array.map (fun x -> LibReference x.fileName) + ] |> Array.toList let statements = src.statements - |> Seq.collect ( + |> Array.toList + |> List.collect ( ParserImpl.readStatement (ctx |> JS.cloneWith (fun ctx -> ctx.currentSource <- src))) - |> Seq.toList { statements = statements fileName = src.fileName hasNoDefaultLib = src.hasNoDefaultLib references = references }) - |> List.ofSeq + |> List.ofArray let info = match sources with diff --git a/lib/Syntax.fs b/lib/Syntax.fs index cdda94db..0e4cb6e8 100644 --- a/lib/Syntax.fs +++ b/lib/Syntax.fs @@ -45,12 +45,12 @@ with sprintf "line %i, col %i of %s" (int pos.line + 1) (int pos.character + 1) - src.fileName + (Path.relativeToCwd src.fileName) | Location l -> sprintf "line %i, col %i of %s" (int l.line + 1) (int l.character + 1) - l.src.fileName + (Path.relativeToCwd l.src.fileName) | MultipleLocation l -> l |> List.map (fun x -> x.AsString) |> String.concat " and " | UnknownLocation -> "" @@ -199,13 +199,29 @@ and TupleType = { isReadOnly: bool } -and Ident = { +and IdentMiscData = { + maxArity: int option + /// if true, then this ident was created by ts2ocaml. + /// otherwise, then this ident came from `.d.ts`. + internallyCreated: bool +} with + static member Empty = { + maxArity = None + internallyCreated = false + } + static member Internal = { IdentMiscData.Empty with internallyCreated = true } + +and [] Ident = { name: string list kind: Set option fullName: FullName list loc: Location parent: Ident option -} + misc: IdentMiscData +} with + member i.AsString = + String.concat "." i.name + " (at " + i.loc.AsString + ")" + override i.ToString() = i.AsString and [] FullName = { source: Path.Absolute @@ -357,15 +373,15 @@ and Statement = /// ``` | Enum of Enum /// ```ts - /// module Name { ... } + /// namespace Name { ... } /// ``` - /// or + | Namespace of Namespace /// ```ts - /// namespace Name { ... } + /// declare module "name" { ... } /// ``` - | Module of Module + | AmbientModule of AmbientModule /// ```ts - /// namespace global { ... } + /// declare global { ... } /// ``` | Global of Global /// ```ts @@ -399,23 +415,26 @@ and Statement = member this.loc = match this with | TypeAlias ta -> ta.loc | Class c -> c.loc | Enum e -> e.loc - | Module m -> m.loc | Global m -> m.loc | Variable v -> v.loc | Function f -> f.loc + | Namespace m -> m.loc | AmbientModule m -> m.loc | Global m -> m.loc + | Variable v -> v.loc | Function f -> f.loc | Import i -> i.loc | Export e -> e.loc | ReExport e -> e.loc | Pattern p -> p.loc | UnknownStatement u -> u.loc | FloatingComment c -> c.loc member this.isExported = match this with | TypeAlias { isExported = i } | Class { isExported = i } - | Enum { isExported = i } | Module { isExported = i } + | Enum { isExported = i } | Namespace { isExported = i } | Variable { isExported = i } | Function { isExported = i } | Import { isExported = i } -> i | Pattern p -> p.isExported + | AmbientModule _ -> Exported.Declared | Export _ | ReExport _ | UnknownStatement _ | FloatingComment _ | Global _ -> Exported.No interface ICommented with member this.getComments() = match this with | TypeAlias ta -> ta.comments | Class c -> c.comments - | Enum e -> e.comments | Module m -> m.comments | Global m -> m.comments + | Enum e -> e.comments + | Namespace m -> m.comments | AmbientModule m -> m.comments | Global m -> m.comments | Variable v -> v.comments | Function f -> f.comments | Import i -> i.comments | Export e -> e.comments | ReExport e -> e.comments @@ -428,7 +447,8 @@ and Statement = | TypeAlias ta -> TypeAlias (map f ta) | Class c -> Class (map f c) | Enum e -> Enum (map f e) - | Module m -> Module (map f m) + | Namespace m -> Namespace (map f m) + | AmbientModule m -> AmbientModule (map f m) | Global m -> Global (map f m) | Variable v -> Variable (map f v) | Function g -> Function (map f g) @@ -483,20 +503,25 @@ and Pattern = | ImmediateConstructor (bi, ci, v) -> ImmediateConstructor ((bi :> ICommented<_>).mapComments f, (ci :> ICommented<_>).mapComments f, (v :> ICommented<_>).mapComments f) -and Module<'name> = { +and NamespaceLike<'name, 'exported> = { name: 'name - isExported: Exported - isNamespace: bool + isExported: 'exported statements: Statement list comments: Comment list loc: Location } with - interface ICommented> with + interface ICommented> with member this.getComments() = this.comments member this.mapComments f = { this with comments = f this.comments } -and Module = Module -and Global = Module +and Namespace = NamespaceLike +and QuotedString = { + /// This is used in TyperContext. + orig: string + unquoted: string +} +and AmbientModule = NamespaceLike +and Global = NamespaceLike and Export = { comments: Comment list diff --git a/lib/TypeScriptHelper.fs b/lib/TypeScriptHelper.fs index 87fd4895..566d3a40 100644 --- a/lib/TypeScriptHelper.fs +++ b/lib/TypeScriptHelper.fs @@ -7,7 +7,7 @@ let defaultCompilerOptions = jsOptions(fun o -> o.target <- Some Ts.ScriptTarget.Latest o.noEmit <- Some true - o.moduleResolution <- Some Ts.ModuleResolutionKind.Node12 + o.moduleResolution <- Some Ts.ModuleResolutionKind.NodeNext ) type IDummyCompilerHost = @@ -43,12 +43,12 @@ let createDummyCompilerHost (fileNames: string[]) (sourceFiles: Ts.SourceFile[]) !!host let createProgramForNode (fileNames: string[]) (options: Ts.CompilerOptions) = - ts.createProgram(ResizeArray fileNames, options, ts.createCompilerHost(options, true)) + ts.createProgram(fileNames, options, ts.createCompilerHost(options, true)) let createProgramForBrowser (sourceFiles: Ts.SourceFile[]) (options: Ts.CompilerOptions) = let fileNames = sourceFiles |> Array.map (fun s -> s.fileName) ts.createProgram( - ResizeArray (sourceFiles |> Array.map (fun s -> s.fileName)), + sourceFiles |> Array.map (fun s -> s.fileName), options, createDummyCompilerHost fileNames sourceFiles ) diff --git a/lib/Typer.fs b/lib/Typer.fs index a0678200..380a220a 100644 --- a/lib/Typer.fs +++ b/lib/Typer.fs @@ -16,6 +16,10 @@ type TyperOptions = /// Make class inherit `PromiseLike` when it has `then(onfulfilled: T => _, onrejected: _)`. abstract inheritPromiselike: bool with get,set + /// Make class contain all the members inherited from the parent classes. + /// Useful for targets without proper nominal subtyping. + abstract addAllParentMembersToClass: bool with get,set + /// Replaces alias to function type with named interface. /// ```ts /// type F = (...) => T // before @@ -44,7 +48,7 @@ type [] Definition = | Class of Class | Enum of Enum | EnumCase of EnumCase * Enum - | Module of Module + | Namespace of Namespace | Variable of Variable | Function of Function | Import of ImportClause * Import @@ -54,7 +58,7 @@ type [] InheritingType = | KnownIdent of {| fullName: FullName; tyargs: Type list |} | Prim of PrimType * tyargs:Type list | Other of Type - | UnknownIdent of {| name: string list; tyargs: Type list |} + | UnknownIdent of {| name: string list; tyargs: Type list; maxArity: int option |} type AnonymousInterfaceOrigin = { // the name of the type containing the anonymous interface. @@ -83,11 +87,27 @@ type AnonymousInterfaceInfo = { origin: AnonymousInterfaceOrigin } +type [] KnownType = + | Ident of fullName:FullName + | AnonymousInterface of AnonymousInterface * AnonymousInterfaceInfo + +type [] ExportType = + | Child of ExportType * path:string list + | CommonJS + | ES6Default + | ES6 of renameAs:string option +with + member this.CreateChild(name) = + match this with + | Child (e, path) -> Child (e, path @ [name]) + | e -> Child (e, [name]) + type SourceFileInfo = { sourceFile: SourceFile definitionsMap: Trie typeLiteralsMap: Map anonymousInterfacesMap: Map + exportMap: Trie unknownIdentTypes: Trie> } @@ -116,7 +136,7 @@ type TyperContext<'Options, 'State when 'Options :> IOptions> = private { member this.logger = this.logger let inline private warn (ctx: IContext<_>) (loc: Location) fmt = - Printf.kprintf (fun s -> ctx.logger.warnf "%s at %s" s loc.AsString) fmt + Printf.kprintf (fun s -> ctx.logger.warnf "%s at %s" s (Path.relativeToCwd loc.AsString)) fmt module TyperContext = type private Anonoymous<'Options, 'State when 'Options :> IOptions> = {| @@ -167,6 +187,8 @@ module TyperContext = | _ -> List.rev ctx._currentNamespace @ name { name = name; source = ctx._currentSourceFile } + let getFullNameOfCurrentNamespace (ctx: TyperContext<'a, 's>) : FullName = getFullName [] ctx + let getFullNameString (name: string list) (ctx: TyperContext<'a, 's>) = (getFullName name ctx).name |> String.concat "." @@ -188,6 +210,11 @@ module TyperContext = ctx.logger.errorf "%s not in [%s]" ctx._currentSourceFile (ctx._info |> Map.toSeq |> Seq.map fst |> String.concat ", ") ctx._info |> Map.tryFind ctx._currentSourceFile |> Option.bind f + let getExportTypeOfName (name: string list) (ctx: TyperContext<'a, 's>) = + ctx |> bindCurrentSourceInfo (fun info -> + info.exportMap |> Trie.tryFind (ctx.currentNamespace @ name) + ) + module FullName = let getDefinitions (ctx: TyperContext<_, _>) (fullName: FullName) : Definition list = match ctx.info |> Map.tryFind fullName.source with @@ -195,16 +222,21 @@ module FullName = | Some info -> info.definitionsMap |> Trie.tryFind fullName.name - |> Option.defaultValue [] + |? [] + + let getExportType (ctx: TyperContext<_, _>) (fullName: FullName) : ExportType option = + match ctx.info |> Map.tryFind fullName.source with + | None -> None + | Some info -> info.exportMap |> Trie.tryFind fullName.name let private classify = function | Definition.TypeAlias _ -> Kind.OfTypeAlias | Definition.Class c -> if c.isInterface then Kind.OfInterface else Kind.OfClass | Definition.Enum _ -> Kind.OfEnum | Definition.EnumCase _ -> Kind.OfEnumCase - | Definition.Module m -> if m.isNamespace then Kind.OfNamespace else Kind.OfModule + | Definition.Namespace _ -> Kind.OfNamespace | Definition.Variable _ | Definition.Function _ -> Kind.OfValue - | Definition.Import (c, _) -> c.kind |> Option.map Set.toList |> Option.defaultValue [] + | Definition.Import (c, _) -> c.kind |> Option.map Set.toList |? [] | Definition.Member _ -> Kind.OfMember let hasKind (ctx: TyperContext<_, _>) (kind: Kind) (fullName: FullName) = @@ -235,6 +267,12 @@ module Ident = let pickDefinitionWithFullName ctx ident (picker: FullName -> Definition -> _ option) = getDefinitionsWithFullName ctx ident |> List.tryPick (fun x -> picker x.fullName x.definition) + let collectDefinition ctx ident collector = + getDefinitions ctx ident |> List.collect collector + + let collectDefinitionWithFullName ctx ident (collector: FullName -> Definition -> _ list) = + getDefinitionsWithFullName ctx ident |> List.collect (fun x -> collector x.fullName x.definition) + let hasKind (ctx: TyperContext<_, _>) (kind: Kind) (ident: Ident) = match ident.kind with | Some kinds -> kinds |> Set.contains kind @@ -270,6 +308,12 @@ module Type = args = List.map (mapInArg mapping ctx) f.args } and mapInClass mapping (ctx: 'Context) (c: Class<'a>) : Class<'a> = + { c with + implements = c.implements |> List.map (mapping ctx) + members = c.members |> List.map (mapInMember mapping ctx) + typeParams = c.typeParams |> List.map (mapInTypeParam mapping ctx) } + + and mapInMember mapping ctx (ma, m) = let mapMember = function | Field (f, m) -> Field (mapInFieldLike mapping ctx f, m) | Callable (f, tps) -> Callable (mapInFuncType mapping ctx f, List.map (mapInTypeParam mapping ctx) tps) @@ -281,10 +325,7 @@ module Type = | Method (name, f, tps) -> Method (name, mapInFuncType mapping ctx f, List.map (mapInTypeParam mapping ctx) tps) | SymbolIndexer (sn, ft, m) -> SymbolIndexer (sn, mapInFuncType mapping ctx ft, m) | UnknownMember msgo -> UnknownMember msgo - { c with - implements = c.implements |> List.map (mapping ctx) - members = c.members |> List.map (fun (a, m) -> a, mapMember m) - typeParams = c.typeParams |> List.map (mapInTypeParam mapping ctx) } + ma, mapMember m and mapInFieldLike mapping (ctx: 'Context) (fl: FieldLike) : FieldLike = { fl with value = mapping ctx fl.value } @@ -381,8 +422,8 @@ module Type = let rec findTypesInFieldLike pred s (fl: FieldLike) = findTypes pred s fl.value and findTypesInTypeParam pred s (tp: TypeParam) = seq { - yield! tp.extends |> Option.map (findTypes pred s) |> Option.defaultValue Seq.empty - yield! tp.defaultType |> Option.map (findTypes pred s) |> Option.defaultValue Seq.empty + yield! tp.extends |> Option.map (findTypes pred s) |? Seq.empty + yield! tp.defaultType |> Option.map (findTypes pred s) |? Seq.empty } and findTypesInFuncType pred s (ft: FuncType) = seq { @@ -507,6 +548,14 @@ module Type = | [] -> [] maxArity :: go maxArity typrms |> Set.ofList + let matchArity arity (typrms: TypeParam list) : TypeParam list option = + let rec go i acc = function + | tp :: rest when i > 0 -> go (i-1) (tp :: acc) rest + | { defaultType = None } :: _ -> None + | { defaultType = Some _ } :: rest -> go 0 acc rest + | [] -> if i = 0 then List.rev acc |> Some else None + go arity [] typrms + let createFunctionInterface (funcs: {| ty: FuncType; typrms: TypeParam list; comments: Comment list; loc: Location; isNewable: bool |} list) = let usedTyprms = funcs |> Seq.collect (fun f -> getTypeVars (Func (f.ty, f.typrms, f.loc))) |> Set.ofSeq @@ -606,14 +655,17 @@ module Type = |> Seq.map (fun (t, d) -> substTypeVarInInheritingType subst ctx t, d) |> Some | _ -> None ) |> Seq.concat - | Ident { name = name } & Dummy ts | App (AIdent { name = name }, ts, _) -> + | Ident { name = name; misc = misc } & Dummy ts | App (AIdent { name = name; misc = misc }, ts, _) -> yield! treatPrimTypeInterfaces name ts |> Option.toList if includeSelf then - yield InheritingType.UnknownIdent {| name = name; tyargs = ts |}, depth + yield InheritingType.UnknownIdent {| name = name; tyargs = ts; maxArity = misc.maxArity |}, depth | Prim p & Dummy ts | App (APrim p, ts, _) -> if includeSelf then yield InheritingType.Prim (p, ts), depth + | Intersection i -> + for t in i.types do + yield! getAllInheritancesImpl (depth+1) includeSelf ctx t | _ -> if includeSelf then yield InheritingType.Other ty, depth @@ -635,7 +687,10 @@ module Type = |> List.choose (function | Definition.Class c -> let self = - InheritingType.KnownIdent {| fullName = fn; tyargs = c.typeParams |> List.map (fun tp -> TypeVar tp.name) |} + InheritingType.KnownIdent {| + fullName = fn + tyargs = c.typeParams |> List.map (fun tp -> TypeVar tp.name) + |} let s = c.implements |> Seq.collect (getAllInheritancesImpl (depth+1) true ctx) Some (s, Some self) | Definition.TypeAlias a -> @@ -676,6 +731,25 @@ module Type = let getAllInheritancesAndSelf ctx ty = getAllInheritancesImpl 0 true ctx ty |> removeDuplicatesFromInheritingTypes let getAllInheritancesAndSelfFromName ctx fn = getAllInheritancesFromNameImpl 0 true ctx fn |> removeDuplicatesFromInheritingTypes + let isSuperClass ctx (super: Type) (sub: Type) = + Set.isProperSubset (getAllInheritancesAndSelf ctx super) (getAllInheritancesAndSelf ctx sub) + + let isSubClass ctx (sub: Type) (super: Type) = + Set.isProperSuperset (getAllInheritancesAndSelf ctx super) (getAllInheritancesAndSelf ctx sub) + + let getKnownTypes (ctx: TyperContext<_, _>) t = + findTypes (fun state -> function + | Ident { fullName = fns } -> None, state, List.map KnownType.Ident fns + | AnonymousInterface a -> + let info = + ctx |> TyperContext.bindCurrentSourceInfo (fun info -> info.anonymousInterfacesMap |> Map.tryFind a) + None, state, + match info with + | None -> [] + | Some info -> [KnownType.AnonymousInterface (a, info)] + | _ -> None, state, [] + ) () t |> Set.ofSeq + let rec resolveErasedTypeImpl typeQueries ctx = function | PolymorphicThis -> PolymorphicThis | Intrinsic -> Intrinsic | Ident i -> Ident i | TypeVar v -> TypeVar v | Prim p -> Prim p | TypeLiteral l -> TypeLiteral l @@ -936,63 +1010,9 @@ module Type = s1 + s2 | UnknownType _ -> "unknown" -type [] KnownType = - | Ident of fullName:FullName - | AnonymousInterface of AnonymousInterface * AnonymousInterfaceInfo - module Statement = open Type - let createDefinitionsMap (stmts: Statement list) : Trie = - let add ns name x trie = - let key = List.rev (name :: ns) - trie |> Trie.addOrUpdate key [x] List.append - let rec go (ns: string list) trie s = - match s with - | Export _ - | ReExport _ - | UnknownStatement _ - | FloatingComment _ -> trie - | Import import -> - import.clauses - |> List.fold (fun trie c -> - match c with - | NamespaceImport i -> trie |> add ns i.name (Definition.Import (c, import)) - | ES6WildcardImport _ -> trie - | ES6Import i -> trie |> add ns i.name (Definition.Import (c, import)) - | ES6DefaultImport i -> trie |> add ns i.name (Definition.Import (c, import)) - | LocalImport i -> trie |> add ns i.name (Definition.Import (c, import)) - ) trie - | TypeAlias a -> trie |> add ns a.name (Definition.TypeAlias a) - | Class c -> - match c.name with - | Name name -> - c.members - |> List.fold (fun trie (ma, m) -> - let ns = name :: ns - let d = Definition.Member (ma, m, c) - match m with - | Field (fl, _) | Getter fl | Setter fl -> trie |> add ns fl.name d - | Method (n, _, _) -> trie |> add ns n d - | _ -> trie - ) trie - |> add ns name (Definition.Class c) - | ExportDefaultUnnamedClass -> trie - | Enum e -> - e.cases - |> List.fold (fun trie c -> trie |> add (e.name :: ns) c.name (Definition.EnumCase (c, e))) trie - |> add ns e.name (Definition.Enum e) - | Variable v -> trie |> add ns v.name (Definition.Variable v) - | Function f -> trie |> add ns f.name (Definition.Function f) - | Pattern p -> p.underlyingStatements |> List.fold (go ns) trie - | Module m -> - m.statements - |> List.fold (go (m.name :: ns)) trie - |> add ns m.name (Definition.Module m) - | Global m -> - m.statements |> List.fold (go []) trie - stmts |> List.fold (go []) Trie.empty - type StatementFinder<'State, 'Result> = string list -> 'State -> Statement -> Statement list option * 'State * 'Result seq @@ -1005,14 +1025,14 @@ module Statement = match stmts with | Some stmts -> match stmt with - | Module { name = name } -> + | Namespace { name = name } -> yield! go (name :: ns) state stmts | _ -> yield! go ns state stmts | None -> match stmt with - | Module { name = name; statements = statements } -> + | Namespace { name = name; statements = statements } -> yield! go (name :: ns) state statements - | Global { statements = statements } -> + | Global { statements = statements } | AmbientModule { statements = statements } -> yield! go [] state statements | Pattern p -> yield! go ns state p.underlyingStatements @@ -1049,11 +1069,11 @@ module Statement = | Pattern p -> for stmt in p.underlyingStatements do yield! go ns state stmt - | Module m -> + | Namespace m -> for stmt in m.statements do yield! go (m.name :: ns) state stmt - | Global m -> - for stmt in m.statements do + | AmbientModule { statements = statements } | Global { statements = statements } -> + for stmt in statements do yield! go [] state stmt } stmts |> Seq.collect (go [] state) @@ -1078,8 +1098,8 @@ module Statement = and treatTypeParameters (state: {| origin: AnonymousInterfaceOrigin; namespace_: string list |}) (tps: TypeParam list) = seq { for tp in tps do - yield! tp.extends |> Option.map (findTypes typeFinder state) |> Option.defaultValue Seq.empty - yield! tp.defaultType |> Option.map (findTypes typeFinder state) |> Option.defaultValue Seq.empty + yield! tp.extends |> Option.map (findTypes typeFinder state) |? Seq.empty + yield! tp.defaultType |> Option.map (findTypes typeFinder state) |? Seq.empty } and treatNamed (state: {| origin: AnonymousInterfaceOrigin; namespace_: string list |}) name value = findTypes typeFinder {| state with origin = { state.origin with valueName = Some name } |} value @@ -1194,8 +1214,8 @@ module Statement = | ReExport e -> ReExport e | Variable v -> Variable (mapVariable v) | Function f -> Function (mapFunction f) - | Module m -> - Module { + | Namespace m -> + Namespace { m with statements = mapTypeWith @@ -1218,6 +1238,18 @@ module Statement = (ctx |> ctxOfRoot) m.statements } + | AmbientModule m -> + AmbientModule { + m with + statements = + mapTypeWith + overrideFunc + mapping + ctxOfChildNamespace + ctxOfRoot + (ctx |> ctxOfChildNamespace m.name.orig) + m.statements + } | UnknownStatement u -> UnknownStatement u | FloatingComment c -> FloatingComment c | Pattern (ImmediateInstance (i, v)) -> Pattern (ImmediateInstance (mapInClass mapping ctx i, mapVariable v)) @@ -1262,32 +1294,32 @@ module Statement = type Class<'a> with /// check if an interface consists only of fields and properties (but not methods) /// - /// setters are ignored + /// setters and indexers are ignored member this.isPOJO : bool = this.isInterface && this.members |> List.exists (fun (_, m) -> match m with Field _ | Getter _ -> true | _ -> false) && this.members - |> List.filter (fun (_, m) -> match m with Setter _ | UnknownMember _ -> false | _ -> true) + |> List.filter (fun (_, m) -> match m with Setter _ | UnknownMember _ | Indexer _ -> false | _ -> true) |> List.forall (fun (_, m) -> match m with | Field _ | Getter _ -> true - | Method _ | Callable _ | Newable _ | Indexer _ | Constructor _ | SymbolIndexer _ -> false - | Setter _ | UnknownMember _ -> true // impossible + | Method _ | Callable _ | Newable _ | Constructor _ | SymbolIndexer _ -> false + | Setter _ | UnknownMember _ | Indexer _ -> true // impossible ) /// check if an interface consists only of fields, properties, and methods (but not callable, newable, etc) /// - /// setters are ignored + /// setters and indexers are ignored member this.isPOJOWithMethods : bool = this.isInterface && this.members |> List.exists (fun (_, m) -> match m with Field _ | Getter _ | Method _ -> true | _ -> false) && this.members - |> List.filter (fun (_, m) -> match m with Setter _ | UnknownMember _ -> false | _ -> true) + |> List.filter (fun (_, m) -> match m with Setter _ | UnknownMember _ | Indexer _ -> false | _ -> true) |> List.forall (fun (_, m) -> match m with | Field _ | Getter _ | Method _ -> true - | Callable _ | Newable _ | Indexer _ | Constructor _ | SymbolIndexer _ -> false - | Setter _ | UnknownMember _ -> true // impossible + | Callable _ | Newable _ | Constructor _ | SymbolIndexer _ -> false + | Setter _ | UnknownMember _ | Indexer _ -> true // impossible ) type [] Typeofable = Number | String | Boolean | Symbol | BigInt @@ -1338,6 +1370,7 @@ module ResolvedUnion = cases |> String.concat " | " let checkNullOrUndefined (u: UnionType) : {| hasNull: bool; hasUndefined: bool; rest: Type list |} = + let u = Type.normalizeUnion u let nullOrUndefined, rest = u.types |> List.partition (function Prim (Null | Undefined) -> true | _ -> false) let hasNull = nullOrUndefined |> List.contains (Prim Null) @@ -1440,7 +1473,7 @@ module ResolvedUnion = let inline getLiteralFieldsFromClass c = getLiteralFieldsFromClass getLiteralFieldsFromType c match ty with | Intrinsic | PolymorphicThis | TypeVar _ | Prim _ | TypeLiteral _ | Tuple _ | Func _ | NewableFunc _ -> Map.empty - | Erased _ -> failwith "impossible_getDiscriminatedFromUnion_getLiteralFieldsFromType_Erased" + | Erased _ -> impossible "getDiscriminatedFromUnion_getLiteralFieldsFromType_Erased" | Union u -> let result = u.types |> List.map getLiteralFieldsFromType result |> List.fold (fun state fields -> @@ -1590,6 +1623,15 @@ module ResolvedUnion = resolveUnionMap <- resolveUnionMap |> Map.add u result result +module Member = + let getActualTypeOfFieldLike (fl: FieldLike) = + if fl.isOptional then + Type.createUnion [Prim Undefined; fl.value] + else + match fl.value with + | Union u -> Union (Type.normalizeUnion u) + | t -> t + let inferEnumCaseValue (stmts: Statement list) : Statement list = let rec go = function | Enum e -> @@ -1605,16 +1647,17 @@ let inferEnumCaseValue (stmts: Statement list) : Statement list = | Some _ -> None { c with value = v }, v Enum { e with cases = e.cases |> List.mapFold f None |> fst } - | Module m -> Module { m with statements = m.statements |> List.map go } + | Namespace m -> Namespace { m with statements = m.statements |> List.map go } | Global m -> Global { m with statements = m.statements |> List.map go } | s -> s stmts |> List.map go let rec mergeStatements (stmts: Statement list) = - let mutable result : Choice list = [] + let mutable result : Choice list = [] let mutable intfMap = Map.empty let mutable nsMap = Map.empty + let mutable amMap = Map.empty let mutable globalM = None let mutable otherStmtSet = Set.empty let mergeTypeParams tps1 tps2 = @@ -1649,38 +1692,51 @@ let rec mergeStatements (stmts: Statement list) = | None -> let iref = ref i intfMap <- (intfMap |> Map.add i.name iref) - result <- Choice2Of4 iref :: result + result <- Choice2Of5 iref :: result | Some iref' -> let i' = iref'.Value assert (i.accessibility = i'.accessibility) let i = { i with isInterface = i.isInterface && i'.isInterface - comments = i.comments @ i'.comments |> List.distinct + comments = List.distinct (i.comments @ i'.comments) loc = i.loc ++ i'.loc typeParams = mergeTypeParams i.typeParams i'.typeParams implements = List.distinct (i.implements @ i'.implements) - members = i.members @ i'.members } + members = List.distinct (i.members @ i'.members) } iref'.Value <- i - | Module n (* when n.isNamespace *) -> + | Namespace n -> match nsMap |> Map.tryFind n.name with | None -> let nref = ref n nsMap <- (nsMap |> Map.add n.name nref) - result <- Choice3Of4 nref :: result + result <- Choice3Of5 nref :: result + | Some nref' -> + let n' = nref'.Value + nref'.Value <- + { n with + loc = n.loc ++ n'.loc + comments = List.distinct (n.comments @ n'.comments) + statements = List.distinct (n'.statements @ n.statements) } + | AmbientModule n -> + match amMap |> Map.tryFind n.name with + | None -> + let nref = ref n + amMap <- (amMap |> Map.add n.name nref) + result <- Choice4Of5 nref :: result | Some nref' -> let n' = nref'.Value nref'.Value <- { n with loc = n.loc ++ n'.loc comments = n.comments @ n'.comments |> List.distinct - statements = n'.statements @ n.statements } + statements = n'.statements @ n.statements |> List.distinct } | Global n -> match globalM with | None -> let nref = ref n globalM <- Some nref - result <- Choice4Of4 nref :: result + result <- Choice5Of5 nref :: result | Some nref -> let n' = nref.Value nref.Value <- @@ -1691,14 +1747,15 @@ let rec mergeStatements (stmts: Statement list) = | stmt -> if otherStmtSet |> Set.contains stmt |> not then otherStmtSet <- otherStmtSet |> Set.add stmt - result <- Choice1Of4 stmt :: result + result <- Choice1Of5 stmt :: result result |> List.rev |> List.map (function - | Choice1Of4 s -> s - | Choice2Of4 i -> Class i.Value - | Choice3Of4 n -> Module { n.Value with statements = mergeStatements n.Value.statements } - | Choice4Of4 n -> Global { n.Value with statements = mergeStatements n.Value.statements } + | Choice1Of5 s -> s + | Choice2Of5 i -> Class i.Value + | Choice3Of5 n -> Namespace { n.Value with statements = mergeStatements n.Value.statements } + | Choice4Of5 n -> AmbientModule { n.Value with statements = mergeStatements n.Value.statements } + | Choice5Of5 n -> Global { n.Value with statements = mergeStatements n.Value.statements } ) let mergeSources newFileName (srcs: SourceFile list) = @@ -1706,7 +1763,7 @@ let mergeSources newFileName (srcs: SourceFile list) = srcs |> List.map (fun src -> src.fileName, newFileName) |> Map.ofList let f (i: Ident) = i |> Ident.mapSource (fun path -> - sourceMapping |> Map.tryFind path |> Option.defaultValue path + sourceMapping |> Map.tryFind path |? path ) let statements = srcs @@ -1770,11 +1827,86 @@ let addDefaultConstructorToClass (ctx: TyperContext<_, _>) (stmts: Statement lis let rec go stmts = stmts |> List.map (function | Class c when not c.isInterface -> Class (addConstructors c |> fst) - | Module m -> Module { m with statements = go m.statements } + | Namespace m -> Namespace { m with statements = go m.statements } + | AmbientModule m -> AmbientModule { m with statements = go m.statements } | Global m -> Global { m with statements = go m.statements } | x -> x) go stmts +[] +type private MemberType = + | Getter of string | Setter of string + | Method of string * int | Callable of int | Newable of int | Indexer of int | Constructor of int + +let addParentMembersToClass (ctx: TyperContext<#TyperOptions, _>) (stmts: Statement list) : Statement list = + if not ctx.options.addAllParentMembersToClass then stmts + else + let m = new MutableMap() + let processing = new MutableSet() + let rec addMembers (c: Class) = + match m.TryGetValue(c.loc) with + | true, c -> c + | false, _ when processing.Contains(c.loc) -> c + | false, _ -> + processing.Add(c.loc) |> ignore + // we remove any parent type which is a super type of some other parent type + let implements = + c.implements + |> List.filter (fun t -> c.implements |> List.forall (fun t' -> Type.isSuperClass ctx t t' |> not)) + let getMemberType m = + match m with + | Field (fl, _) | Getter fl -> MemberType.Getter (fl.name |> String.normalize) |> Some + | Setter fl -> MemberType.Setter (fl.name |> String.normalize) |> Some + | Method (name, ft, _) -> MemberType.Method (name |> String.normalize, ft.args.Length) |> Some + | Callable (ft, _) -> MemberType.Callable (ft.args.Length) |> Some + | Newable (ft, _) -> MemberType.Newable (ft.args.Length) |> Some + | Indexer (ft, _) -> MemberType.Indexer (ft.args.Length) |> Some + | Constructor ft -> MemberType.Constructor (ft.args.Length) |> Some + | SymbolIndexer _ | UnknownMember _ -> None + // if a parent member has the same arity as the member in a child, + // we should only keep the one from the child. + let memberTypes : Set = + c.members |> List.choose (snd >> getMemberType) |> Set.ofList + let parentMembers : (MemberAttribute * Member) list = + let (|Dummy|) _ = [] + let rec collector : _ -> _ list = function + | (Ident ({ loc = loc } & i) & Dummy ts) | App (AIdent i, ts, loc) -> + let collect = function + | Definition.TypeAlias a -> + if List.isEmpty ts then collector a.target + else + let bindings = Type.createBindings i.name loc a.typeParams ts + collector a.target |> List.map (Type.mapInMember (Type.substTypeVar bindings) ()) + // we ignore `implements` clauses i.e. interfaces inherited by a class. + | Definition.Class c' when c.isInterface || not c'.isInterface -> + if List.isEmpty ts then (addMembers c').members + else + let members = (addMembers c').members + let bindings = Type.createBindings i.name loc c'.typeParams ts + members |> List.map (Type.mapInMember (Type.substTypeVar bindings) ()) + | _ -> [] + Ident.collectDefinition ctx i collect |> List.distinct + | Intersection i -> i.types |> List.collect collector |> List.distinct + | _ -> [] + implements + |> List.collect collector + |> List.filter (fun (_, m) -> + match getMemberType m with + | None -> false + | Some mt -> memberTypes |> Set.contains mt |> not) + |> List.distinct + let c = { c with members = c.members @ parentMembers } + m[c.loc] <- c + c + let rec go stmts = + stmts |> List.map (function + | Class c when c.isInterface -> Class (addMembers c) + | Namespace m -> Namespace { m with statements = go m.statements } + | AmbientModule m -> AmbientModule { m with statements = go m.statements } + | Global m -> Global { m with statements = go m.statements } + | x -> x) + go stmts + let introduceAdditionalInheritance (ctx: IContext<#TyperOptions>) (stmts: Statement list) : Statement list = let opts = ctx.options let rec go stmts = @@ -1790,8 +1922,16 @@ let introduceAdditionalInheritance (ctx: IContext<#TyperOptions>) (stmts: Statem | _ -> false ) - let inline app t ts loc = - App (AIdent { name = [t]; kind = Some (Set.ofList [Kind.Type; Kind.ClassLike; Kind.Statement]); fullName = []; loc = loc; parent = None}, ts, loc) + let inline app esVersion t ts loc = + App ( + AIdent { + name = [t] + kind = Some (Set.ofList [Kind.Type; Kind.ClassLike; Kind.Statement]) + fullName = [{ name = [t]; source = Path.absolute $"./node_modules/typescript/lib/lib.{esVersion}.d.ts" }] + loc = loc + parent = None + misc = { IdentMiscData.Internal with maxArity = Some (List.length ts) } + }, ts, loc) for ma, m in c.members do match m with @@ -1799,42 +1939,43 @@ let introduceAdditionalInheritance (ctx: IContext<#TyperOptions>) (stmts: Statem | SymbolIndexer ("iterator", { returnType = ty }, _) when opts.inheritIterable -> match ty with | App (AIdent { name = ["Iterator"] }, [argTy], _) when not (has "Iterable") -> - inherits.Add(app "Iterable" [argTy] ma.loc) + inherits.Add(app "es2015.iterable" "Iterable" [argTy] ma.loc) | App (AIdent { name = ["IterableIterator"] }, [argTy], _) when not (has "IterableIterator") -> - inherits.Add(app "IterableIterator" [argTy] ma.loc) + inherits.Add(app "es2015.iterable" "IterableIterator" [argTy] ma.loc) | _ -> () // async iterator & iterable iterator | SymbolIndexer ("asyncIterator", { returnType = ty }, _) when opts.inheritIterable -> match ty with | App (AIdent { name = ["AsyncIterator"] }, [argTy], _) when not (has "AsyncIterable") -> - inherits.Add(app "AsyncIterable" [argTy] ma.loc) + inherits.Add(app "es2018.asynciterable" "AsyncIterable" [argTy] ma.loc) | App (AIdent { name = ["AsyncIterableIterator"] }, [argTy], _) when not (has "AsyncIterableIterator") -> - inherits.Add(app "AsyncIterableIterator" [argTy] ma.loc) + inherits.Add(app "es2018.asynciterable" "AsyncIterableIterator" [argTy] ma.loc) | _ -> () // ArrayLike | Indexer ({ args = [Choice1Of2 { value = Prim Number } | Choice2Of2 (Prim Number)]; returnType = retTy }, _) - when opts.inheritArraylike && not (has "ArrayLike") -> inherits.Add(app "ArrayLike" [retTy] ma.loc) + when opts.inheritArraylike && not (has "ArrayLike") -> inherits.Add(app "es5" "ArrayLike" [retTy] ma.loc) // PromiseLike | Method ("then", { args = [Choice1Of2 { name = "onfulfilled"; value = onfulfilled }; Choice1Of2 { name = "onrejected" }] }, _) when opts.inheritPromiselike && not (has "PromiseLike") -> match onfulfilled with | Func ({ args = [Choice1Of2 { value = t } | Choice2Of2 t] }, _, _) -> - inherits.Add(app "PromiseLike" [t] ma.loc) + inherits.Add(app "es5" "PromiseLike" [t] ma.loc) | Union { types = ts } -> for t in ts do match t with | Func ({ args = [Choice1Of2 { value = t } | Choice2Of2 t] }, _, _) -> - inherits.Add(app "PromiseLike" [t] ma.loc) + inherits.Add(app "es5" "PromiseLike" [t] ma.loc) | _ -> () | _ -> () | _ -> () Class { c with implements = List.ofSeq inherits |> List.distinct } - | Module m -> Module { m with statements = go m.statements } + | Namespace m -> Namespace { m with statements = go m.statements } + | AmbientModule m -> AmbientModule { m with statements = go m.statements } | Global m -> Global { m with statements = go m.statements } | x -> x ) @@ -1897,7 +2038,8 @@ let detectPatterns (stmts: Statement list) : Statement list = if immediateCtors.Contains origName then None else Some (Class intf) else Some (Class intf) - | Module m -> Some (Module { m with statements = go m.statements }) + | Namespace m -> Some (Namespace { m with statements = go m.statements }) + | AmbientModule m -> Some (AmbientModule { m with statements = go m.statements }) | Global m -> Global { m with statements = go m.statements } |> Some | x -> Some x ) @@ -1905,7 +2047,8 @@ let detectPatterns (stmts: Statement list) : Statement list = let replaceAliasToFunction (ctx: #IContext<#TyperOptions>) stmts = let rec go = function - | Module m -> Module { m with statements = List.map go m.statements } + | Namespace m -> Namespace { m with statements = List.map go m.statements } + | AmbientModule m -> AmbientModule { m with statements = List.map go m.statements } | Global m -> Global { m with statements = List.map go m.statements } | TypeAlias ta -> match ta.target with @@ -1982,16 +2125,128 @@ let replaceFunctions (ctx: #IContext<#TyperOptions>) (stmts: Statement list) = | _ -> None Statement.mapTypeWith goStatement goType (fun _ x -> x) id ctx stmts +let createExportMap (stmts: Statement list) : Trie = + let add ns name xo trie = + match xo with + | Some x -> trie |> Trie.add (List.rev (name :: ns)) x + | None -> trie + let rec go (eo: ExportType option) (ns: string list) trie stmts = + let exportMap = + stmts + |> List.collect (function + | Export e -> + e.clauses |> List.choose (function + | CommonJsExport { name = [name] } -> + Some (name, ExportType.CommonJS) + | ES6DefaultExport { name = [name] } -> + Some (name, ExportType.ES6Default) + | ES6Export e when e.target.name.Length = 1 -> + let name = e.target.name[0] + Some (name, ExportType.ES6 e.renameAs) + | _ -> None + ) + | _ -> []) + |> Map.ofList + let getExportType name (isExported: Exported) = + match isExported with + | Exported.Yes -> Some (ExportType.ES6 None) + | Exported.Default -> Some ExportType.ES6Default + | Exported.Declared | Exported.No -> + match exportMap |> Map.tryFind name with + | Some e -> Some e + | None -> eo |> Option.map (fun e -> e.CreateChild name) + let rec f trie s = + match s with + | Export _ | ReExport _ | UnknownStatement _ | FloatingComment _ | Import _ | TypeAlias _ -> trie + | Pattern p -> p.underlyingStatements |> List.fold f trie + | Namespace m -> + let eo = getExportType m.name m.isExported + let trie = trie |> add ns m.name eo + go eo (m.name :: ns) trie m.statements + | AmbientModule m -> go None (m.name.orig :: ns) trie m.statements + | Global m -> go None [] trie m.statements + | Class c -> + if c.isInterface then trie + else + match c.name with + | ExportDefaultUnnamedClass -> trie + | Name n -> trie |> add ns n (getExportType n c.isExported) + | Enum e -> + let eo = getExportType e.name e.isExported + let trie = trie |> add ns e.name eo + e.cases |> List.fold (fun trie c -> + let ceo = eo |> Option.map (fun e -> e.CreateChild c.name) + trie |> add (e.name :: ns) c.name ceo + ) trie + | Variable { name = name; isExported = isExported } + | Function { name = name; isExported = isExported } -> + trie |> add ns name (getExportType name isExported) + stmts |> List.fold f trie + go None [] Trie.empty stmts + +let createDefinitionsMap (stmts: Statement list) : Trie = + let add ns name x trie = + let key = List.rev (name :: ns) + trie |> Trie.addOrUpdate key [x] List.append + let rec go (ns: string list) trie s = + match s with + | Export _ + | ReExport _ + | UnknownStatement _ + | FloatingComment _ -> trie + | Import import -> + import.clauses + |> List.fold (fun trie c -> + match c with + | NamespaceImport i -> trie |> add ns i.name (Definition.Import (c, import)) + | ES6WildcardImport _ -> trie + | ES6Import i -> trie |> add ns i.name (Definition.Import (c, import)) + | ES6DefaultImport i -> trie |> add ns i.name (Definition.Import (c, import)) + | LocalImport i -> trie |> add ns i.name (Definition.Import (c, import)) + ) trie + | TypeAlias a -> trie |> add ns a.name (Definition.TypeAlias a) + | Class c -> + match c.name with + | Name name -> + c.members + |> List.fold (fun trie (ma, m) -> + let ns = name :: ns + let d = Definition.Member (ma, m, c) + match m with + | Field (fl, _) | Getter fl | Setter fl -> trie |> add ns fl.name d + | Method (n, _, _) -> trie |> add ns n d + | _ -> trie + ) trie + |> add ns name (Definition.Class c) + | ExportDefaultUnnamedClass -> trie + | Enum e -> + e.cases + |> List.fold (fun trie c -> trie |> add (e.name :: ns) c.name (Definition.EnumCase (c, e))) trie + |> add ns e.name (Definition.Enum e) + | Variable v -> trie |> add ns v.name (Definition.Variable v) + | Function f -> trie |> add ns f.name (Definition.Function f) + | Pattern p -> p.underlyingStatements |> List.fold (go ns) trie + | Namespace m -> + m.statements + |> List.fold (go (m.name :: ns)) trie + |> add ns m.name (Definition.Namespace m) + | AmbientModule m -> + m.statements |> List.fold (go (m.name.orig :: ns)) trie + | Global m -> + m.statements |> List.fold (go []) trie + stmts |> List.fold (go []) Trie.empty + let private createRootContextForTyper (srcs: SourceFile list) (baseCtx: IContext<'Options>) : TyperContext<'Options, unit> = let info = srcs |> List.map (fun sf -> sf.fileName, { sourceFile = sf - definitionsMap = Statement.createDefinitionsMap sf.statements + definitionsMap = createDefinitionsMap sf.statements typeLiteralsMap = Map.empty anonymousInterfacesMap = Map.empty - unknownIdentTypes = Trie.empty }) + unknownIdentTypes = Trie.empty + exportMap = Trie.empty }) |> Map.ofList { _currentSourceFile = ""; _currentNamespace = []; _info = info; _state = () @@ -2009,10 +2264,12 @@ let createRootContext (srcs: SourceFile list) (baseCtx: IContext<'Options>) : Ty Statement.getAnonymousInterfaces stmts |> Seq.mapi (fun i (c, info) -> c, { id = i; namespace_ = info.namespace_; origin = info.origin }) |> Map.ofSeq let uit = Statement.getUnknownIdentTypes ctx stmts + let exm = createExportMap stmts { v with typeLiteralsMap = tlm anonymousInterfacesMap = aim - unknownIdentTypes = uit } + unknownIdentTypes = uit + exportMap = exm } ) } module Ts = TypeScript.Ts @@ -2026,23 +2283,26 @@ let mergeESLibDefinitions (srcs: SourceFile list) = let getESVersionFromFileName (s: string) = let es = s.Split '.' |> Array.tryFind (fun s -> s.StartsWith "es") match es with - | None -> Ts.ScriptTarget.ESNext - | Some "es3" -> Ts.ScriptTarget.ES3 - | Some "es5" -> Ts.ScriptTarget.ES5 - | Some "es6" | Some "es2015" -> Ts.ScriptTarget.ES2015 - | Some "es2016" -> Ts.ScriptTarget.ES2016 - | Some "es2017" -> Ts.ScriptTarget.ES2017 - | Some "es2018" -> Ts.ScriptTarget.ES2018 - | Some "es2019" -> Ts.ScriptTarget.ES2019 - | Some "es2020" -> Ts.ScriptTarget.ES2020 - | Some _ -> Ts.ScriptTarget.ESNext + | None -> Some Ts.ScriptTarget.ESNext + | Some "es3" -> Some Ts.ScriptTarget.ES3 + | Some "es5" -> Some Ts.ScriptTarget.ES5 + | Some "es6" | Some "es2015" -> Some Ts.ScriptTarget.ES2015 + | Some "es2016" -> Some Ts.ScriptTarget.ES2016 + | Some "es2017" -> Some Ts.ScriptTarget.ES2017 + | Some "es2018" -> Some Ts.ScriptTarget.ES2018 + | Some "es2019" -> Some Ts.ScriptTarget.ES2019 + | Some "es2020" -> Some Ts.ScriptTarget.ES2020 + | Some "es2021" -> Some Ts.ScriptTarget.ES2021 + | Some "es2022" -> Some Ts.ScriptTarget.ES2022 + | Some "esnext" -> Some Ts.ScriptTarget.ESNext + | _ -> None let map (parentVersion: Ts.ScriptTarget option) (loc: Location) (x: ICommented<_>) = let esVersion = let rec go = function | UnknownLocation -> None - | LocationTs (sf, _) -> getESVersionFromFileName sf.fileName |> Some - | Location x -> getESVersionFromFileName x.src.fileName |> Some + | LocationTs (sf, _) -> getESVersionFromFileName sf.fileName + | Location x -> getESVersionFromFileName x.src.fileName | MultipleLocation ls -> match ls |> List.choose go with | [] -> None @@ -2059,7 +2319,8 @@ let mergeESLibDefinitions (srcs: SourceFile list) = let rec mapStmt (s: Statement) = let vo, s = map None s.loc s match s with - | Module m -> Module { m with statements = List.map mapStmt m.statements } + | Namespace m -> Namespace { m with statements = List.map mapStmt m.statements } + | AmbientModule m -> AmbientModule { m with statements = List.map mapStmt m.statements } | Global m -> Global { m with statements = List.map mapStmt m.statements } | Enum e -> Enum { e with cases = e.cases |> List.map (fun c -> map vo c.loc c |> snd) } | Class c -> Class { c with members = c.members |> List.map (fun (a, m) -> map vo a.loc a |> snd, m) } @@ -2085,6 +2346,8 @@ let runAll (srcs: SourceFile list) (baseCtx: IContext<#TyperOptions>) = withSourceFileContext ctx (fun ctx src -> src |> mapStatements (fun stmts -> stmts + // add members inherited from parent classes/interfaces to interfaces + |> addParentMembersToClass ctx |> Statement.resolveErasedTypes ctx // add common inheritances which tends not to be defined by `extends` or `implements` |> introduceAdditionalInheritance ctx diff --git a/lib/ts2ml.fsproj b/lib/ts2ml.fsproj index 018e8cf7..0a5e2655 100644 --- a/lib/ts2ml.fsproj +++ b/lib/ts2ml.fsproj @@ -5,6 +5,8 @@ + + diff --git a/package.json b/package.json index b2dd36c4..03d81e0e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ocsigen/ts2ocaml", - "version": "1.4.6", + "version": "2.0.0-alpha.0", "description": "Generate OCaml bindings from TypeScript definitions via the TypeScript compiler API", "repository": { "type": "git", @@ -25,21 +25,25 @@ "main": "./dist/ts2ocaml.js", "bin": "./dist/ts2ocaml.js", "dependencies": { + "@babel/code-frame": "^7.18.6", "browser-or-node": "^2.0.0", - "typescript": "4.6.4", - "yargs": "17.7.1" + "chalk": "^5.0.1", + "typescript": "^5.1.6", + "yargs": "^17.5.1" }, "devDependencies": { "@angular/common": "^16.0.1", "@babel/core": "7.22.1", + "@types/babel__code-frame": "^7.0.3", "@types/react-modal": "3.16.0", "@types/semver": "7.5.0", "@types/vscode": "^1.63.1", - "@types/yargs": "17.0.10", + "@types/yargs": "^17.0.10", "cassandra-driver": "^4.6.3", "cdk8s": "^2.2.41", "monaco-editor": "0.40.0", "react-player": "2.12.0", + "ts2fable": "0.8.0-build.723", "webpack": "5.88.0", "webpack-cli": "5.1.0", "webpack-dev-server": "4.15.0" diff --git a/src/Common.fs b/src/Common.fs index 8d18701a..886a2c06 100644 --- a/src/Common.fs +++ b/src/Common.fs @@ -1,6 +1,32 @@ [] module Common +open Fable.Core + +[] +type FeatureFlag = + | [] Full + | [] Provide + | [] Consume + | [] Off + | [] Default +with + static member Values = [|Full; Provide; Consume; Off; Default|] + + member this.HasProvide = match this with Full | Provide -> true | _ -> false + member this.HasConsume = match this with Full | Consume -> true | _ -> false + member this.IsOffOrDefault = match this with Off | Default -> true | _ -> false + + member this.WithProvide(b: bool) = + match this with + | Provide | Off | Default -> if b then Provide else Off + | Full | Consume -> if b then Full else Consume + + member this.WithConsume(b: bool) = + match this with + | Consume | Off | Default -> if b then Consume else Off + | Full | Provide -> if b then Full else Provide + open Ts2Ml.Common type GlobalOptions = @@ -19,7 +45,14 @@ module Log = let warnf (opt: 'Options) fmt : _ when 'Options :> GlobalOptions = Printf.ksprintf (fun str -> if not opt.nowarn then - eprintfn "warn: %s" str + eprintfn "%s %s" (Chalk.chalk.yellow["warn:"]) str + ) fmt + + let errorf fmt = + Printf.ksprintf (fun str -> + eprintfn "%s %s" (Chalk.chalk.red["error:"]) str + Node.Api.``process``.exit -1 + failwith str ) fmt let createBaseContext (opts: #GlobalOptions) : IContext<_> = @@ -27,7 +60,7 @@ let createBaseContext (opts: #GlobalOptions) : IContext<_> = { new ILogger with member _.tracef fmt = Log.tracef opts fmt member _.warnf fmt = Log.warnf opts fmt - member _.errorf fmt = failwithf fmt + member _.errorf fmt = Log.errorf fmt } { new IContext<_> with member _.options = opts diff --git a/src/Extensions.fs b/src/Extensions.fs index f7c8c4ea..3eadb51d 100644 --- a/src/Extensions.fs +++ b/src/Extensions.fs @@ -59,7 +59,7 @@ type Argv<'T> with :> Argv<'U> member this.addFlag (key: string, f: 'U -> bool, ?descr, ?defaultValue, ?defaultDescr, ?alias) = this.boolean(!^key) - .addImpl(key, descr, dv=(defaultValue |> Option.defaultValue false), ?dd=defaultDescr, ?alias=alias) + .addImpl(key, descr, dv=(defaultValue |? false), ?dd=defaultDescr, ?alias=alias) :> Argv<'U> member this.addCounter (key: string, f: 'U -> int, ?descr, ?alias) = this.count(!^key) @@ -82,3 +82,5 @@ type Argv<'T> with | None -> failwithf "Unknown value '%s' for option '%s'" s key) |> Array.toList) :> Argv<'U> + member this.addDeprecated (key: string, ?msg) = + this.deprecateOption(key, ?msg=msg) diff --git a/src/Main.fs b/src/Main.fs index f69cf6d9..2bcacbfb 100644 --- a/src/Main.fs +++ b/src/Main.fs @@ -5,13 +5,7 @@ open Fable.Core.JsInterop open TypeScript open Syntax -let options = - jsOptions(fun o -> - o.target <- Some Ts.ScriptTarget.Latest - o.noEmit <- Some true - o.moduleResolution <- Some Ts.ModuleResolutionKind.Node12 - //o.traceResolution <- Some true - ) +let options = TypeScriptHelper.defaultCompilerOptions open Yargs diff --git a/src/Targets/JsOfOCaml/Common.fs b/src/Targets/JsOfOCaml/Common.fs index 31f396be..fc09e543 100644 --- a/src/Targets/JsOfOCaml/Common.fs +++ b/src/Targets/JsOfOCaml/Common.fs @@ -15,30 +15,6 @@ with member this.IsOffOrDefault = match this with Off | Default -> true | _ -> false -[] -type FeatureFlag = - | [] Full - | [] Provide - | [] Consume - | [] Off - | [] Default -with - static member Values = [|Full; Provide; Consume; Off; Default|] - - member this.HasProvide = match this with Full | Provide -> true | _ -> false - member this.HasConsume = match this with Full | Consume -> true | _ -> false - member this.IsOffOrDefault = match this with Off | Default -> true | _ -> false - - member this.WithProvide(b: bool) = - match this with - | Provide | Off | Default -> if b then Provide else Off - | Full | Consume -> if b then Full else Consume - - member this.WithConsume(b: bool) = - match this with - | Consume | Off | Default -> if b then Consume else Off - | Full | Provide -> if b then Full else Provide - [] type Simplify = | [] All @@ -111,7 +87,6 @@ type Options = abstract subtyping: Subtyping list with get, set abstract inheritWithTags: FeatureFlag with get, set abstract recModule: RecModule with get, set - abstract safeArity: FeatureFlag with get, set abstract simplify: Simplify list with get, set abstract readableNames: bool with get, set abstract functor: Functor with get, set @@ -139,8 +114,6 @@ module Options = opts.recModule <- RecModule.Optimized if p = Preset.Safe || p = Preset.Full then - if opts.safeArity = FeatureFlag.Default then - opts.safeArity <- FeatureFlag.Full if subtypingIsDefault then opts.subtyping <- Subtyping.CastFunction :: opts.subtyping @@ -239,12 +212,6 @@ module Options = "functor" ], "Code Generator Options:") - .addChoice( - "safe-arity", - FeatureFlag.Values, - (fun (o: Options) -> o.safeArity), - descr="Use `TypeName.t_n` type names to safely use overloaded types from other packages.", - defaultValue=FeatureFlag.Default) .addChoice( "rec-module", RecModule.Values, @@ -272,6 +239,18 @@ module Options = defaultValue=Functor.On ) + .group( + !^ResizeArray[ + "safe-arity"; + ], + "Deprecated Options:") + .addOption( + "safe-arity", + (fun (o: Options) -> ""), + descr="Use `TypeName.t_n` type names to safely use overloaded types from other packages.", + defaultValue="") + .addDeprecated("safe-arity", "now optimal by default.") + .middleware(!^validate) diff --git a/src/Targets/JsOfOCaml/OCamlHelper.fs b/src/Targets/JsOfOCaml/OCamlHelper.fs index 37727746..b1f4cfef 100644 --- a/src/Targets/JsOfOCaml/OCamlHelper.fs +++ b/src/Targets/JsOfOCaml/OCamlHelper.fs @@ -298,6 +298,20 @@ let external_ name tyarg tyret extName = // we don't sanitize names in OCamlHelper; callers should do it themselves module Naming = + let keywords = + Set.ofList [ + "and"; "as"; "assert"; "asr"; "begin"; "class"; + "constraint"; "do"; "done"; "downto"; "else"; "end"; + "exception"; "external"; "false"; "for"; "fun"; "function"; + "functor"; "if"; "in"; "include"; "inherit"; "initializer"; + "land"; "lazy"; "let"; "lor"; "lsl"; "lsr"; + "lxor"; "match"; "method"; "mod"; "module"; "mutable"; + "new"; "nonrec"; "object"; "of"; "open"; "or"; + "private"; "rec"; "sig"; "struct"; "then"; "to"; + "true"; "try"; "type"; "val"; "virtual"; "when"; + "while"; "with" + ] + let ourReservedNames = set [ "create"; "apply"; "invoke"; "get"; "set"; "cast_from" @@ -305,12 +319,12 @@ module Naming = let reservedValueNames = Set.unionMany [ - Naming.Keywords.keywords + keywords ourReservedNames ] let removeInvalidChars (s: string) = - s.ToCharArray() + s.Trim('"').ToCharArray() |> Array.map (fun c -> if Char.isAlphabetOrDigit c || c = '_' then c else '_') |> System.String @@ -333,12 +347,12 @@ module Naming = else if Char.IsUpper name.[0] then sprintf "%c%s" (Char.ToLower name.[0]) name.[1..] else name - if Naming.Keywords.keywords |> Set.contains result then result + "_" else result + if keywords |> Set.contains result then result + "_" else result let reservedModuleNames = Set.ofList [ "Export"; "Default" - ] |> Set.union Naming.Keywords.keywords + ] |> Set.union keywords let moduleNameReserved (name: string) = let name = removeInvalidChars name @@ -358,7 +372,7 @@ module Naming = if Char.IsLower s.[0] then sprintf "%c%s" (Char.ToUpper s.[0]) s.[1..] else s - if Naming.Keywords.keywords |> Set.contains result then result + "_" else result + if keywords |> Set.contains result then result + "_" else result let structured (baseName: string -> string) (name: string list) = let rec prettify = function @@ -372,7 +386,7 @@ module Naming = let result = if Char.IsUpper s.[0] then "_" + s else s - if Naming.Keywords.keywords |> Set.contains result then result + "_" else result + if keywords |> Set.contains result then result + "_" else result let createTypeNameOfArity arity maxArityOpt name = match maxArityOpt with @@ -406,11 +420,17 @@ module Kind = Set.intersect kind (Set.ofList [Kind.Type; Kind.ClassLike; Kind.Module]) |> Set.isEmpty |> not let jsBuilder name (fields: {| isOptional: bool; name: string; value: text |} list) (thisType: text) = + let renamer = new OverloadRenamer(used=(fields |> List.map (fun x -> "arg", x.name) |> Set.ofList)) let args = fields + |> List.distinctBy (fun x -> x.name) |> List.map (fun f -> let prefix = if f.isOptional then str "?" else empty - let name = Naming.valueName f.name + let name = + match Naming.valueName f.name with + | "_" -> renamer.Rename "arg" "__" + | s when not (Char.isAlphabet s[0] || s[0] = '_') -> renamer.Rename "arg" $"_{s}" + | name -> name let value = if name = f.name then f.value else diff --git a/src/Targets/JsOfOCaml/Target.fs b/src/Targets/JsOfOCaml/Target.fs index 329b578d..1411f973 100644 --- a/src/Targets/JsOfOCaml/Target.fs +++ b/src/Targets/JsOfOCaml/Target.fs @@ -22,7 +22,7 @@ let private run (input: Input) (ctx: IContext) = if Node.Api.path.isAbsolute dir then dir else Node.Api.path.join [|curdir; dir|] let fail () = - failwithf "The output directory '%s' does not exist." path + ctx.logger.errorf "The output directory '%s' does not exist." path try if Node.Api.fs.lstatSync(!^path).isDirectory() then path else fail () @@ -60,7 +60,7 @@ let private run (input: Input) (ctx: IContext) = .Split([|Node.Api.os.EOL|], System.StringSplitOptions.RemoveEmptyEntries) |> Set.ofArray else - failwithf "The path '%s' is not a file." stubFile + ctx.logger.errorf "The path '%s' is not a file." stubFile let stubLines = Set.union existingStubLines newStubLines if stubLines <> existingStubLines then ctx.logger.tracef "* writing the stub file to '%s'..." stubFile diff --git a/src/Targets/JsOfOCaml/Writer.fs b/src/Targets/JsOfOCaml/Writer.fs index 77dd45e6..600e2635 100644 --- a/src/Targets/JsOfOCaml/Writer.fs +++ b/src/Targets/JsOfOCaml/Writer.fs @@ -100,13 +100,13 @@ let anonymousInterfaceToIdentifier (ctx: Context) (a: AnonymousInterface) : text tprintf "%s.t" (anonymousInterfaceModuleName ctx i) else tprintf "anonymous_interface_%d" i.id - | None -> failwithf "impossible_anonymousInterfaceToIdentifier(%s)" a.loc.AsString + | None -> impossible "anonymousInterfaceToIdentifier(%s)" a.loc.AsString let enumCaseToIdentifier (e: Enum) (c: EnumCase) = let duplicateCases = e.cases |> List.filter (fun c' -> c.value = c'.value) match duplicateCases with - | [] -> failwith "impossible_enumCaseToIdentifier" + | [] -> impossible "enumCaseToIdentifier" | [c'] -> assert (c = c') Naming.constructorName [c.name] @@ -132,9 +132,7 @@ type EmitTypeFlags = { skipAttributesOnContravariantPosition: bool avoidTheseArgumentNames: Set forceVariadic: bool - hasTypeArgumentsHandled: bool forceSkipAttributes: bool - convertNonIdentityPrimitives: bool simplifyContravariantUnion: bool } @@ -148,9 +146,7 @@ module EmitTypeFlags = skipAttributesOnContravariantPosition = false avoidTheseArgumentNames = Set.empty forceVariadic = false - hasTypeArgumentsHandled = false forceSkipAttributes = false - convertNonIdentityPrimitives = false simplifyContravariantUnion = false } @@ -193,7 +189,7 @@ let rec emitTypeImpl (flags: EmitTypeFlags) (overrideFunc: OverrideFunc) (ctx: C let forceSkipAttr text = if flags.forceSkipAttributes then empty else text let treatIdent (i: Ident) (tyargs: Type list) (loc: Location) = let arity = List.length tyargs - let flagsForArgs = { flags with needParen = true; forceVariadic = false; convertNonIdentityPrimitives = true } + let flagsForArgs = { flags with needParen = true; forceVariadic = false } let withTyargs ty = Type.appOpt ty (tyargs |> List.map (emitTypeImpl flagsForArgs overrideFunc ctx)) let origin = @@ -210,10 +206,9 @@ let rec emitTypeImpl (flags: EmitTypeFlags) (overrideFunc: OverrideFunc) (ctx: C let tyName = let fallback () = let tyName = - match ctx.options.safeArity with - | FeatureFlag.Full | FeatureFlag.Consume -> - Naming.createTypeNameOfArity arity None "t" - | _ -> "t" + if Option.isSome i.misc.maxArity then + Naming.createTypeNameOfArity arity i.misc.maxArity "t" + else "t" Naming.structured Naming.moduleName i.name + "." + tyName |> str match i.name with | [name] -> @@ -276,7 +271,7 @@ let rec emitTypeImpl (flags: EmitTypeFlags) (overrideFunc: OverrideFunc) (ctx: C commentStr (sprintf "FIXME: type '%s' cannot be used for variadic argument" (Type.pp ty)) + Type.app Type.array [Type.any] | App (t, ts, loc) -> let emit t ts = - Type.appOpt (emitTypeImpl { flags with hasTypeArgumentsHandled = true } overrideFunc ctx t) (List.map (emitTypeImpl { flags with needParen = true } overrideFunc ctx) ts) + Type.appOpt (emitTypeImpl flags overrideFunc ctx t) (List.map (emitTypeImpl { flags with needParen = true } overrideFunc ctx) ts) match t with | AIdent i -> treatIdent i ts loc | APrim _ | AAnonymousInterface _ -> emit (Type.ofAppLeftHandSide t) ts @@ -356,9 +351,9 @@ let rec emitTypeImpl (flags: EmitTypeFlags) (overrideFunc: OverrideFunc) (ctx: C | [] -> Type.void_ | [t] -> emitTypeImpl flags overrideFunc ctx t.value | ts -> Type.tuple (ts |> List.map (fun x -> emitTypeImpl flags overrideFunc ctx x.value)) - | Erased (_, loc, origText) -> failwithf "impossible_emitTypeImpl_erased: %s (%s)" loc.AsString origText - | Func (_, _ :: _, loc) -> failwithf "impossible_emitTypeImpl_Func_poly: %s (%s)" loc.AsString (Type.pp ty) - | NewableFunc (_, _, loc) -> failwithf "impossible_emitTypeImpl_NewableFunc: %s (%s)" loc.AsString (Type.pp ty) + | Erased (_, loc, origText) -> impossible "emitTypeImpl_erased: %s (%s)" loc.AsString origText + | Func (_, _ :: _, loc) -> impossible "emitTypeImpl_Func_poly: %s (%s)" loc.AsString (Type.pp ty) + | NewableFunc (_, _, loc) -> impossible "emitTypeImpl_NewableFunc: %s (%s)" loc.AsString (Type.pp ty) | UnknownType msgo -> match msgo with None -> commentStr "FIXME: unknown type" + Type.any | Some msg -> commentStr (sprintf "FIXME: unknown type '%s'" msg) + Type.any @@ -409,7 +404,7 @@ and emitUnion (flags: EmitTypeFlags) (overrideFunc: OverrideFunc) (ctx: Context) yield body + skipOnContravariant (Attr.js (Term.literal l)) ]) + forceSkipAttr (tprintf " [@js.union on_field \"%s\"]" tagName) |> between "(" ")" if Map.isEmpty du then - failwith "impossible_emitResolvedUnion_baseType_go" + impossible "emitResolvedUnion_baseType_go" else Map.toList du |> List.map (fun (tagName, cases) -> treatDU tagName cases) @@ -457,7 +452,7 @@ and emitUnion (flags: EmitTypeFlags) (overrideFunc: OverrideFunc) (ctx: Context) Type.app (str "Primitive.t") [cases] match baseType, Set.toList ru.typeofableTypes, ru.caseNull, ru.caseUndefined with - | None, [], false, false -> failwith "impossible_emitUnion_empty_union" + | None, [], false, false -> impossible "emitUnion_empty_union" | None, [], true, false -> Type.null_ | None, [], false, true -> Type.undefined | None, [], true, true when flags.variance = Covariant -> Type.option Type.undefined @@ -499,13 +494,12 @@ and getLabelsFromInheritingTypes (flags: EmitTypeFlags) (overrideFunc: OverrideF | [] -> str (Naming.constructorName name) | [arg] -> tprintf "%s of %A" (Naming.constructorName name) arg | _ -> tprintf "%s of %A" (Naming.constructorName name) (Type.tuple args) - let emitTagType name args = + let emitTagType name args maxArity = let arity = List.length args let tagTypeName = - if ctx.options.safeArity.HasConsume then - Naming.createTypeNameOfArity arity None "tags" - else - "tags" + if Option.isSome maxArity then + Naming.createTypeNameOfArity arity maxArity "tags" + else "tags" let ty = Naming.structured Naming.moduleName name + "." + tagTypeName let args = args |> List.map (emitType_ ctx) Type.appOpt (str ty) args @@ -515,7 +509,7 @@ and getLabelsFromInheritingTypes (flags: EmitTypeFlags) (overrideFunc: OverrideF | InheritingType.KnownIdent i -> yield str pv_head + emitCase i.fullName.name (i.tyargs |> List.map (emitType_ ctx)) |> Case | InheritingType.UnknownIdent i -> - yield emitTagType i.name i.tyargs |> TagType + yield emitTagType i.name i.tyargs i.maxArity |> TagType | InheritingType.Prim (p, ts) -> match p.AsJSClassName with | Some name -> @@ -539,7 +533,11 @@ and getLabelOfFullName flags overrideFunc (ctx: Context) (fullName: FullName) (t let prim = Type.nonJsablePrimitives |> Map.find name Choice2Of2 (prim, Case (tprintf "%s%s" pv_head name)) | _ -> - let inheritingType = InheritingType.KnownIdent {| fullName = fullName; tyargs = typeParams |> List.map (fun tp -> TypeVar tp.name) |} + let inheritingType = + InheritingType.KnownIdent {| + fullName = fullName + tyargs = typeParams |> List.map (fun tp -> TypeVar tp.name) + |} getLabelsFromInheritingTypes flags overrideFunc ctx (Set.singleton inheritingType) |> Choice1Of2 type StructuredTextItem = @@ -563,7 +561,7 @@ with match s1, s2 with | No, No -> No | Force s1, Force s2 when s1 <> s2 -> - failwithf "impossible_Scoped_union(%s, %s)" s1 s2 + impossible "Scoped_union(%s, %s)" s1 s2 | Force s, _ | _, Force s -> Force s | Yes, _ | _, Yes -> Yes @@ -581,6 +579,7 @@ and StructuredText = Trie module StructuredTextNode = let empty : StructuredTextNode = {| scoped = Scoped.No; items = []; docCommentLines = []; exports = []; knownTypes = Set.empty; anonymousInterfaces = Set.empty |} + let union (a: StructuredTextNode) (b: StructuredTextNode) : StructuredTextNode = {| scoped = Scoped.union a.scoped b.scoped items = List.append a.items b.items @@ -589,70 +588,21 @@ module StructuredTextNode = knownTypes = Set.union a.knownTypes b.knownTypes anonymousInterfaces = Set.union a.anonymousInterfaces b.anonymousInterfaces |} + let getReferences (ctx: Context) (v: StructuredTextNode) : WeakTrie = + v.knownTypes + |> Set.fold (fun state -> function + | KnownType.Ident fn when fn.source = ctx.currentSourceFile -> state |> WeakTrie.add fn.name + | KnownType.AnonymousInterface (_, i) -> + state |> WeakTrie.add (i.namespace_ @ [anonymousInterfaceModuleName ctx i]) + | _ -> state + ) WeakTrie.empty + module StructuredTextItem = let emit renamer = function | ImportText t | TypeDef t | ScopeIndependent t -> [t] | Functor _ -> [] | OverloadedText f -> f renamer - -module StructuredText = - let pp (x: StructuredText) = - let rec go (x: StructuredText) = - concat newline [ - for k, v in x.children |> Map.toArray do - tprintf "- %s" k - indent (go v) - ] - go x - - let rec getReferences (ctx: Context) (x: StructuredText) : WeakTrie = - match ctx.state.referencesCache.TryGetValue(ctx.currentNamespace) with - | true, ts -> ts - | false, _ -> - let fn = ctx.currentNamespace - let trie = - x.value - |> Option.map (fun v -> - v.knownTypes - |> Set.fold (fun state -> function - | KnownType.Ident fn when fn.source = ctx.currentSourceFile -> state |> WeakTrie.add fn.name - | KnownType.AnonymousInterface (_, i) -> - state |> WeakTrie.add (i.namespace_ @ [anonymousInterfaceModuleName ctx i]) - | _ -> state - ) WeakTrie.empty) - |> Option.defaultValue WeakTrie.empty - let trie = - x.children - |> Map.fold (fun state k child -> - WeakTrie.union state (getReferences (ctx |> Context.ofChildNamespace k) child)) trie - |> WeakTrie.remove fn - ctx.state.referencesCache.[fn] <- trie - trie - - let getDependenciesOfChildren (ctx: Context) (x: StructuredText) : (string * string) list = - let parent = ctx.currentNamespace - x.children - |> Map.fold (fun state k child -> - let refs = - getReferences (ctx |> Context.ofChildNamespace k) child - |> WeakTrie.getSubTrie parent - |> Option.defaultValue WeakTrie.empty - |> WeakTrie.ofDepth 1 - |> WeakTrie.toList - |> List.map (function - | [x] -> k, x - | xs -> failwithf "impossible_StructuredText_getDependencyGraphOfChildren_refs(%s): %A" (ctx |> Context.getFullNameString [k]) xs) - refs :: state) [] - |> List.rev - |> List.concat - - let calculateSCCOfChildren (ctx: Context) (x: StructuredText) : string list list = - let g = - let deps = getDependenciesOfChildren ctx x - Graph.ofEdges deps - Graph.stronglyConnectedComponents g (x.children |> Map.toList |> List.map fst) - let removeLabels (xs: Choice list) = xs |> List.map (function Choice2Of2 t -> Choice2Of2 t | Choice1Of2 fl -> Choice2Of2 fl.value) @@ -683,7 +633,7 @@ let rec emitMembers flags overrideFunc ctx (selfTy: Type) (ma: MemberAttribute) let ft = func { ft with args = Choice2Of2 selfTy :: ft.args } |> emitType_ ctx yield! comments () yield overloaded (fun rename -> [val_ (rename "create") ft + str " " + Attr.js_apply true]) - | Field ({ name = name; value = Func (ft, _typrm, _) }, _) + | Field ({ name = name; value = Func (ft, _typrm, _); isOptional = false }, _) | Method (name, ft, _typrm) -> let ty, attr = if ma.isStatic then func ft, Attr.js_global name @@ -759,11 +709,11 @@ let rec emitMembers flags overrideFunc ctx (selfTy: Type) (ma: MemberAttribute) let emitMappers (ctx: Context) emitType tName (typrms: TypeParam list) = let t = - { name = [tName]; fullName = []; kind = None; loc = UnknownLocation; parent = None } + { name = [tName]; fullName = []; kind = None; loc = UnknownLocation; parent = None; misc = IdentMiscData.Internal } let t_ty = if List.isEmpty typrms then Ident t else App (AIdent t, typrms |> List.map (fun typrm -> TypeVar typrm.name), UnknownLocation) - let ojs_t = { name = ["Ojs"; "t"]; fullName = []; kind = None; loc = UnknownLocation; parent = None } + let ojs_t = { name = ["Ojs"; "t"]; fullName = []; kind = None; loc = UnknownLocation; parent = None; misc = IdentMiscData.Internal } let ojs_t_ty = Ident ojs_t let orf _flags _emitType _ctx ty = match ty with @@ -795,6 +745,7 @@ let emitTypeAliasesImpl (baseName: string) flags overrideFunc (ctx: Context) + (loc: Location) (typrms: TypeParam list) (target: text) (lines: {| name: string; tyargs:(TypeParam * text) list; target: text; isOverload: bool |} -> 'a list) = @@ -805,26 +756,36 @@ let emitTypeAliasesImpl let arities = getPossibleArity typrms let maxArity = List.length tyargs for arity in arities |> Set.toSeq |> Seq.sortDescending do - if arity <> maxArity || ctx.options.safeArity.HasProvide then + if arity <> maxArity then let name = Naming.createTypeNameOfArity arity None baseName + let tyargs' = List.take arity tyargs let typrms' = List.take arity typrms + + let bindings = + createBindings (ctx.currentNamespace @ [name]) loc + (typrms |> List.skip arity) + (typrms |> List.skip arity |> List.map (fun t -> + match t.defaultType with + | None -> impossible "emitTypeAliases" + | Some t -> t + )) + let target = Type.appOpt (str baseName) [ for tyarg in tyargs' do yield tyarg for t in typrms |> List.skip arity do - match t.defaultType with - | None -> failwith "impossible_emitTypeAliases" - | Some t -> yield emitType_ ctx t + let t' = repeatUntilEquilibrium (substTypeVar bindings ctx) (TypeVar t.name) + yield emitType_ ctx t' ] yield! lines {| name = name; tyargs = List.zip typrms' tyargs'; target = target; isOverload = true |} ] -let emitTypeAliases flags overrideFunc ctx (typrms: TypeParam list) target = +let emitTypeAliases flags overrideFunc ctx loc (typrms: TypeParam list) target = let emitType = emitTypeImpl flags - emitTypeAliasesImpl "t" flags overrideFunc ctx typrms target ( + emitTypeAliasesImpl "t" flags overrideFunc ctx loc typrms target ( fun x -> [ yield typeAlias x.name (x.tyargs |> List.map snd) x.target |> TypeDef yield! emitMappers ctx emitType x.name (x.tyargs |> List.map fst) @@ -884,7 +845,7 @@ module GetSelfTyText = let getExportFromStatement (ctx: Context) (name: string) (kind: Kind list) (kindString: string) (s: Statement) : ExportItem option = let fn = ctx |> Context.getFullName [name] - let ident = { name = [name]; fullName = [fn]; kind = Some (Set.ofList kind); parent = None; loc = s.loc } + let ident = { name = [name]; fullName = [fn]; kind = Some (Set.ofList kind); parent = None; loc = s.loc; misc = IdentMiscData.Internal } match s.isExported.AsExport ident with | None -> None | Some clause -> @@ -895,14 +856,14 @@ let getExportFromStatement (ctx: Context) (name: string) (kind: Kind list) (kind Some (ExportItem.Export {| comments = []; clauses = [clause, Set.ofList kind]; loc = s.loc; origText = sprintf "%s %s %s" prefix kindString name |}) let getTrie name current = - current |> Trie.getSubTrie name |> Option.defaultValue Trie.empty + current |> Trie.getSubTrie name |? Trie.empty let setTrie name trie current = current |> Trie.setSubTrie name trie let inTrie name f current = let m = current |> Trie.getSubTrie name - |> Option.defaultValue Trie.empty + |? Trie.empty |> f current |> Trie.setSubTrie name m let set node current = current |> Trie.setOrUpdate node StructuredTextNode.union @@ -921,7 +882,7 @@ let rec emitClass flags overrideFunc (ctx: Context) (current: StructuredText) (c match c.name with | Choice1Of2 (Name n) -> let k = ctx |> Context.getFullName [n] - let ident = { name = [n]; fullName = [k]; kind = Some (Set.ofList Kind.OfClass); parent = None; loc = UnknownLocation } + let ident = { name = [n]; fullName = [k]; kind = Some (Set.ofList Kind.OfClass); parent = None; loc = UnknownLocation; misc = IdentMiscData.Internal } let selfTy = if List.isEmpty c.typeParams then Ident ident else App (AIdent ident, typrms, UnknownLocation) @@ -935,7 +896,7 @@ let rec emitClass flags overrideFunc (ctx: Context) (current: StructuredText) (c | Choice2Of2 Anonymous -> let ai = c.MapName (fun _ -> Anonymous) match ctx |> Context.bindCurrentSourceInfo (fun info -> info.anonymousInterfacesMap |> Map.tryFind ai) with - | None -> failwith "impossible_emitClass_unknown_anonymousInterface" + | None -> impossible "emitClass_unknown_anonymousInterface" | Some i -> let selfTy = if List.isEmpty c.typeParams then AnonymousInterface ai @@ -969,11 +930,6 @@ let rec emitClass flags overrideFunc (ctx: Context) (current: StructuredText) (c | ClassKind.NormalClass x -> Context.ofChildNamespace x.name | ClassKind.AnonymousInterface x -> Context.ofChildNamespace x.name | ClassKind.ExportDefaultClass _ -> id) - |> Context.mapOptions (fun options -> - if not isAnonymous then options - else - // no need to generate t_n types for anonymous interfaces - ctx.options |> JS.cloneWith (fun o -> o.safeArity <- o.safeArity.WithProvide(false))) let typrms = List.map (fun (tp: TypeParam) -> tprintf "'%s" tp.name) c.typeParams let selfTyText = Type.appOpt (str "t") typrms let currentNamespace = innerCtx |> Context.getFullName [] @@ -1071,7 +1027,7 @@ let rec emitClass flags overrideFunc (ctx: Context) (current: StructuredText) (c match kind with | ClassKind.ExportDefaultClass _ -> Scoped.No | _ -> - let scoped = forceScoped |> Option.defaultValue Scoped.No + let scoped = forceScoped |? Scoped.No let shouldBeScoped = c.members |> List.exists (fun (ma, m) -> if ma.isStatic then true @@ -1087,7 +1043,7 @@ let rec emitClass flags overrideFunc (ctx: Context) (current: StructuredText) (c if useTags && innerCtx.options.inheritWithTags.HasProvide then let alias = emitTypeAliasesImpl - "tags" { flags with forceSkipAttributes = true } overrideFunc innerCtx c.typeParams (emitLabels innerCtx labels) + "tags" { flags with forceSkipAttributes = true } overrideFunc innerCtx c.loc c.typeParams (emitLabels innerCtx labels) (fun x -> [typeAlias x.name (x.tyargs |> List.map snd) x.target]) |> concat newline Attr.js_stop_start_implem alias alias |> TypeDef |> Some @@ -1120,7 +1076,7 @@ let rec emitClass flags overrideFunc (ctx: Context) (current: StructuredText) (c | ClassKind.NormalClass x -> GetSelfTyText.class_ { flags with failContravariantTypeVar = true } overrideFunc innerCtx x.orig | ClassKind.ExportDefaultClass x -> GetSelfTyText.class_ { flags with failContravariantTypeVar = true } overrideFunc innerCtx x.orig | ClassKind.AnonymousInterface _ -> str "private Ojs.t" - emitTypeAliases flags overrideFunc innerCtx c.typeParams selfTyText + emitTypeAliases flags overrideFunc innerCtx c.loc c.typeParams selfTyText let castFunctions = [ // add a generic cast function if tag is available @@ -1180,7 +1136,6 @@ let rec emitClass flags overrideFunc (ctx: Context) (current: StructuredText) (c let nulls, others = u.types |> List.partition (function Prim Null | Prim Undefined -> true | _ -> false) if List.isEmpty nulls then fl.value, fl.isOptional - else if List.isEmpty others then Prim Null, true else Union { types = others }, true | _ -> fl.value, fl.isOptional {| fl with value = value |> emitType_ innerCtx; isOptional = isOptional |} @@ -1282,7 +1237,7 @@ and addAnonymousInterfaceExcluding emitTypeFlags (ctx: Context) knownTypes ais ( let shouldSkip = current.value |> Option.map (fun v -> v.anonymousInterfaces |> Set.contains a) - |> Option.defaultValue false + |? false if shouldSkip then current else emitClass emitTypeFlags OverrideFunc.noOverride ctx current (a.MapName Choice2Of2) ((fun _ _ _ -> []), Set.empty, None) @@ -1338,16 +1293,16 @@ let emitImport (ctx: Context) (i: Import) : StructuredTextItem list = | None -> JsHelper.resolveRelativeImportPath (ctx.state.info |> Result.toOption) ctx.currentSourceFile ctx.state.fileNames specifier |> JsHelper.InferenceResult.tryUnwrap - |> Option.defaultValue specifier + |? specifier |> Naming.jsModuleNameToOCamlModuleName |> Some let isModule (name: string) (kind: Set option) = i.isTypeOnly || kind |> Option.map Kind.generatesOCamlModule - |> Option.defaultValue false + |? false || ctx |> Context.tryCurrentSourceInfo (fun i -> i.unknownIdentTypes |> Trie.containsKey [name]) - |> Option.defaultValue false + |? false || name |> Naming.isCase Naming.PascalCase match c with @@ -1363,16 +1318,16 @@ let emitImport (ctx: Context) (i: Import) : StructuredTextItem list = getModuleName x.specifier |> Option.map (fun moduleName -> [moduleAlias (Naming.moduleName x.name) (sprintf "%s.Export" moduleName) |> ImportText]) - |> Option.defaultValue [] + |? [] | ES6WildcardImport s -> getModuleName s |> Option.map (fun moduleName -> [open_ [sprintf "%s.Export" moduleName] |> ImportText]) - |> Option.defaultValue [] + |? [] | ES6DefaultImport x when isModule x.name x.kind -> getModuleName x.specifier |> Option.map (fun moduleName -> [moduleAlias (Naming.moduleName x.name) (sprintf "%s.Export.Default" moduleName) |> ImportText]) - |> Option.defaultValue [] + |? [] | ES6Import x when isModule x.name x.kind -> let name = match x.renameAs with @@ -1381,7 +1336,7 @@ let emitImport (ctx: Context) (i: Import) : StructuredTextItem list = getModuleName x.specifier |> Option.map (fun moduleName -> [moduleAlias name (sprintf "%s.Export.%s" moduleName (Naming.moduleName x.name)) |> ImportText]) - |> Option.defaultValue [] + |? [] | NamespaceImport _ | ES6DefaultImport _ | ES6Import _ -> [] [ yield! i.comments |> List.map (emitCommentBody >> comment >> ImportText) @@ -1432,7 +1387,7 @@ let createStructuredText (rootCtx: Context) (stmts: Statement list) : Structured let ty = emitType_ ctx (func ft) yield! cmt yield overloaded (fun rename -> [val_ (rename "invoke") ty + str " " + Attr.js_invoke]) - | Constructor _ -> failwith "impossible_emitStructuredDefinition_Pattern_intfToModule_Constructor" // because interface! + | Constructor _ -> impossible "emitStructuredDefinition_Pattern_intfToModule_Constructor" // because interface! | Indexer (ft, _) -> yield ScopeIndependent (comment (tprintf "unsupported indexer of type: %s" (Type.pp (func ft)))) | UnknownMember (Some msg) -> yield ScopeIndependent (commentStr msg) | SymbolIndexer _ | UnknownMember None -> () ] @@ -1454,7 +1409,7 @@ let createStructuredText (rootCtx: Context) (stmts: Statement list) : Structured let addAnonymousInterfaceExcluding ais current = addAnonymousInterfaceExcludingWithKnownTypes (knownTypes ()) ais current match s with - | Module m -> + | Namespace m -> let module' = let node = {| StructuredTextNode.empty with docCommentLines = comments; knownTypes = knownTypes () |} let module' = current |> getTrie [m.name] |> set node @@ -1468,7 +1423,14 @@ let createStructuredText (rootCtx: Context) (stmts: Statement list) : Structured let kind = if v.scoped <> Scoped.No then Kind.OfModule else Kind.OfNamespace - current |> addExport m.name kind (if m.isNamespace then "namespace" else "module") + current |> addExport m.name kind "namespace" + | AmbientModule m -> + let module' = + let node = {| StructuredTextNode.empty with docCommentLines = comments; knownTypes = knownTypes (); scoped = Scoped.Force (m.name.unquoted) |} + let module' = current |> getTrie [m.name.orig] |> set node + let ctx = ctx |> Context.ofChildNamespace m.name.orig + m.statements |> List.fold (folder ctx) module' + current |> setTrie [m.name.orig] module' | Global m -> m.statements |> List.fold (folder ctx) current | Class c -> emitClass emitTypeFlags OverrideFunc.noOverride ctx current (c.MapName Choice1Of2) ((fun _ _ _ -> []), Set.empty, None) @@ -1476,7 +1438,7 @@ let createStructuredText (rootCtx: Context) (stmts: Statement list) : Structured current |> inTrie [e.name] (fun module' -> let ctx = ctx |> Context.ofChildNamespace e.name - let items = emitTypeAliases emitTypeFlags OverrideFunc.noOverride ctx [] (GetSelfTyText.enumCases e e.cases) + let items = emitTypeAliases emitTypeFlags OverrideFunc.noOverride ctx e.loc [] (GetSelfTyText.enumCases e e.cases) let module' = let node = {| StructuredTextNode.empty with items = items; docCommentLines = comments; knownTypes = knownTypes () |} module' |> set node @@ -1484,7 +1446,7 @@ let createStructuredText (rootCtx: Context) (stmts: Statement list) : Structured let ctx = ctx |> Context.ofChildNamespace c.name let comments = List.map emitCommentBody c.comments let items = - emitTypeAliases emitTypeFlags OverrideFunc.noOverride ctx [] (GetSelfTyText.enumCases e [c]) + emitTypeAliases emitTypeFlags OverrideFunc.noOverride ctx e.loc [] (GetSelfTyText.enumCases e [c]) let node = {| StructuredTextNode.empty with items = items; docCommentLines = comments; knownTypes = knownTypes () |} state |> add [c.name] node ) module') @@ -1492,7 +1454,7 @@ let createStructuredText (rootCtx: Context) (stmts: Statement list) : Structured | TypeAlias ta -> let ctx = ctx |> Context.ofChildNamespace ta.name let items = - emitTypeAliases emitTypeFlags OverrideFunc.noOverride ctx ta.typeParams (emitSelfType ctx ta.target) + emitTypeAliases emitTypeFlags OverrideFunc.noOverride ctx ta.loc ta.typeParams (emitSelfType ctx ta.target) let node = {| StructuredTextNode.empty with items = items; docCommentLines = comments; knownTypes = knownTypes () |} current |> inTrie [ta.name] (set node) @@ -1608,30 +1570,92 @@ let createStructuredText (rootCtx: Context) (stmts: Statement list) : Structured stmts |> List.fold (folder rootCtx) Trie.empty -type ModuleEmitter = Context -> StructuredText -> (TextModuleSig list -> text list) +type ModuleEmitter = Context -> (TextModuleSig list -> text list) module ModuleEmitter = - let nonRec _ctx _st modules = moduleSigNonRec modules - let recAll _ctx _st modules = moduleSigRec modules - let recOptimized (ctx: Context) (st: StructuredText) = - if Map.count st.children < 3 then - recAll ctx st - else - let scc = StructuredText.calculateSCCOfChildren ctx st - fun (modules: TextModuleSig list) -> - let modules = modules |> List.fold (fun state x -> state |> Map.add x.origName x) Map.empty + let nonRec _ctx modules = moduleSigNonRec modules + let recAll _ctx modules = moduleSigRec modules + let recOptimized dt (ctx: Context) = + let scc = dt |> Trie.tryFind ctx.currentNamespace |? [] + let sccSet = scc |> List.concat |> Set.ofList + fun (modules: TextModuleSig list) -> + let modulesMap = modules |> List.fold (fun state x -> state |> Map.add x.origName x) Map.empty + let sccModules = scc |> List.map (fun group -> - group |> List.map (fun name -> modules |> Map.find name) |> moduleSigRec) + group |> List.choose (fun name -> modulesMap |> Map.tryFind name) |> moduleSigRec) |> List.concat - let fromOption (opt: Options) = + let otherModules = + modules + |> List.filter (fun x -> sccSet |> Set.contains x.origName |> not) + |> moduleSigNonRec + sccModules @ otherModules + let create (dt: DependencyTrie) (opt: Options) : ModuleEmitter = match opt.recModule with | RecModule.Off | RecModule.Default -> nonRec | RecModule.Naive -> recAll - | RecModule.Optimized -> recOptimized + | RecModule.Optimized -> recOptimized dt type ExportWithKind = {| comments: Comment list; clauses: (ExportClause * Set) list; loc: Location; origText: string |} -let rec emitExportModule (moduleEmitter: ModuleEmitter) (ctx: Context) (exports: ExportItem list) : text list = +let rec private emitStructuredText (reserved: bool) (moduleEmitter: ModuleEmitter) (ctx: Context) (st: StructuredText) : {| scoped: Scoped; imports: text list; content: text list; docCommentBody: text list |} = + let renamer = new OverloadRenamer() + let modules : TextModuleSig list = + st.children + |> Map.toList + |> List.map (fun (k, v) -> + let name = + let name = + if reserved then Naming.moduleNameReserved k + else Naming.moduleName k + name |> renamer.Rename "module" + let ctx = ctx |> Context.ofChildNamespace k + let result = emitStructuredText reserved moduleEmitter ctx v + {| + name = name + origName = k + scope = + match result.scoped with + | Scoped.Force s -> Some s + | Scoped.Yes -> Some k + | Scoped.No -> None + content = result.imports @ result.content + docCommentBody = result.docCommentBody + |} + ) + let emitModules = moduleEmitter ctx + let imports, typedefs, items, functors, docCommentBody = + match st.value with + | None -> [], [], [], [], [] + | Some node -> + let imports, typedefs, functors, items = + List.fold (fun (imports, typedefs, functors, items) -> function + | ImportText x -> (x :: imports, typedefs, functors, items) + | TypeDef x -> (imports, x :: typedefs, functors, items) + | ScopeIndependent x -> (imports, typedefs, functors, [x] :: items) + | OverloadedText f -> (imports, typedefs, functors, f renamer :: items) + | Functor (n, ais, f) -> (imports, typedefs, (n, ais, f) :: functors, items) + ) ([], [], [], []) node.items + List.rev imports, List.rev typedefs, List.rev items, List.rev functors, node.docCommentLines + let scoped = + match st.value with + | Some v -> v.scoped + | None -> Scoped.No + let content = + [ + yield! emitModules modules + for (name, ais, functor) in functors do + let ais = emitStructuredText reserved moduleEmitter ctx ais + yield functor (Naming.moduleName name) ais.content + yield! typedefs + for item in items do yield! item + match st.value with + | None -> () + | Some v -> + yield! emitExportModule moduleEmitter ctx v.exports + ] + {| scoped = scoped; imports = imports; content = content; docCommentBody = docCommentBody |} + +and emitExportModule (moduleEmitter: ModuleEmitter) (ctx: Context) (exports: ExportItem list) : text list = let emitComment isFirst comments origText = [ let hasDocComment = not (List.isEmpty comments) if not isFirst && hasDocComment then yield ScopeIndependent empty @@ -1641,7 +1665,7 @@ let rec emitExportModule (moduleEmitter: ModuleEmitter) (ctx: Context) (exports: ] let emitModuleAlias name (i: Ident) = - if i.kind |> Option.map Kind.generatesOCamlModule |> Option.defaultValue false then + if i.kind |> Option.map Kind.generatesOCamlModule |? false then [ moduleAlias (name |> Naming.moduleNameReserved) (i.name |> Naming.structured Naming.moduleName) |> ScopeIndependent] @@ -1668,7 +1692,7 @@ let rec emitExportModule (moduleEmitter: ModuleEmitter) (ctx: Context) (exports: | ES6DefaultExport e :: rest -> go' (acc |> setItems ["Export"] (emitModuleAlias "Default" e)) rest | ES6Export e :: rest -> - let name = e.renameAs |> Option.defaultValue (e.target.name |> List.last) + let name = e.renameAs |? List.last e.target.name go' (acc |> setItems ["Export"] (emitModuleAlias name e.target)) rest let acc = let generatesExportModule = @@ -1685,71 +1709,13 @@ let rec emitExportModule (moduleEmitter: ModuleEmitter) (ctx: Context) (exports: go isFirst acc rest let st = go true Trie.empty exports - let emitted = st |> emitStructuredText true moduleEmitter ctx + let emitted = st |> emitStructuredText true ModuleEmitter.nonRec ctx // add newline if not empty if not (List.isEmpty emitted.content) then empty :: emitted.content else [] -and private emitStructuredText (reserved: bool) (moduleEmitter: ModuleEmitter) (ctx: Context) (st: StructuredText) : {| scoped: Scoped; imports: text list; content: text list; docCommentBody: text list |} = - let renamer = new OverloadRenamer() - let modules : TextModuleSig list = - st.children - |> Map.toList - |> List.map (fun (k, v) -> - let name = - let name = - if reserved then Naming.moduleNameReserved k - else Naming.moduleName k - name |> renamer.Rename "module" - let ctx = ctx |> Context.ofChildNamespace k - let result = emitStructuredText reserved moduleEmitter ctx v - {| - name = name - origName = k - scope = - match result.scoped with - | Scoped.Force s -> Some s - | Scoped.Yes -> Some k - | Scoped.No -> None - content = result.imports @ result.content - docCommentBody = result.docCommentBody - |} - ) - let emitModules = moduleEmitter ctx st - let imports, typedefs, items, functors, docCommentBody = - match st.value with - | None -> [], [], [], [], [] - | Some node -> - let imports, typedefs, functors, items = - List.fold (fun (imports, typedefs, functors, items) -> function - | ImportText x -> (x :: imports, typedefs, functors, items) - | TypeDef x -> (imports, x :: typedefs, functors, items) - | ScopeIndependent x -> (imports, typedefs, functors, [x] :: items) - | OverloadedText f -> (imports, typedefs, functors, f renamer :: items) - | Functor (n, ais, f) -> (imports, typedefs, (n, ais, f) :: functors, items) - ) ([], [], [], []) node.items - List.rev imports, List.rev typedefs, List.rev items, List.rev functors, node.docCommentLines - let scoped = - match st.value with - | Some v -> v.scoped - | None -> Scoped.No - let content = - [ - yield! emitModules modules - for (name, ais, functor) in functors do - let ais = emitStructuredText reserved moduleEmitter ctx ais - yield functor (Naming.moduleName name) ais.content - yield! typedefs - for item in items do yield! item - match st.value with - | None -> () - | Some v -> - yield! emitExportModule moduleEmitter ctx v.exports - ] - {| scoped = scoped; imports = imports; content = content; docCommentBody = docCommentBody |} - let emitFlattenedDefinitions (ctx: Context) (stmts: Statement list) : text list = let flags = { EmitTypeFlags.defaultValue with failContravariantTypeVar = true } let emitType_ = emitTypeImpl flags OverrideFunc.noOverride @@ -1790,7 +1756,8 @@ let emitFlattenedDefinitions (ctx: Context) (stmts: Statement list) : text list let selfTyText = emitType_ ctx target [prefix() @+ " " @+ emitTypeName fn.name typrm +@ " = " + selfTyText] // TODO: emit extends of type parameters - | Module m -> m.statements |> List.collect (go prefix (ctx |> Context.ofChildNamespace m.name)) + | Namespace m -> m.statements |> List.collect (go prefix (ctx |> Context.ofChildNamespace m.name)) + | AmbientModule m -> m.statements |> List.collect (go prefix (ctx |> Context.ofChildNamespace m.name.orig)) | Global m -> m.statements |> List.collect (go prefix (ctx |> Context.ofRoot)) | Pattern p -> match p with @@ -1807,7 +1774,6 @@ let emitFlattenedDefinitions (ctx: Context) (stmts: Statement list) : text list | Import _ | Variable _ | Function _ - | Module _ | Export _ | ReExport _ | UnknownStatement _ @@ -1830,7 +1796,7 @@ let emitFlattenedDefinitions (ctx: Context) (stmts: Statement list) : text list else "and" let aim = - ctx |> Context.tryCurrentSourceInfo (fun info -> info.anonymousInterfacesMap) |> Option.defaultValue Map.empty + ctx |> Context.tryCurrentSourceInfo (fun info -> info.anonymousInterfacesMap) |? Map.empty List.distinct [ for a in aim |> Map.toList |> List.map fst do @@ -1840,7 +1806,8 @@ let emitFlattenedDefinitions (ctx: Context) (stmts: Statement list) : text list ] let emitStatementsWithStructuredText (ctx: Context) (stmts: Statement list) (st: StructuredText) = - let moduleEmitter = ModuleEmitter.fromOption ctx.options + let dt = DependencyTrie.ofTrie (StructuredTextNode.getReferences ctx) st + let moduleEmitter = ModuleEmitter.create dt ctx.options let result = st |> emitStructuredText false moduleEmitter ctx let imports = if List.isEmpty result.imports then [] @@ -1907,7 +1874,6 @@ let emitStdlib (input: Input) (ctx: IContext) : Output list = let opts = ctx.options opts.simplify <- [Simplify.All] opts.inheritWithTags <- FeatureFlag.Full - opts.safeArity <- FeatureFlag.Full opts.recModule <- RecModule.Optimized opts.subtyping <- [Subtyping.Tag] opts.functor <- Functor.On @@ -2052,7 +2018,7 @@ let private emitImpl (sources: SourceFile list) (info: PackageInfo option) (ctx: let sources, mergedFileName = match sources with - | [] -> failwith "impossible_emitImpl (empty sources)" + | [] -> impossible "emitImpl (empty sources)" | [src] -> [src], src.fileName | _ -> [mergeSources "input.d.ts" sources], "input.d.ts" diff --git a/ts2ocaml.sln b/ts2ocaml.sln index 7ac19560..9419bc26 100644 --- a/ts2ocaml.sln +++ b/ts2ocaml.sln @@ -7,7 +7,7 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "ts2ocaml", "src\ts2ocaml.fs EndProject Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "ts2ml", "lib\ts2ml.fsproj", "{EAC815EE-8CCA-4E25-A82D-F9F2D46D9CC9}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "build", "build.fsproj", "{CF67588E-3D8A-4208-ACAB-F66F7D79E236}" +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "build", "build\build.fsproj", "{CF67588E-3D8A-4208-ACAB-F66F7D79E236}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/webpack.config.js b/webpack.config.js index ffea9526..34d78ca3 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -30,14 +30,15 @@ fs.readdirSync(nodeModulesDir) module.exports = { target: "node", entry: CONFIG.fsharpEntry, - externals: nodeExternals, + externals: { + typescript: "commonjs typescript", + yargs: "commonjs yargs", + 'yargs-parser': "commonjs yargs-parser" + }, output: { path: path.join(__dirname, CONFIG.outputDir), filename: 'ts2ocaml.js' }, - resolve: { - modules: [nodeModulesDir] - }, plugins: [ new webpack.BannerPlugin({ banner: "#!/usr/bin/env node", diff --git a/yarn.lock b/yarn.lock index 625a5400..a5d91dc7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17,6 +17,13 @@ dependencies: tslib "^2.3.0" +"@babel/code-frame@^7.18.6": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.22.5.tgz#234d98e1551960604f1246e6475891a570ad5658" + integrity sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ== + dependencies: + "@babel/highlight" "^7.22.5" + "@babel/code-frame@^7.21.4": version "7.21.4" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.21.4.tgz#d0fa9e4413aca81f2b23b9442797bda1826edb39" @@ -126,7 +133,7 @@ dependencies: "@babel/types" "^7.18.6" -"@babel/helper-string-parser@^7.19.4": +"@babel/helper-string-parser@^7.19.4", "@babel/helper-string-parser@^7.22.5": version "7.22.5" resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz#533f36457a25814cf1df6488523ad547d784a99f" integrity sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw== @@ -146,6 +153,11 @@ resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz#7eea834cf32901ffdc1a7ee555e2f9c27e249ca2" integrity sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w== +"@babel/helper-validator-identifier@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz#9544ef6a33999343c8740fa51350f30eeaaaf193" + integrity sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ== + "@babel/helper-validator-option@^7.21.0": version "7.21.0" resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.21.0.tgz#8224c7e13ace4bafdc4004da2cf064ef42673180" @@ -169,6 +181,20 @@ chalk "^2.0.0" js-tokens "^4.0.0" +"@babel/highlight@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.22.5.tgz#aa6c05c5407a67ebce408162b7ede789b4d22031" + integrity sha512-BSKlD1hgnedS5XRnGOljZawtag7H1yPfQp0tdNJCHoH6AZ+Pcm9VvkrK59/Yy593Ypg0zMxH2BxD1VPYUQ7UIw== + dependencies: + "@babel/helper-validator-identifier" "^7.22.5" + chalk "^2.0.0" + js-tokens "^4.0.0" + +"@babel/parser@^7.20.7": + version "7.22.7" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.22.7.tgz#df8cf085ce92ddbdbf668a7f186ce848c9036cae" + integrity sha512-7NF8pOkHP5o2vpmGgNGcfAeCvOYhGLyA3Z4eBQkT1RJlWu47n63bCs93QfJ2hIAFCil7L5P2IWhs1oToVgrL0Q== + "@babel/parser@^7.21.9", "@babel/parser@^7.22.0": version "7.22.3" resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.22.3.tgz#838ae31893373222cd9062568e2192c670037e00" @@ -217,6 +243,15 @@ "@babel/helper-validator-identifier" "^7.19.1" to-fast-properties "^2.0.0" +"@babel/types@^7.20.7": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.22.5.tgz#cd93eeaab025880a3a47ec881f4b096a5b786fbe" + integrity sha512-zo3MIHGOkPOfoRXitsgHLjEXmlDaD/5KU1Uzuc9GNiZPhSqVxVRtxuPaSBZDsYZ9qV88AjtMtWW7ww98loJ9KA== + dependencies: + "@babel/helper-string-parser" "^7.22.5" + "@babel/helper-validator-identifier" "^7.22.5" + to-fast-properties "^2.0.0" + "@babel/types@^7.21.4": version "7.21.4" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.21.4.tgz#2d5d6bb7908699b3b416409ffd3b5daa25b030d4" @@ -437,6 +472,11 @@ dependencies: "@octokit/openapi-types" "^12.11.0" +"@types/babel__code-frame@^7.0.3": + version "7.0.3" + resolved "https://registry.yarnpkg.com/@types/babel__code-frame/-/babel__code-frame-7.0.3.tgz#eda94e1b7c9326700a4b69c485ebbc9498a0b63f" + integrity sha512-2TN6oiwtNjOezilFVl77zwdNPwQWaDBBCCWWxyo1ctiO3vAtd7H/aB/CBJdw9+kqq3+latD0SXoedIuHySSZWw== + "@types/body-parser@*": version "1.19.2" resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.2.tgz#aea2059e28b7658639081347ac4fab3de166e6f0" @@ -624,10 +664,10 @@ resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.0.tgz#0c60e537fa790f5f9472ed2776c2b71ec117351b" integrity sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA== -"@types/yargs@17.0.10": - version "17.0.10" - resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.10.tgz#591522fce85d8739bca7b8bb90d048e4478d186a" - integrity sha512-gmEaFwpj/7f/ROdtIlci1R1VYU1J4j95m8T+Tj3iBgiBFKg1foE/PSl93bBd5T9LDXNPo8UlNN6W0qwD8O5OaA== +"@types/yargs@^17.0.10": + version "17.0.24" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.24.tgz#b3ef8d50ad4aa6aecf6ddc97c580a00f5aa11902" + integrity sha512-6i0aC7jV6QzQB8ne1joVZ0eSFIstHsCrobmOtghM11yGlH0j43FKL2UhWdELkyps0zuf7qVTUVCCR+tgSlyLLw== dependencies: "@types/yargs-parser" "*" @@ -1100,6 +1140,11 @@ chalk@^4.1.0, chalk@^4.1.1: ansi-styles "^4.1.0" supports-color "^7.1.0" +chalk@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.0.1.tgz#ca57d71e82bb534a296df63bbacc4a1c22b2a4b6" + integrity sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w== + chardet@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" @@ -3125,6 +3170,13 @@ triple-beam@^1.3.0: resolved "https://registry.yarnpkg.com/triple-beam/-/triple-beam-1.4.1.tgz#6fde70271dc6e5d73ca0c3b24e2d92afb7441984" integrity sha512-aZbgViZrg1QNcG+LULa7nhZpJTZSLm/mXnHXnbAbjmN5aSa0y7V+wvv6+4WaBtpISJzThKy+PIPxc1Nq1EJ9mg== +ts2fable@0.8.0-build.723: + version "0.8.0-build.723" + resolved "https://registry.yarnpkg.com/ts2fable/-/ts2fable-0.8.0-build.723.tgz#6ac654b11af361d4a5bc17ff9fcdb6ac02b16516" + integrity sha512-tqKWKwGgzDOPY4OWsycxnrAQUta070cG9wEm9lakbKPOBR4UccszxtDrovFR1rNzwjD8Fvk+HQyAQjCiOR/Uyw== + dependencies: + typescript "3.7.4" + tslib@^2.1.0: version "2.6.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.0.tgz#b295854684dbda164e181d259a22cd779dcd7bc3" @@ -3148,10 +3200,15 @@ type-is@~1.6.18: media-typer "0.3.0" mime-types "~2.1.24" -typescript@4.6.4: - version "4.6.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.4.tgz#caa78bbc3a59e6a5c510d35703f6a09877ce45e9" - integrity sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg== +typescript@3.7.4: + version "3.7.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.4.tgz#1743a5ec5fef6a1fa9f3e4708e33c81c73876c19" + integrity sha512-A25xv5XCtarLwXpcDNZzCGvW2D1S3/bACratYBx2sax8PefsFhlYmkQicKHvpYflFS8if4zne5zT5kpJ7pzuvw== + +typescript@^5.1.6: + version "5.1.6" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274" + integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA== universal-user-agent@^6.0.0: version "6.0.0" @@ -3438,19 +3495,6 @@ yargs-parser@^21.0.1, yargs-parser@^21.1.1: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== -yargs@17.7.1: - version "17.7.1" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.1.tgz#34a77645201d1a8fc5213ace787c220eabbd0967" - integrity sha512-cwiTb08Xuv5fqF4AovYacTFNxk62th7LKJ6BL9IGUpTJrWoU7/7WdQGTP2SjKf1dUNBGzDd28p/Yfs/GI6JrLw== - dependencies: - cliui "^8.0.1" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.3" - y18n "^5.0.5" - yargs-parser "^21.1.1" - yargs@^17.5.1: version "17.7.2" resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269"