### Example Usage of `setup` and `assign` with Actors Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/inferenceExactOptionalProperties2.errors.txt This snippet shows how to use the `setup` function to configure actors and the `assign` function within a machine's entry point. It demonstrates a valid actor spawn and an invalid one, triggering a TypeScript error. ```typescript // example usage setup({ actors: { counter: counterLogic }, }).createMachine({ entry: assign((spawn) => { spawn("counter"); // ok spawn("alarm"); // error ~~~~~~~ !!! error TS2345: Argument of type '"alarm"' is not assignable to parameter of type '"counter"'. return {}; }), }); // no provided actors, `assign` should still work setup().createMachine({ entry: assign(() => ({})), }); ``` -------------------------------- ### Example Node Module Package.json Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/nodeModulesNoDirectoryModule.errors.txt This package.json configuration for a Node.js module specifies 'type': 'module' and a 'main' entry point. It is part of the setup for demonstrating module import behavior. ```json { "name": "i-have-a-dir-and-main", "version": "1.0.0", "type": "module", "main": "dist/index.js" } ``` -------------------------------- ### Example d.ts File Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/nodeNextModuleResolution2.errors.txt A declaration file for a module named 'foo'. This file is part of the setup for demonstrating module resolution. ```typescript export declare let x: number ``` -------------------------------- ### Example @types Package.json Configuration (bar) Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt This is an example of a package.json file for the '@types/bar' package. It specifies the location of the type definitions. ```json { "name": "@types/bar", "version": "1.0.0", "types": "index.d.ts", "exports": { ".": { "require": "./index.d.ts" } } } ``` -------------------------------- ### Example Package.json Configuration (foo) Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt This is an example of a package.json file for a module named 'foo'. It demonstrates the 'exports' field, which specifies different entry points for different module formats. ```json { "name": "foo", "version": "1.0.0", "main": "index.js", "types": "index.d.ts", "exports": { ".": { "import": "./index.mjs", "require": "./index.js" } } } ``` -------------------------------- ### Install and Run TypeScript Native Preview Source: https://github.com/microsoft/typescript-go/blob/main/README.md Install the preview build of TypeScript's native port using npm and run it using the npx tsgo command. ```sh npm install @typescript/native-preview npx tsgo # Use this as you would tsc. ``` -------------------------------- ### Example Package.json Configuration (bar) Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt This is an example of a package.json file for the module named 'bar'. It includes the 'exports' field for different module formats. ```json { "name": "bar", "version": "1.0.0", "main": "index.js", "exports": { ".": { "import": "./index.mjs", "require": "./index.js" } } } ``` -------------------------------- ### Start Debugging VS Code Extension Source: https://github.com/microsoft/typescript-go/blob/main/CONTRIBUTING.md Launch a new VS Code instance for debugging the Corsa LS backend without global installation. Requires copying launch configuration. ```sh code . cp .vscode/launch.template.json .vscode/launch.json # Then press F5 or use the command palette ``` -------------------------------- ### React JSX Transform Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt This snippet demonstrates a successful JSX transformation using the 'react' import pragma. It requires the appropriate React types to be installed. ```typescript /// /* @jsxImportSource react */ import "./preact"; const a = <>

text
export {}; ``` -------------------------------- ### TypeScript Import Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/nodeModulesAtTypesPriority.errors.txt Example of importing React and createStore from Redux in a TypeScript file. ```typescript import React from "react"; import { createStore } from "redux"; ``` -------------------------------- ### Install Hereby Tools Source: https://github.com/microsoft/typescript-go/blob/main/CONTRIBUTING.md Install additional development tools, such as linters, required for the project using the 'hereby' tool. ```sh hereby install-tools ``` -------------------------------- ### Example index.ts File Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/compiler/processingDiagnostic.errors.txt A simple TypeScript file demonstrating the import of a module named 'foo'. This serves as a basic example for module usage. ```typescript import { foo } from 'foo'; const y = foo; ``` -------------------------------- ### Example ES Module (foo) Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt This is an example of an ES module export for 'foo'. It uses the 'export' keyword. ```javascript export const foo = 1; ``` -------------------------------- ### Example Declaration File for .d.ts Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/declarationFileForTsJsImport(module=node18).errors.txt This is a nested declaration file example, demonstrating a declaration file for another declaration file. ```typescript declare var bad: "bad9"; export default bad; ``` -------------------------------- ### Bluebird Promise Try Usage Examples Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/bluebirdStaticThis.errors.txt Examples demonstrating the usage of the Promise.try static method with different argument combinations. ```typescript fooProm = Promise.try(Promise, () => { return foo; }); ``` ```typescript fooProm = Promise.try(Promise, () => { return foo; }, arr); ``` ```typescript fooProm = Promise.try(Promise, () => { return foo; }, arr, x); ``` -------------------------------- ### Subfolder2 ES Module Import Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/nodeModules1(module=node16).errors.txt Example of importing an ES module from the subfolder2 directory. ```typescript import * as m7 from "./subfolder2/index.js"; ``` -------------------------------- ### Unsanitized Stack Trace Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/lsp/stackSanitizer/genericSecretWorkaround.md This is an example of a raw stack trace before sanitization. It may contain sensitive information. ```go goroutine 7 [running]: runtime/debug.Stack() runtime/debug/stack.go:26 +0x5e github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getSignatureHelp(0x1) github.com/microsoft/typescript-go/internal/ls/signature.go:42 +0x10 github.com/microsoft/typescript-go/internal/ls.LookupKey(0x2) github.com/microsoft/typescript-go/internal/ls/keys.go:7 +0x10 github.com/microsoft/typescript-go/internal/ls.validateToken(0x3) github.com/microsoft/typescript-go/internal/ls/token.go:9 +0x10 github.com/microsoft/typescript-go/internal/ls.signRequest(0x4) github.com/microsoft/typescript-go/internal/ls/sig.go:11 +0x10 github.com/microsoft/typescript-go/internal/ls.setPwd(0x5) github.com/microsoft/typescript-go/internal/ls/pwd.go:13 +0x10 ``` -------------------------------- ### Subfolder ES Module Import Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/nodeModules1(module=node16).errors.txt Example of importing an ES module from a subfolder. ```typescript import * as m4 from "./subfolder/index.js"; ``` -------------------------------- ### Example JavaScript Module (foo) Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt This is an example of a JavaScript module export for 'foo'. It uses CommonJS module syntax. ```javascript module.exports = { foo: 1 }; ``` -------------------------------- ### TypeScript Declaration File Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/nodeModulesAtTypesPriority.errors.txt Example of a TypeScript declaration file for React, showing no errors. ```typescript declare const React: any; export = React; ``` -------------------------------- ### Get Start of Day for ZonedDateTime Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/temporal.errors.txt Get the ZonedDateTime representing the start of the day for a given ZonedDateTime. Note that the time will be adjusted based on the time zone's offset. ```typescript const zdt = Temporal.ZonedDateTime.from("2015-10-18T12:00-02:00[America/Sao_Paulo]"); zdt.startOfDay(); // => 2015-10-18T01:00:00-02:00[America/Sao_Paulo] ``` -------------------------------- ### TypeScript Get Accessor Must Return Value Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/parserMemberAccessor1(target=es2015).errors.txt A 'get' accessor in a TypeScript class must always return a value. This example shows an error where the 'get' accessor is empty. ```typescript class C { get foo() { } ~ !!! error TS2378: A 'get' accessor must return a value. set foo(a) { } } ``` -------------------------------- ### JavaScript File Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitBlockedCorrectly.errors.txt Example of a JavaScript file within a TypeScript project. ```javascript function foo() { } ``` -------------------------------- ### Get Script Fragment Position Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/parserRealSource6.errors.txt Retrieves the starting character position of a script fragment. This method relies on the AST node for fragment start. ```typescript public getScriptFragmentPosition(): number { return this.getScriptFragmentStartAST().minChar; } ``` -------------------------------- ### Example: Node Modules Package JSON Configuration Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).errors.txt These examples show the package.json configurations for 'foo' and 'bar' modules, including 'main', 'types', and 'exports' fields, which are relevant for module resolution. ```json { "name": "foo", "version": "1.0.0", "main": "index.js", "types": "index.d.ts", "exports": { ".": { "import": "./index.mjs", "require": "./index.js" } } } ``` ```json { "name": "@types/bar", "version": "1.0.0", "types": "index.d.ts", "exports": { ".": { "require": "./index.d.ts" } } } ``` ```json { "name": "bar", "version": "1.0.0", "main": "index.js", "exports": { ".": { "import": "./index.mjs", "require": "./index.js" } } } ``` -------------------------------- ### TypeScript Module Export Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/exportsAndImportsWithContextualKeywordNames01(target=es2015).errors.txt This code defines and exports a 'set' object with a setter and a 'get' variable. This is a prerequisite for the import example that uses './t1'. ```typescript let set = { set foo(x: number) { } } let get = 10; export { set, get }; ``` -------------------------------- ### Example Usage of createXMachine Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/reverseMappedTypeIntersectionConstraint.errors.txt This example demonstrates how to use the `createXMachine` function with a specific actor configuration. The `types.actors` property is explicitly cast to satisfy the type inference for `TActor`. ```typescript const child = () => Promise.resolve("foo"); const config = createXMachine({ types: {} as { actors: { src: "str"; logic: typeof child; }; } }); ``` -------------------------------- ### Valid tsconfig.json Path Mapping Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/pathMappingBasedModuleResolution1_node.errors.txt An example of a valid tsconfig.json path mapping configuration. Relative paths should start with './' to avoid TS5090 errors. ```json { "compilerOptions": { "paths": { "*": [ "./*", "./generated/*" ] } } } ``` -------------------------------- ### Basic Filesystem Watcher Usage Source: https://github.com/microsoft/typescript-go/blob/main/internal/fswatch/README.md Demonstrates how to watch a directory for filesystem events and log them. Ensure the 'fswatch' package is imported. The callback function processes events or errors. ```go package main import ( "fmt" "log" "os" "os/signal" "github.com/microsoft/typescript-go/internal/fswatch" ) func main() { dir, _ := os.Getwd() sub, err := fswatch.Default().WatchDirectory(dir, func(events []fswatch.Event, err error) { if err != nil { log.Println("watch error:", err) return } for _, e := range events { fmt.Printf("%s %s\n", e.Kind, e.Path) } }) if err != nil { log.Fatal(err) } defer sub.Close() c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) <-c } ``` -------------------------------- ### Subfolder2 Another ES Module Import Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/nodeModules1(module=node16).errors.txt Example of importing an ES module from the subfolder2/another directory. ```typescript import * as m10 from "./subfolder2/another/index.js"; ``` -------------------------------- ### TypeScript Error: Duplicate Get Accessor Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/computedPropertyNames49_ES6.errors.txt This example shows an object literal with multiple 'get' accessors named 'foo'. TypeScript prohibits duplicate accessors with the same name within an object literal. ```typescript get foo() { if (1 == 1) { return 10; } } ``` ```typescript get foo() { if (2 == 2) { return 20; } } ``` -------------------------------- ### Example Declaration File for .d.mts Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/declarationFileForTsJsImport(module=node18).errors.txt This is a nested declaration file example for an ES module, demonstrating a declaration file for another declaration file. ```typescript declare var bad: "bad10"; export default bad; ``` -------------------------------- ### TypeScript Class with Public and Private Get Accessors Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/privacyAccessorDeclFile(target=es2015).errors.txt This example defines a class with public and private static and instance get accessors. It demonstrates the structure for implementing getters with varying privacy settings. ```typescript class privateClassWithWithPrivateGetAccessorTypes { static get myPublicStaticMethod(): privateClass { return null; ~~~~~~ !!! error TS2322: Type 'null' is not assignable to type 'privateClass'. } private static get myPrivateStaticMethod(): privateClass { return null; ~~~~~~ !!! error TS2322: Type 'null' is not assignable to type 'privateClass'. } get myPublicMethod(): privateClass { return null; ~~~~~~ !!! error TS2322: Type 'null' is not assignable to type 'privateClass'. } private get myPrivateMethod(): privateClass { return null; ~~~~~~ !!! error TS2322: Type 'null' is not assignable to type 'privateClass'. } static get myPublicStaticMethod1() { return new privateClass(); } private static get myPrivateStaticMethod1() { return new privateClass(); } get myPublicMethod1() { return new privateClass(); } private get myPrivateMethod1() { return new privateClass(); } } ``` -------------------------------- ### ZonedDateTime Example with DST Transition Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/temporal.errors.txt An example illustrating a ZonedDateTime instance around a Daylight Saving Time transition. ```typescript const zdt = Temporal.ZonedDateTime.from("2020-03-08T00:00-08:00[America/Los_Angeles]"); ``` -------------------------------- ### Preact JSX Transform Error Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformKeyPropCustomImportPragma(jsx=react-jsx).errors.txt Attempts to configure the JSX transform for Preact. This example results in an error because the 'preact/jsx-runtime' module cannot be found. Ensure the necessary Preact types and runtime are installed and correctly referenced. ```tsx /// /* @jsxImportSource preact */ const props = { answer: 42 } const a =
text
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. const b =
text
; export {}; ``` -------------------------------- ### Example package.json for Module Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/nodeNextModuleResolution2.errors.txt A package.json file configured for ES module support, specifying the main entry point for the module. ```json { "name": "foo", "type": "module", "exports": { ".": "./index.d.ts" } } ``` -------------------------------- ### Example TypeScript Declaration File (foo) Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt This is an example of a TypeScript declaration file for 'foo'. It declares the exported types. ```typescript export declare const foo: number; ``` -------------------------------- ### package.json configurations Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/nodeModulesForbidenSyntax(module=nodenext).errors.txt These package.json examples show different 'type' configurations that affect module resolution. ```json { "name": "package", "private": true, "type": "module" } ``` ```json { "type": "commonjs" } ``` ```json { "type": "module" } ``` ```json {} ``` -------------------------------- ### React JSX Transform Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformKeyPropCustomImportPragma(jsx=react-jsx).errors.txt Configures the JSX transform to use React. Ensure React types are installed. ```tsx /// /* @jsxImportSource react */ import "./preact"; const props2 = { answer: 42 } const a2 =
text
; const b2 =
text
; export {}; ``` -------------------------------- ### Subfolder2 CJS Module Import Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/nodeModules1(module=node16).errors.txt Example of importing a CommonJS module from the subfolder2 directory. ```typescript import * as m9 from "./subfolder2/index.cjs"; ``` -------------------------------- ### Example Package JSON Configuration Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/moduleResolutionWithModule(module=commonjs,moduleresolution=nodenext).errors.txt A sample package.json file demonstrating the 'exports' field, which is relevant for NodeNext module resolution. ```json { "name": "pkg", "version": "0.0.1", "exports": "./entrypoint.js" } ``` -------------------------------- ### Configuration JSON File Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/nodeModulesJson(module=node16).errors.txt A sample configuration JSON file with a version property. ```json { "version": 1 } ``` -------------------------------- ### Example ES Module (bar) Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt This is an example of an ES module export for 'bar' using the 'export' keyword. ```javascript export const bar = 1; ``` -------------------------------- ### Example Type Definition File Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/tripleSlashTypesReferenceWithMissingExports(module=node18).errors.txt This is a sample index.d.ts file for the 'pkg' package, defining the 'GlobalThing' interface. Ensure this file exists and is correctly referenced in package.json. ```typescript interface GlobalThing { a: number } ``` -------------------------------- ### Contextual Typing of Get Accessor Return Expression Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/getSetAccessorContextualTyping(target=es2015).errors.txt In a class, if a 'get' accessor has no return type annotation and a matching 'set' accessor exists with a parameter type annotation, the 'get' accessor's return expression is contextually typed by the 'set' accessor's parameter type. This example shows an error when a string is returned where a number is expected. ```typescript class C { set X(x: number) { } get X() { return "string"; // Error; get contextual type by set accessor parameter type annotation ~~~~~~ } set Y(y) { } get Y() { return true; } set W(w) { } get W(): boolean { return true; } set Z(z: number) { } get Z() { return 1; } } ``` -------------------------------- ### Example package.json Configuration Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/moduleExportNonStructured.errors.txt This JSON configuration shows a typical package.json file. Ensure your 'type' and 'module' fields align with your TypeScript module settings. ```json { "name": "test", "version": "1.0.0", "description": "", "type": "module", "module": "index.mjs" } ``` -------------------------------- ### Get Script Edit Range Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/parserharness.errors.txt Retrieves the edit range (start, limit, delta) for a script since a specified version. Formatted as a comma-separated string. ```typescript public getScriptEditRangeSinceVersion(scriptIndex: number, scriptVersion: number): string { var range = this.scripts[scriptIndex].getEditRangeSinceVersion(scriptVersion); var result = (range.minChar + "," + range.limChar + "," + range.delta); return result; } ``` -------------------------------- ### TypeScript File Compilation Example (No Errors) Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/jsFileCompilationEmitBlockedCorrectly.errors.txt Example of a TypeScript file intended for emission, compiling without errors. ```typescript // this should be emitted class d { } ``` -------------------------------- ### Example index.mts File Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/moduleExportNonStructured.errors.txt This TypeScript module file demonstrates importing various types and namespaces. Ensure your import paths and types are correctly configured. ```typescript import * as exportAny from "./exportAny.cjs"; import * as exportUnknown from "./exportUnknown.cjs"; import * as exportSymbol from "./exportSymbol.cjs"; import type * as exportAnyType from "./exportAny.cjs"; import type * as exportUnknownType from "./exportUnknown.cjs"; import type * as exportSymbolType from "./exportSymbol.cjs"; ``` -------------------------------- ### Module Definitions for Examples Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/exportNamespace8.errors.txt These are the source module definitions used in the examples above. They are provided for context and do not produce errors themselves. ```typescript export class A {} export class B {} ``` ```typescript export class B {} export class C {} ``` -------------------------------- ### Complete Point.prototype Definition Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/contextualTyping.sourcemap.txt Assigns an object literal to Point.prototype, typically used to define methods or properties for all Point instances. This example shows the start of such an assignment. ```javascript Point.prototype = { }; ``` -------------------------------- ### Example Declaration File for .d.cts Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/declarationFileForTsJsImport(module=node18).errors.txt This is a nested declaration file example for a CommonJS module, demonstrating a declaration file for another declaration file. ```typescript declare var bad: "bad11"; export default bad; ``` -------------------------------- ### Declare Robot Interface and Console Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/sourceMapValidationDestructuringParameterObjectBindingPattern.sourcemap.txt Defines a TypeScript interface for a Robot object and declares a global console object for logging. This setup is used in subsequent examples. ```typescript interface Robot { name: string; skill: string; } declare var console: { log(msg: string): void; } ``` -------------------------------- ### Run Hereby Format Task Source: https://github.com/microsoft/typescript-go/blob/main/CONTRIBUTING.md Format the project's code according to established style guidelines using the 'hereby' tool. ```sh hereby format ``` -------------------------------- ### Token Information Setup for Equality Check Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/parserRealSource10.errors.txt This example configures token information for the equality operator (==). It uses 'NodeType.Eq' and 'ErrorRecoverySet.BinOp', which are undefined and result in TS2304 errors. ```typescript setTokenInfo(TokenID.EqualsEquals, Reservation.None, OperatorPrecedence.Equality, NodeType.Eq, OperatorPrecedence.None, NodeType.None, "==", ErrorRecoverySet.BinOp); // == ``` -------------------------------- ### Display tsgo Help Information Source: https://github.com/microsoft/typescript-go/blob/main/_packages/native-preview/README.md Use the `tsgo` command with the `--help` flag to see available options, similar to how you would use `tsc`. ```sh npx tsgo --help ``` -------------------------------- ### Correct Intl.DisplayNames usage with type option Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/es2020IntlAPIs.errors.txt Shows the correct way to instantiate Intl.DisplayNames by providing the required 'type' option. This example demonstrates getting the language name for a locale. ```typescript console.log((new Intl.DisplayNames(undefined, {type: 'language'})).of('en-GB')); // "British English" ``` -------------------------------- ### Example Declaration File for .d.json.ts Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/declarationFileForTsJsImport(module=node18).errors.txt This is a declaration file example for a JSON module, demonstrating a declaration file for a TypeScript-processed JSON file. ```typescript declare var bad: "bad12"; export default bad; ``` -------------------------------- ### Token Information Setup for Bitwise OR Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/parserRealSource10.errors.txt This example shows the configuration for the bitwise OR operator. The use of 'NodeType.Or' and 'ErrorRecoverySet.BinOp' suggests these are part of a larger token definition system that is currently incomplete. ```typescript setTokenInfo(TokenID.Bar, Reservation.None, OperatorPrecedence.BitwiseOr, NodeType.Or, OperatorPrecedence.None, NodeType.None, "|", ErrorRecoverySet.BinOp); // | ``` -------------------------------- ### Initialize List_TextEditInfo Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/parserindenter.errors.txt Initializes a new instance of List_TextEditInfo. This is a common setup step before populating edit information. ```typescript var result = new List_TextEditInfo(); ``` -------------------------------- ### Class Hierarchy and Type Narrowing Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/intersectionWithConflictingPrivates.errors.txt Defines an abstract class hierarchy and concrete subclasses. This setup is often used in scenarios requiring type discrimination, such as in the `Foo` class example. ```typescript abstract class ViewNode { } abstract class ViewRefNode extends ViewNode { } abstract class ViewRefFileNode extends ViewRefNode { } class CommitFileNode extends ViewRefFileNode { private _id: any; } class ResultsFileNode extends ViewRefFileNode { private _id: any; } class StashFileNode extends CommitFileNode { private _id2: any; } class StatusFileNode extends ViewNode { private _id: any; } ``` -------------------------------- ### TypeScript Class Instantiation Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/es6ClassTest.errors.txt Shows how to create an instance of the 'Foo' class. ```typescript var f = new Foo(); ``` -------------------------------- ### Class Instantiation and Method Call Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/callOverloads4.errors.txt Example of creating an instance of the Foo class and calling its method. This demonstrates the usage after a class definition. ```typescript var f1 = new Foo("hey"); f1.bar1(); ``` -------------------------------- ### Implicit 'any' for Parameter with Rest Parameter in Ambient Module Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/noImplicitAnyParametersInAmbientModule.errors.txt This example shows a function signature in an ambient module with both a regular parameter 'x' and a rest parameter 'r'. If 'x' is not explicitly typed, it implicitly gets an 'any' type, and the rest parameter 'r' implicitly gets an 'any[]' type, both flagged as errors. ```typescript var dm_f14: (x, ...r) => string; ``` -------------------------------- ### Example JavaScript file with JSDoc annotations Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/jsFileCompilationSyntaxError.errors.txt This is an example of a JavaScript file that might be part of a mixed-language project. It includes JSDoc annotations for type checking. ```javascript /** * @type {number} * @type {string} */ var v; ``` -------------------------------- ### Auto-import from cross-project node_modules Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/fourslash/autoImports/autoImportCrossProjectNodeModules.baseline.md This example shows the expected auto-import behavior when a module is published from another project within the same workspace. Ensure the external package is correctly linked or installed in node_modules. ```typescript // @FileName: /project-b/index.ts pkg_/**/ ``` ```typescript import { pkg_listed_value } from "pkg-listed"; pkg_ ``` -------------------------------- ### Dynamic Import Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/moduleExportAliasImported.errors.txt Demonstrates how to dynamically import a module using the `import()` function. This is useful for code splitting and lazy loading. ```javascript import('./bug28014') ``` -------------------------------- ### Class Instantiation and Method Call Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/callOverloads2.errors.txt Demonstrates instantiating a class and calling one of its methods. ```typescript var f1 = new Foo("hey"); f1.bar1(); ``` -------------------------------- ### Run Benchmarks Function Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/parserharness.errors.txt Iterates through a list of benchmark classes, instantiates them, runs their tests, and emits log messages for test start and results. It includes setup, teardown, and iteration logic. ```typescript export function runBenchmarks() { for (var i = 0; i < benchmarks.length; i++) { var b = new benchmarks[i](); var t = new Timer(); b.before(); for (var j = 0; j < b.iterations; j++) { b.beforeEach(); timeFunction(b); b.afterEach(); } b.after(); for (var prop in b.results) { var description = b.description + (prop ? ": " + prop : ''); emitLog('testStart', { desc: description }); emitLog('pass', { desc: description, pass: true, perfResults: { mean: b.results[prop].mean(), min: b.results[prop].min(), max: b.results[prop].max(), stdDev: b.results[prop].stdDev(), trials: b.results[prop].data } }); } } } ``` -------------------------------- ### JSX Element with Attributes, Text Content, and Namespace Prefix Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/jsxNamespacePrefixInName.errors.txt A comprehensive example of a JSX element with both attributes and text content, utilizing a namespace prefix. Proper JSX setup is crucial. ```typescript var justElement5 = {\"text\"}; ``` -------------------------------- ### Class Instance Initialization Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/genericClassExpressionInFunction.errors.txt This code demonstrates the instantiation of classes that were defined using various class expression patterns. It shows how to create objects from these dynamically defined classes. ```typescript var c = new C(); var k = new K(); var s = new S(); c.genericVar = 12; k.genericVar = 12; s.genericVar = 12; ``` -------------------------------- ### Preact JSX Transform Error Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt Attempts to configure the JSX transform to use 'preact' as the import source. This example results in an error because the 'preact/jsx-runtime' module is not found. Ensure types for the appropriate package are installed. ```tsx /// /* @jsxImportSource preact */ const a = <> ~~ !!! error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed.

text
export {}; ``` -------------------------------- ### TypeScript Decorator Error: Multiple Accessors Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/decoratorOnClassAccessor7(target=es2015).errors.txt TypeScript prevents applying decorators to both the get and set accessors of the same property. This example demonstrates the error when a decorator is applied to the getter and another to the setter of property 'x'. ```typescript declare function dec1(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; declare function dec2(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor; class A { @dec1 get x() { return 0; } set x(value: number) { } } class B { get x() { return 0; } @dec2 set x(value: number) { } } class C { @dec1 set x(value: number) { } get x() { return 0; } } class D { set x(value: number) { } @dec2 get x() { return 0; } } class E { @dec1 get x() { return 0; } @dec2 set x(value: number) { } ~ !!! error TS1207: Decorators cannot be applied to multiple get/set accessors of the same name. } class F { @dec1 set x(value: number) { } @dec2 get x() { return 0; } ~ !!! error TS1207: Decorators cannot be applied to multiple get/set accessors of the same name. } ``` -------------------------------- ### TypeScript Configuration Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/libTypeScriptSubfileResolvingConfig.errors.txt An empty tsconfig.json file. This configuration is minimal and might lead to errors if specific libraries are not implicitly included or explicitly referenced. ```json { "": "" } ``` -------------------------------- ### Accessor Accidental Call Diagnostic Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/accessorAccidentalCallDiagnostic(target=es2015).errors.txt This snippet demonstrates the TS6234 error. It shows a class with a 'get' accessor and a function that incorrectly attempts to call this accessor as a function, leading to a 'not callable' error. ```typescript // https://github.com/microsoft/TypeScript/issues/24554 class Test24554 { get property(): number { return 1; } } function test24554(x: Test24554) { return x.property(); ~~~~~~~~ ``` ```typescript !!! error TS6234: This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'? !!! error TS6234: Type 'Number' has no call signatures. ``` -------------------------------- ### JSX Multiline Attribute on New Line Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/compiler/jsxMultilineAttributeStringValues2.errors.txt This example demonstrates a JSX element where the multiline string value for the 'className' attribute starts on a new line. Proper indentation and syntax are crucial for correct parsing. ```typescript const c =
; ``` -------------------------------- ### Creating ZonedDateTime from String and Object Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/temporal.errors.txt Demonstrates creating ZonedDateTime instances from ISO 8601 strings and plain objects. Shows handling of different string formats, time zone offsets, and calendar systems. Also illustrates 'overflow' options ('constrain' and 'reject'). ```javascript let zdt: Temporal.ZonedDateTime; zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Cairo]"); zdt = Temporal.ZonedDateTime.from("1995-12-07T03:24:30+02:00[Africa/Cairo][u-ca=islamic]"); zdt = Temporal.ZonedDateTime.from("19951207T032430+0200[Africa/Cairo]"); ``` ```javascript zdt = Temporal.ZonedDateTime.from({ timeZone: "America/Los_Angeles", year: 1995, month: 12, day: 7, hour: 3, minute: 24, second: 30, millisecond: 0, microsecond: 3, nanosecond: 500, }); // => 1995-12-07T03:24:30.0000035-08:00[America/Los_Angeles] ``` ```javascript // Different overflow modes zdt = Temporal.ZonedDateTime.from({ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 }, { overflow: "constrain" }); // => 2001-12-01T00:00:00+01:00[Europe/Paris] ``` ```javascript zdt = Temporal.ZonedDateTime.from({ timeZone: "Europe/Paris", year: 2001, month: 13, day: 1 }, { overflow: "reject" }); // => throws RangeError ``` -------------------------------- ### TypeScript Import Type Error Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/importTypeWithUnparenthesizedGenericFunctionParsed.errors.txt This snippet demonstrates the TypeScript error TS2591 when 'module' is used in an import type without proper context or type definitions. It suggests installing `@types/node` and configuring `tsconfig.json`. ```typescript export declare const fail1: import("module").Modifier<(x: T) => T>; // shouldn't be a parse error ``` -------------------------------- ### TypeScript Class with String Index Signature Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/classIndexer3.errors.txt This example shows a base class `C123` that defines a string index signature, meaning it expects all string properties to be of type `number`. This is a valid setup for a base class. ```typescript class C123 { [s: string]: number; constructor() { } } ``` -------------------------------- ### ES2022 Module Import Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/elidedJSImport2(module=es2022).errors.txt Demonstrates various ways to import modules in JavaScript using ES2022 syntax, including named, namespace, and default imports. ```javascript import { Foo } from "./other.js"; import * as other from "./other.js"; import defaultFoo from "./other.js"; const x = new Foo(); const y = other.Foo(); const z = new defaultFoo(); ``` -------------------------------- ### TypeScript Error TS2318 Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/missingDecoratorType(target=es2015).errors.txt This error typically arises in scenarios involving decorators or when custom property descriptors are used without proper global type definitions. Ensure your TypeScript configuration and installed typings are correct. ```typescript declare function dec(t, k, d); class C { @dec method() {} } ``` -------------------------------- ### TypeScript Harness Global Setup Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/parserharness.errors.txt This code sets up global functions for the TypeScript test harness. It defines 'describe', 'run', 'it', and 'assert' for use in test files. ```typescript var currentRun = new Run(); global.describe = describe; global.run = run; global.it = it; global.assert = Harness.Assert; } ``` -------------------------------- ### Example package.json Configuration Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/nestedPackageJsonRedirect(moduleresolution=nodenext).errors.txt This package.json demonstrates a common configuration for Node.js projects using ES Modules. Ensure your tsconfig.json aligns with these settings to avoid module resolution errors. ```json { "name": "@restart/hooks", "version": "0.3.25", "main": "cjs/index.js", "types": "cjs/index.d.ts", "module": "esm/index.js" } ``` ```json { "name": "@restart/hooks/useMergedRefs", "private": true, "main": "../cjs/useMergedRefs.js", "module": "../esm/useMergedRefs.js", "types": "../esm/useMergedRefs.d.ts" } ``` -------------------------------- ### TypeScript Error: Duplicate Identifier in Accessors Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/computedPropertyNames49_ES5.errors.txt This example shows a TypeScript error (TS2300) resulting from duplicate 'get' accessor names within an object literal. Each accessor name, whether computed or literal, must be unique. ```typescript get foo() { ~~~ !!! error TS2300: Duplicate identifier 'foo'. if (1 == 1) { return 10; } }, get foo() { ~~~ !!! error TS1118: An object literal cannot have multiple get/set accessors with the same name. ~~~ !!! error TS2300: Duplicate identifier 'foo'. if (2 == 2) { return 20; } } ``` -------------------------------- ### Nested JSX Fragment with Implicit Any Type Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/jsxFactoryAndJsxFragmentFactoryNull.errors.txt This example shows a nested JSX fragment structure that results in TS7026 errors. Each JSX element, including those within fragments, implicitly gets the 'any' type when JSX.IntrinsicElements is missing. ```typescript declare var h: any; <>1<>2.12.2; ``` -------------------------------- ### TypeScript BiMap Usage Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/genericReversingTypeParameters.errors.txt This code demonstrates the instantiation and basic usage of the `BiMap` class with specific generic types `string` and `number`. It includes calls to `get` and `inverse` methods, illustrating how the generic types are applied. ```typescript } var b = new BiMap(); var r1 = b.get(''); var i = b.inverse(); // used to get the type wrong here. var r2b = i.get(1); ``` -------------------------------- ### Example Declaration File for a Module Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/declarationNotFoundPackageBundlesTypes.errors.txt This snippet shows how to create a declaration file for a module that does not have one. This helps TypeScript understand the module's structure and types. ```typescript declare module 'foo/other'; ``` -------------------------------- ### Package JSON for an Untyped Module Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/untypedModuleImport_noImplicitAny.errors.txt This is a sample package.json file for a module. It specifies the module's name and version but does not include information about its type definitions. ```json { "name": "foo", "version": "1.2.3" } ``` -------------------------------- ### Object with Specific Key Type Error Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/noImplicitAnyStringIndexerOnObject.errors.txt This example shows an object with methods accepting specific literal types for keys. Accessing with a string indexer results in an error. Use the defined methods like 'get' or 'set' for access. ```typescript let e = { get: (key: "hello" | "world") => 'foobar', set: (key: "hello" | "world", value: string) => 'foobar' }; e['hello']; ``` ```typescript e['hello'] = 'modified'; ``` ```typescript e['hello'] += 1; ``` ```typescript e['hello'] ++; ``` -------------------------------- ### Class Methods for Generic Property Access Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/keyofAndIndexedAccess.errors.txt A class `C1` with generic `get` and `set` methods that use `keyof this` to allow type-safe access and modification of its own properties. Examples show direct access, bracket notation, and using the generic methods. ```typescript class C1 { x: number; get(key: K) { return this[key]; } set(key: K, value: this[K]) { this[key] = value; } foo() { let x1 = this.x; // number let x2 = this["x"]; // number let x3 = this.get("x"); // this["x"] let x4 = getProperty(this, "x"); // this["x"] this.x = 42; this["x"] = 42; this.set("x", 42); setProperty(this, "x", 42); } } ``` -------------------------------- ### Initialize Git Submodules Source: https://github.com/microsoft/typescript-go/blob/main/CONTRIBUTING.md Initialize and update git submodules for an already cloned repository. ```sh git submodule update --init --recursive ``` -------------------------------- ### TypeScript Class Getter Compilation Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/properties(target=es2015).sourcemap.txt This example illustrates the compilation of a TypeScript class getter into JavaScript. The generated code includes the 'get' keyword and the return statement. Source mapping details are provided to link back to the original TypeScript source. ```javascript get Count() { return 42; } ``` -------------------------------- ### TypeScript tsconfig.json Configuration Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/configFileExtendsAsList.errors.txt Demonstrates how to extend multiple tsconfig files to combine compiler options. This is useful for layering configurations, such as enabling 'noImplicitAny' from one file and 'strictNullChecks' from another. ```json { "extends": ["./tsconfig1.json", "./tsconfig2.json"] } ``` -------------------------------- ### TypeScript Class with Private Fields and Async Method Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/importHelpersES6.errors.txt This example demonstrates a class 'A' using private fields ('#x') and an async method ('f'). Such features require helper functions from 'tslib'. The error TS2354 arises if 'tslib' is not installed or imported. ```typescript declare var dec: any; @dec export class A { #x: number = 1; async f() { this.#x = await this.#x; } g(u) { return #x in u; } } ``` -------------------------------- ### Importing a Scoped Module Without Declaration File Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/untypedModuleImport_noImplicitAny_typesForPackageExist.errors.txt This example shows an import of a scoped module ('@scope/bar/sub') where TypeScript cannot find the associated declaration file. This results in the module implicitly having an 'any' type. The recommended solutions are to install the types package or add a local declaration file. ```typescript import * as scopeBarSub from "@scope/bar/sub"; ``` -------------------------------- ### IPromise and Promise Chaining Examples Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/promisePermutations.errors.txt Illustrates chaining .then() calls on both IPromise and native Promise objects, using various callback functions. ```typescript declare var r1: IPromise; var r1a = r1.then(testFunction, testFunction, testFunction); var r1b = r1.then(testFunction, testFunction, testFunction).then(testFunction, testFunction, testFunction); declare var s1: Promise; var s1a = s1.then(testFunction, testFunction, testFunction); var s1b = s1.then(testFunctionP, testFunctionP, testFunctionP); var s1c = s1.then(testFunctionP, testFunction, testFunction); var s1d = s1.then(testFunctionP, testFunction, testFunction).then(testFunction, testFunction, testFunction); ``` ```typescript declare var r2: IPromise<{ x: number; }>; var r2a = r2.then(testFunction2, testFunction2, testFunction2); var r2b = r2.then(testFunction2, testFunction2, testFunction2).then(testFunction2, testFunction2, testFunction2); declare var s2: Promise<{ x: number; }>; var s2a = s2.then(testFunction2, testFunction2, testFunction2); var s2b = s2.then(testFunction2P, testFunction2P, testFunction2P); var s2c = s2.then(testFunction2P, testFunction2, testFunction2); var s2d = s2.then(testFunction2P, testFunction2, testFunction2).then(testFunction2, testFunction2, testFunction2); ``` ```typescript declare var r3: IPromise; var r3a = r3.then(testFunction3, testFunction3, testFunction3); var r3b = r3.then(testFunction3, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3); declare var s3: Promise; var s3a = s3.then(testFunction3, testFunction3, testFunction3); var s3b = s3.then(testFunction3P, testFunction3P, testFunction3P); var s3c = s3.then(testFunction3P, testFunction3, testFunction3); var s3d = s3.then(testFunction3P, testFunction3, testFunction3).then(testFunction3, testFunction3, testFunction3); ``` -------------------------------- ### Using Fragment Pragma with Snabbdom (No JSX) Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/inlineJsxAndJsxFragPragma.errors.txt Demonstrates using the Fragment pragma with Snabbdom when JSX is not explicitly used. Requires 'jsx' to be imported. ```typescript /* @jsx jsx */ /* @jsxfrag null */ import {jsx} from "./renderer"; <> ``` -------------------------------- ### Array Manipulation: First, Initial, Last, Rest Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/underscoreTest1.errors.txt These functions provide ways to extract portions of an array. _.first gets the first N elements, _.initial gets all but the last N, _.last gets the last N, and _.rest gets all but the first N. ```typescript _.first([5, 4, 3, 2, 1]); ``` ```typescript _.initial([5, 4, 3, 2, 1]); ``` ```typescript _.last([5, 4, 3, 2, 1]); ``` ```typescript _.rest([5, 4, 3, 2, 1]); ``` -------------------------------- ### TypeScript Get Accessor Error Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/complicatedPrivacy(target=es2015).errors.txt A 'get' accessor in a TypeScript class cannot accept parameters. This error occurs when a parameter is incorrectly added to a 'get' accessor definition. ```typescript export class C2 implements m3.i3 { public get p1(arg) { ~~ !!! error TS1054: A 'get' accessor cannot have parameters. return new C1(); } public set p1(arg1: C1) { } public f55() { return "Hello world"; } } ``` -------------------------------- ### Fixing 'get' Accessor Without Return Value in TypeScript Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/parserAccessors1(target=es2015).errors.txt A 'get' accessor must always return a value. Ensure that your 'get' accessor includes a return statement. ```typescript class C { get Foo() { } ~~~ !!! error TS2378: A 'get' accessor must return a value. } ``` -------------------------------- ### TypeScript Import and Usage Example Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/staticInstanceResolution3.errors.txt Demonstrates how to import a module and use a static method. This snippet is error-free and shows correct module import and method invocation. ```typescript /// import WinJS = require('./staticInstanceResolution3_0'); WinJS.Promise.timeout(10); ``` -------------------------------- ### Resolving TS7016: Installing Type Definitions Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/untypedModuleImport_noImplicitAny_scoped.errors.txt When encountering the TS7016 error, a common solution is to install the necessary type definitions from npm. This command attempts to install the types for '@foo/bar' if they are available. ```bash npm i --save-dev @types/foo__bar ``` -------------------------------- ### Create Machine 2 with Specific Event Type Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/contextualTypeFunctionObjectPropertyIntersection.errors.txt Illustrates using createMachine2 with a specific event type 'FOO'. This example is similar to the first but uses a different machine configuration interface. ```typescript createMachine2({ schema: { events: {} as { type: "FOO" } | { type: "bar" }, }, on: { FOO: (ev) => { ev.type; // should be 'FOO' }, }, }); ``` -------------------------------- ### Get Offset Nanoseconds Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/compiler/temporal.errors.txt Demonstrates how to get the offset from UTC in nanoseconds for a ZonedDateTime. ```typescript const zdt = Temporal.ZonedDateTime.from("2020-11-01T01:30-07:00[America/Los_Angeles]"); zdt.offsetNanoseconds; // => -25200000000000 // (-7 * 3600 * 1e9) ``` -------------------------------- ### Watch Specific Directory with Recursive Option Source: https://github.com/microsoft/typescript-go/blob/main/internal/fswatch/README.md Shows how to use a specific watcher (e.g., Inotify) and enable recursive watching of a directory. The callback function and directory path must be provided. ```go sub, err := fswatch.Inotify().WatchDirectory(dir, callback, fswatch.WithRecursive()) ``` -------------------------------- ### Example Declaration File for .js Source: https://github.com/microsoft/typescript-go/blob/main/testdata/baselines/reference/submodule/conformance/declarationFileForTsJsImport(module=node18).errors.txt This is a sample declaration file for a JavaScript module. It defines the expected type for the default export. ```typescript declare var bad: "bad1"; export default bad; ```