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

Specify import type when applicable #244

Merged
merged 2 commits into from
Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 0 deletions .github/workflows/oak-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ jobs:
run: deno lint --unstable
- name: run tests
run: deno test --config tsconfig.json --allow-read --allow-write
- name: run tests unstable
run: deno test --config tsconfig.json --allow-read --allow-write --unstable
2 changes: 1 addition & 1 deletion application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "./deps.ts";
import { Key, KeyStack } from "./keyStack.ts";
import { compose, Middleware } from "./middleware.ts";
import {
import type {
Serve,
Server,
ServerRequest,
Expand Down
2 changes: 1 addition & 1 deletion body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { assert } from "./deps.ts";
import { httpErrors } from "./httpError.ts";
import { isMediaType } from "./isMediaType.ts";
import { FormDataReader } from "./multipart.ts";
import { ServerRequest } from "./types.d.ts";
import type { ServerRequest } from "./types.d.ts";

export type BodyType =
| "form"
Expand Down
6 changes: 3 additions & 3 deletions context.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// Copyright 2018-2020 the oak authors. All rights reserved. MIT license.

import { Application, State } from "./application.ts";
import type { Application, State } from "./application.ts";
import { Cookies } from "./cookies.ts";
import {
acceptable,
acceptWebSocket,
WebSocket,
} from "./deps.ts";
import { createHttpError } from "./httpError.ts";
import { KeyStack } from "./keyStack.ts";
import type { KeyStack } from "./keyStack.ts";
import { Request } from "./request.ts";
import { Response } from "./response.ts";
import { send, SendOptions } from "./send.ts";
import {
ServerSentEventTarget,
ServerSentEventTargetOptions,
} from "./server_sent_event.ts";
import { ErrorStatus, ServerRequest } from "./types.d.ts";
import type { ErrorStatus, ServerRequest } from "./types.d.ts";

export interface ContextSendOptions extends SendOptions {
/** The filename to send, which will be resolved based on the other options.
Expand Down
2 changes: 1 addition & 1 deletion context_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Cookies } from "./cookies.ts";
import { Request } from "./request.ts";
import { Response } from "./response.ts";
import { httpErrors } from "./httpError.ts";
import { ServerRequest } from "./types.d.ts";
import type { ServerRequest } from "./types.d.ts";

function createMockApp<S extends State = Record<string, any>>(
state = {} as S,
Expand Down
6 changes: 3 additions & 3 deletions cookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// This was heavily influenced by
// [cookies](https://github.com/pillarjs/cookies/blob/master/index.js)

import { KeyStack } from "./keyStack.ts";
import { Request } from "./request.ts";
import { Response } from "./response.ts";
import type { KeyStack } from "./keyStack.ts";
import type { Request } from "./request.ts";
import type { Response } from "./response.ts";

export interface CookiesOptions {
keys?: KeyStack;
Expand Down
2 changes: 1 addition & 1 deletion headers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018-2020 the oak authors. All rights reserved. MIT license.

import { BufReader } from "./buf_reader.ts";
import type { BufReader } from "./buf_reader.ts";
import { httpErrors } from "./httpError.ts";

const COLON = ":".charCodeAt(0);
Expand Down
4 changes: 2 additions & 2 deletions helpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2018-2020 the oak authors. All rights reserved. MIT license.

import { Context } from "./context.ts";
import { RouterContext } from "./router.ts";
import type { Context } from "./context.ts";
import type { RouterContext } from "./router.ts";

function isRouterContext(value: Context): value is RouterContext {
return "params" in value;
Expand Down
2 changes: 1 addition & 1 deletion httpError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/

import { Status, STATUS_TEXT } from "./deps.ts";
import { ErrorStatus } from "./types.d.ts";
import type { ErrorStatus } from "./types.d.ts";

const errorStatusMap = {
"BadRequest": 400,
Expand Down
4 changes: 2 additions & 2 deletions middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

// deno-lint-ignore-file

import { State } from "./application.ts";
import { Context } from "./context.ts";
import type { State } from "./application.ts";
import type { Context } from "./context.ts";

/** Middleware are functions which are chained together to deal with requests. */
export interface Middleware<
Expand Down
2 changes: 1 addition & 1 deletion middleware_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { State } from "./application.ts";
import { Context } from "./context.ts";
import { Status } from "./deps.ts";
import { createHttpError, httpErrors } from "./httpError.ts";
import { ErrorStatus } from "./types.d.ts";
import type { ErrorStatus } from "./types.d.ts";
import { compose, Middleware } from "./middleware.ts";
function createMockContext<S extends State = Record<string, any>>() {
return ({
Expand Down
2 changes: 1 addition & 1 deletion request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
BodyText,
} from "./body.ts";
import { RequestBody } from "./body.ts";
import { HTTPMethods, ServerRequest } from "./types.d.ts";
import type { HTTPMethods, ServerRequest } from "./types.d.ts";
import { preferredCharsets } from "./negotiation/charset.ts";
import { preferredEncodings } from "./negotiation/encoding.ts";
import { preferredLanguages } from "./negotiation/language.ts";
Expand Down
2 changes: 1 addition & 1 deletion request_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
assertStrictEquals,
} from "./test_deps.ts";
import { Request } from "./request.ts";
import { ServerRequest } from "./types.d.ts";
import type { ServerRequest } from "./types.d.ts";
import { assertThrowsAsync } from "https://deno.land/std@0.69.0/testing/asserts.ts";
const encoder = new TextEncoder();

Expand Down
4 changes: 2 additions & 2 deletions response.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2018-2020 the oak authors. All rights reserved. MIT license.

import { contentType, Status } from "./deps.ts";
import { Request } from "./request.ts";
import { ServerResponse } from "./types.d.ts";
import type { Request } from "./request.ts";
import type { ServerResponse } from "./types.d.ts";
import { isHtml, isRedirectStatus, encodeUrl } from "./util.ts";

type Body =
Expand Down
6 changes: 3 additions & 3 deletions router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
* THE SOFTWARE.
*/

import { State } from "./application.ts";
import { Context } from "./context.ts";
import type { State } from "./application.ts";
import type { Context } from "./context.ts";
import {
assert,
compile,
Expand All @@ -39,7 +39,7 @@ import {
} from "./deps.ts";
import { httpErrors } from "./httpError.ts";
import { Middleware, compose } from "./middleware.ts";
import { HTTPMethods, RedirectStatus } from "./types.d.ts";
import type { HTTPMethods, RedirectStatus } from "./types.d.ts";
import { decodeComponent } from "./util.ts";

interface Matches {
Expand Down
2 changes: 1 addition & 1 deletion send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* with the MIT license.
*/

import { Context } from "./context.ts";
import type { Context } from "./context.ts";
import { createHttpError } from "./httpError.ts";
import { basename, extname, parse, sep } from "./deps.ts";
import { decodeComponent, resolvePath } from "./util.ts";
Expand Down
4 changes: 2 additions & 2 deletions server_sent_event.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2018-2020 the oak authors. All rights reserved. MIT license.

import { Application } from "./application.ts";
import type { Application } from "./application.ts";
import { assert, BufWriter } from "./deps.ts";
import { ServerRequest } from "./types.d.ts";
import type { ServerRequest } from "./types.d.ts";

const encoder = new TextEncoder();

Expand Down
2 changes: 1 addition & 1 deletion server_sent_event_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {

import { Application } from "./application.ts";
import { ServerSentEvent, ServerSentEventTarget } from "./server_sent_event.ts";
import { ServerRequest } from "./types.d.ts";
import type { ServerRequest } from "./types.d.ts";

const preamble = `HTTP/1.1 200 OK
connection: Keep-Alive
Expand Down
2 changes: 1 addition & 1 deletion util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Status,
} from "./deps.ts";
import { createHttpError } from "./httpError.ts";
import { ErrorStatus, RedirectStatus } from "./types.d.ts";
import type { ErrorStatus, RedirectStatus } from "./types.d.ts";

const ENCODE_CHARS_REGEXP =
/(?:[^\x21\x25\x26-\x3B\x3D\x3F-\x5B\x5D\x5F\x61-\x7A\x7E]|%(?:[^0-9A-Fa-f]|[0-9A-Fa-f][^0-9A-Fa-f]|$))+/g;
Expand Down