Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add more explicit types #4018

Merged
merged 3 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bytes/last_index_of_needle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
export function lastIndexOfNeedle(
source: Uint8Array,
needle: Uint8Array,
start = source.length - 1,
start: number = source.length - 1,
iuioiua marked this conversation as resolved.
Show resolved Hide resolved
): number {
if (start < 0) {
return -1;
Expand Down
6 changes: 3 additions & 3 deletions http/unstable_cookie_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@
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}.
Expand Down Expand Up @@ -417,7 +417,7 @@
return init;
}

[Symbol.for("Deno.customInspect")]() {
[Symbol.for("Deno.customInspect")](): string {
return `${this.constructor.name} []`;
}

Expand All @@ -426,7 +426,7 @@
// deno-lint-ignore no-explicit-any
options: any,
inspect: (value: unknown, options?: unknown) => string,
) {
): string {

Check warning on line 429 in http/unstable_cookie_map.ts

View check run for this annotation

Codecov / codecov/patch

http/unstable_cookie_map.ts#L429

Added line #L429 was not covered by tests
if (depth < 0) {
return options.stylize(`[${this.constructor.name}]`, "special");
}
Expand Down
2 changes: 1 addition & 1 deletion io/slice_long_to_bytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
export function sliceLongToBytes(
d: number,
dest = Array.from<number>({ length: 8 }),
dest: number[] = Array.from<number>({ length: 8 }),
iuioiua marked this conversation as resolved.
Show resolved Hide resolved
): number[] {
let big = BigInt(d);
for (let i = 0; i < 8; i++) {
Expand Down
2 changes: 1 addition & 1 deletion log/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 11 additions & 3 deletions log/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -431,15 +431,23 @@ const state = {
* For examples check source code of {@linkcode FileHandler}`
* and {@linkcode TestHandler}.
*/
export const handlers = {
export const handlers: {
iuioiua marked this conversation as resolved.
Show resolved Hide resolved
BaseHandler: typeof BaseHandler;
ConsoleHandler: typeof ConsoleHandler;
WriterHandler: typeof WriterHandler;
FileHandler: typeof FileHandler;
RotatingFileHandler: typeof RotatingFileHandler;
iuioiua marked this conversation as resolved.
Show resolved Hide resolved
} = {
BaseHandler,
ConsoleHandler,
WriterHandler,
FileHandler,
RotatingFileHandler,
};

export const formatters = {
export const formatters: {
jsonFormatter(logRecord: LogRecord): string;
} = {
jsonFormatter,
};

Expand Down
2 changes: 1 addition & 1 deletion path/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion path/posix/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
* console.log(p); // "./deno/std/"
* ```
*/
export function common(paths: string[], sep = SEP): string {
export function common(paths: string[], sep: typeof SEP = SEP): string {

Check warning on line 19 in path/posix/common.ts

View check run for this annotation

Codecov / codecov/patch

path/posix/common.ts#L19

Added line #L19 was not covered by tests
return _common(paths, sep);
}
2 changes: 1 addition & 1 deletion path/windows/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
* console.log(p); // "./deno/std/"
* ```
*/
export function common(paths: string[], sep = SEP): string {
export function common(paths: string[], sep: typeof SEP = SEP): string {

Check warning on line 19 in path/windows/common.ts

View check run for this annotation

Codecov / codecov/patch

path/windows/common.ts#L19

Added line #L19 was not covered by tests
return _common(paths, sep);
}
2 changes: 1 addition & 1 deletion streams/byte_slice_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion yaml/schema/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
iuioiua marked this conversation as resolved.
Show resolved Hide resolved
include: [json],
});
2 changes: 1 addition & 1 deletion yaml/schema/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion yaml/schema/extended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
});
2 changes: 1 addition & 1 deletion yaml/schema/failsafe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
});
2 changes: 1 addition & 1 deletion yaml/schema/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
});