Remove doc strings from cli/js TS files (#4329)

Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
This commit is contained in:
crowlKats 2020-03-13 10:22:22 +01:00 committed by GitHub
parent 3ac642c183
commit e435c2be15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
87 changed files with 0 additions and 2025 deletions

View file

@ -7,115 +7,61 @@ import { DiagnosticItem } from "../diagnostics.ts";
import * as util from "../util.ts";
import * as runtimeCompilerOps from "../ops/runtime_compiler.ts";
/** A specific subset TypeScript compiler options that can be supported by
* the Deno TypeScript compiler. */
export interface CompilerOptions {
/** Allow JavaScript files to be compiled. Defaults to `true`. */
allowJs?: boolean;
/** Allow default imports from modules with no default export. This does not
* affect code emit, just typechecking. Defaults to `false`. */
allowSyntheticDefaultImports?: boolean;
/** Allow accessing UMD globals from modules. Defaults to `false`. */
allowUmdGlobalAccess?: boolean;
/** Do not report errors on unreachable code. Defaults to `false`. */
allowUnreachableCode?: boolean;
/** Do not report errors on unused labels. Defaults to `false` */
allowUnusedLabels?: boolean;
/** Parse in strict mode and emit `"use strict"` for each source file.
* Defaults to `true`. */
alwaysStrict?: boolean;
/** Base directory to resolve non-relative module names. Defaults to
* `undefined`. */
baseUrl?: string;
/** Report errors in `.js` files. Use in conjunction with `allowJs`. Defaults
* to `false`. */
checkJs?: boolean;
/** Generates corresponding `.d.ts` file. Defaults to `false`. */
declaration?: boolean;
/** Output directory for generated declaration files. */
declarationDir?: string;
/** Generates a source map for each corresponding `.d.ts` file. Defaults to
* `false`. */
declarationMap?: boolean;
/** Provide full support for iterables in `for..of`, spread and
* destructuring when targeting ES5 or ES3. Defaults to `false`. */
downlevelIteration?: boolean;
/** Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.
* Defaults to `false`. */
emitBOM?: boolean;
/** Only emit `.d.ts` declaration files. Defaults to `false`. */
emitDeclarationOnly?: boolean;
/** Emit design-type metadata for decorated declarations in source. See issue
* [microsoft/TypeScript#2577](https://github.com/Microsoft/TypeScript/issues/2577)
* for details. Defaults to `false`. */
emitDecoratorMetadata?: boolean;
/** Emit `__importStar` and `__importDefault` helpers for runtime babel
* ecosystem compatibility and enable `allowSyntheticDefaultImports` for type
* system compatibility. Defaults to `true`. */
esModuleInterop?: boolean;
/** Enables experimental support for ES decorators. Defaults to `false`. */
experimentalDecorators?: boolean;
/** Emit a single file with source maps instead of having a separate file.
* Defaults to `false`. */
inlineSourceMap?: boolean;
/** Emit the source alongside the source maps within a single file; requires
* `inlineSourceMap` or `sourceMap` to be set. Defaults to `false`. */
inlineSources?: boolean;
/** Perform additional checks to ensure that transpile only would be safe.
* Defaults to `false`. */
isolatedModules?: boolean;
/** Support JSX in `.tsx` files: `"react"`, `"preserve"`, `"react-native"`.
* Defaults to `"react"`. */
jsx?: "react" | "preserve" | "react-native";
/** Specify the JSX factory function to use when targeting react JSX emit,
* e.g. `React.createElement` or `h`. Defaults to `React.createElement`. */
jsxFactory?: string;
/** Resolve keyof to string valued property names only (no numbers or
* symbols). Defaults to `false`. */
keyofStringsOnly?: string;
/** Emit class fields with ECMAScript-standard semantics. Defaults to `false`.
* Does not apply to `"esnext"` target. */
useDefineForClassFields?: boolean;
/** List of library files to be included in the compilation. If omitted,
* then the Deno main runtime libs are used. */
lib?: string[];
/** The locale to use to show error messages. */
locale?: string;
/** Specifies the location where debugger should locate map files instead of
* generated locations. Use this flag if the `.map` files will be located at
* run-time in a different location than the `.js` files. The location
* specified will be embedded in the source map to direct the debugger where
* the map files will be located. Defaults to `undefined`. */
mapRoot?: string;
/** Specify the module format for the emitted code. Defaults to
* `"esnext"`. */
module?:
| "none"
| "commonjs"
@ -126,115 +72,58 @@ export interface CompilerOptions {
| "es2015"
| "esnext";
/** Do not generate custom helper functions like `__extends` in compiled
* output. Defaults to `false`. */
noEmitHelpers?: boolean;
/** Report errors for fallthrough cases in switch statement. Defaults to
* `false`. */
noFallthroughCasesInSwitch?: boolean;
/** Raise error on expressions and declarations with an implied any type.
* Defaults to `true`. */
noImplicitAny?: boolean;
/** Report an error when not all code paths in function return a value.
* Defaults to `false`. */
noImplicitReturns?: boolean;
/** Raise error on `this` expressions with an implied `any` type. Defaults to
* `true`. */
noImplicitThis?: boolean;
/** Do not emit `"use strict"` directives in module output. Defaults to
* `false`. */
noImplicitUseStrict?: boolean;
/** Do not add triple-slash references or module import targets to the list of
* compiled files. Defaults to `false`. */
noResolve?: boolean;
/** Disable strict checking of generic signatures in function types. Defaults
* to `false`. */
noStrictGenericChecks?: boolean;
/** Report errors on unused locals. Defaults to `false`. */
noUnusedLocals?: boolean;
/** Report errors on unused parameters. Defaults to `false`. */
noUnusedParameters?: boolean;
/** Redirect output structure to the directory. This only impacts
* `Deno.compile` and only changes the emitted file names. Defaults to
* `undefined`. */
outDir?: string;
/** List of path mapping entries for module names to locations relative to the
* `baseUrl`. Defaults to `undefined`. */
paths?: Record<string, string[]>;
/** Do not erase const enum declarations in generated code. Defaults to
* `false`. */
preserveConstEnums?: boolean;
/** Remove all comments except copy-right header comments beginning with
* `/*!`. Defaults to `true`. */
removeComments?: boolean;
/** Include modules imported with `.json` extension. Defaults to `true`. */
resolveJsonModule?: boolean;
/** Specifies the root directory of input files. Only use to control the
* output directory structure with `outDir`. Defaults to `undefined`. */
rootDir?: string;
/** List of _root_ folders whose combined content represent the structure of
* the project at runtime. Defaults to `undefined`. */
rootDirs?: string[];
/** Generates corresponding `.map` file. Defaults to `false`. */
sourceMap?: boolean;
/** Specifies the location where debugger should locate TypeScript files
* instead of source locations. Use this flag if the sources will be located
* at run-time in a different location than that at design-time. The location
* specified will be embedded in the sourceMap to direct the debugger where
* the source files will be located. Defaults to `undefined`. */
sourceRoot?: string;
/** Enable all strict type checking options. Enabling `strict` enables
* `noImplicitAny`, `noImplicitThis`, `alwaysStrict`, `strictBindCallApply`,
* `strictNullChecks`, `strictFunctionTypes` and
* `strictPropertyInitialization`. Defaults to `true`. */
strict?: boolean;
/** Enable stricter checking of the `bind`, `call`, and `apply` methods on
* functions. Defaults to `true`. */
strictBindCallApply?: boolean;
/** Disable bivariant parameter checking for function types. Defaults to
* `true`. */
strictFunctionTypes?: boolean;
/** Ensure non-undefined class properties are initialized in the constructor.
* This option requires `strictNullChecks` be enabled in order to take effect.
* Defaults to `true`. */
strictPropertyInitialization?: boolean;
/** In strict null checking mode, the `null` and `undefined` values are not in
* the domain of every type and are only assignable to themselves and `any`
* (the one exception being that `undefined` is also assignable to `void`). */
strictNullChecks?: boolean;
/** Suppress excess property checks for object literals. Defaults to
* `false`. */
suppressExcessPropertyErrors?: boolean;
/** Suppress `noImplicitAny` errors for indexing objects lacking index
* signatures. */
suppressImplicitAnyIndexErrors?: boolean;
/** Specify ECMAScript target version. Defaults to `esnext`. */
target?:
| "es3"
| "es5"
@ -247,59 +136,20 @@ export interface CompilerOptions {
| "es2020"
| "esnext";
/** List of names of type definitions to include. Defaults to `undefined`.
*
* The type definitions are resolved according to the normal Deno resolution
* irrespective of if sources are provided on the call. Like other Deno
* modules, there is no "magical" resolution. For example:
*
* Deno.compile(
* "./foo.js",
* undefined,
* {
* types: [ "./foo.d.ts", "https://deno.land/x/example/types.d.ts" ]
* }
* );
*
*/
types?: string[];
}
/** Internal function to just validate that the specifier looks relative, that
* it starts with `./`. */
function checkRelative(specifier: string): string {
return specifier.match(/^([\.\/\\]|https?:\/{2}|file:\/{2})/)
? specifier
: `./${specifier}`;
}
/** The results of a transpile only command, where the `source` contains the
* emitted source, and `map` optionally contains the source map.
*/
export interface TranspileOnlyResult {
source: string;
map?: string;
}
/** Takes a set of TypeScript sources and resolves with a map where the key was
* the original file name provided in sources and the result contains the
* `source` and optionally the `map` from the transpile operation. This does no
* type checking and validation, it effectively "strips" the types from the
* file.
*
* const results = await Deno.transpileOnly({
* "foo.ts": `const foo: string = "foo";`
* });
*
* @param sources A map where the key is the filename and the value is the text
* to transpile. The filename is only used in the transpile and
* not resolved, for example to fill in the source name in the
* source map.
* @param options An option object of options to send to the compiler. This is
* a subset of ts.CompilerOptions which can be supported by Deno.
* Many of the options related to type checking and emitting
* type declaration files will have no impact on the output.
*/
export async function transpileOnly(
sources: Record<string, string>,
options: CompilerOptions = {}
@ -313,33 +163,6 @@ export async function transpileOnly(
return JSON.parse(result);
}
/** Takes a root module name, any optionally a record set of sources. Resolves
* with a compiled set of modules. If just a root name is provided, the modules
* will be resolved as if the root module had been passed on the command line.
*
* If sources are passed, all modules will be resolved out of this object, where
* the key is the module name and the value is the content. The extension of
* the module name will be used to determine the media type of the module.
*
* const [ maybeDiagnostics1, output1 ] = await Deno.compile("foo.ts");
*
* const [ maybeDiagnostics2, output2 ] = await Deno.compile("/foo.ts", {
* "/foo.ts": `export * from "./bar.ts";`,
* "/bar.ts": `export const bar = "bar";`
* });
*
* @param rootName The root name of the module which will be used as the
* "starting point". If no `sources` is specified, Deno will
* resolve the module externally as if the `rootName` had been
* specified on the command line.
* @param sources An optional key/value map of sources to be used when resolving
* modules, where the key is the module name, and the value is
* the source content. The extension of the key will determine
* the media type of the file when processing. If supplied,
* Deno will not attempt to resolve any modules externally.
* @param options An optional object of options to send to the compiler. This is
* a subset of ts.CompilerOptions which can be supported by Deno.
*/
export async function compile(
rootName: string,
sources?: Record<string, string>,
@ -360,34 +183,6 @@ export async function compile(
return JSON.parse(result);
}
/** Takes a root module name, and optionally a record set of sources. Resolves
* with a single JavaScript string that is like the output of a `deno bundle`
* command. If just a root name is provided, the modules will be resolved as if
* the root module had been passed on the command line.
*
* If sources are passed, all modules will be resolved out of this object, where
* the key is the module name and the value is the content. The extension of the
* module name will be used to determine the media type of the module.
*
* const [ maybeDiagnostics1, output1 ] = await Deno.bundle("foo.ts");
*
* const [ maybeDiagnostics2, output2 ] = await Deno.bundle("/foo.ts", {
* "/foo.ts": `export * from "./bar.ts";`,
* "/bar.ts": `export const bar = "bar";`
* });
*
* @param rootName The root name of the module which will be used as the
* "starting point". If no `sources` is specified, Deno will
* resolve the module externally as if the `rootName` had been
* specified on the command line.
* @param sources An optional key/value map of sources to be used when resolving
* modules, where the key is the module name, and the value is
* the source content. The extension of the key will determine
* the media type of the file when processing. If supplied,
* Deno will not attempt to resolve any modules externally.
* @param options An optional object of options to send to the compiler. This is
* a subset of ts.CompilerOptions which can be supported by Deno.
*/
export async function bundle(
rootName: string,
sources?: Record<string, string>,

View file

@ -31,22 +31,10 @@ host.getSourceFile(
ts.ScriptTarget.ESNext
);
/**
* This function spins up TS compiler and loads all available libraries
* into memory (including ones specified above).
*
* Used to generate the foundational AST for all other compilations, so it can
* be cached as part of the snapshot and available to speed up startup.
*/
export const TS_SNAPSHOT_PROGRAM = ts.createProgram({
rootNames: [`${ASSETS}/bootstrap.ts`],
options,
host
});
/** A module loader which is concatenated into bundle files.
*
* We read all static assets during the snapshotting process, which is
* why this is located in compiler_bootstrap.
*/
export const SYSTEM_LOADER = getAsset("system_loader.js");

View file

@ -4,10 +4,8 @@ import { SYSTEM_LOADER } from "./bootstrap.ts";
import { commonPath, normalizeString, CHAR_FORWARD_SLASH } from "./util.ts";
import { assert } from "../util.ts";
/** Local state of what the root exports are of a root module. */
let rootExports: string[] | undefined;
/** Take a URL and normalize it, resolving relative path parts. */
function normalizeUrl(rootName: string): string {
const match = /^(\S+:\/{2,3})(.+)$/.exec(rootName);
if (match) {
@ -23,8 +21,6 @@ function normalizeUrl(rootName: string): string {
}
}
/** Given a root name, contents, and source files, enrich the data of the
* bundle with a loader and re-export the exports of the root name. */
export function buildBundle(
rootName: string,
data: string,
@ -63,7 +59,6 @@ export function buildBundle(
return `${SYSTEM_LOADER}\n${data}\n${instantiate}`;
}
/** Set the rootExports which will by the `emitBundle()` */
export function setRootExports(program: ts.Program, rootModule: string): void {
// get a reference to the type checker, this will let us find symbols from
// the AST.

View file

@ -6,26 +6,17 @@ import { cwd } from "../ops/fs/dir.ts";
import { assert, notImplemented } from "../util.ts";
import * as util from "../util.ts";
/** Specifies the target that the host should use to inform the TypeScript
* compiler of what types should be used to validate the program against. */
export enum CompilerHostTarget {
/** The main isolate library, where the main program runs. */
Main = "main",
/** The runtime API library. */
Runtime = "runtime",
/** The worker isolate library, where worker programs run. */
Worker = "worker"
}
export interface CompilerHostOptions {
/** Flag determines if the host should assume a single bundle output. */
bundle?: boolean;
/** Determines what the default library that should be used when type checking
* TS code. */
target: CompilerHostTarget;
/** A function to be used when the program emit occurs to write out files. */
writeFile: WriteFileCallback;
}
@ -34,8 +25,6 @@ export interface ConfigureResponse {
diagnostics?: ts.Diagnostic[];
}
/** Options that need to be used when generating a bundle (either trusted or
* runtime). */
export const defaultBundlerOptions: ts.CompilerOptions = {
allowJs: true,
inlineSourceMap: false,
@ -46,7 +35,6 @@ export const defaultBundlerOptions: ts.CompilerOptions = {
sourceMap: false
};
/** Default options used by the compiler Host when compiling. */
export const defaultCompileOptions: ts.CompilerOptions = {
allowJs: false,
allowNonTsExtensions: true,
@ -62,12 +50,10 @@ export const defaultCompileOptions: ts.CompilerOptions = {
target: ts.ScriptTarget.ESNext
};
/** Options that need to be used when doing a runtime (non bundled) compilation */
export const defaultRuntimeCompileOptions: ts.CompilerOptions = {
outDir: undefined
};
/** Default options used when doing a transpile only. */
export const defaultTranspileOptions: ts.CompilerOptions = {
esModuleInterop: true,
module: ts.ModuleKind.ESNext,
@ -76,8 +62,6 @@ export const defaultTranspileOptions: ts.CompilerOptions = {
target: ts.ScriptTarget.ESNext
};
/** Options that either do nothing in Deno, or would cause undesired behavior
* if modified. */
const ignoredCompilerOptions: readonly string[] = [
"allowSyntheticDefaultImports",
"baseUrl",
@ -164,7 +148,6 @@ export class Host implements ts.CompilerHost {
/* Deno specific APIs */
/** Provides the `ts.HostCompiler` interface for Deno. */
constructor({ bundle = false, target, writeFile }: CompilerHostOptions) {
this._target = target;
this._writeFile = writeFile;
@ -174,9 +157,6 @@ export class Host implements ts.CompilerHost {
}
}
/** Take a configuration string, parse it, and use it to merge with the
* compiler's configuration options. The method returns an array of compiler
* options which were ignored, or `undefined`. */
configure(path: string, configurationText: string): ConfigureResponse {
util.log("compiler::host.configure", path);
assert(configurationText);
@ -208,8 +188,6 @@ export class Host implements ts.CompilerHost {
};
}
/** Merge options into the host's current set of compiler options and return
* the merged set. */
mergeOptions(...options: ts.CompilerOptions[]): ts.CompilerOptions {
Object.assign(this._options, ...options);
return Object.assign({}, this._options);

View file

@ -7,7 +7,6 @@ import { assert } from "../util.ts";
import * as util from "../util.ts";
import * as compilerOps from "../ops/compiler.ts";
/** Resolve a path to the final path segment passed. */
function resolvePath(...pathSegments: string[]): string {
let resolvedPath = "";
let resolvedAbsolute = false;
@ -45,8 +44,6 @@ function resolvePath(...pathSegments: string[]): string {
else return ".";
}
/** Resolve a relative specifier based on the referrer. Used when resolving
* modules internally within the runtime compiler API. */
function resolveSpecifier(specifier: string, referrer: string): string {
if (!specifier.startsWith(".")) {
return specifier;
@ -58,7 +55,6 @@ function resolveSpecifier(specifier: string, referrer: string): string {
return resolvePath(path, specifier);
}
/** Ops to Rust to resolve modules' URLs. */
export function resolveModules(
specifiers: string[],
referrer?: string
@ -67,7 +63,6 @@ export function resolveModules(
return compilerOps.resolveModules(specifiers, referrer);
}
/** Ops to Rust to fetch modules meta data. */
function fetchSourceFiles(
specifiers: string[],
referrer?: string
@ -76,8 +71,6 @@ function fetchSourceFiles(
return compilerOps.fetchSourceFiles(specifiers, referrer);
}
/** Given a filename, determine the media type based on extension. Used when
* resolving modules internally in a runtime compile. */
function getMediaType(filename: string): MediaType {
const maybeExtension = /\.([a-zA-Z]+)$/.exec(filename);
if (!maybeExtension) {
@ -104,12 +97,6 @@ function getMediaType(filename: string): MediaType {
}
}
/** Recursively process the imports of modules from within the supplied sources,
* generating `SourceFile`s of any imported files.
*
* Specifiers are supplied in an array of tuples where the first is the
* specifier that will be requested in the code and the second is the specifier
* that should be actually resolved. */
export function processLocalImports(
sources: Record<string, string>,
specifiers: Array<[string, string]>,
@ -148,12 +135,6 @@ export function processLocalImports(
return moduleNames;
}
/** Recursively process the imports of modules, generating `SourceFile`s of any
* imported files.
*
* Specifiers are supplied in an array of tuples where the first is the
* specifier that will be requested in the code and the second is the specifier
* that should be actually resolved. */
export async function processImports(
specifiers: Array<[string, string]>,
referrer?: string,

View file

@ -15,7 +15,6 @@ export enum MediaType {
Unknown = 6
}
/** The shape of the SourceFile that comes from the privileged side */
export interface SourceFileJson {
url: string;
filename: string;
@ -25,7 +24,6 @@ export interface SourceFileJson {
export const ASSETS = "$asset$";
/** Returns the TypeScript Extension enum for a given media type. */
function getExtension(fileName: string, mediaType: MediaType): ts.Extension {
switch (mediaType) {
case MediaType.JavaScript:
@ -49,15 +47,10 @@ function getExtension(fileName: string, mediaType: MediaType): ts.Extension {
}
}
/** A self registering abstraction of source files. */
export class SourceFile {
extension!: ts.Extension;
filename!: string;
/** An array of tuples which represent the imports for the source file. The
* first element is the one that will be requested at compile time, the
* second is the one that should be actually resolved. This provides the
* feature of type directives for Deno. */
importedFiles?: Array<[string, string]>;
mediaType!: MediaType;
@ -75,8 +68,6 @@ export class SourceFile {
SourceFile._moduleCache.set(this.url, this);
}
/** Cache the source file to be able to be retrieved by `moduleSpecifier` and
* `containingFile`. */
cache(moduleSpecifier: string, containingFile?: string): void {
containingFile = containingFile || "";
let innerCache = SourceFile._specifierCache.get(containingFile);
@ -87,7 +78,6 @@ export class SourceFile {
innerCache.set(moduleSpecifier, this);
}
/** Process the imports for the file and return them. */
imports(processJsImports: boolean): Array<[string, string]> {
if (this.processed) {
throw new Error("SourceFile has already been processed.");
@ -152,19 +142,13 @@ export class SourceFile {
return files;
}
/** A cache of all the source files which have been loaded indexed by the
* url. */
private static _moduleCache: Map<string, SourceFile> = new Map();
/** A cache of source files based on module specifiers and containing files
* which is used by the TypeScript compiler to resolve the url */
private static _specifierCache: Map<
string,
Map<string, SourceFile>
> = new Map();
/** Retrieve a `SourceFile` based on a `moduleSpecifier` and `containingFile`
* or return `undefined` if not preset. */
static getUrl(
moduleSpecifier: string,
containingFile: string
@ -177,12 +161,10 @@ export class SourceFile {
return undefined;
}
/** Retrieve a `SourceFile` based on a `url` */
static get(url: string): SourceFile | undefined {
return this._moduleCache.get(url);
}
/** Determine if a source file exists or not */
static has(url: string): boolean {
return this._moduleCache.has(url);
}

View file

@ -6,7 +6,6 @@ interface FileReference {
end: number;
}
/** Remap the module name based on any supplied type directives passed. */
export function getMappedModuleName(
source: FileReference,
typeDirectives: Map<FileReference, string>
@ -20,29 +19,10 @@ export function getMappedModuleName(
return source.fileName;
}
/** Matches directives that look something like this and parses out the value
* of the directive:
*
* // @deno-types="./foo.d.ts"
*
* [See Diagram](http://bit.ly/31nZPCF)
*/
const typeDirectiveRegEx = /@deno-types\s*=\s*(["'])((?:(?=(\\?))\3.)*?)\1/gi;
/** Matches `import`, `import from` or `export from` statements and parses out the value of the
* module specifier in the second capture group:
*
* import "./foo.js"
* import * as foo from "./foo.js"
* export { a, b, c } from "./bar.js"
*
* [See Diagram](http://bit.ly/2lOsp0K)
*/
const importExportRegEx = /(?:import|export)(?:\s+|\s+[\s\S]*?from\s+)?(["'])((?:(?=(\\?))\3.)*?)\1/;
/** Parses out any Deno type directives that are part of the source code, or
* returns `undefined` if there are not any.
*/
export function parseTypeDirectives(
sourceCode: string | undefined
): Map<FileReference, string> | undefined {

View file

@ -11,16 +11,12 @@ import * as util from "../util.ts";
import { assert } from "../util.ts";
import { writeFileSync } from "../write_file.ts";
/** Type for the write fall callback that allows delegation from the compiler
* host on writing files. */
export type WriteFileCallback = (
fileName: string,
data: string,
sourceFiles?: readonly ts.SourceFile[]
) => void;
/** An object which is passed to `createWriteFile` to be used to read and set
* state related to the emit of a program. */
export interface WriteFileState {
type: CompilerRequestType;
bundle?: boolean;
@ -42,7 +38,6 @@ export enum CompilerRequestType {
export const OUT_DIR = "$deno$";
/** Cache the contents of a file on the trusted side. */
function cache(
moduleId: string,
emittedFileName: string,
@ -81,13 +76,10 @@ function cache(
}
}
/** Retrieve an asset from Rust. */
export function getAsset(name: string): string {
return compilerOps.getAsset(name);
}
/** Generates a `writeFile` function which can be passed to the compiler `Host`
* to use when emitting files. */
export function createWriteFile(state: WriteFileState): WriteFileCallback {
const encoder = new TextEncoder();
if (state.type === CompilerRequestType.Compile) {
@ -171,8 +163,6 @@ export interface ConvertCompilerOptionsResult {
options: ts.CompilerOptions;
}
/** Take a runtime set of compiler options as stringified JSON and convert it
* to a set of TypeScript compiler options. */
export function convertCompilerOptions(
str: string
): ConvertCompilerOptionsResult {
@ -269,7 +259,6 @@ export function convertCompilerOptions(
};
}
/** An array of TypeScript diagnostic types we ignore. */
export const ignoredDiagnostics = [
// TS2306: File 'file:///Users/rld/src/deno/cli/tests/subdir/amd_like.js' is
// not a module.
@ -301,8 +290,6 @@ export const ignoredDiagnostics = [
7016
];
/** When doing a host configuration, processing the response and logging out
* and options which were ignored. */
export function processConfigureResponse(
configResult: ConfigureResponse,
configPath: string
@ -322,7 +309,6 @@ export function processConfigureResponse(
export const CHAR_DOT = 46; /* . */
export const CHAR_FORWARD_SLASH = 47; /* / */
/** Resolves `.` and `..` elements in a path with directory names */
export function normalizeString(
path: string,
allowAboveRoot: boolean,
@ -390,12 +376,6 @@ export function normalizeString(
return res;
}
/** Return the common path shared by the `paths`.
*
* @param paths The set of paths to compare.
* @param sep An optional separator to use. Defaults to `/`.
* @internal
*/
export function commonPath(paths: string[], sep = "/"): string {
const [first = "", ...remaining] = paths;
if (first === "" || remaining.length === 0) {
@ -420,8 +400,6 @@ export function commonPath(paths: string[], sep = "/"): string {
return prefix.endsWith(sep) ? prefix : `${prefix}${sep}`;
}
/** Utility function to turn the number of bytes into a human readable
* unit */
function humanFileSize(bytes: number): string {
const thresh = 1000;
if (Math.abs(bytes) < thresh) {