Skip to content

Commit

Permalink
feat: add --no-check option (denoland/deno#6456)
Browse files Browse the repository at this point in the history
This commit adds a "--no-check" option to following subcommands:
- "deno cache"
- "deno info"
- "deno run"
- "deno test"

The "--no-check" options allows to skip type checking step and instead 
directly transpiles TS sources to JS sources. 

This solution uses `ts.transpileModule()` API and is just an interim
solution before implementing it fully in Rust.
  • Loading branch information
kitsonk authored and caspervonb committed Jan 31, 2021
1 parent 97decd1 commit 25e2103
Show file tree
Hide file tree
Showing 40 changed files with 62 additions and 55 deletions.
2 changes: 1 addition & 1 deletion encoding/_yaml/dumper/dumper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* eslint-disable max-len */

import { YAMLError } from "../error.ts";
import { RepresentFn, StyleVariant, Type } from "../type.ts";
import type { RepresentFn, StyleVariant, Type } from "../type.ts";
import * as common from "../utils.ts";
import { DumperState, DumperStateOptions } from "./dumper_state.ts";

Expand Down
6 changes: 3 additions & 3 deletions encoding/_yaml/dumper/dumper_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { Schema, SchemaDefinition } from "../schema.ts";
import type { Schema, SchemaDefinition } from "../schema.ts";
import { State } from "../state.ts";
import { StyleVariant, Type } from "../type.ts";
import { ArrayObject, Any } from "../utils.ts";
import type { StyleVariant, Type } from "../type.ts";
import type { ArrayObject, Any } from "../utils.ts";

const _hasOwnProperty = Object.prototype.hasOwnProperty;

Expand Down
2 changes: 1 addition & 1 deletion encoding/_yaml/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { Mark } from "./mark.ts";
import type { Mark } from "./mark.ts";

export class YAMLError extends Error {
constructor(
Expand Down
2 changes: 1 addition & 1 deletion encoding/_yaml/loader/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { YAMLError } from "../error.ts";
import { Mark } from "../mark.ts";
import { Type } from "../type.ts";
import type { Type } from "../type.ts";
import * as common from "../utils.ts";
import { LoaderState, LoaderStateOptions, ResultType } from "./loader_state.ts";

Expand Down
8 changes: 4 additions & 4 deletions encoding/_yaml/loader/loader_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { YAMLError } from "../error.ts";
import { Schema, SchemaDefinition, TypeMap } from "../schema.ts";
import type { YAMLError } from "../error.ts";
import type { Schema, SchemaDefinition, TypeMap } from "../schema.ts";
import { State } from "../state.ts";
import { Type } from "../type.ts";
import { Any, ArrayObject } from "../utils.ts";
import type { Type } from "../type.ts";
import type { Any, ArrayObject } from "../utils.ts";

export interface LoaderStateOptions {
legacy?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion encoding/_yaml/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { CbFunction, load, loadAll } from "./loader/loader.ts";
import { LoaderStateOptions } from "./loader/loader_state.ts";
import type { LoaderStateOptions } from "./loader/loader_state.ts";

export type ParseOptions = LoaderStateOptions;

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

import { YAMLError } from "./error.ts";
import { KindType, Type } from "./type.ts";
import { ArrayObject, Any } from "./utils.ts";
import type { KindType, Type } from "./type.ts";
import type { ArrayObject, Any } from "./utils.ts";

function compileList(
schema: Schema,
Expand Down
2 changes: 1 addition & 1 deletion encoding/_yaml/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { SchemaDefinition } from "./schema.ts";
import type { SchemaDefinition } from "./schema.ts";
import { DEFAULT_SCHEMA } from "./schema/mod.ts";

export abstract class State {
Expand Down
2 changes: 1 addition & 1 deletion encoding/_yaml/stringify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { dump } from "./dumper/dumper.ts";
import { DumperStateOptions } from "./dumper/dumper_state.ts";
import type { DumperStateOptions } from "./dumper/dumper_state.ts";

export type DumpOptions = DumperStateOptions;

Expand Down
2 changes: 1 addition & 1 deletion encoding/_yaml/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { ArrayObject, Any } from "./utils.ts";
import type { ArrayObject, Any } from "./utils.ts";

export type KindType = "sequence" | "scalar" | "mapping";
export type StyleVariant = "lowercase" | "uppercase" | "camelcase" | "decimal";
Expand Down
2 changes: 1 addition & 1 deletion encoding/_yaml/type/binary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { Type } from "../type.ts";
import { Any } from "../utils.ts";
import type { Any } from "../utils.ts";

// [ 64, 65, 66 ] -> [ padding, CR, LF ]
const BASE64_MAP =
Expand Down
2 changes: 1 addition & 1 deletion encoding/_yaml/type/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { Type } from "../type.ts";
import { Any } from "../utils.ts";
import type { Any } from "../utils.ts";

export const map = new Type("tag:yaml.org,2002:map", {
construct(data): Any {
Expand Down
2 changes: 1 addition & 1 deletion encoding/_yaml/type/omap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { Type } from "../type.ts";
import { Any } from "../utils.ts";
import type { Any } from "../utils.ts";

const _hasOwnProperty = Object.prototype.hasOwnProperty;
const _toString = Object.prototype.toString;
Expand Down
2 changes: 1 addition & 1 deletion encoding/_yaml/type/pairs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { Type } from "../type.ts";
import { Any } from "../utils.ts";
import type { Any } from "../utils.ts";

const _toString = Object.prototype.toString;

Expand Down
2 changes: 1 addition & 1 deletion encoding/_yaml/type/seq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { Type } from "../type.ts";
import { Any } from "../utils.ts";
import type { Any } from "../utils.ts";

export const seq = new Type("tag:yaml.org,2002:seq", {
construct(data): Any {
Expand Down
2 changes: 1 addition & 1 deletion encoding/_yaml/type/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { Type } from "../type.ts";
import { Any } from "../utils.ts";
import type { Any } from "../utils.ts";

const _hasOwnProperty = Object.prototype.hasOwnProperty;

Expand Down
13 changes: 6 additions & 7 deletions encoding/yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

export { ParseOptions, parse, parseAll } from "./_yaml/parse.ts";
export {
DumpOptions as StringifyOptions,
stringify,
} from "./_yaml/stringify.ts";
export { SchemaDefinition } from "./_yaml/schema.ts";
export { StyleVariant } from "./_yaml/type.ts";
export type { ParseOptions } from "./_yaml/parse.ts";
export { parse, parseAll } from "./_yaml/parse.ts";
export type { DumpOptions as StringifyOptions } from "./_yaml/stringify.ts";
export { stringify } from "./_yaml/stringify.ts";
export type { SchemaDefinition } from "./_yaml/schema.ts";
export type { StyleVariant } from "./_yaml/type.ts";
export {
CORE_SCHEMA,
DEFAULT_SCHEMA,
Expand Down
2 changes: 1 addition & 1 deletion hash/_wasm/hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import init, {

import * as hex from "../../encoding/hex.ts";
import * as base64 from "../../encoding/base64.ts";
import { Hasher, Message, OutputFormat } from "../hasher.ts";
import type { Hasher, Message, OutputFormat } from "../hasher.ts";

await init(source);

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

import { Hash } from "./_wasm/hash.ts";
import { Hasher } from "./hasher.ts";
import type { Hasher } from "./hasher.ts";

export { Hasher } from "./hasher.ts";
export type { Hasher } from "./hasher.ts";
export type SupportedAlgorithm =
| "md2"
| "md4"
Expand Down
2 changes: 1 addition & 1 deletion io/ioutil.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { BufReader } from "./bufio.ts";
import type { BufReader } from "./bufio.ts";
type Reader = Deno.Reader;
type Writer = Deno.Writer;
import { assert } from "../_util/assert.ts";
Expand Down
2 changes: 1 addition & 1 deletion log/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { getLevelByName, LevelName, LogLevels } from "./levels.ts";
import { LogRecord } from "./logger.ts";
import type { LogRecord } from "./logger.ts";
import { red, yellow, blue, bold } from "../fmt/colors.ts";
import { existsSync, exists } from "../fs/exists.ts";
import { BufWriterSync } from "../io/bufio.ts";
Expand Down
2 changes: 1 addition & 1 deletion log/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
getLevelName,
LevelName,
} from "./levels.ts";
import { BaseHandler } from "./handlers.ts";
import type { BaseHandler } from "./handlers.ts";

export interface LogRecordOptions {
msg: string;
Expand Down
2 changes: 1 addition & 1 deletion log/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
RotatingFileHandler,
} from "./handlers.ts";
import { assert } from "../_util/assert.ts";
import { LevelName } from "./levels.ts";
import type { LevelName } from "./levels.ts";

export { LogLevels, LevelName } from "./levels.ts";
export { Logger } from "./logger.ts";
Expand Down
2 changes: 1 addition & 1 deletion node/_fs/_fs_access.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { CallbackWithError } from "./_fs_common.ts";
import type { CallbackWithError } from "./_fs_common.ts";
import { notImplemented } from "../_utils.ts";

/** Revist once https://github.com/denoland/deno/issues/4017 lands */
Expand Down
2 changes: 1 addition & 1 deletion node/_fs/_fs_chmod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { CallbackWithError } from "./_fs_common.ts";
import type { CallbackWithError } from "./_fs_common.ts";
import { fromFileUrl } from "../path.ts";

const allowedModes = /^[0-7]{3}/;
Expand Down
2 changes: 1 addition & 1 deletion node/_fs/_fs_chown.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { CallbackWithError } from "./_fs_common.ts";
import type { CallbackWithError } from "./_fs_common.ts";
import { fromFileUrl } from "../path.ts";

/**
Expand Down
2 changes: 1 addition & 1 deletion node/_fs/_fs_close.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { CallbackWithError } from "./_fs_common.ts";
import type { CallbackWithError } from "./_fs_common.ts";

export function close(fd: number, callback: CallbackWithError): void {
queueMicrotask(() => {
Expand Down
2 changes: 1 addition & 1 deletion node/_fs/_fs_copy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { CallbackWithError } from "./_fs_common.ts";
import type { CallbackWithError } from "./_fs_common.ts";
import { fromFileUrl } from "../path.ts";

export function copyFile(
Expand Down
2 changes: 1 addition & 1 deletion node/_fs/_fs_dir_test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert, assertEquals, fail } from "../../testing/asserts.ts";
import Dir from "./_fs_dir.ts";
import Dirent from "./_fs_dirent.ts";
import type Dirent from "./_fs_dirent.ts";

Deno.test({
name: "Closing current directory with callback is successful",
Expand Down
2 changes: 1 addition & 1 deletion node/_fs/_fs_link.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { CallbackWithError } from "./_fs_common.ts";
import type { CallbackWithError } from "./_fs_common.ts";
import { fromFileUrl } from "../path.ts";

/**
Expand Down
8 changes: 5 additions & 3 deletions node/_fs/_fs_mkdir.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { CallbackWithError } from "./_fs_common.ts";
import type { CallbackWithError } from "./_fs_common.ts";
import { fromFileUrl } from "../path.ts";

/**
Expand Down Expand Up @@ -31,10 +31,11 @@ export function mkdir(
if (options.recursive !== undefined) recursive = options.recursive;
if (options.mode !== undefined) mode = options.mode;
}
if (typeof recursive !== "boolean")
if (typeof recursive !== "boolean") {
throw new Deno.errors.InvalidData(
"invalid recursive option , must be a boolean"
);
}
Deno.mkdir(path, { recursive, mode })
.then(() => {
if (typeof callback === "function") {
Expand All @@ -61,10 +62,11 @@ export function mkdirSync(path: string | URL, options?: MkdirOptions): void {
if (options.recursive !== undefined) recursive = options.recursive;
if (options.mode !== undefined) mode = options.mode;
}
if (typeof recursive !== "boolean")
if (typeof recursive !== "boolean") {
throw new Deno.errors.InvalidData(
"invalid recursive option , must be a boolean"
);
}

Deno.mkdirSync(path, { recursive, mode });
}
2 changes: 1 addition & 1 deletion node/_fs/_fs_writeFile_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
assertThrows,
} from "../../testing/asserts.ts";
import { writeFile, writeFileSync } from "./_fs_writeFile.ts";
import { TextEncodings } from "./_fs_common.ts";
import type { TextEncodings } from "./_fs_common.ts";
import * as path from "../../path/mod.ts";

const testDataDir = path.resolve(path.join("node", "_fs", "testdata"));
Expand Down
5 changes: 3 additions & 2 deletions node/_fs/promises/_fs_readFile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import {
import type {
FileOptionsArgument,
BinaryOptionsArgument,
TextOptionsArgument,
Expand All @@ -21,8 +21,9 @@ export function readFile(
return new Promise((resolve, reject) => {
readFileCallback(path, options, (err, data): void => {
if (err) return reject(err);
if (data == null)
if (data == null) {
return reject(new Error("Invalid state: data missing, but no error"));
}
resolve(data);
});
});
Expand Down
2 changes: 1 addition & 1 deletion node/_fs/promises/_fs_writeFile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { Encodings, WriteFileOptions } from "../_fs_common.ts";
import type { Encodings, WriteFileOptions } from "../_fs_common.ts";

import { writeFile as writeFileCallback } from "../_fs_writeFile.ts";

Expand Down
2 changes: 1 addition & 1 deletion node/_fs/promises/_fs_writeFile_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
assertThrowsAsync,
} from "../../../testing/asserts.ts";
import { writeFile } from "./_fs_writeFile.ts";
import { TextEncodings } from "../_fs_common.ts";
import type { TextEncodings } from "../_fs_common.ts";

const decoder = new TextDecoder("utf-8");

Expand Down
2 changes: 1 addition & 1 deletion path/_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Ported from https://github.com/browserify/path-browserify/
/** This module is browser compatible. */

import { FormatInputPathObject } from "./_interface.ts";
import type { FormatInputPathObject } from "./_interface.ts";
import {
CHAR_UPPERCASE_A,
CHAR_LOWERCASE_A,
Expand Down
2 changes: 1 addition & 1 deletion path/posix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Ported from https://github.com/browserify/path-browserify/
/** This module is browser compatible. */

import { FormatInputPathObject, ParsedPath } from "./_interface.ts";
import type { FormatInputPathObject, ParsedPath } from "./_interface.ts";
import { CHAR_DOT, CHAR_FORWARD_SLASH } from "./_constants.ts";

import {
Expand Down
2 changes: 1 addition & 1 deletion path/win32.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Ported from https://github.com/browserify/path-browserify/
/** This module is browser compatible. */

import { FormatInputPathObject, ParsedPath } from "./_interface.ts";
import type { FormatInputPathObject, ParsedPath } from "./_interface.ts";
import {
CHAR_DOT,
CHAR_BACKWARD_SLASH,
Expand Down
2 changes: 1 addition & 1 deletion textproto/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

import { BufReader } from "../io/bufio.ts";
import type { BufReader } from "../io/bufio.ts";
import { concat } from "../bytes/mod.ts";
import { decode } from "../encoding/utf8.ts";

Expand Down
Loading

0 comments on commit 25e2103

Please sign in to comment.