chore: add more explicit types (#4018)

* Add explicit types

* Format.

* Revert
This commit is contained in:
David Sherret 2023-12-21 23:35:15 -05:00 committed by GitHub
parent fd3116778e
commit ceb107f4ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 19 additions and 17 deletions

View File

@ -20,7 +20,7 @@
export function lastIndexOfNeedle(
source: Uint8Array,
needle: Uint8Array,
start = source.length - 1,
start: number = source.length - 1,
): number {
if (start < 0) {
return -1;

View File

@ -370,7 +370,7 @@ const keys = Symbol("#keys");
const requestHeaders = Symbol("#requestHeaders");
const responseHeaders = Symbol("#responseHeaders");
const isSecure = Symbol("#secure");
const requestKeys = Symbol("#requestKeys");
const requestKeys: unique symbol = Symbol("#requestKeys");
/** An internal abstract class which provides common functionality for
* {@link CookieMap} and {@link SecureCookieMap}.
@ -417,7 +417,7 @@ abstract class CookieMapBase implements Mergeable {
return init;
}
[Symbol.for("Deno.customInspect")]() {
[Symbol.for("Deno.customInspect")](): string {
return `${this.constructor.name} []`;
}
@ -426,7 +426,7 @@ abstract class CookieMapBase implements Mergeable {
// deno-lint-ignore no-explicit-any
options: any,
inspect: (value: unknown, options?: unknown) => string,
) {
): string {
if (depth < 0) {
return options.stylize(`[${this.constructor.name}]`, "special");
}

View File

@ -10,7 +10,7 @@
*/
export function sliceLongToBytes(
d: number,
dest = Array.from<number>({ length: 8 }),
dest: number[] = Array.from<number>({ length: 8 }),
): number[] {
let big = BigInt(d);
for (let i = 0; i < 8; i++) {

View File

@ -143,7 +143,7 @@ export class FileHandler extends WriterHandler {
protected _filename: string;
protected _mode: LogMode;
protected _openOptions: Deno.OpenOptions;
protected _encoder = new TextEncoder();
protected _encoder: TextEncoder = new TextEncoder();
#unloadCallback = (() => {
this.destroy();
}).bind(this);

View File

@ -357,7 +357,7 @@
*/
import { Logger } from "./logger.ts";
import type { GenericFunction } from "./logger.ts";
import type { GenericFunction, LogRecord } from "./logger.ts";
import {
BaseHandler,
ConsoleHandler,
@ -439,7 +439,9 @@ export const handlers = {
RotatingFileHandler,
};
export const formatters = {
export const formatters: {
jsonFormatter(logRecord: LogRecord): string;
} = {
jsonFormatter,
};

View File

@ -16,6 +16,6 @@ import { SEP } from "./separator.ts";
* console.log(p); // "./deno/std/"
* ```
*/
export function common(paths: string[], sep = SEP): string {
export function common(paths: string[], sep: typeof SEP = SEP): string {
return _common(paths, sep);
}

View File

@ -16,6 +16,6 @@ import { SEP } from "./separator.ts";
* console.log(p); // "./deno/std/"
* ```
*/
export function common(paths: string[], sep = SEP): string {
export function common(paths: string[], sep: typeof SEP = SEP): string {
return _common(paths, sep);
}

View File

@ -16,6 +16,6 @@ import { SEP } from "./separator.ts";
* console.log(p); // "./deno/std/"
* ```
*/
export function common(paths: string[], sep = SEP): string {
export function common(paths: string[], sep: typeof SEP = SEP): string {
return _common(paths, sep);
}

View File

@ -21,7 +21,7 @@ export class ByteSliceStream extends TransformStream<Uint8Array, Uint8Array> {
#offsetEnd = 0;
/** Constructs a new instance. */
constructor(start = 0, end = Infinity) {
constructor(start = 0, end: number = Infinity) {
super({
start: () => {
assert(start >= 0, "`start` must be greater than 0");

View File

@ -9,6 +9,6 @@ import { json } from "./json.ts";
// Standard YAML's Core schema.
// http://www.yaml.org/spec/1.2/spec.html#id2804923
export const core = new Schema({
export const core: Schema = new Schema({
include: [json],
});

View File

@ -10,7 +10,7 @@ import { core } from "./core.ts";
// JS-YAML's default schema for `safeLoad` function.
// It is not described in the YAML specification.
export const def = new Schema({
export const def: Schema = new Schema({
explicit: [binary, omap, pairs, set],
implicit: [timestamp, merge],
include: [core],

View File

@ -33,7 +33,7 @@ import { def } from "./default.ts";
* );
* ```
*/
export const extended = new Schema({
export const extended: Schema = new Schema({
explicit: [regexp, undefinedType],
include: [def],
});

View File

@ -9,6 +9,6 @@ import { map, seq, str } from "../_type/mod.ts";
// Standard YAML's Failsafe schema.
// http://www.yaml.org/spec/1.2/spec.html#id2802346
export const failsafe = new Schema({
export const failsafe: Schema = new Schema({
explicit: [str, seq, map],
});

View File

@ -10,7 +10,7 @@ import { failsafe } from "./failsafe.ts";
// Standard YAML's JSON schema.
// http://www.yaml.org/spec/1.2/spec.html#id2803231
export const json = new Schema({
export const json: Schema = new Schema({
implicit: [nil, bool, int, float],
include: [failsafe],
});