refactor: add some missing explicit types (#3997)

* refactor: add some missing return types and mark some non-exported types as `@internal`

* Update expect/fn.ts

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>

* Remove @internals

* nits

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
This commit is contained in:
David Sherret 2023-12-19 01:26:13 +01:00 committed by GitHub
parent 83fe26f36d
commit b0803619af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 146 additions and 118 deletions

View File

@ -167,7 +167,7 @@ export class CsvParseStream<
}
}
get readable() {
get readable(): ReadableStream<RowType<T>> {
return this.#readable as ReadableStream<RowType<T>>;
}

View File

@ -13,7 +13,7 @@ import {
} from "./_io.ts";
import { assert } from "../assert/assert.ts";
export { ParseError, ReadOptions };
export { ParseError, type ParseResult, ReadOptions };
const BYTE_ORDER_MARK = "\ufeff";

View File

@ -61,7 +61,7 @@ export class BinaryHeap<T> implements Iterable<T> {
#data: T[] = [];
constructor(private compare: (a: T, b: T) => number = descend) {}
/** Returns the underlying cloned array in arbitrary order without sorting */
toArray() {
toArray(): T[] {
return Array.from(this.#data);
}
/** Creates a new binary heap from an array like or iterable object. */

View File

@ -2,11 +2,11 @@
/** This module is browser compatible. */
/** Compares its two arguments for ascending order using JavaScript's built in comparison operators. */
export function ascend<T>(a: T, b: T) {
export function ascend<T>(a: T, b: T): -1 | 0 | 1 {
return a < b ? -1 : a > b ? 1 : 0;
}
/** Compares its two arguments for descending order using JavaScript's built in comparison operators. */
export function descend<T>(a: T, b: T) {
export function descend<T>(a: T, b: T): -1 | 0 | 1 {
return a < b ? 1 : a > b ? -1 : 0;
}

View File

@ -22,7 +22,7 @@ export const SECOND = 1e3;
* console.log(MINUTE); // => 60000 (60 * 1000)
* ```
*/
export const MINUTE = SECOND * 60;
export const MINUTE: number = SECOND * 60;
/**
* The number of milliseconds in an hour.
*
@ -33,7 +33,7 @@ export const MINUTE = SECOND * 60;
* console.log(HOUR); // => 3600000 (60 * 60 * 1000)
* ```
*/
export const HOUR = MINUTE * 60;
export const HOUR: number = MINUTE * 60;
/**
* The number of milliseconds in a day.
*
@ -44,7 +44,7 @@ export const HOUR = MINUTE * 60;
* console.log(DAY); // => 86400000 (24 * 60 * 60 * 1000)
* ```
*/
export const DAY = HOUR * 24;
export const DAY: number = HOUR * 24;
/**
* The number of milliseconds in a week.
*
@ -55,4 +55,4 @@ export const DAY = HOUR * 24;
* console.log(WEEK); // => 604800000 (7 * 24 * 60 * 60 * 1000)
* ```
*/
export const WEEK = DAY * 7;
export const WEEK: number = DAY * 7;

View File

@ -12,7 +12,7 @@
* @param object object to be stringified
* @returns string of object
*/
export function stringify(object: Record<string, string>) {
export function stringify(object: Record<string, string>): string {
const lines: string[] = [];
for (const [key, value] of Object.entries(object)) {
let quote;

View File

@ -4,7 +4,7 @@
import { MOCK_SYMBOL, MockCall } from "./_mock_util.ts";
export function fn(...stubs: Function[]) {
export function fn(...stubs: Function[]): Function {
const calls: MockCall[] = [];
const f = (...args: any[]) => {

View File

@ -567,7 +567,7 @@ const ANSI_PATTERN = new RegExp(
* Remove ANSI escape codes from the string.
* @param string to remove ANSI escape codes from
*/
export const stripColor = stripAnsiCode;
export const stripColor: typeof stripAnsiCode = stripAnsiCode;
/**
* Remove ANSI escape codes from the string.

View File

@ -1,6 +1,6 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { createExtractor, Parser } from "./create_extractor.ts";
import { createExtractor, type Extractor, Parser } from "./create_extractor.ts";
import { parse as parseYAML } from "../yaml/parse.ts";
import { parse as parseTOML } from "../toml/parse.ts";
@ -10,7 +10,7 @@ export {
test,
} from "./test.ts";
export const extract = createExtractor({
export const extract: Extractor = createExtractor({
yaml: parseYAML as Parser,
toml: parseTOML as Parser,
json: JSON.parse as Parser,

View File

@ -1,6 +1,6 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { createExtractor, Parser } from "./create_extractor.ts";
import { createExtractor, type Extractor, Parser } from "./create_extractor.ts";
import { test as _test } from "./test.ts";
export { Format } from "./_formats.ts";
@ -10,6 +10,8 @@ export function test(str: string): boolean {
return _test(str, ["json"]);
}
export const extract = createExtractor({ json: JSON.parse as Parser });
export const extract: Extractor = createExtractor({
json: JSON.parse as Parser,
});
/** @deprecated (will be removed after 0.210.0) Import {@linkcode extract} as a named import instead. */
export default extract;

View File

@ -1,6 +1,6 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { createExtractor, Parser } from "./create_extractor.ts";
import { createExtractor, type Extractor, Parser } from "./create_extractor.ts";
import { test as _test } from "./test.ts";
import { parse } from "../toml/parse.ts";
@ -11,6 +11,8 @@ export function test(str: string): boolean {
return _test(str, ["toml"]);
}
export const extract = createExtractor({ ["toml"]: parse as Parser });
export const extract: Extractor = createExtractor({
["toml"]: parse as Parser,
});
/** @deprecated (will be removed after 0.210.0) Import {@linkcode extract} as a named import instead. */
export default extract;

View File

@ -1,6 +1,6 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { createExtractor, Parser } from "./create_extractor.ts";
import { createExtractor, type Extractor, Parser } from "./create_extractor.ts";
import { test as _test } from "./test.ts";
import { parse } from "../yaml/parse.ts";
@ -11,6 +11,8 @@ export function test(str: string): boolean {
return _test(str, ["yaml"]);
}
export const extract = createExtractor({ ["yaml"]: parse as Parser });
export const extract: Extractor = createExtractor({
["yaml"]: parse as Parser,
});
/** @deprecated (will be removed after 0.210.0) Import {@linkcode extract} as a named import instead. */
export default extract;

View File

@ -36,7 +36,7 @@ const rawRe = new RegExp(`[${[...rawToEntity.keys()].join("")}]`, "g");
* assertEquals(escape("þð"), "þð");
* ```
*/
export function escape(str: string) {
export function escape(str: string): string {
return str.replaceAll(rawRe, (m) => rawToEntity.get(m)!);
}
@ -73,7 +73,7 @@ const entityListRegexCache = new WeakMap<EntityList, RegExp>();
export function unescape(
str: string,
options: Partial<UnescapeOptions> = {},
) {
): string {
const { entityList } = { ...defaultUnescapeOptions, ...options };
let entityRe = entityListRegexCache.get(entityList);

View File

@ -146,7 +146,8 @@ export type SecureCookieMapSetDeleteOptions = SecureCookieMapSetDeleteOptions_;
*
* @deprecated (will be removed after 0.212.0) Use {@link https://deno.land/std/http/cookie.ts} instead.
*/
export const cookieMapHeadersInitSymbol = cookieMapHeadersInitSymbol_;
export const cookieMapHeadersInitSymbol: typeof cookieMapHeadersInitSymbol_ =
cookieMapHeadersInitSymbol_;
/**
* Allows merging of various sources of headers into a final set of headers
@ -159,7 +160,7 @@ export const cookieMapHeadersInitSymbol = cookieMapHeadersInitSymbol_;
*
* @deprecated (will be removed after 0.212.0) Use {@link https://deno.land/std/http/cookie.ts} instead.
*/
export const mergeHeaders = mergeHeaders_;
export const mergeHeaders: typeof mergeHeaders_ = mergeHeaders_;
/**
* Provides a way to manage cookies in a request and response on the server
@ -174,7 +175,7 @@ export const mergeHeaders = mergeHeaders_;
*
* @deprecated (will be removed after 0.212.0) Use {@link https://deno.land/std/http/cookie.ts} instead.
*/
export const CookieMap = CookieMap_;
export const CookieMap: typeof CookieMap_ = CookieMap_;
/**
* Types of data that can be signed cryptographically.
@ -211,4 +212,4 @@ export type KeyRing = KeyRing_;
*
* @deprecated (will be removed after 0.212.0) Use {@link https://deno.land/std/http/unstable_signed_cookie.ts} instead.
*/
export const SecureCookieMap = SecureCookieMap_;
export const SecureCookieMap: typeof SecureCookieMap_ = SecureCookieMap_;

View File

@ -608,7 +608,10 @@ export interface ServeDirOptions {
*
* @param req The request to handle
*/
export async function serveDir(req: Request, opts: ServeDirOptions = {}) {
export async function serveDir(
req: Request,
opts: ServeDirOptions = {},
): Promise<Response> {
let response: Response;
try {
response = await createServeDirResponse(req, opts);

View File

@ -38,7 +38,7 @@ import * as status from "./status.ts";
/**
* @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/http/status.ts} instead.
*/
export const Status = status.Status;
export const Status: typeof status.Status = status.Status;
/**
* @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/http/status.ts} instead.
*/
@ -46,7 +46,7 @@ export type Status = status.Status;
/**
* @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/http/status.ts} instead.
*/
export const STATUS_TEXT = status.STATUS_TEXT;
export const STATUS_TEXT: typeof status.STATUS_TEXT = status.STATUS_TEXT;
/**
* @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/http/status.ts} instead.
*/
@ -74,24 +74,29 @@ export type ErrorStatus = status.ErrorStatus;
/**
* @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/http/status.ts} instead.
*/
export const isInformationalStatus = status.isInformationalStatus;
export const isInformationalStatus: typeof status.isInformationalStatus =
status.isInformationalStatus;
/**
* @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/http/status.ts} instead.
*/
export const isSuccessfulStatus = status.isSuccessfulStatus;
export const isSuccessfulStatus: typeof status.isSuccessfulStatus =
status.isSuccessfulStatus;
/**
* @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/http/status.ts} instead.
*/
export const isRedirectStatus = status.isRedirectStatus;
export const isRedirectStatus: typeof status.isRedirectStatus =
status.isRedirectStatus;
/**
* @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/http/status.ts} instead.
*/
export const isClientErrorStatus = status.isClientErrorStatus;
export const isClientErrorStatus: typeof status.isClientErrorStatus =
status.isClientErrorStatus;
/**
* @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/http/status.ts} instead.
*/
export const isServerErrorStatus = status.isServerErrorStatus;
export const isServerErrorStatus: typeof status.isServerErrorStatus =
status.isServerErrorStatus;
/**
* @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/http/status.ts} instead.
*/
export const isErrorStatus = status.isErrorStatus;
export const isErrorStatus: typeof status.isErrorStatus = status.isErrorStatus;

View File

@ -138,7 +138,7 @@ export class Server {
*
* @param listener The listener to accept connections from.
*/
async serve(listener: Deno.Listener) {
async serve(listener: Deno.Listener): Promise<void> {
if (this.#closed) {
throw new Deno.errors.Http(ERROR_SERVER_CLOSED);
}
@ -188,7 +188,7 @@ export class Server {
* await server.listenAndServe();
* ```
*/
async listenAndServe() {
async listenAndServe(): Promise<void> {
if (this.#closed) {
throw new Deno.errors.Http(ERROR_SERVER_CLOSED);
}
@ -238,7 +238,7 @@ export class Server {
* @param certFile The path to the file containing the TLS certificate.
* @param keyFile The path to the file containing the TLS private key.
*/
async listenAndServeTls(certFile: string, keyFile: string) {
async listenAndServeTls(certFile: string, keyFile: string): Promise<void> {
if (this.#closed) {
throw new Deno.errors.Http(ERROR_SERVER_CLOSED);
}
@ -559,7 +559,7 @@ export async function serveListener(
listener: Deno.Listener,
handler: Handler,
options?: ServeListenerOptions,
) {
): Promise<void> {
const server = new Server({ handler, onError: options?.onError });
options?.signal?.addEventListener("abort", () => server.close(), {
@ -626,7 +626,7 @@ function hostnameForDisplay(hostname: string) {
export async function serve(
handler: Handler,
options: ServeInit = {},
) {
): Promise<void> {
let port = options.port ?? 8000;
if (typeof port !== "number") {
port = Number(port);
@ -744,7 +744,7 @@ export interface ServeTlsInit extends ServeInit {
export async function serveTls(
handler: Handler,
options: ServeTlsInit,
) {
): Promise<void> {
if (!options.key && !options.keyFile) {
throw new Error("TLS config is given, but 'key' is missing.");
}

View File

@ -322,7 +322,7 @@ class Cookie implements CookieAttributes {
*
* @deprecated (will be removed in 0.212.0) Use {@link https://deno.land/std/http/cookie.ts} instead.
*/
export const cookieMapHeadersInitSymbol = Symbol.for(
export const cookieMapHeadersInitSymbol: unique symbol = Symbol.for(
"Deno.std.cookieMap.headersInit",
);
@ -373,7 +373,8 @@ const isSecure = Symbol("#secure");
const requestKeys = Symbol("#requestKeys");
/** An internal abstract class which provides common functionality for
* {@link CookieMap} and {@link SecureCookieMap}. */
* {@link CookieMap} and {@link SecureCookieMap}.
*/
abstract class CookieMapBase implements Mergeable {
[keys]?: string[];
[requestHeaders]: Headers;

View File

@ -1054,7 +1054,14 @@ export class UserAgent {
return this.#ua;
}
toJSON() {
toJSON(): {
browser: Browser;
cpu: Cpu;
device: Device;
engine: Engine;
os: Os;
ua: string;
} {
const { browser, cpu, device, engine, os, ua } = this;
return { browser, cpu, device, engine, os, ua };
}

View File

@ -14,6 +14,11 @@ export interface FormattingOptions {
deduplicate?: boolean;
}
type Formatting = Omit<FormattingOptions, "lineBreak" | "commentChar"> & {
lineBreak?: string;
commentChar?: string;
};
/** Options for parsing INI strings. */
export interface ParseOptions {
/** The character used to assign a value to a key; defaults to '='. */
@ -166,10 +171,7 @@ export class IniMap {
return this.comments;
},
};
#formatting: Omit<FormattingOptions, "lineBreak" | "commentChar"> & {
lineBreak?: string;
commentChar?: string;
};
#formatting: Formatting;
constructor(formatting?: FormattingOptions) {
this.#formatting = this.#cleanFormatting(formatting);
@ -184,7 +186,7 @@ export class IniMap {
return size;
}
get formatting() {
get formatting(): Formatting {
return this.#formatting;
}
@ -467,7 +469,7 @@ export class IniMap {
}
/** Convenience method for `JSON.stringify`. */
toJSON() {
toJSON(): Record<string, unknown | Record<string, unknown>> {
return this.toObject();
}

View File

@ -30,7 +30,7 @@ export class BaseHandler {
if (this.level > logRecord.level) return;
const msg = this.format(logRecord);
return this.log(msg);
this.log(msg);
}
format(logRecord: LogRecord): string {
@ -81,7 +81,7 @@ export class ConsoleHandler extends BaseHandler {
return msg;
}
applyColors(msg: string, level: number) {
applyColors(msg: string, level: number): string {
switch (level) {
case LogLevels.INFO:
msg = blue(msg);

View File

@ -33,7 +33,7 @@ export type LogLevel = typeof LogLevels[LevelName];
export type LevelName = Exclude<keyof typeof LogLevels, number>;
/** Permitted log level names */
export const LogLevelNames = Object.keys(LogLevels).filter((key) =>
export const LogLevelNames: LevelName[] = Object.keys(LogLevels).filter((key) =>
isNaN(Number(key))
) as LevelName[];

View File

@ -14,7 +14,7 @@ import { ValueType } from "./encode.ts";
* console.log(decode(encoded))
* ```
*/
export function decode(uint8: Uint8Array) {
export function decode(uint8: Uint8Array): ValueType {
const pointer = { consumed: 0 };
const dataView = new DataView(
uint8.buffer,

View File

@ -47,7 +47,7 @@ const encoder = new TextEncoder();
* console.log(encode(obj))
* ```
*/
export function encode(object: ValueType) {
export function encode(object: ValueType): Uint8Array {
const byteParts: Uint8Array[] = [];
encodeSlice(object, byteParts);
return concat(byteParts);

View File

@ -9,6 +9,6 @@ import { join as windowsJoin } from "./windows/join.ts";
* Join all given a sequence of `paths`,then normalizes the resulting path.
* @param paths to be joined and normalized
*/
export function join(...paths: string[]) {
export function join(...paths: string[]): string {
return isWindows ? windowsJoin(...paths) : posixJoin(...paths);
}

View File

@ -39,13 +39,15 @@ import * as _windows from "./windows/mod.ts";
import * as _posix from "./posix/mod.ts";
/** @deprecated (will be removed after 1.0.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const win32 = _windows;
export const win32: typeof _windows = _windows;
/** @deprecated (will be removed after 1.0.0) Import from {@link https://deno.land/std/posix/mod.ts} instead. */
export const posix = _posix;
export const posix: typeof _posix = _posix;
export const sep = isWindows ? _windows.sep : _posix.sep;
export const delimiter = isWindows ? _windows.delimiter : _posix.delimiter;
export const sep: "/" | "\\" = isWindows ? _windows.sep : _posix.sep;
export const delimiter: ":" | ";" = isWindows
? _windows.delimiter
: _posix.delimiter;
export * from "./basename.ts";
export * from "./dirname.ts";

View File

@ -4,46 +4,47 @@
import * as path from "./posix/mod.ts";
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const SEP = path.SEP;
export const SEP: typeof path.SEP = path.SEP;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const SEP_PATTERN = path.SEP_PATTERN;
export const SEP_PATTERN: typeof path.SEP_PATTERN = path.SEP_PATTERN;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const basename = path.basename;
export const basename: typeof path.basename = path.basename;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const common = path.common;
export const common: typeof path.common = path.common;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const delimiter = path.delimiter;
export const delimiter: typeof path.delimiter = path.delimiter;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const dirname = path.dirname;
export const dirname: typeof path.dirname = path.dirname;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const extname = path.extname;
export const extname: typeof path.extname = path.extname;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const format = path.format;
export const format: typeof path.format = path.format;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const fromFileUrl = path.fromFileUrl;
export const fromFileUrl: typeof path.fromFileUrl = path.fromFileUrl;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const globToRegExp = path.globToRegExp;
export const globToRegExp: typeof path.globToRegExp = path.globToRegExp;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const isAbsolute = path.isAbsolute;
export const isAbsolute: typeof path.isAbsolute = path.isAbsolute;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const isGlob = path.isGlob;
export const isGlob: typeof path.isGlob = path.isGlob;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const join = path.join;
export const join: typeof path.join = path.join;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const joinGlobs = path.joinGlobs;
export const joinGlobs: typeof path.joinGlobs = path.joinGlobs;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const normalize = path.normalize;
export const normalize: typeof path.normalize = path.normalize;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const normalizeGlob = path.normalizeGlob;
export const normalizeGlob: typeof path.normalizeGlob = path.normalizeGlob;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const parse = path.parse;
export const parse: typeof path.parse = path.parse;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const relative = path.relative;
export const relative: typeof path.relative = path.relative;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const resolve = path.resolve;
export const resolve: typeof path.resolve = path.resolve;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const sep = path.sep;
export const sep: typeof path.sep = path.sep;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const toFileUrl = path.toFileUrl;
export const toFileUrl: typeof path.toFileUrl = path.toFileUrl;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/posix/mod.ts} instead. */
export const toNamespacedPath = path.toNamespacedPath;
export const toNamespacedPath: typeof path.toNamespacedPath =
path.toNamespacedPath;

View File

@ -14,7 +14,7 @@ import { isAbsolute } from "./is_absolute.ts";
* ```
* @param path to convert to file URL
*/
export function toFileUrl(path: string) {
export function toFileUrl(path: string): URL {
if (!isAbsolute(path)) {
throw new TypeError("Must be an absolute path.");
}

View File

@ -3,5 +3,5 @@
import { isWindows } from "./_os.ts";
export const SEP = isWindows ? "\\" : "/";
export const SEP_PATTERN = isWindows ? /[\\/]+/ : /\/+/;
export const SEP: "/" | "\\" = isWindows ? "\\" : "/";
export const SEP_PATTERN: RegExp = isWindows ? /[\\/]+/ : /\/+/;

View File

@ -4,46 +4,47 @@
import * as path from "./windows/mod.ts";
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const SEP = path.SEP;
export const SEP: typeof path.SEP = path.SEP;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const SEP_PATTERN = path.SEP_PATTERN;
export const SEP_PATTERN: typeof path.SEP_PATTERN = path.SEP_PATTERN;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const basename = path.basename;
export const basename: typeof path.basename = path.basename;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const common = path.common;
export const common: typeof path.common = path.common;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const delimiter = path.delimiter;
export const delimiter: typeof path.delimiter = path.delimiter;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const dirname = path.dirname;
export const dirname: typeof path.dirname = path.dirname;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const extname = path.extname;
export const extname: typeof path.extname = path.extname;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const format = path.format;
export const format: typeof path.format = path.format;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const fromFileUrl = path.fromFileUrl;
export const fromFileUrl: typeof path.fromFileUrl = path.fromFileUrl;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const globToRegExp = path.globToRegExp;
export const globToRegExp: typeof path.globToRegExp = path.globToRegExp;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const isAbsolute = path.isAbsolute;
export const isAbsolute: typeof path.isAbsolute = path.isAbsolute;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const isGlob = path.isGlob;
export const isGlob: typeof path.isGlob = path.isGlob;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const join = path.join;
export const join: typeof path.join = path.join;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const joinGlobs = path.joinGlobs;
export const joinGlobs: typeof path.joinGlobs = path.joinGlobs;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const normalize = path.normalize;
export const normalize: typeof path.normalize = path.normalize;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const normalizeGlob = path.normalizeGlob;
export const normalizeGlob: typeof path.normalizeGlob = path.normalizeGlob;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const parse = path.parse;
export const parse: typeof path.parse = path.parse;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const relative = path.relative;
export const relative: typeof path.relative = path.relative;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const resolve = path.resolve;
export const resolve: typeof path.resolve = path.resolve;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const sep = path.sep;
export const sep: typeof path.sep = path.sep;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const toFileUrl = path.toFileUrl;
export const toFileUrl: typeof path.toFileUrl = path.toFileUrl;
/** @deprecated (will be removed after 0.210.0) Import from {@link https://deno.land/std/path/windows/mod.ts} instead. */
export const toNamespacedPath = path.toNamespacedPath;
export const toNamespacedPath: typeof path.toNamespacedPath =
path.toNamespacedPath;

View File

@ -75,7 +75,7 @@ const RX_REGEXP_ESCAPE = new RegExp(
* assertNotMatch("a", re);
* ```
*/
export function escape(str: string) {
export function escape(str: string): string {
return str.replaceAll(
RX_REGEXP_ESCAPE,
(m) => reservedCharMap[m as keyof typeof reservedCharMap],

View File

@ -8,7 +8,7 @@ import { format } from "./format.ts";
* @param comparator
* @returns A string representation of the comparator
*/
export function comparatorFormat(comparator: SemVerComparator) {
export function comparatorFormat(comparator: SemVerComparator): string {
const { semver, operator } = comparator;
return `${operator}${format(semver)}`;
}

View File

@ -22,7 +22,7 @@ function formatNumber(value: number) {
* @param semver The semantic version to format
* @returns The string representation of a semantic version.
*/
export function format(semver: SemVer, style: FormatStyle = "full") {
export function format(semver: SemVer, style: FormatStyle = "full"): string {
if (semver === ANY) {
return "*";
}

View File

@ -12,4 +12,4 @@ import { isComparator } from "./is_comparator.ts";
* @returns True if the object is a SemVerComparator otherwise false
* @deprecated (will be removed in 0.212.0) Use {@linkcode isComparator} instead.
*/
export const isSemVerComparator = isComparator;
export const isSemVerComparator: typeof isComparator = isComparator;

View File

@ -8,9 +8,7 @@ import { comparatorFormat } from "./comparator_format.ts";
* @param range The range to format
* @returns A string representation of the range
*/
export function rangeFormat(range: SemVerRange) {
export function rangeFormat(range: SemVerRange): string {
return range.ranges.map((c) => c.map((c) => comparatorFormat(c)).join(" "))
.join(
"||",
);
.join("||");
}

View File

@ -24,7 +24,7 @@ const getWordDistance = levenshteinDistance;
export function compareSimilarity(
givenWord: string,
options?: { caseSensitive?: boolean },
) {
): (a: string, b: string) => number {
const { caseSensitive } = { ...options };
if (caseSensitive) {
return (a: string, b: string) =>

View File

@ -7,4 +7,5 @@ import { ParserFactory, Toml } from "./_parser.ts";
* Parse parses TOML string into an object.
* @param tomlString
*/
export const parse = ParserFactory(Toml);
export const parse: (tomlString: string) => Record<string, unknown> =
ParserFactory(Toml);

View File

@ -92,7 +92,7 @@ export class Schema implements SchemaDefinition {
}
/* Returns a new extended schema from current schema */
public extend(definition: SchemaDefinition) {
public extend(definition: SchemaDefinition): Schema {
return new Schema({
implicit: [
...new Set([...this.implicit, ...(definition?.implicit ?? [])]),