diff --git a/types/kotobee/.npmignore b/types/kotobee/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/kotobee/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/kotobee/index.d.ts b/types/kotobee/index.d.ts new file mode 100644 index 00000000000000..fe6c4e19493a13 --- /dev/null +++ b/types/kotobee/index.d.ts @@ -0,0 +1,55 @@ +type LanguageCode = + | "ar" + | "de" + | "es" + | "hu" + | "jp" + | "ms" + | "no" + | "pt" + | "ru" + | "tr" + | "zh-tw" + | "cy" + | "en" + | "fr" + | "it" + | "ko" + | "nl" + | "pl" + | "ro" + | "sw" + | "zh-cn" + | "zh"; + +type Directions = "ltr" | "rtl"; + +interface KotobeeReader { + /** + * Clears cached local data used by the reader. + */ + clearCache: () => void; + + /** + * Clears all event listeners attached by the reader. + */ + clearListeners: () => void; + + /** + * Clears remotely fetched data (e.g., cloud sync, remote storage). + */ + clearRemoteData: () => void; + + /** + * Sets the active UI language of the reader. + */ + setLanguage: (language: LanguageCode) => void; + + /** + * Sets reading direction (left-to-right or right-to-left). + */ + setDirection: (direction: Directions) => void; +} + +// Declare the global variable +declare const Kotobee: KotobeeReader; diff --git a/types/kotobee/kotobee-tests.ts b/types/kotobee/kotobee-tests.ts new file mode 100644 index 00000000000000..872382f6ae5a35 --- /dev/null +++ b/types/kotobee/kotobee-tests.ts @@ -0,0 +1,68 @@ +// ------------------- Correct usage ------------------- +const validLanguages: LanguageCode[] = [ + "ar", + "de", + "es", + "hu", + "jp", + "ms", + "no", + "pt", + "ru", + "tr", + "zh-tw", + "cy", + "en", + "fr", + "it", + "ko", + "nl", + "pl", + "ro", + "sw", + "zh-cn", + "zh", +]; + +const validDirections: Directions[] = ["ltr", "rtl"]; + +// Test all valid languages +validLanguages.forEach(lang => Kotobee.setLanguage(lang)); + +// Test all valid directions +validDirections.forEach(dir => Kotobee.setDirection(dir)); + +// ------------------- Incorrect usage ------------------- + +// Invalid language +// @ts-expect-error +Kotobee.setLanguage("invalid"); + +// Invalid direction +// @ts-expect-error +Kotobee.setDirection("up"); + +// Calling clearCache with parameters should error +// @ts-expect-error +Kotobee.clearCache(123); + +// Calling clearListeners with parameters should error +// @ts-expect-error +Kotobee.clearListeners("test"); + +// ------------------- Type assignments ------------------- + +// Assign valid types +validLanguages.forEach(lang => { + const l: LanguageCode = lang; // $ExpectType LanguageCode +}); + +validDirections.forEach(dir => { + const d: Directions = dir; // $ExpectType Directions +}); + +// Invalid assignments +// @ts-expect-error +const fakeLang: LanguageCode = "madeup"; +// @ts-expect-error +const dirCenter: Directions = "center"; diff --git a/types/kotobee/package.json b/types/kotobee/package.json new file mode 100644 index 00000000000000..683be6ab37deef --- /dev/null +++ b/types/kotobee/package.json @@ -0,0 +1,19 @@ +{ + "private": true, + "name": "@types/kotobee", + "nonNpm": true, + "nonNpmDescription": "This is an SDK for Kotobee Author application.", + "version": "0.0.9999", + "projects": [ + "https://support.kotobee.com/en/support/solutions/folders/8000082574" + ], + "devDependencies": { + "@types/kotobee": "workspace:." + }, + "owners": [ + { + "name": "Bashamega", + "githubUsername": "Bashamega" + } + ] +} diff --git a/types/kotobee/tsconfig.json b/types/kotobee/tsconfig.json new file mode 100644 index 00000000000000..745356d063ff64 --- /dev/null +++ b/types/kotobee/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "kotobee-tests.ts" + ] +} diff --git a/types/markdown-it-container/.npmignore b/types/markdown-it-container/.npmignore index 93e307400a5456..d73cba2e3a91b8 100644 --- a/types/markdown-it-container/.npmignore +++ b/types/markdown-it-container/.npmignore @@ -3,3 +3,4 @@ !**/*.d.cts !**/*.d.mts !**/*.d.*.ts +/v2/ diff --git a/types/markdown-it-container/index.d.mts b/types/markdown-it-container/index.d.mts new file mode 100644 index 00000000000000..6fd766a7d08364 --- /dev/null +++ b/types/markdown-it-container/index.d.mts @@ -0,0 +1,5 @@ +import MarkdownItContainer = require("./index.js"); + +export type ContainerOpts = MarkdownItContainer.ContainerOpts; + +export default MarkdownItContainer; diff --git a/types/markdown-it-container/index.d.ts b/types/markdown-it-container/index.d.ts index 87aafd33c0def0..540a3baf9adbc6 100644 --- a/types/markdown-it-container/index.d.ts +++ b/types/markdown-it-container/index.d.ts @@ -1,11 +1,10 @@ import MarkdownIt = require("markdown-it"); -import Renderer = require("markdown-it/lib/renderer"); declare namespace MarkdownItContainer { interface ContainerOpts { marker?: string | undefined; validate?(params: string): boolean; - render?: Renderer.RenderRule | undefined; + render?: MarkdownIt.Renderer.RenderRule | undefined; } } diff --git a/types/markdown-it-container/package.json b/types/markdown-it-container/package.json index dc089f647432bc..88c4314ab38780 100644 --- a/types/markdown-it-container/package.json +++ b/types/markdown-it-container/package.json @@ -1,12 +1,22 @@ { "private": true, "name": "@types/markdown-it-container", - "version": "2.0.9999", + "version": "4.0.9999", "projects": [ "https://github.com/markdown-it/markdown-it-container" ], + "exports": { + ".": { + "require": "./index.d.ts", + "import": "./index.d.mts" + }, + "./*": { + "require": "./*", + "import": "./*" + } + }, "dependencies": { - "@types/markdown-it": "<14" + "@types/markdown-it": ">=14" }, "devDependencies": { "@types/markdown-it-container": "workspace:." diff --git a/types/markdown-it-container/tsconfig.json b/types/markdown-it-container/tsconfig.json index a088dbc9ab8fcd..a8a7500f5a8d6a 100644 --- a/types/markdown-it-container/tsconfig.json +++ b/types/markdown-it-container/tsconfig.json @@ -14,6 +14,7 @@ }, "files": [ "index.d.ts", + "index.d.mts", "markdown-it-container-tests.ts" ] } diff --git a/types/markdown-it-container/v2/.npmignore b/types/markdown-it-container/v2/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/markdown-it-container/v2/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/markdown-it-container/v2/index.d.ts b/types/markdown-it-container/v2/index.d.ts new file mode 100644 index 00000000000000..87aafd33c0def0 --- /dev/null +++ b/types/markdown-it-container/v2/index.d.ts @@ -0,0 +1,14 @@ +import MarkdownIt = require("markdown-it"); +import Renderer = require("markdown-it/lib/renderer"); + +declare namespace MarkdownItContainer { + interface ContainerOpts { + marker?: string | undefined; + validate?(params: string): boolean; + render?: Renderer.RenderRule | undefined; + } +} + +declare function MarkdownItContainer(md: MarkdownIt, name: string, opts: MarkdownItContainer.ContainerOpts): void; + +export = MarkdownItContainer; diff --git a/types/markdown-it-container/v2/markdown-it-container-tests.ts b/types/markdown-it-container/v2/markdown-it-container-tests.ts new file mode 100644 index 00000000000000..7b9e1276d3a0de --- /dev/null +++ b/types/markdown-it-container/v2/markdown-it-container-tests.ts @@ -0,0 +1,36 @@ +import MarkdownIt = require("markdown-it"); + +import MarkdownItContainer = require("markdown-it-container"); + +const md = new MarkdownIt(); + +md.use(MarkdownItContainer, "spoiler", { + validate: (params: string) => params.trim().match(/^spoiler\s+(.*)$/), + render: (tokens: MarkdownIt.Token[], index: number) => { + const match = tokens[index].info.trim().match(/^spoiler\s+(.*)$/); + const onClick = "this.parentNode.classList.toggle('_expanded');" + "event.preventDefault();"; + + if (tokens[index].nesting === 1) { + return ( + // tslint:disable-next-line prefer-template + "
\n" + + "
\n" + + md.utils.escapeHtml((match && match[1]) || "") + + "\n" + + "
\n" + + "
\n" + ); + } else { + return "
\n"; + } + }, + marker: "marker", +}); + +const src = `:::spoiler This Is Spoiler Title +Here is spoiler content. +:::`; + +md.render(src); diff --git a/types/markdown-it-container/v2/package.json b/types/markdown-it-container/v2/package.json new file mode 100644 index 00000000000000..dc089f647432bc --- /dev/null +++ b/types/markdown-it-container/v2/package.json @@ -0,0 +1,20 @@ +{ + "private": true, + "name": "@types/markdown-it-container", + "version": "2.0.9999", + "projects": [ + "https://github.com/markdown-it/markdown-it-container" + ], + "dependencies": { + "@types/markdown-it": "<14" + }, + "devDependencies": { + "@types/markdown-it-container": "workspace:." + }, + "owners": [ + { + "name": "Vyacheslav Demot", + "githubUsername": "hronex" + } + ] +} diff --git a/types/markdown-it-container/v2/tsconfig.json b/types/markdown-it-container/v2/tsconfig.json new file mode 100644 index 00000000000000..a088dbc9ab8fcd --- /dev/null +++ b/types/markdown-it-container/v2/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "markdown-it-container-tests.ts" + ] +} diff --git a/types/node/process.d.ts b/types/node/process.d.ts index 2d12c9cf3f224f..914106fc05ce3b 100644 --- a/types/node/process.d.ts +++ b/types/node/process.d.ts @@ -1,6 +1,5 @@ declare module "node:process" { import { Control, MessageOptions, SendHandle } from "node:child_process"; - import { InternalEventEmitter } from "node:events"; import { PathLike } from "node:fs"; import * as tty from "node:tty"; import { Worker } from "node:worker_threads"; @@ -687,7 +686,7 @@ declare module "node:process" { readonly visibility: string; }; } - interface Process extends InternalEventEmitter { + interface Process extends EventEmitter { /** * The `process.stdout` property returns a stream connected to`stdout` (fd `1`). It is a `net.Socket` (which is a `Duplex` stream) unless fd `1` refers to a file, in which case it is * a `Writable` stream. @@ -2100,6 +2099,57 @@ declare module "node:process" { * **Default:** `process.env`. */ execve?(file: string, args?: readonly string[], env?: ProcessEnv): never; + // #region InternalEventEmitter + addListener( + eventName: E, + listener: (...args: ProcessEventMap[E]) => void, + ): this; + addListener(eventName: string | symbol, listener: (...args: any[]) => void): this; + emit(eventName: E, ...args: ProcessEventMap[E]): boolean; + emit(eventName: string | symbol, ...args: any[]): boolean; + listenerCount( + eventName: E, + listener?: (...args: ProcessEventMap[E]) => void, + ): number; + listenerCount(eventName: string | symbol, listener?: (...args: any[]) => void): number; + listeners(eventName: E): ((...args: ProcessEventMap[E]) => void)[]; + listeners(eventName: string | symbol): ((...args: any[]) => void)[]; + off( + eventName: E, + listener: (...args: ProcessEventMap[E]) => void, + ): this; + off(eventName: string | symbol, listener: (...args: any[]) => void): this; + on( + eventName: E, + listener: (...args: ProcessEventMap[E]) => void, + ): this; + on(eventName: string | symbol, listener: (...args: any[]) => void): this; + once( + eventName: E, + listener: (...args: ProcessEventMap[E]) => void, + ): this; + once(eventName: string | symbol, listener: (...args: any[]) => void): this; + prependListener( + eventName: E, + listener: (...args: ProcessEventMap[E]) => void, + ): this; + prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this; + prependOnceListener( + eventName: E, + listener: (...args: ProcessEventMap[E]) => void, + ): this; + prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this; + rawListeners(eventName: E): ((...args: ProcessEventMap[E]) => void)[]; + rawListeners(eventName: string | symbol): ((...args: any[]) => void)[]; + // eslint-disable-next-line @definitelytyped/no-unnecessary-generics + removeAllListeners(eventName?: E): this; + removeAllListeners(eventName?: string | symbol): this; + removeListener( + eventName: E, + listener: (...args: ProcessEventMap[E]) => void, + ): this; + removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this; + // #endregion } } } diff --git a/types/npmcli__arborist/index.d.ts b/types/npmcli__arborist/index.d.ts index 588779849f93b7..45d2646e5f63d2 100644 --- a/types/npmcli__arborist/index.d.ts +++ b/types/npmcli__arborist/index.d.ts @@ -42,9 +42,10 @@ declare class Arborist extends EventEmitter { /** returns a set of root dependencies, excluding dependencies that are exclusively workspace dependencies */ excludeWorkspacesDependencySet(tree: Arborist.Node): Set; } +type ArboristConstructor = typeof Arborist; declare namespace Arborist { - const Arborist: Arborist; + const Arborist: ArboristConstructor; interface Options extends PacoteOptions, Partial> { path?: string; nodeVersion?: string; diff --git a/types/npmcli__arborist/npmcli__arborist-tests.ts b/types/npmcli__arborist/npmcli__arborist-tests.ts index 1030bda30e4305..3395c2c14cde25 100644 --- a/types/npmcli__arborist/npmcli__arborist-tests.ts +++ b/types/npmcli__arborist/npmcli__arborist-tests.ts @@ -15,6 +15,7 @@ const arb = new Arborist({ progress: true, formatPackageLock: true, }); +new Arborist.Arborist(); arb.loadActual().then(tree => { tree; // $ExpectType Node diff --git a/types/vscode/README.md b/types/vscode/README.md new file mode 100644 index 00000000000000..d157602f93bf13 --- /dev/null +++ b/types/vscode/README.md @@ -0,0 +1,7 @@ +# @types/vscode + +## Contributing + +`@types/vscode/index.d.ts` is an idential re-export of `src/vscode-dts/vscode.d.ts` in https://github.com/microsoft/vscode. See https://github.com/microsoft/vscode/tree/main/build/azure-pipelines/publish-types for how these types are updated. + +If you would like to contribute, please open an issue or a pull request there. Any code changes on `@types/vscode` without going through `microsoft/vscode` repo will risk being eliminated by microsoft's pipeline.