mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-12 03:20:56 -06:00
Remove unused exports & dead code (using Knip) (#56817)
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
This commit is contained in:
parent
f7833b2a72
commit
752135eb40
14
.github/workflows/ci.yml
vendored
14
.github/workflows/ci.yml
vendored
@ -83,6 +83,20 @@ jobs:
|
||||
- name: Linter
|
||||
run: npm run lint
|
||||
|
||||
knip:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
with:
|
||||
node-version: '*'
|
||||
check-latest: true
|
||||
- run: npm ci
|
||||
|
||||
- name: Unused exports
|
||||
run: npm run knip
|
||||
|
||||
format:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
|
||||
@ -565,6 +565,13 @@ export const checkFormat = task({
|
||||
run: () => exec(process.execPath, ["node_modules/dprint/bin.js", "check"], { ignoreStdout: true }),
|
||||
});
|
||||
|
||||
export const knip = task({
|
||||
name: "knip",
|
||||
description: "Runs knip.",
|
||||
dependencies: [generateDiagnostics],
|
||||
run: () => exec(process.execPath, ["node_modules/knip/bin/knip.js", "--tags=+internal,-knipignore", "--exclude=duplicates,enumMembers", ...(cmdLineOptions.fix ? ["--fix"] : [])]),
|
||||
});
|
||||
|
||||
const { main: cancellationToken, watch: watchCancellationToken } = entrypointBuildTask({
|
||||
name: "cancellation-token",
|
||||
project: "src/cancellationToken",
|
||||
|
||||
38
knip.jsonc
Normal file
38
knip.jsonc
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
"$schema": "https://unpkg.com/knip@5/schema.json",
|
||||
"includeEntryExports": true,
|
||||
"entry": [
|
||||
"Herebyfile.mjs",
|
||||
"src/cancellationToken/cancellationToken.ts",
|
||||
"src/testRunner/_namespaces/Harness.ts",
|
||||
"src/tsc/tsc.ts",
|
||||
"src/tsserver/server.ts",
|
||||
"src/typescript/typescript.ts",
|
||||
"src/typingsInstaller/nodeTypingsInstaller.ts",
|
||||
"src/watchGuard/watchGuard.ts",
|
||||
|
||||
"src/testRunner/tests.ts",
|
||||
"src/testRunner/_namespaces/Harness.ts",
|
||||
|
||||
// The rest of the entry files, mostly to track used dependencies:
|
||||
".eslint-plugin-local.cjs",
|
||||
".gulp.js",
|
||||
"scripts/eslint/{rules,tests}/*.cjs",
|
||||
"scripts/*.{cjs,mjs}"
|
||||
],
|
||||
"project": [
|
||||
"src/**",
|
||||
"scripts/**",
|
||||
"!src/lib/**/*.d.ts"
|
||||
],
|
||||
"ignore": [
|
||||
"scripts/failed-tests.d.cts"
|
||||
],
|
||||
"ignoreDependencies": ["c8", "eslint-formatter-autolinkable-stylish", "mocha-fivemat-progress-reporter"],
|
||||
"ignoreExportsUsedInFile": {
|
||||
"enum": true,
|
||||
"interface": true,
|
||||
"type": true
|
||||
},
|
||||
"mocha": false
|
||||
}
|
||||
1022
package-lock.json
generated
1022
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -69,6 +69,7 @@
|
||||
"glob": "^10.4.2",
|
||||
"hereby": "^1.8.9",
|
||||
"jsonc-parser": "^3.3.1",
|
||||
"knip": "^5.23.1",
|
||||
"minimist": "^1.2.8",
|
||||
"mocha": "^10.5.2",
|
||||
"mocha-fivemat-progress-reporter": "^0.1.0",
|
||||
@ -93,6 +94,7 @@
|
||||
"clean": "hereby clean",
|
||||
"gulp": "hereby",
|
||||
"lint": "hereby lint",
|
||||
"knip": "hereby knip",
|
||||
"format": "dprint fmt",
|
||||
"setup-hooks": "node scripts/link-hooks.mjs"
|
||||
},
|
||||
|
||||
@ -1144,8 +1144,7 @@ export interface NonIncrementalBuildInfo extends BuildInfo {
|
||||
checkPending: true | undefined;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isNonIncrementalBuildInfo(info: BuildInfo): info is NonIncrementalBuildInfo {
|
||||
function isNonIncrementalBuildInfo(info: BuildInfo): info is NonIncrementalBuildInfo {
|
||||
return !isIncrementalBuildInfo(info) && !!(info as NonIncrementalBuildInfo).root;
|
||||
}
|
||||
|
||||
@ -1599,8 +1598,7 @@ export function computeSignatureWithDiagnostics(
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function computeSignature(text: string, host: HostForComputeHash, data?: WriteFileCallbackData) {
|
||||
function computeSignature(text: string, host: HostForComputeHash, data?: WriteFileCallbackData) {
|
||||
return (host.createHash ?? generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
|
||||
}
|
||||
|
||||
|
||||
@ -52131,8 +52131,7 @@ export function signatureHasRestParameter(s: Signature) {
|
||||
return !!(s.flags & SignatureFlags.HasRestParameter);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function signatureHasLiteralTypes(s: Signature) {
|
||||
function signatureHasLiteralTypes(s: Signature) {
|
||||
return !!(s.flags & SignatureFlags.HasLiteralTypes);
|
||||
}
|
||||
|
||||
|
||||
@ -123,8 +123,7 @@ import {
|
||||
WatchOptions,
|
||||
} from "./_namespaces/ts.js";
|
||||
|
||||
/** @internal */
|
||||
export const compileOnSaveCommandLineOption: CommandLineOption = {
|
||||
const compileOnSaveCommandLineOption: CommandLineOption = {
|
||||
name: "compileOnSave",
|
||||
type: "boolean",
|
||||
defaultValueDescription: false,
|
||||
@ -1626,12 +1625,11 @@ export const optionsAffectingProgramStructure: readonly CommandLineOption[] = op
|
||||
/** @internal */
|
||||
export const transpileOptionValueCompilerOptions: readonly CommandLineOption[] = optionDeclarations.filter(option => hasProperty(option, "transpileOptionValue"));
|
||||
|
||||
/** @internal */
|
||||
export const configDirTemplateSubstitutionOptions: readonly CommandLineOption[] = optionDeclarations.filter(
|
||||
const configDirTemplateSubstitutionOptions: readonly CommandLineOption[] = optionDeclarations.filter(
|
||||
option => option.allowConfigDirTemplateSubstitution || (!option.isCommandLineOnly && option.isFilePath),
|
||||
);
|
||||
/** @internal */
|
||||
export const configDirTemplateSubstitutionWatchOptions: readonly CommandLineOption[] = optionsForWatch.filter(
|
||||
|
||||
const configDirTemplateSubstitutionWatchOptions: readonly CommandLineOption[] = optionsForWatch.filter(
|
||||
option => option.allowConfigDirTemplateSubstitution || (!option.isCommandLineOnly && option.isFilePath),
|
||||
);
|
||||
|
||||
@ -1745,8 +1743,7 @@ const compilerOptionsAlternateMode: AlternateModeDiagnostics = {
|
||||
getOptionsNameMap: getBuildOptionsNameMap,
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
export const defaultInitCompilerOptions: CompilerOptions = {
|
||||
const defaultInitCompilerOptions: CompilerOptions = {
|
||||
module: ModuleKind.CommonJS,
|
||||
target: ScriptTarget.ES2016,
|
||||
strict: true,
|
||||
@ -2903,8 +2900,7 @@ function directoryOfCombinedPath(fileName: string, basePath: string) {
|
||||
return getDirectoryPath(getNormalizedAbsolutePath(fileName, basePath));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export const defaultIncludeSpec = "**/*";
|
||||
const defaultIncludeSpec = "**/*";
|
||||
|
||||
/**
|
||||
* Parse the contents of a config file from json or json source file (tsconfig.json).
|
||||
|
||||
@ -17,8 +17,6 @@ import {
|
||||
export const emptyArray: never[] = [] as never[];
|
||||
/** @internal */
|
||||
export const emptyMap: ReadonlyMap<never, never> = new Map<never, never>();
|
||||
/** @internal */
|
||||
export const emptySet: ReadonlySet<never> = new Set<never>();
|
||||
|
||||
/** @internal */
|
||||
export function length(array: readonly any[] | undefined): number {
|
||||
@ -218,22 +216,6 @@ export function findLastIndex<T>(array: readonly T[] | undefined, predicate: (el
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first truthy result of `callback`, or else fails.
|
||||
* This is like `forEach`, but never returns undefined.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function findMap<T, U>(array: readonly T[], callback: (element: T, index: number) => U | undefined): U {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const result = callback(array[i], i);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return Debug.fail();
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function contains<T>(array: readonly T[] | undefined, value: T, equalityComparer: EqualityComparer<T> = equateValues): boolean {
|
||||
if (array !== undefined) {
|
||||
@ -827,17 +809,6 @@ export function sortAndDeduplicate<T>(array: readonly T[], comparer?: Comparer<T
|
||||
return deduplicateSorted(sort(array, comparer), equalityComparer ?? comparer ?? compareStringsCaseSensitive as any as Comparer<T>);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function arrayIsSorted<T>(array: readonly T[], comparer: Comparer<T>) {
|
||||
if (array.length < 2) return true;
|
||||
for (let i = 1, len = array.length; i < len; i++) {
|
||||
if (comparer(array[i - 1], array[i]) === Comparison.GreaterThan) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function arrayIsEqualTo<T>(array1: readonly T[] | undefined, array2: readonly T[] | undefined, equalityComparer: (a: T, b: T, index: number) => boolean = equateValues): boolean {
|
||||
if (array1 === undefined || array2 === undefined) {
|
||||
@ -1875,10 +1846,8 @@ export function identity<T>(x: T) {
|
||||
|
||||
/**
|
||||
* Returns lower case string
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function toLowerCase(x: string) {
|
||||
function toLowerCase(x: string) {
|
||||
return x.toLowerCase();
|
||||
}
|
||||
|
||||
@ -1963,82 +1932,6 @@ export function memoizeOne<A extends string | number | boolean | undefined, T>(c
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A version of `memoize` that supports a single non-primitive argument, stored as keys of a WeakMap.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function memoizeWeak<A extends object, T>(callback: (arg: A) => T): (arg: A) => T {
|
||||
const map = new WeakMap<A, T>();
|
||||
return (arg: A) => {
|
||||
let value = map.get(arg);
|
||||
if (value === undefined && !map.has(arg)) {
|
||||
value = callback(arg);
|
||||
map.set(arg, value);
|
||||
}
|
||||
return value!;
|
||||
};
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export interface MemoizeCache<A extends any[], T> {
|
||||
has(args: A): boolean;
|
||||
get(args: A): T | undefined;
|
||||
set(args: A, value: T): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* A version of `memoize` that supports multiple arguments, backed by a provided cache.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function memoizeCached<A extends any[], T>(callback: (...args: A) => T, cache: MemoizeCache<A, T>): (...args: A) => T {
|
||||
return (...args: A) => {
|
||||
let value = cache.get(args);
|
||||
if (value === undefined && !cache.has(args)) {
|
||||
value = callback(...args);
|
||||
cache.set(args, value);
|
||||
}
|
||||
return value!;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* High-order function, composes functions. Note that functions are composed inside-out;
|
||||
* for example, `compose(a, b)` is the equivalent of `x => b(a(x))`.
|
||||
*
|
||||
* @param args The functions to compose.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function compose<T>(...args: ((t: T) => T)[]): (t: T) => T;
|
||||
/** @internal */
|
||||
export function compose<T>(a: (t: T) => T, b: (t: T) => T, c: (t: T) => T, d: (t: T) => T, e: (t: T) => T): (t: T) => T {
|
||||
if (!!e) {
|
||||
const args: ((t: T) => T)[] = [];
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
|
||||
return t => reduceLeft(args, (u, f) => f(u), t);
|
||||
}
|
||||
else if (d) {
|
||||
return t => d(c(b(a(t))));
|
||||
}
|
||||
else if (c) {
|
||||
return t => c(b(a(t)));
|
||||
}
|
||||
else if (b) {
|
||||
return t => b(a(t));
|
||||
}
|
||||
else if (a) {
|
||||
return t => a(t);
|
||||
}
|
||||
else {
|
||||
return t => t;
|
||||
}
|
||||
}
|
||||
/** @internal */
|
||||
export const enum AssertionLevel {
|
||||
None = 0,
|
||||
@ -2054,8 +1947,6 @@ export const enum AssertionLevel {
|
||||
* @internal
|
||||
*/
|
||||
export type AnyFunction = (...args: never[]) => void;
|
||||
/** @internal */
|
||||
export type AnyConstructor = new (...args: unknown[]) => unknown;
|
||||
|
||||
/** @internal */
|
||||
export function equateValues<T>(a: T, b: T) {
|
||||
@ -2467,8 +2358,7 @@ export function orderedRemoveItemAt<T>(array: T[], index: number): void {
|
||||
array.pop();
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function unorderedRemoveItemAt<T>(array: T[], index: number): void {
|
||||
function unorderedRemoveItemAt<T>(array: T[], index: number): void {
|
||||
// Fill in the "hole" left at `index`.
|
||||
array[index] = array[array.length - 1];
|
||||
array.pop();
|
||||
|
||||
@ -33,16 +33,6 @@ export interface ReadonlyCollection<K> {
|
||||
keys(): IterableIterator<K>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Common write methods for ES6 Map/Set.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export interface Collection<K> extends ReadonlyCollection<K> {
|
||||
delete(key: K): boolean;
|
||||
clear(): void;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export type EqualityComparer<T> = (a: T, b: T) => boolean;
|
||||
|
||||
|
||||
@ -503,8 +503,7 @@ export function canEmitTsBuildInfo(options: CompilerOptions) {
|
||||
return isIncrementalCompilation(options) || !!options.tscBuild;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getOutputPathsForBundle(options: CompilerOptions, forceDtsPaths: boolean): EmitFileNames {
|
||||
function getOutputPathsForBundle(options: CompilerOptions, forceDtsPaths: boolean): EmitFileNames {
|
||||
const outPath = options.outFile!;
|
||||
const jsFilePath = options.emitDeclarationOnly ? undefined : outPath;
|
||||
const sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options);
|
||||
|
||||
@ -696,10 +696,8 @@ export function compareEmitHelpers(x: EmitHelper, y: EmitHelper) {
|
||||
/**
|
||||
* @param input Template string input strings
|
||||
* @param args Names which need to be made file-level unique
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function helperString(input: TemplateStringsArray, ...args: string[]) {
|
||||
function helperString(input: TemplateStringsArray, ...args: string[]) {
|
||||
return (uniqueName: EmitHelperUniqueNameCallback) => {
|
||||
let result = "";
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
@ -713,8 +711,7 @@ export function helperString(input: TemplateStringsArray, ...args: string[]) {
|
||||
|
||||
// TypeScript Helpers
|
||||
|
||||
/** @internal */
|
||||
export const decorateHelper: UnscopedEmitHelper = {
|
||||
const decorateHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:decorate",
|
||||
importName: "__decorate",
|
||||
scoped: false,
|
||||
@ -728,8 +725,7 @@ export const decorateHelper: UnscopedEmitHelper = {
|
||||
};`,
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
export const metadataHelper: UnscopedEmitHelper = {
|
||||
const metadataHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:metadata",
|
||||
importName: "__metadata",
|
||||
scoped: false,
|
||||
@ -740,8 +736,7 @@ export const metadataHelper: UnscopedEmitHelper = {
|
||||
};`,
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
export const paramHelper: UnscopedEmitHelper = {
|
||||
const paramHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:param",
|
||||
importName: "__param",
|
||||
scoped: false,
|
||||
@ -753,8 +748,7 @@ export const paramHelper: UnscopedEmitHelper = {
|
||||
};
|
||||
|
||||
// ES Decorators Helpers
|
||||
/** @internal */
|
||||
export const esDecorateHelper: UnscopedEmitHelper = {
|
||||
const esDecorateHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:esDecorate",
|
||||
importName: "__esDecorate",
|
||||
scoped: false,
|
||||
@ -789,8 +783,7 @@ export const esDecorateHelper: UnscopedEmitHelper = {
|
||||
};`,
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
export const runInitializersHelper: UnscopedEmitHelper = {
|
||||
const runInitializersHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:runInitializers",
|
||||
importName: "__runInitializers",
|
||||
scoped: false,
|
||||
@ -807,8 +800,7 @@ export const runInitializersHelper: UnscopedEmitHelper = {
|
||||
|
||||
// ES2018 Helpers
|
||||
|
||||
/** @internal */
|
||||
export const assignHelper: UnscopedEmitHelper = {
|
||||
const assignHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:assign",
|
||||
importName: "__assign",
|
||||
scoped: false,
|
||||
@ -827,8 +819,7 @@ export const assignHelper: UnscopedEmitHelper = {
|
||||
};`,
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
export const awaitHelper: UnscopedEmitHelper = {
|
||||
const awaitHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:await",
|
||||
importName: "__await",
|
||||
scoped: false,
|
||||
@ -836,8 +827,7 @@ export const awaitHelper: UnscopedEmitHelper = {
|
||||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }`,
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
export const asyncGeneratorHelper: UnscopedEmitHelper = {
|
||||
const asyncGeneratorHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:asyncGenerator",
|
||||
importName: "__asyncGenerator",
|
||||
scoped: false,
|
||||
@ -857,8 +847,7 @@ export const asyncGeneratorHelper: UnscopedEmitHelper = {
|
||||
};`,
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
export const asyncDelegator: UnscopedEmitHelper = {
|
||||
const asyncDelegator: UnscopedEmitHelper = {
|
||||
name: "typescript:asyncDelegator",
|
||||
importName: "__asyncDelegator",
|
||||
scoped: false,
|
||||
@ -871,8 +860,7 @@ export const asyncDelegator: UnscopedEmitHelper = {
|
||||
};`,
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
export const asyncValues: UnscopedEmitHelper = {
|
||||
const asyncValues: UnscopedEmitHelper = {
|
||||
name: "typescript:asyncValues",
|
||||
importName: "__asyncValues",
|
||||
scoped: false,
|
||||
@ -888,8 +876,7 @@ export const asyncValues: UnscopedEmitHelper = {
|
||||
|
||||
// ES2018 Destructuring Helpers
|
||||
|
||||
/** @internal */
|
||||
export const restHelper: UnscopedEmitHelper = {
|
||||
const restHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:rest",
|
||||
importName: "__rest",
|
||||
scoped: false,
|
||||
@ -909,8 +896,7 @@ export const restHelper: UnscopedEmitHelper = {
|
||||
|
||||
// ES2017 Helpers
|
||||
|
||||
/** @internal */
|
||||
export const awaiterHelper: UnscopedEmitHelper = {
|
||||
const awaiterHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:awaiter",
|
||||
importName: "__awaiter",
|
||||
scoped: false,
|
||||
@ -929,8 +915,7 @@ export const awaiterHelper: UnscopedEmitHelper = {
|
||||
|
||||
// ES2015 Helpers
|
||||
|
||||
/** @internal */
|
||||
export const extendsHelper: UnscopedEmitHelper = {
|
||||
const extendsHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:extends",
|
||||
importName: "__extends",
|
||||
scoped: false,
|
||||
@ -954,8 +939,7 @@ export const extendsHelper: UnscopedEmitHelper = {
|
||||
})();`,
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
export const templateObjectHelper: UnscopedEmitHelper = {
|
||||
const templateObjectHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:makeTemplateObject",
|
||||
importName: "__makeTemplateObject",
|
||||
scoped: false,
|
||||
@ -967,8 +951,7 @@ export const templateObjectHelper: UnscopedEmitHelper = {
|
||||
};`,
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
export const readHelper: UnscopedEmitHelper = {
|
||||
const readHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:read",
|
||||
importName: "__read",
|
||||
scoped: false,
|
||||
@ -991,8 +974,7 @@ export const readHelper: UnscopedEmitHelper = {
|
||||
};`,
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
export const spreadArrayHelper: UnscopedEmitHelper = {
|
||||
const spreadArrayHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:spreadArray",
|
||||
importName: "__spreadArray",
|
||||
scoped: false,
|
||||
@ -1008,8 +990,7 @@ export const spreadArrayHelper: UnscopedEmitHelper = {
|
||||
};`,
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
export const propKeyHelper: UnscopedEmitHelper = {
|
||||
const propKeyHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:propKey",
|
||||
importName: "__propKey",
|
||||
scoped: false,
|
||||
@ -1020,8 +1001,7 @@ export const propKeyHelper: UnscopedEmitHelper = {
|
||||
};
|
||||
|
||||
// https://tc39.es/ecma262/#sec-setfunctionname
|
||||
/** @internal */
|
||||
export const setFunctionNameHelper: UnscopedEmitHelper = {
|
||||
const setFunctionNameHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:setFunctionName",
|
||||
importName: "__setFunctionName",
|
||||
scoped: false,
|
||||
@ -1034,8 +1014,7 @@ export const setFunctionNameHelper: UnscopedEmitHelper = {
|
||||
|
||||
// ES2015 Destructuring Helpers
|
||||
|
||||
/** @internal */
|
||||
export const valuesHelper: UnscopedEmitHelper = {
|
||||
const valuesHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:values",
|
||||
importName: "__values",
|
||||
scoped: false,
|
||||
@ -1116,8 +1095,7 @@ export const valuesHelper: UnscopedEmitHelper = {
|
||||
// entering a finally block.
|
||||
//
|
||||
// For examples of how these are used, see the comments in ./transformers/generators.ts
|
||||
/** @internal */
|
||||
export const generatorHelper: UnscopedEmitHelper = {
|
||||
const generatorHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:generator",
|
||||
importName: "__generator",
|
||||
scoped: false,
|
||||
@ -1154,8 +1132,7 @@ export const generatorHelper: UnscopedEmitHelper = {
|
||||
|
||||
// ES Module Helpers
|
||||
|
||||
/** @internal */
|
||||
export const createBindingHelper: UnscopedEmitHelper = {
|
||||
const createBindingHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:commonjscreatebinding",
|
||||
importName: "__createBinding",
|
||||
scoped: false,
|
||||
@ -1174,8 +1151,7 @@ export const createBindingHelper: UnscopedEmitHelper = {
|
||||
}));`,
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
export const setModuleDefaultHelper: UnscopedEmitHelper = {
|
||||
const setModuleDefaultHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:commonjscreatevalue",
|
||||
importName: "__setModuleDefault",
|
||||
scoped: false,
|
||||
@ -1189,8 +1165,7 @@ export const setModuleDefaultHelper: UnscopedEmitHelper = {
|
||||
};
|
||||
|
||||
// emit helper for `import * as Name from "foo"`
|
||||
/** @internal */
|
||||
export const importStarHelper: UnscopedEmitHelper = {
|
||||
const importStarHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:commonjsimportstar",
|
||||
importName: "__importStar",
|
||||
scoped: false,
|
||||
@ -1207,8 +1182,7 @@ export const importStarHelper: UnscopedEmitHelper = {
|
||||
};
|
||||
|
||||
// emit helper for `import Name from "foo"`
|
||||
/** @internal */
|
||||
export const importDefaultHelper: UnscopedEmitHelper = {
|
||||
const importDefaultHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:commonjsimportdefault",
|
||||
importName: "__importDefault",
|
||||
scoped: false,
|
||||
@ -1218,8 +1192,7 @@ export const importDefaultHelper: UnscopedEmitHelper = {
|
||||
};`,
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
export const exportStarHelper: UnscopedEmitHelper = {
|
||||
const exportStarHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:export-star",
|
||||
importName: "__exportStar",
|
||||
scoped: false,
|
||||
@ -1278,10 +1251,8 @@ export const exportStarHelper: UnscopedEmitHelper = {
|
||||
*
|
||||
* Reading from a private static method (TS 4.3+):
|
||||
* __classPrivateFieldGet(<any>, <constructor>, "m", <function>)
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const classPrivateFieldGetHelper: UnscopedEmitHelper = {
|
||||
const classPrivateFieldGetHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:classPrivateFieldGet",
|
||||
importName: "__classPrivateFieldGet",
|
||||
scoped: false,
|
||||
@ -1343,10 +1314,8 @@ export const classPrivateFieldGetHelper: UnscopedEmitHelper = {
|
||||
* Writing to a private static method (TS 4.3+):
|
||||
* __classPrivateFieldSet(<any>, <constructor>, <any>, "m", <function>)
|
||||
* NOTE: This always results in a runtime error.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const classPrivateFieldSetHelper: UnscopedEmitHelper = {
|
||||
const classPrivateFieldSetHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:classPrivateFieldSet",
|
||||
importName: "__classPrivateFieldSet",
|
||||
scoped: false,
|
||||
@ -1370,10 +1339,8 @@ export const classPrivateFieldSetHelper: UnscopedEmitHelper = {
|
||||
* Usage:
|
||||
* This helper is used to transform `#field in expression` to
|
||||
* `__classPrivateFieldIn(<weakMap/weakSet/constructor>, expression)`
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const classPrivateFieldInHelper: UnscopedEmitHelper = {
|
||||
const classPrivateFieldInHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:classPrivateFieldIn",
|
||||
importName: "__classPrivateFieldIn",
|
||||
scoped: false,
|
||||
@ -1384,10 +1351,7 @@ export const classPrivateFieldInHelper: UnscopedEmitHelper = {
|
||||
};`,
|
||||
};
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const addDisposableResourceHelper: UnscopedEmitHelper = {
|
||||
const addDisposableResourceHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:addDisposableResource",
|
||||
importName: "__addDisposableResource",
|
||||
scoped: false,
|
||||
@ -1420,10 +1384,8 @@ export const addDisposableResourceHelper: UnscopedEmitHelper = {
|
||||
* The `s` variable represents two boolean flags from the `DisposeResources` algorithm:
|
||||
* - `needsAwait` (`1`) — Indicates that an `await using` for a `null` or `undefined` resource was encountered.
|
||||
* - `hasAwaited` (`2`) — Indicates that the algorithm has performed an Await.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const disposeResourcesHelper: UnscopedEmitHelper = {
|
||||
const disposeResourcesHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:disposeResources",
|
||||
importName: "__disposeResources",
|
||||
scoped: false,
|
||||
|
||||
@ -364,7 +364,7 @@ export function setIdentifierAutoGenerate<T extends Identifier | PrivateIdentifi
|
||||
return node;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export function getIdentifierAutoGenerate(node: Identifier | PrivateIdentifier): AutoGenerateInfo | undefined {
|
||||
return node.emitNode?.autoGenerate;
|
||||
}
|
||||
|
||||
@ -476,7 +476,7 @@ export const enum NodeFactoryFlags {
|
||||
|
||||
const nodeFactoryPatchers: ((factory: NodeFactory) => void)[] = [];
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export function addNodeFactoryPatcher(fn: (factory: NodeFactory) => void) {
|
||||
nodeFactoryPatchers.push(fn);
|
||||
}
|
||||
@ -7295,10 +7295,8 @@ function aggregateChildrenFlags(children: MutableNodeArray<Node>) {
|
||||
|
||||
/**
|
||||
* Gets the transform flags to exclude when unioning the transform flags of a subtree.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function getTransformFlagsSubtreeExclusions(kind: SyntaxKind) {
|
||||
function getTransformFlagsSubtreeExclusions(kind: SyntaxKind) {
|
||||
if (kind >= SyntaxKind.FirstTypeNode && kind <= SyntaxKind.LastTypeNode) {
|
||||
return TransformFlags.TypeExcludes;
|
||||
}
|
||||
|
||||
@ -17,8 +17,6 @@ import {
|
||||
BindingOrAssignmentPattern,
|
||||
BitwiseOperator,
|
||||
BitwiseOperatorOrHigher,
|
||||
Block,
|
||||
BooleanLiteral,
|
||||
CharacterCodes,
|
||||
CommaListExpression,
|
||||
compareStringsCaseSensitive,
|
||||
@ -78,7 +76,6 @@ import {
|
||||
isAssignmentExpression,
|
||||
isAssignmentOperator,
|
||||
isAssignmentPattern,
|
||||
isBlock,
|
||||
isCommaListExpression,
|
||||
isComputedPropertyName,
|
||||
isDeclarationBindingElement,
|
||||
@ -91,10 +88,8 @@ import {
|
||||
isGeneratedPrivateIdentifier,
|
||||
isIdentifier,
|
||||
isInJSFile,
|
||||
isLiteralExpression,
|
||||
isMemberName,
|
||||
isMinusToken,
|
||||
isModifierKind,
|
||||
isObjectLiteralElementLike,
|
||||
isParenthesizedExpression,
|
||||
isPlusToken,
|
||||
@ -139,7 +134,6 @@ import {
|
||||
NodeArray,
|
||||
NodeFactory,
|
||||
nodeIsSynthesized,
|
||||
NullLiteral,
|
||||
NumericLiteral,
|
||||
ObjectLiteralElementLike,
|
||||
ObjectLiteralExpression,
|
||||
@ -333,16 +327,6 @@ export function createForOfBindingStatement(factory: NodeFactory, node: ForIniti
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function insertLeadingStatement(factory: NodeFactory, dest: Statement, source: Statement): Block {
|
||||
if (isBlock(dest)) {
|
||||
return factory.updateBlock(dest, setTextRange(factory.createNodeArray([source, ...dest.statements]), dest.statements));
|
||||
}
|
||||
else {
|
||||
return factory.createBlock(factory.createNodeArray([dest, source]), /*multiLine*/ true);
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function createExpressionFromEntityName(factory: NodeFactory, node: EntityName | Expression): Expression {
|
||||
if (isQualifiedName(node)) {
|
||||
@ -679,15 +663,6 @@ export function walkUpOuterExpressions(node: Expression, kinds = OuterExpression
|
||||
return parent;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function skipAssertions(node: Expression): Expression;
|
||||
/** @internal */
|
||||
export function skipAssertions(node: Node): Node;
|
||||
/** @internal */
|
||||
export function skipAssertions(node: Node): Node {
|
||||
return skipOuterExpressions(node, OuterExpressionKinds.Assertions);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function startOnNewLine<T extends Node>(node: T): T {
|
||||
return setStartsOnNewLine(node, /*newLine*/ true);
|
||||
@ -761,8 +736,7 @@ export function createExternalHelpersImportDeclarationIfNeeded(nodeFactory: Node
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getOrCreateExternalHelpersModuleNameIfNeeded(factory: NodeFactory, node: SourceFile, compilerOptions: CompilerOptions, hasExportStarsToExportValues?: boolean, hasImportStarOrImportDefault?: boolean) {
|
||||
function getOrCreateExternalHelpersModuleNameIfNeeded(factory: NodeFactory, node: SourceFile, compilerOptions: CompilerOptions, hasExportStarsToExportValues?: boolean, hasImportStarOrImportDefault?: boolean) {
|
||||
if (compilerOptions.importHelpers && isEffectiveExternalModule(node, compilerOptions)) {
|
||||
const externalHelpersModuleName = getExternalHelpersModuleName(node);
|
||||
if (externalHelpersModuleName) {
|
||||
@ -1116,7 +1090,7 @@ export function getJSDocTypeAliasName(fullName: JSDocNamespaceBody | undefined)
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export function canHaveIllegalType(node: Node): node is HasIllegalType {
|
||||
const kind = node.kind;
|
||||
return kind === SyntaxKind.Constructor
|
||||
@ -1183,16 +1157,6 @@ export function isModuleName(node: Node): node is ModuleName {
|
||||
return isIdentifier(node) || isStringLiteral(node);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isLiteralTypeLikeExpression(node: Node): node is NullLiteral | BooleanLiteral | LiteralExpression | PrefixUnaryExpression {
|
||||
const kind = node.kind;
|
||||
return kind === SyntaxKind.NullKeyword
|
||||
|| kind === SyntaxKind.TrueKeyword
|
||||
|| kind === SyntaxKind.FalseKeyword
|
||||
|| isLiteralExpression(node)
|
||||
|| isPrefixUnaryExpression(node);
|
||||
}
|
||||
|
||||
function isExponentiationOperator(kind: SyntaxKind): kind is ExponentiationOperator {
|
||||
return kind === SyntaxKind.AsteriskAsteriskToken;
|
||||
}
|
||||
@ -1521,12 +1485,6 @@ export function isExportOrDefaultModifier(node: Node): node is ExportKeyword | D
|
||||
return isExportOrDefaultKeywordKind(kind);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isNonExportDefaultModifier(node: Node): node is Exclude<Modifier, ExportKeyword | DefaultKeyword> {
|
||||
const kind = node.kind;
|
||||
return isModifierKind(kind) && !isExportOrDefaultKeywordKind(kind);
|
||||
}
|
||||
|
||||
/**
|
||||
* If `nodes` is not undefined, creates an empty `NodeArray` that preserves the `pos` and `end` of `nodes`.
|
||||
* @internal
|
||||
|
||||
@ -967,8 +967,7 @@ export interface CacheWithRedirects<K, V> {
|
||||
/** @internal */
|
||||
export type RedirectsCacheKey = string & { __compilerOptionsKey: any; };
|
||||
|
||||
/** @internal */
|
||||
export function createCacheWithRedirects<K, V>(ownOptions: CompilerOptions | undefined, optionsToRedirectsKey: Map<CompilerOptions, RedirectsCacheKey>): CacheWithRedirects<K, V> {
|
||||
function createCacheWithRedirects<K, V>(ownOptions: CompilerOptions | undefined, optionsToRedirectsKey: Map<CompilerOptions, RedirectsCacheKey>): CacheWithRedirects<K, V> {
|
||||
const redirectsMap = new Map<CompilerOptions, Map<K, V>>();
|
||||
const redirectsKeyToMap = new Map<RedirectsCacheKey, Map<K, V>>();
|
||||
let ownMap = new Map<K, V>();
|
||||
@ -1752,8 +1751,10 @@ function tryResolveJSModuleWorker(moduleName: string, initialDir: string, host:
|
||||
/*conditions*/ undefined,
|
||||
);
|
||||
}
|
||||
|
||||
// knip applies the internal marker to _all_ declarations, not just the one overload.
|
||||
export function bundlerModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations;
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export function bundlerModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, conditions?: string[]): ResolvedModuleWithFailedLookupLocations; // eslint-disable-line @typescript-eslint/unified-signatures
|
||||
export function bundlerModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, conditions?: string[]): ResolvedModuleWithFailedLookupLocations {
|
||||
const containingDirectory = getDirectoryPath(containingFile);
|
||||
@ -2432,8 +2433,7 @@ function readPackageJsonPeerDependencies(packageJsonInfo: PackageJsonInfo, state
|
||||
return result;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getPackageJsonInfo(packageDirectory: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PackageJsonInfo | undefined {
|
||||
function getPackageJsonInfo(packageDirectory: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PackageJsonInfo | undefined {
|
||||
const { host, traceEnabled } = state;
|
||||
const packageJsonPath = combinePaths(packageDirectory, "package.json");
|
||||
if (onlyRecordFailures) {
|
||||
|
||||
@ -424,6 +424,7 @@ let SourceFileConstructor: new (kind: SyntaxKind.SourceFile, pos: number, end: n
|
||||
* NOTE: You should not use this, it is only exported to support `createNode` in `~/src/deprecatedCompat/deprecations.ts`.
|
||||
*
|
||||
* @internal
|
||||
* @knipignore
|
||||
*/
|
||||
export const parseBaseNodeFactory: BaseNodeFactory = {
|
||||
createBaseSourceFileNode: kind => new (SourceFileConstructor || (SourceFileConstructor = objectAllocator.getSourceFileConstructor()))(kind, -1, -1),
|
||||
|
||||
@ -907,8 +907,7 @@ export function startsWithDirectory(fileName: string, directoryName: string, get
|
||||
|
||||
//// Relative Paths
|
||||
|
||||
/** @internal */
|
||||
export function getPathComponentsRelativeTo(from: string, to: string, stringEqualityComparer: (a: string, b: string) => boolean, getCanonicalFileName: GetCanonicalFileName) {
|
||||
function getPathComponentsRelativeTo(from: string, to: string, stringEqualityComparer: (a: string, b: string) => boolean, getCanonicalFileName: GetCanonicalFileName) {
|
||||
const fromComponents = reducePathComponents(getPathComponents(from));
|
||||
const toComponents = reducePathComponents(getPathComponents(to));
|
||||
|
||||
|
||||
@ -1374,8 +1374,7 @@ export function getImpliedNodeFormatForFileWorker(
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export const plainJSErrors = new Set<number>([
|
||||
const plainJSErrors = new Set<number>([
|
||||
// binder errors
|
||||
Diagnostics.Cannot_redeclare_block_scoped_variable_0.code,
|
||||
Diagnostics.A_module_cannot_have_multiple_default_exports.code,
|
||||
|
||||
@ -34,7 +34,6 @@ import {
|
||||
getResolvedTypeReferenceDirectiveFromResolution,
|
||||
HasInvalidatedLibResolutions,
|
||||
HasInvalidatedResolutions,
|
||||
hasTrailingDirectorySeparator,
|
||||
ignoredPaths,
|
||||
inferredTypesContainingFile,
|
||||
isDiskPathRoot,
|
||||
@ -495,11 +494,6 @@ export function getRootDirectoryOfResolutionCache(rootDirForResolution: string,
|
||||
normalized;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getRootPathSplitLength(rootPath: Path) {
|
||||
return rootPath.split(directorySeparator).length - (hasTrailingDirectorySeparator(rootPath) ? 1 : 0);
|
||||
}
|
||||
|
||||
function getModuleResolutionHost(resolutionHost: ResolutionCacheHost) {
|
||||
return resolutionHost.getCompilerHost?.() || resolutionHost;
|
||||
}
|
||||
|
||||
@ -418,12 +418,12 @@ export function stringToToken(s: string): SyntaxKind | undefined {
|
||||
|
||||
const regExpFlagCharCodes = makeReverseMap(charCodeToRegExpFlag);
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export function regularExpressionFlagToCharacterCode(f: RegularExpressionFlags): CharacterCodes | undefined {
|
||||
return regExpFlagCharCodes[f];
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export function characterCodeToRegularExpressionFlag(ch: CharacterCodes): RegularExpressionFlags | undefined {
|
||||
return charCodeToRegExpFlag.get(ch);
|
||||
}
|
||||
@ -602,8 +602,7 @@ function isWordCharacter(ch: number): boolean {
|
||||
return isASCIILetter(ch) || isDigit(ch) || ch === CharacterCodes._;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isOctalDigit(ch: number): boolean {
|
||||
function isOctalDigit(ch: number): boolean {
|
||||
return ch >= CharacterCodes._0 && ch <= CharacterCodes._7;
|
||||
}
|
||||
|
||||
@ -788,15 +787,13 @@ function scanConflictMarkerTrivia(text: string, pos: number, error?: (diag: Diag
|
||||
|
||||
const shebangTriviaRegex = /^#!.*/;
|
||||
|
||||
/** @internal */
|
||||
export function isShebangTrivia(text: string, pos: number) {
|
||||
function isShebangTrivia(text: string, pos: number) {
|
||||
// Shebangs check must only be done at the start of the file
|
||||
Debug.assert(pos === 0);
|
||||
return shebangTriviaRegex.test(text);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function scanShebangTrivia(text: string, pos: number) {
|
||||
function scanShebangTrivia(text: string, pos: number) {
|
||||
const shebang = shebangTriviaRegex.exec(text)![0];
|
||||
pos = pos + shebang.length;
|
||||
return pos;
|
||||
|
||||
@ -405,8 +405,7 @@ function isStringOrNull(x: any) {
|
||||
return typeof x === "string" || x === null;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isRawSourceMap(x: any): x is RawSourceMap {
|
||||
function isRawSourceMap(x: any): x is RawSourceMap {
|
||||
return x !== null
|
||||
&& typeof x === "object"
|
||||
&& x.version === 3
|
||||
|
||||
@ -1996,7 +1996,7 @@ export let sys: System = (() => {
|
||||
return sys!;
|
||||
})();
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export function setSys(s: System) {
|
||||
sys = s;
|
||||
}
|
||||
|
||||
@ -29,9 +29,8 @@ import {
|
||||
* @param classThis The identifier to use for the captured static `this` reference, usually with the name `_classThis`.
|
||||
* @param thisExpression Overrides the expression to use for the actual `this` reference. This can be used to provide an
|
||||
* expression that has already had its `EmitFlags` set or may have been tracked to prevent substitution.
|
||||
* @internal
|
||||
*/
|
||||
export function createClassThisAssignmentBlock(factory: NodeFactory, classThis: Identifier, thisExpression = factory.createThis()): ClassThisAssignmentBlock {
|
||||
function createClassThisAssignmentBlock(factory: NodeFactory, classThis: Identifier, thisExpression = factory.createThis()): ClassThisAssignmentBlock {
|
||||
// produces:
|
||||
//
|
||||
// static { _classThis = this; }
|
||||
|
||||
@ -52,9 +52,8 @@ import {
|
||||
|
||||
/**
|
||||
* Gets a string literal to use as the assigned name of an anonymous class or function declaration.
|
||||
* @internal
|
||||
*/
|
||||
export function getAssignedNameOfIdentifier(factory: NodeFactory, name: Identifier, expression: WrappedExpression<AnonymousFunctionDefinition>): StringLiteral {
|
||||
function getAssignedNameOfIdentifier(factory: NodeFactory, name: Identifier, expression: WrappedExpression<AnonymousFunctionDefinition>): StringLiteral {
|
||||
const original = getOriginalNode(skipOuterExpressions(expression));
|
||||
if (
|
||||
(isClassDeclaration(original) || isFunctionDeclaration(original)) &&
|
||||
@ -98,9 +97,8 @@ function getAssignedNameOfPropertyName(context: TransformationContext, name: Pro
|
||||
* side effects.
|
||||
* @param thisExpression Overrides the expression to use for the actual `this` reference. This can be used to provide an
|
||||
* expression that has already had its `EmitFlags` set or may have been tracked to prevent substitution.
|
||||
* @internal
|
||||
*/
|
||||
export function createClassNamedEvaluationHelperBlock(context: TransformationContext, assignedName: Expression, thisExpression: Expression = context.factory.createThis()): ClassNamedEvaluationHelperBlock {
|
||||
function createClassNamedEvaluationHelperBlock(context: TransformationContext, assignedName: Expression, thisExpression: Expression = context.factory.createThis()): ClassNamedEvaluationHelperBlock {
|
||||
// produces:
|
||||
//
|
||||
// static { __setFunctionName(this, "C"); }
|
||||
|
||||
@ -429,8 +429,7 @@ export class IdentifierNameMap<V> {
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export class IdentifierNameMultiMap<V> extends IdentifierNameMap<V[]> {
|
||||
class IdentifierNameMultiMap<V> extends IdentifierNameMap<V[]> {
|
||||
add(key: Identifier, value: V): V[] {
|
||||
let values = this.get(key);
|
||||
if (values) {
|
||||
@ -801,8 +800,7 @@ export interface LexicalEnvironment<in out TEnvData, TPrivateEnvData, TPrivateEn
|
||||
readonly previous: LexicalEnvironment<TEnvData, TPrivateEnvData, TPrivateEntry> | undefined;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function walkUpLexicalEnvironments<TEnvData, TPrivateEnvData, TPrivateEntry, U>(
|
||||
function walkUpLexicalEnvironments<TEnvData, TPrivateEnvData, TPrivateEntry, U>(
|
||||
env: LexicalEnvironment<TEnvData, TPrivateEnvData, TPrivateEntry> | undefined,
|
||||
cb: (env: LexicalEnvironment<TEnvData, TPrivateEnvData, TPrivateEntry>) => U,
|
||||
): U | undefined {
|
||||
@ -856,8 +854,7 @@ export function accessPrivateIdentifier<
|
||||
return walkUpLexicalEnvironments(env, env => getPrivateIdentifier(env.privateEnv, name));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isSimpleParameter(node: ParameterDeclaration) {
|
||||
function isSimpleParameter(node: ParameterDeclaration) {
|
||||
return !node.initializer && isIdentifier(node.name);
|
||||
}
|
||||
|
||||
|
||||
@ -198,10 +198,8 @@ function getOrCreateValueMapFromConfigFileMap<K extends string, V>(configFileMap
|
||||
|
||||
/**
|
||||
* Helper to use now method instead of current date for testing purposes to get consistent baselines
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function getCurrentTime(host: { now?(): Date; }) {
|
||||
function getCurrentTime(host: { now?(): Date; }) {
|
||||
return host.now ? host.now() : new Date();
|
||||
}
|
||||
|
||||
|
||||
@ -1302,7 +1302,7 @@ export type HasExpressionInitializer =
|
||||
| PropertyAssignment
|
||||
| EnumMember;
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export type HasIllegalExpressionInitializer = PropertySignature;
|
||||
|
||||
// NOTE: Changing the following list requires changes to:
|
||||
@ -2308,7 +2308,7 @@ export interface TypeOperatorNode extends TypeNode {
|
||||
readonly type: TypeNode;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export interface UniqueTypeOperatorNode extends TypeOperatorNode {
|
||||
readonly operator: SyntaxKind.UniqueKeyword;
|
||||
}
|
||||
@ -2660,7 +2660,7 @@ export type ObjectBindingOrAssignmentElement =
|
||||
| SpreadAssignment // AssignmentRestProperty
|
||||
;
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export type ObjectAssignmentElement = Exclude<ObjectBindingOrAssignmentElement, BindingElement>;
|
||||
|
||||
export type ArrayBindingOrAssignmentElement =
|
||||
@ -2691,7 +2691,7 @@ export type BindingOrAssignmentElementTarget =
|
||||
| ElementAccessExpression
|
||||
| OmittedExpression;
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export type AssignmentElementTarget = Exclude<BindingOrAssignmentElementTarget, BindingPattern>;
|
||||
|
||||
export type ObjectBindingOrAssignmentPattern =
|
||||
@ -5493,12 +5493,6 @@ export const enum SymbolAccessibility {
|
||||
NotResolved,
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export const enum SyntheticSymbolKind {
|
||||
UnionOrIntersection,
|
||||
Spread,
|
||||
}
|
||||
|
||||
export const enum TypePredicateKind {
|
||||
This,
|
||||
Identifier,
|
||||
@ -7994,12 +7988,6 @@ export interface CompilerHost extends ModuleResolutionHost {
|
||||
*/
|
||||
export type SourceOfProjectReferenceRedirect = string | true;
|
||||
|
||||
/** @internal */
|
||||
export interface ResolvedProjectReferenceCallbacks {
|
||||
getSourceOfProjectReferenceRedirect(fileName: string): SourceOfProjectReferenceRedirect | undefined;
|
||||
forEachResolvedProjectReference<T>(cb: (resolvedProjectReference: ResolvedProjectReference) => T | undefined): T | undefined;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export const enum TransformFlags {
|
||||
None = 0,
|
||||
@ -8217,9 +8205,6 @@ export interface UnscopedEmitHelper extends EmitHelperBase {
|
||||
|
||||
export type EmitHelper = ScopedEmitHelper | UnscopedEmitHelper;
|
||||
|
||||
/** @internal */
|
||||
export type UniqueNameHandler = (baseName: string, checkFn?: (name: string) => boolean, optimistic?: boolean) => string;
|
||||
|
||||
export type EmitHelperUniqueNameCallback = (name: string) => string;
|
||||
|
||||
/**
|
||||
|
||||
@ -11,7 +11,7 @@ import {
|
||||
AmpersandAmpersandEqualsToken,
|
||||
AnyImportOrBareOrAccessedRequire,
|
||||
AnyImportOrReExport,
|
||||
AnyImportOrRequireStatement,
|
||||
type AnyImportOrRequireStatement,
|
||||
AnyImportSyntax,
|
||||
AnyValidImportOrReExport,
|
||||
append,
|
||||
@ -150,7 +150,6 @@ import {
|
||||
flatMapToMutable,
|
||||
flatten,
|
||||
forEach,
|
||||
forEachAncestorDirectory,
|
||||
forEachChild,
|
||||
forEachChildRecursively,
|
||||
ForInOrOfStatement,
|
||||
@ -523,7 +522,6 @@ import {
|
||||
StringLiteralType,
|
||||
stringToToken,
|
||||
SuperCall,
|
||||
SuperExpression,
|
||||
SuperProperty,
|
||||
SwitchStatement,
|
||||
Symbol,
|
||||
@ -689,8 +687,7 @@ export function changesAffectModuleResolution(oldOptions: CompilerOptions, newOp
|
||||
optionsHaveModuleResolutionChanges(oldOptions, newOptions);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function optionsHaveModuleResolutionChanges(oldOptions: CompilerOptions, newOptions: CompilerOptions) {
|
||||
function optionsHaveModuleResolutionChanges(oldOptions: CompilerOptions, newOptions: CompilerOptions) {
|
||||
return optionsHaveChanges(oldOptions, newOptions, moduleResolutionOptionDeclarations);
|
||||
}
|
||||
|
||||
@ -964,7 +961,7 @@ export function getStartPositionOfLine(line: number, sourceFile: SourceFileLike)
|
||||
}
|
||||
|
||||
// This is a useful function for debugging purposes.
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export function nodePosToString(node: Node): string {
|
||||
const file = getSourceFileOfNode(node);
|
||||
const loc = getLineAndCharacterOfPosition(file, node.pos);
|
||||
@ -1107,6 +1104,7 @@ export function insertStatementsAfterCustomPrologue<T extends Statement>(to: T[]
|
||||
* Prepends statements to an array while taking care of prologue directives.
|
||||
*
|
||||
* @internal
|
||||
* @knipignore
|
||||
*/
|
||||
export function insertStatementAfterStandardPrologue<T extends Statement>(to: T[], statement: T | undefined): T[] {
|
||||
return insertStatementAfterPrologue(to, statement, isPrologueDirective);
|
||||
@ -1900,10 +1898,8 @@ export function isNonGlobalAmbientModule(node: Node): node is ModuleDeclaration
|
||||
* 1. An actual declaration: namespace X { ... }
|
||||
* 2. A Javascript declaration, which is:
|
||||
* An identifier in a nested property access expression: Y in `X.Y.Z = { ... }`
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function isEffectiveModuleDeclaration(node: Node) {
|
||||
function isEffectiveModuleDeclaration(node: Node) {
|
||||
return isModuleDeclaration(node) || isIdentifier(node);
|
||||
}
|
||||
|
||||
@ -2579,12 +2575,10 @@ export function getJSDocCommentRanges(node: Node, text: string) {
|
||||
text.charCodeAt(comment.pos + 3) !== CharacterCodes.slash);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export const fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)(('[^']*')|("[^"]*")).*?\/>/;
|
||||
const fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)(('[^']*')|("[^"]*")).*?\/>/;
|
||||
const fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*<reference\s+types\s*=\s*)(('[^']*')|("[^"]*")).*?\/>/;
|
||||
const fullTripleSlashLibReferenceRegEx = /^(\/\/\/\s*<reference\s+lib\s*=\s*)(('[^']*')|("[^"]*")).*?\/>/;
|
||||
/** @internal */
|
||||
export const fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*<amd-dependency\s+path\s*=\s*)(('[^']*')|("[^"]*")).*?\/>/;
|
||||
const fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*<amd-dependency\s+path\s*=\s*)(('[^']*')|("[^"]*")).*?\/>/;
|
||||
const fullTripleSlashAMDModuleRegEx = /^\/\/\/\s*<amd-module\s+.*?\/>/;
|
||||
const defaultLibReferenceRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)(('[^']*')|("[^"]*"))\s*\/>/;
|
||||
|
||||
@ -2690,17 +2684,6 @@ function isPartOfTypeExpressionWithTypeArguments(node: Node) {
|
||||
|| isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isChildOfNodeWithKind(node: Node, kind: SyntaxKind): boolean {
|
||||
while (node) {
|
||||
if (node.kind === kind) {
|
||||
return true;
|
||||
}
|
||||
node = node.parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Warning: This has the same semantics as the forEach family of functions,
|
||||
// in that traversal terminates in the event that 'visitor' supplies a truthy value.
|
||||
/** @internal */
|
||||
@ -3217,12 +3200,6 @@ export function getImmediatelyInvokedFunctionExpression(func: Node): CallExpress
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isSuperOrSuperProperty(node: Node): node is SuperExpression | SuperProperty {
|
||||
return node.kind === SyntaxKind.SuperKeyword
|
||||
|| isSuperProperty(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a node is a property or element access expression for `super`.
|
||||
*
|
||||
@ -3624,11 +3601,6 @@ export function isSourceFileJS(file: SourceFile): boolean {
|
||||
return isInJSFile(file);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isSourceFileNotJS(file: SourceFile): boolean {
|
||||
return !isInJSFile(file);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isInJSFile(node: Node | undefined): boolean {
|
||||
return !!node && !!(node.flags & NodeFlags.JavaScriptFile);
|
||||
@ -3943,19 +3915,15 @@ export function isBindableObjectDefinePropertyCall(expr: CallExpression): expr i
|
||||
|
||||
/**
|
||||
* x.y OR x[0]
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function isLiteralLikeAccess(node: Node): node is LiteralLikeElementAccessExpression | PropertyAccessExpression {
|
||||
function isLiteralLikeAccess(node: Node): node is LiteralLikeElementAccessExpression | PropertyAccessExpression {
|
||||
return isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* x[0] OR x['a'] OR x[Symbol.y]
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function isLiteralLikeElementAccess(node: Node): node is LiteralLikeElementAccessExpression {
|
||||
function isLiteralLikeElementAccess(node: Node): node is LiteralLikeElementAccessExpression {
|
||||
return isElementAccessExpression(node) && isStringOrNumericLiteralLike(node.argumentExpression);
|
||||
}
|
||||
|
||||
@ -4302,8 +4270,7 @@ function getSourceOfDefaultedAssignment(node: Node): Node | undefined {
|
||||
: undefined;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node: Node): Expression | undefined {
|
||||
function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node: Node): Expression | undefined {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.VariableStatement:
|
||||
const v = getSingleVariableOfVariableStatement(node);
|
||||
@ -4630,7 +4597,7 @@ export function getTypeParameterFromJsDoc(node: TypeParameterDeclaration & { par
|
||||
return typeParameters && find(typeParameters, p => p.name.escapedText === name);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export function hasTypeArguments(node: Node): node is HasTypeArguments {
|
||||
return !!(node as HasTypeArguments).typeArguments;
|
||||
}
|
||||
@ -4946,46 +4913,6 @@ export function isIdentifierName(node: Identifier): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
// An alias symbol is created by one of the following declarations:
|
||||
// import <symbol> = ...
|
||||
// import <symbol> from ...
|
||||
// import * as <symbol> from ...
|
||||
// import { x as <symbol> } from ...
|
||||
// export { x as <symbol> } from ...
|
||||
// export * as ns <symbol> from ...
|
||||
// export = <EntityNameExpression>
|
||||
// export default <EntityNameExpression>
|
||||
// module.exports = <EntityNameExpression>
|
||||
// module.exports.x = <EntityNameExpression>
|
||||
// const x = require("...")
|
||||
// const { x } = require("...")
|
||||
// const x = require("...").y
|
||||
// const { x } = require("...").y
|
||||
/** @internal */
|
||||
export function isAliasSymbolDeclaration(node: Node): boolean {
|
||||
if (
|
||||
node.kind === SyntaxKind.ImportEqualsDeclaration ||
|
||||
node.kind === SyntaxKind.NamespaceExportDeclaration ||
|
||||
node.kind === SyntaxKind.ImportClause && !!(node as ImportClause).name ||
|
||||
node.kind === SyntaxKind.NamespaceImport ||
|
||||
node.kind === SyntaxKind.NamespaceExport ||
|
||||
node.kind === SyntaxKind.ImportSpecifier ||
|
||||
node.kind === SyntaxKind.ExportSpecifier ||
|
||||
node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(node as ExportAssignment)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return isInJSFile(node) && (
|
||||
isBinaryExpression(node) && getAssignmentDeclarationKind(node) === AssignmentDeclarationKind.ModuleExports && exportAssignmentIsAlias(node) ||
|
||||
isPropertyAccessExpression(node)
|
||||
&& isBinaryExpression(node.parent)
|
||||
&& node.parent.left === node
|
||||
&& node.parent.operatorToken.kind === SyntaxKind.EqualsToken
|
||||
&& isAliasableExpression(node.parent.right)
|
||||
);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getAliasDeclarationFromName(node: EntityName): Declaration | undefined {
|
||||
switch (node.parent.kind) {
|
||||
@ -5124,23 +5051,12 @@ export function isNonContextualKeyword(token: SyntaxKind): boolean {
|
||||
return isKeyword(token) && !isContextualKeyword(token);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isFutureReservedKeyword(token: SyntaxKind): boolean {
|
||||
return SyntaxKind.FirstFutureReservedWord <= token && token <= SyntaxKind.LastFutureReservedWord;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isStringANonContextualKeyword(name: string) {
|
||||
const token = stringToToken(name);
|
||||
return token !== undefined && isNonContextualKeyword(token);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isStringAKeyword(name: string) {
|
||||
const token = stringToToken(name);
|
||||
return token !== undefined && isKeyword(token);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isIdentifierANonContextualKeyword(node: Identifier): boolean {
|
||||
const originalKeywordKind = identifierToKeywordKind(node);
|
||||
@ -5292,11 +5208,6 @@ export function getEscapedTextOfIdentifierOrLiteral(node: PropertyNameLiteral):
|
||||
return isMemberName(node) ? node.escapedText : isJsxNamespacedName(node) ? getEscapedTextOfJsxNamespacedName(node) : escapeLeadingUnderscores(node.text);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getPropertyNameForUniqueESSymbol(symbol: Symbol): __String {
|
||||
return `__@${getSymbolId(symbol)}@${symbol.escapedName}` as __String;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getSymbolNameForPrivateIdentifier(containingClassSymbol: Symbol, description: __String): __String {
|
||||
return `__#${getSymbolId(containingClassSymbol)}@${description}` as __String;
|
||||
@ -5312,24 +5223,13 @@ export function isPrivateIdentifierSymbol(symbol: Symbol): boolean {
|
||||
return startsWith(symbol.escapedName as string, "__#");
|
||||
}
|
||||
|
||||
/**
|
||||
* Includes the word "Symbol" with unicode escapes
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function isESSymbolIdentifier(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.Identifier && (node as Identifier).escapedText === "Symbol";
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether a property name is the special `__proto__` property.
|
||||
* Per the ECMA-262 spec, this only matters for property assignments whose name is
|
||||
* the Identifier `__proto__`, or the string literal `"__proto__"`, but not for
|
||||
* computed property names.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function isProtoSetter(node: PropertyName) {
|
||||
function isProtoSetter(node: PropertyName) {
|
||||
return isIdentifier(node) ? idText(node) === "__proto__" :
|
||||
isStringLiteral(node) && node.text === "__proto__";
|
||||
}
|
||||
@ -5344,9 +5244,8 @@ export type AnonymousFunctionDefinition =
|
||||
* Indicates whether an expression is an anonymous function definition.
|
||||
*
|
||||
* @see https://tc39.es/ecma262/#sec-isanonymousfunctiondefinition
|
||||
* @internal
|
||||
*/
|
||||
export function isAnonymousFunctionDefinition(node: Expression, cb?: (node: AnonymousFunctionDefinition) => boolean): node is WrappedExpression<AnonymousFunctionDefinition> {
|
||||
function isAnonymousFunctionDefinition(node: Expression, cb?: (node: AnonymousFunctionDefinition) => boolean): node is WrappedExpression<AnonymousFunctionDefinition> {
|
||||
node = skipOuterExpressions(node);
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ClassExpression:
|
||||
@ -5491,11 +5390,6 @@ export function nodeIsSynthesized(range: TextRange): boolean {
|
||||
|| positionIsSynthesized(range.end);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getOriginalSourceFile(sourceFile: SourceFile) {
|
||||
return getParseTreeNode(sourceFile, isSourceFile) || sourceFile;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export const enum Associativity {
|
||||
Left,
|
||||
@ -5556,8 +5450,7 @@ export function getExpressionPrecedence(expression: Expression) {
|
||||
return getOperatorPrecedence(expression.kind, operator, hasArguments);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getOperator(expression: Expression): SyntaxKind {
|
||||
function getOperator(expression: Expression): SyntaxKind {
|
||||
if (expression.kind === SyntaxKind.BinaryExpression) {
|
||||
return (expression as BinaryExpression).operatorToken.kind;
|
||||
}
|
||||
@ -6160,8 +6053,7 @@ export function getIndentString(level: number) {
|
||||
return indentStrings[level];
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getIndentSize() {
|
||||
function getIndentSize() {
|
||||
return indentStrings[1].length;
|
||||
}
|
||||
|
||||
@ -6548,8 +6440,7 @@ export function getSourceFilePathInNewDir(fileName: string, host: EmitHost, newD
|
||||
return getSourceFilePathInNewDirWorker(fileName, newDirPath, host.getCurrentDirectory(), host.getCommonSourceDirectory(), f => host.getCanonicalFileName(f));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getSourceFilePathInNewDirWorker(fileName: string, newDirPath: string, currentDirectory: string, commonSourceDirectory: string, getCanonicalFileName: GetCanonicalFileName): string {
|
||||
function getSourceFilePathInNewDirWorker(fileName: string, newDirPath: string, currentDirectory: string, commonSourceDirectory: string, getCanonicalFileName: GetCanonicalFileName): string {
|
||||
let sourceFilePath = getNormalizedAbsolutePath(fileName, currentDirectory);
|
||||
const isSourceFileInCommonSourceDirectory = getCanonicalFileName(sourceFilePath).indexOf(getCanonicalFileName(commonSourceDirectory)) === 0;
|
||||
sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath;
|
||||
@ -6608,8 +6499,7 @@ export function getLineOfLocalPosition(sourceFile: SourceFile, pos: number) {
|
||||
return computeLineOfPosition(lineStarts, pos);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getLineOfLocalPositionFromLineMap(lineMap: readonly number[], pos: number) {
|
||||
function getLineOfLocalPositionFromLineMap(lineMap: readonly number[], pos: number) {
|
||||
return computeLineOfPosition(lineMap, pos);
|
||||
}
|
||||
|
||||
@ -6793,13 +6683,11 @@ export function getEffectiveSetAccessorTypeAnnotationNode(node: SetAccessorDecla
|
||||
return parameter && getEffectiveTypeAnnotationNode(parameter);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function emitNewLineBeforeLeadingComments(lineMap: readonly number[], writer: EmitTextWriter, node: TextRange, leadingComments: readonly CommentRange[] | undefined) {
|
||||
function emitNewLineBeforeLeadingComments(lineMap: readonly number[], writer: EmitTextWriter, node: TextRange, leadingComments: readonly CommentRange[] | undefined) {
|
||||
emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function emitNewLineBeforeLeadingCommentsOfPosition(lineMap: readonly number[], writer: EmitTextWriter, pos: number, leadingComments: readonly CommentRange[] | undefined) {
|
||||
function emitNewLineBeforeLeadingCommentsOfPosition(lineMap: readonly number[], writer: EmitTextWriter, pos: number, leadingComments: readonly CommentRange[] | undefined) {
|
||||
// If the leading comments start on different line than the start of node, write new line
|
||||
if (
|
||||
leadingComments && leadingComments.length && pos !== leadingComments[0].pos &&
|
||||
@ -6820,8 +6708,7 @@ export function emitNewLineBeforeLeadingCommentOfPosition(lineMap: readonly numb
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function emitComments(
|
||||
function emitComments(
|
||||
text: string,
|
||||
lineMap: readonly number[],
|
||||
writer: EmitTextWriter,
|
||||
@ -7089,7 +6976,7 @@ export function getSelectedEffectiveModifierFlags(node: Node, flags: ModifierFla
|
||||
return getEffectiveModifierFlags(node) & flags;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export function getSelectedSyntacticModifierFlags(node: Node, flags: ModifierFlags): ModifierFlags {
|
||||
return getSyntacticModifierFlags(node) & flags;
|
||||
}
|
||||
@ -7186,6 +7073,7 @@ export function getEffectiveModifierFlagsNoCache(node: Node): ModifierFlags {
|
||||
* NOTE: This function does not use `parent` pointers and will not include modifiers from JSDoc.
|
||||
*
|
||||
* @internal
|
||||
* @knipignore
|
||||
*/
|
||||
export function getSyntacticModifierFlagsNoCache(node: Node): ModifierFlags {
|
||||
let flags = canHaveModifiers(node) ? modifiersToFlags(node.modifiers) : ModifierFlags.None;
|
||||
@ -7325,10 +7213,6 @@ export function isAssignmentExpression(node: Node, excludeCompoundAssignment?: b
|
||||
&& isLeftHandSideExpression(node.left);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isLeftHandSideOfAssignment(node: Node) {
|
||||
return isAssignmentExpression(node.parent) && node.parent.left === node;
|
||||
}
|
||||
/** @internal */
|
||||
export function isDestructuringAssignment(node: Node): node is DestructuringAssignment {
|
||||
if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) {
|
||||
@ -7739,17 +7623,6 @@ export function moveRangePastModifiers(node: Node): TextRange {
|
||||
: moveRangePastDecorators(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a TextRange has the same start and end positions.
|
||||
*
|
||||
* @param range A TextRange.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function isCollapsedRange(range: TextRange) {
|
||||
return range.pos === range.end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TextRange for a token at the provides start position.
|
||||
*
|
||||
@ -7781,7 +7654,7 @@ export function rangeEndPositionsAreOnSameLine(range1: TextRange, range2: TextRa
|
||||
return positionsAreOnSameLine(range1.end, range2.end, sourceFile);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export function rangeStartIsOnSameLineAsRangeEnd(range1: TextRange, range2: TextRange, sourceFile: SourceFile) {
|
||||
return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile, /*includeComments*/ false), range2.end, sourceFile);
|
||||
}
|
||||
@ -7797,7 +7670,7 @@ export function getLinesBetweenRangeEndAndRangeStart(range1: TextRange, range2:
|
||||
return getLinesBetweenPositions(sourceFile, range1.end, range2Start);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export function getLinesBetweenRangeEndPositions(range1: TextRange, range2: TextRange, sourceFile: SourceFile) {
|
||||
return getLinesBetweenPositions(sourceFile, range1.end, range2.end);
|
||||
}
|
||||
@ -7812,7 +7685,7 @@ export function positionsAreOnSameLine(pos1: number, pos2: number, sourceFile: S
|
||||
return getLinesBetweenPositions(sourceFile, pos1, pos2) === 0;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export function getStartPositionOfRange(range: TextRange, sourceFile: SourceFile, includeComments: boolean) {
|
||||
return positionIsSynthesized(range.pos) ? -1 : skipTrivia(sourceFile.text, range.pos, /*stopAfterLineBreak*/ false, includeComments);
|
||||
}
|
||||
@ -8119,11 +7992,6 @@ export function getObjectFlags(type: Type): ObjectFlags {
|
||||
return type.flags & TypeFlags.ObjectFlagsType ? (type as ObjectFlagsType).objectFlags : 0;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function forSomeAncestorDirectory(directory: string, callback: (directory: string) => boolean): boolean {
|
||||
return !!forEachAncestorDirectory(directory, d => callback(d) ? true : undefined);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isUMDExportSymbol(symbol: Symbol | undefined): boolean {
|
||||
return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && isNamespaceExportDeclaration(symbol.declarations[0]);
|
||||
@ -8413,6 +8281,7 @@ const objectAllocatorPatchers: ((objectAllocator: ObjectAllocator) => void)[] =
|
||||
/**
|
||||
* Used by `deprecatedCompat` to patch the object allocator to apply deprecations.
|
||||
* @internal
|
||||
* @knipignore
|
||||
*/
|
||||
export function addObjectAllocatorPatcher(fn: (objectAllocator: ObjectAllocator) => void) {
|
||||
objectAllocatorPatchers.push(fn);
|
||||
@ -8630,8 +8499,7 @@ export function compareDiagnostics(d1: Diagnostic, d2: Diagnostic): Comparison {
|
||||
Comparison.EqualTo;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function compareDiagnosticsSkipRelatedInformation(d1: Diagnostic, d2: Diagnostic): Comparison {
|
||||
function compareDiagnosticsSkipRelatedInformation(d1: Diagnostic, d2: Diagnostic): Comparison {
|
||||
const code1 = getDiagnosticCode(d1);
|
||||
const code2 = getDiagnosticCode(d2);
|
||||
return compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) ||
|
||||
@ -9092,7 +8960,7 @@ export const getEmitScriptTarget = computedOptions.target.computeValue;
|
||||
export const getEmitModuleKind = computedOptions.module.computeValue;
|
||||
/** @internal */
|
||||
export const getEmitModuleResolutionKind = computedOptions.moduleResolution.computeValue;
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export const getEmitModuleDetectionKind = computedOptions.moduleDetection.computeValue;
|
||||
/** @internal */
|
||||
export const getIsolatedModules = computedOptions.isolatedModules.computeValue;
|
||||
@ -9395,8 +9263,7 @@ function escapeRegExpCharacter(match: string) {
|
||||
|
||||
const wildcardCharCodes = [CharacterCodes.asterisk, CharacterCodes.question];
|
||||
|
||||
/** @internal */
|
||||
export const commonPackageFolders: readonly string[] = ["node_modules", "bower_components", "jspm_packages"];
|
||||
const commonPackageFolders: readonly string[] = ["node_modules", "bower_components", "jspm_packages"];
|
||||
|
||||
const implicitExcludePathRegexPattern = `(?!(${commonPackageFolders.join("|")})(/|$))`;
|
||||
|
||||
@ -9758,17 +9625,14 @@ export function getScriptKindFromFileName(fileName: string): ScriptKind {
|
||||
|
||||
/**
|
||||
* Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS)
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const supportedTSExtensions: readonly Extension[][] = [[Extension.Ts, Extension.Tsx, Extension.Dts], [Extension.Cts, Extension.Dcts], [Extension.Mts, Extension.Dmts]];
|
||||
const supportedTSExtensions: readonly Extension[][] = [[Extension.Ts, Extension.Tsx, Extension.Dts], [Extension.Cts, Extension.Dcts], [Extension.Mts, Extension.Dmts]];
|
||||
/** @internal */
|
||||
export const supportedTSExtensionsFlat: readonly Extension[] = flatten(supportedTSExtensions);
|
||||
const supportedTSExtensionsWithJson: readonly Extension[][] = [...supportedTSExtensions, [Extension.Json]];
|
||||
/** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */
|
||||
const supportedTSExtensionsForExtractExtension: readonly Extension[] = [Extension.Dts, Extension.Dcts, Extension.Dmts, Extension.Cts, Extension.Mts, Extension.Ts, Extension.Tsx];
|
||||
/** @internal */
|
||||
export const supportedJSExtensions: readonly Extension[][] = [[Extension.Js, Extension.Jsx], [Extension.Mjs], [Extension.Cjs]];
|
||||
const supportedJSExtensions: readonly Extension[][] = [[Extension.Js, Extension.Jsx], [Extension.Mjs], [Extension.Cjs]];
|
||||
/** @internal */
|
||||
export const supportedJSExtensionsFlat: readonly Extension[] = flatten(supportedJSExtensions);
|
||||
const allSupportedExtensions: readonly Extension[][] = [[Extension.Ts, Extension.Tsx, Extension.Dts, Extension.Js, Extension.Jsx], [Extension.Cts, Extension.Dcts, Extension.Cjs], [Extension.Mts, Extension.Dmts, Extension.Mjs]];
|
||||
@ -9839,8 +9703,7 @@ export const enum ModuleSpecifierEnding {
|
||||
TsExtension,
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function usesExtensionsOnImports({ imports }: SourceFile, hasExtension: (text: string) => boolean = or(hasJSFileExtension, hasTSFileExtension)): boolean {
|
||||
function usesExtensionsOnImports({ imports }: SourceFile, hasExtension: (text: string) => boolean = or(hasJSFileExtension, hasTSFileExtension)): boolean {
|
||||
return firstDefined(imports, ({ text }) =>
|
||||
pathIsRelative(text) && !fileExtensionIsOneOf(text, extensionsNotSupportingExtensionlessResolution)
|
||||
? hasExtension(text)
|
||||
@ -9969,7 +9832,7 @@ export function removeFileExtension(path: string): string {
|
||||
return path;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export function tryRemoveExtension(path: string, extension: string): string | undefined {
|
||||
return fileExtensionIs(path, extension) ? removeExtension(path, extension) : undefined;
|
||||
}
|
||||
@ -10454,24 +10317,6 @@ export function setParent<T extends Node>(child: T | undefined, parent: T["paren
|
||||
return child;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bypasses immutability and directly sets the `parent` property of each `Node` in an array of nodes, if is not already set.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function setEachParent<T extends readonly Node[]>(children: T, parent: T[number]["parent"]): T;
|
||||
/** @internal */
|
||||
export function setEachParent<T extends readonly Node[]>(children: T | undefined, parent: T[number]["parent"]): T | undefined;
|
||||
/** @internal */
|
||||
export function setEachParent<T extends readonly Node[]>(children: T | undefined, parent: T[number]["parent"]): T | undefined {
|
||||
if (children) {
|
||||
for (const child of children) {
|
||||
setParent(child, parent);
|
||||
}
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bypasses immutability and directly sets the `parent` property of each `Node` recursively.
|
||||
* @param rootNode The root node from which to start the recursion.
|
||||
@ -10786,11 +10631,6 @@ export function getNodeModulePathParts(fullPath: string): NodeModulePathParts |
|
||||
return state > States.NodeModules ? { topLevelNodeModulesIndex, topLevelPackageNameIndex, packageRootIndex, fileNameIndex } : undefined;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getParameterTypeNode(parameter: ParameterDeclaration | JSDocParameterTag) {
|
||||
return parameter.kind === SyntaxKind.JSDocParameterTag ? parameter.typeExpression?.type : parameter.type;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isTypeDeclaration(node: Node): node is TypeParameterDeclaration | ClassDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTypedefTag | JSDocCallbackTag | JSDocEnumTag | EnumDeclaration | ImportClause | ImportSpecifier | ExportSpecifier {
|
||||
switch (node.kind) {
|
||||
|
||||
@ -159,10 +159,8 @@ import {
|
||||
isKeyword,
|
||||
isModuleBlock,
|
||||
isNonNullExpression,
|
||||
isNotEmittedStatement,
|
||||
isOmittedExpression,
|
||||
isParameter,
|
||||
isPartiallyEmittedExpression,
|
||||
isPrivateIdentifier,
|
||||
isPropertyAccessExpression,
|
||||
isPropertyAssignment,
|
||||
@ -239,7 +237,6 @@ import {
|
||||
NodeFlags,
|
||||
NonNullChain,
|
||||
normalizePath,
|
||||
NotEmittedStatement,
|
||||
NullLiteral,
|
||||
ObjectBindingOrAssignmentElement,
|
||||
ObjectBindingOrAssignmentPattern,
|
||||
@ -249,7 +246,6 @@ import {
|
||||
OptionalChainRoot,
|
||||
OuterExpressionKinds,
|
||||
ParameterDeclaration,
|
||||
PartiallyEmittedExpression,
|
||||
pathIsRelative,
|
||||
PostfixUnaryExpression,
|
||||
PrefixUnaryExpression,
|
||||
@ -258,7 +254,6 @@ import {
|
||||
PrivateIdentifierPropertyAccessExpression,
|
||||
PropertyAccessChain,
|
||||
PropertyAccessExpression,
|
||||
PropertyDeclaration,
|
||||
PropertyName,
|
||||
QualifiedName,
|
||||
ScriptTarget,
|
||||
@ -1265,11 +1260,6 @@ export function getJSDocTags(node: Node): readonly JSDocTag[] {
|
||||
return getJSDocTagsWorker(node, /*noCache*/ false);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getJSDocTagsNoCache(node: Node): readonly JSDocTag[] {
|
||||
return getJSDocTagsWorker(node, /*noCache*/ true);
|
||||
}
|
||||
|
||||
/** Get the first JSDoc tag of a specified kind, or undefined if not present. */
|
||||
function getFirstJSDocTag<T extends JSDocTag>(node: Node, predicate: (tag: JSDocTag) => tag is T, noCache?: boolean): T | undefined {
|
||||
return find(getJSDocTagsWorker(node, noCache), predicate);
|
||||
@ -1452,10 +1442,6 @@ export function isJSDocPropertyLikeTag(node: Node): node is JSDocPropertyLikeTag
|
||||
//
|
||||
// All node tests in the following list should *not* reference parent pointers so that
|
||||
// they may be used with transformations.
|
||||
/** @internal */
|
||||
export function isNode(node: Node) {
|
||||
return isNodeKind(node.kind);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isNodeKind(kind: SyntaxKind) {
|
||||
@ -1767,19 +1753,6 @@ export function isMethodOrAccessor(node: Node): node is MethodDeclaration | Acce
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isNamedClassElement(node: Node): node is MethodDeclaration | AccessorDeclaration | PropertyDeclaration {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Type members
|
||||
|
||||
export function isModifierLike(node: Node): node is ModifierLike {
|
||||
@ -2114,12 +2087,6 @@ export function isAssertionExpression(node: Node): node is AssertionExpression {
|
||||
|| kind === SyntaxKind.AsExpression;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isNotEmittedOrPartiallyEmittedNode(node: Node): node is NotEmittedStatement | PartiallyEmittedExpression {
|
||||
return isNotEmittedStatement(node)
|
||||
|| isPartiallyEmittedExpression(node);
|
||||
}
|
||||
|
||||
// Statement
|
||||
|
||||
export function isIterationStatement(node: Node, lookInLabeledStatements: false): node is IterationStatement;
|
||||
@ -2139,8 +2106,7 @@ export function isIterationStatement(node: Node, lookInLabeledStatements: boolea
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isScopeMarker(node: Node) {
|
||||
function isScopeMarker(node: Node) {
|
||||
return isExportAssignment(node) || isExportDeclaration(node);
|
||||
}
|
||||
|
||||
@ -2189,14 +2155,14 @@ export function isModuleBody(node: Node): node is ModuleBody {
|
||||
|| kind === SyntaxKind.Identifier;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export function isNamespaceBody(node: Node): node is NamespaceBody {
|
||||
const kind = node.kind;
|
||||
return kind === SyntaxKind.ModuleBlock
|
||||
|| kind === SyntaxKind.ModuleDeclaration;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export function isJSDocNamespaceBody(node: Node): node is JSDocNamespaceBody {
|
||||
const kind = node.kind;
|
||||
return kind === SyntaxKind.Identifier
|
||||
|
||||
@ -155,8 +155,7 @@ function clearScreenIfNotWatchingForFileChanges(system: System, diagnostic: Diag
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export const screenStartingMessageCodes: number[] = [
|
||||
const screenStartingMessageCodes: number[] = [
|
||||
Diagnostics.Starting_compilation_in_watch_mode.code,
|
||||
Diagnostics.File_change_detected_Starting_incremental_compilation.code,
|
||||
];
|
||||
|
||||
@ -77,7 +77,7 @@ export type OverloadBinders<T extends OverloadDefinitions> = { [P in OverloadKey
|
||||
*/
|
||||
export type OverloadDeprecations<T extends OverloadDefinitions> = { [P in OverloadKeys<T>]?: DeprecationOptions; };
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export function createOverload<T extends OverloadDefinitions>(name: string, overloads: T, binder: OverloadBinders<T>, deprecations?: OverloadDeprecations<T>) {
|
||||
Object.defineProperty(call, "name", { ...Object.getOwnPropertyDescriptor(call, "name"), value: name });
|
||||
|
||||
@ -137,7 +137,7 @@ export interface BoundOverloadBuilder<T extends OverloadDefinitions> extends Fin
|
||||
// NOTE: We only use this "builder" because we don't infer correctly when calling `createOverload` directly in < TS 4.7,
|
||||
// but lib is currently at TS 4.4. We can switch to directly calling `createOverload` when we update LKG in main.
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export function buildOverload(name: string): OverloadBuilder {
|
||||
return {
|
||||
overload: overloads => ({
|
||||
|
||||
@ -94,8 +94,7 @@ interface RenameEntry {
|
||||
readonly locations: RenameLocation[];
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function extractMessage(message: string): string {
|
||||
function extractMessage(message: string): string {
|
||||
// Read the content length
|
||||
const contentLengthPrefix = "Content-Length: ";
|
||||
const lines = message.split(/\r?\n/);
|
||||
|
||||
@ -111,8 +111,7 @@ const unprefixedNodeCoreModuleList = [
|
||||
"zlib",
|
||||
];
|
||||
|
||||
/** @internal */
|
||||
export const prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(name => `node:${name}`);
|
||||
const prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(name => `node:${name}`);
|
||||
|
||||
/** @internal */
|
||||
export const nodeCoreModuleList: readonly string[] = [...unprefixedNodeCoreModuleList, ...prefixedNodeCoreModuleList];
|
||||
|
||||
@ -796,9 +796,8 @@ function forEachAncestorProject<T>(
|
||||
* Goes through project's resolved project references and finds, creates or reloads project per kind
|
||||
* If project for this resolved reference exists its used immediately otherwise,
|
||||
* follows all references in order, deciding if references of the visited project can be loaded or not
|
||||
* @internal
|
||||
*/
|
||||
export function forEachResolvedProjectReferenceProject<T>(
|
||||
function forEachResolvedProjectReferenceProject<T>(
|
||||
project: ConfiguredProject,
|
||||
fileName: string | undefined,
|
||||
cb: (child: ConfiguredProject, sentConfigFileDiag: boolean) => T | undefined,
|
||||
|
||||
@ -428,7 +428,7 @@ export interface OutliningSpansRequestFull extends FileRequest {
|
||||
/**
|
||||
* Response to OutliningSpansRequest request.
|
||||
*
|
||||
* @internal
|
||||
* @internal @knipignore
|
||||
*/
|
||||
export interface OutliningSpansResponseFull extends Response {
|
||||
body?: ts.OutliningSpan[];
|
||||
@ -1257,7 +1257,7 @@ export interface RenameFullRequest extends FileLocationRequest {
|
||||
readonly arguments: RenameRequestArgs;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export interface RenameFullResponse extends Response {
|
||||
readonly body: readonly RenameLocation[];
|
||||
}
|
||||
@ -2757,7 +2757,7 @@ export interface CloseFileWatcherEventBody {
|
||||
readonly id: number;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export type AnyEvent =
|
||||
| RequestCompletedEvent
|
||||
| DiagnosticEvent
|
||||
|
||||
@ -1,10 +1,4 @@
|
||||
import {
|
||||
binarySearch,
|
||||
Comparer,
|
||||
getBaseFileName,
|
||||
identity,
|
||||
SortedArray,
|
||||
} from "./_namespaces/ts.js";
|
||||
import { getBaseFileName } from "./_namespaces/ts.js";
|
||||
import {
|
||||
Logger,
|
||||
LogLevel,
|
||||
@ -88,20 +82,3 @@ export function getBaseConfigFileName(configFilePath: NormalizedPath): "tsconfig
|
||||
const base = getBaseFileName(configFilePath);
|
||||
return base === "tsconfig.json" || base === "jsconfig.json" ? base : undefined;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function removeSorted<T>(array: SortedArray<T>, remove: T, compare: Comparer<T>): void {
|
||||
if (!array || array.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (array[0] === remove) {
|
||||
array.splice(0, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
const removeIndex = binarySearch(array, remove, identity, compare);
|
||||
if (removeIndex >= 0) {
|
||||
array.splice(removeIndex, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -610,8 +610,7 @@ function typeContainsTypeParameter(type: Type) {
|
||||
return type.flags & TypeFlags.TypeParameter;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getArgumentTypesAndTypeParameters(checker: TypeChecker, importAdder: ImportAdder, instanceTypes: Type[], contextNode: Node | undefined, scriptTarget: ScriptTarget, flags?: NodeBuilderFlags, tracker?: SymbolTracker) {
|
||||
function getArgumentTypesAndTypeParameters(checker: TypeChecker, importAdder: ImportAdder, instanceTypes: Type[], contextNode: Node | undefined, scriptTarget: ScriptTarget, flags?: NodeBuilderFlags, tracker?: SymbolTracker) {
|
||||
// Types to be used as the types of the parameters in the new function
|
||||
// E.g. from this source:
|
||||
// added("", 0)
|
||||
@ -874,13 +873,11 @@ export function setJsonCompilerOptionValue(
|
||||
setJsonCompilerOptionValues(changeTracker, configFile, [[optionName, optionValue]]);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function createJsonPropertyAssignment(name: string, initializer: Expression) {
|
||||
function createJsonPropertyAssignment(name: string, initializer: Expression) {
|
||||
return factory.createPropertyAssignment(factory.createStringLiteral(name), initializer);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function findJsonProperty(obj: ObjectLiteralExpression, name: string): PropertyAssignment | undefined {
|
||||
function findJsonProperty(obj: ObjectLiteralExpression, name: string): PropertyAssignment | undefined {
|
||||
return find(obj.properties, (p): p is PropertyAssignment => isPropertyAssignment(p) && !!p.name && isStringLiteral(p.name) && p.name.text === name);
|
||||
}
|
||||
|
||||
|
||||
@ -398,7 +398,7 @@ import {
|
||||
// Exported only for tests
|
||||
/** @internal */
|
||||
export const moduleSpecifierResolutionLimit = 100;
|
||||
/** @internal */
|
||||
/** @internal @knipignore */
|
||||
export const moduleSpecifierResolutionCacheAttemptLimit = 1000;
|
||||
|
||||
/** @internal */
|
||||
|
||||
@ -322,8 +322,7 @@ export interface SpanEntry {
|
||||
readonly fileName: string;
|
||||
readonly textSpan: TextSpan;
|
||||
}
|
||||
/** @internal */
|
||||
export function nodeEntry(node: Node, kind: NodeEntryKind = EntryKind.Node): NodeEntry {
|
||||
function nodeEntry(node: Node, kind: NodeEntryKind = EntryKind.Node): NodeEntry {
|
||||
return {
|
||||
kind,
|
||||
node: (node as NamedDeclaration).name || node,
|
||||
@ -884,8 +883,7 @@ function getTextSpan(node: Node, sourceFile: SourceFile, endNode?: Node): TextSp
|
||||
return createTextSpanFromBounds(start, end);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getTextSpanOfEntry(entry: Entry) {
|
||||
function getTextSpanOfEntry(entry: Entry) {
|
||||
return entry.kind === EntryKind.Span ? entry.textSpan :
|
||||
getTextSpan(entry.node, entry.node.getSourceFile());
|
||||
}
|
||||
|
||||
@ -716,8 +716,7 @@ function createDefinitionFromSignatureDeclaration(typeChecker: TypeChecker, decl
|
||||
return createDefinitionInfo(decl, typeChecker, decl.symbol, decl, /*unverified*/ false, failedAliasResolution);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function findReferenceInPosition(refs: readonly FileReference[], pos: number): FileReference | undefined {
|
||||
function findReferenceInPosition(refs: readonly FileReference[], pos: number): FileReference | undefined {
|
||||
return find(refs, ref => textRangeContainsPositionInclusive(ref, pos));
|
||||
}
|
||||
|
||||
|
||||
@ -212,8 +212,7 @@ export function organizeImports(
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getDetectionLists(preferences: UserPreferences): { comparersToTest: Comparer<string>[]; typeOrdersToTest: OrganizeImportsTypeOrder[]; } {
|
||||
function getDetectionLists(preferences: UserPreferences): { comparersToTest: Comparer<string>[]; typeOrdersToTest: OrganizeImportsTypeOrder[]; } {
|
||||
// Returns the possible detection outcomes, given the user's preferences. The earlier in the list, the higher the priority.
|
||||
return {
|
||||
comparersToTest: typeof preferences.organizeImportsIgnoreCase === "boolean"
|
||||
|
||||
@ -287,15 +287,13 @@ export function addNewFileToTsconfig(program: Program, changes: textChanges.Chan
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function deleteMovedStatements(sourceFile: SourceFile, moved: readonly StatementRange[], changes: textChanges.ChangeTracker) {
|
||||
function deleteMovedStatements(sourceFile: SourceFile, moved: readonly StatementRange[], changes: textChanges.ChangeTracker) {
|
||||
for (const { first, afterLast } of moved) {
|
||||
changes.deleteNodeRangeExcludingEnd(sourceFile, first, afterLast);
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function deleteUnusedOldImports(oldFile: SourceFile, toMove: readonly Statement[], toDelete: Set<Symbol>, importAdder: codefix.ImportAdder) {
|
||||
function deleteUnusedOldImports(oldFile: SourceFile, toMove: readonly Statement[], toDelete: Set<Symbol>, importAdder: codefix.ImportAdder) {
|
||||
for (const statement of oldFile.statements) {
|
||||
if (contains(toMove, statement)) continue;
|
||||
forEachImportInStatement(statement, i => {
|
||||
@ -328,8 +326,7 @@ export function addExportsInOldFile(oldFile: SourceFile, targetFileImportsFromOl
|
||||
});
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function updateImportsInOtherFiles(
|
||||
function updateImportsInOtherFiles(
|
||||
changes: textChanges.ChangeTracker,
|
||||
program: Program,
|
||||
host: LanguageServiceHost,
|
||||
@ -438,15 +435,13 @@ function createRequireCall(moduleSpecifier: StringLiteralLike): CallExpression {
|
||||
return factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, [moduleSpecifier]);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function moduleSpecifierFromImport(i: SupportedImport): StringLiteralLike {
|
||||
function moduleSpecifierFromImport(i: SupportedImport): StringLiteralLike {
|
||||
return (i.kind === SyntaxKind.ImportDeclaration ? i.moduleSpecifier
|
||||
: i.kind === SyntaxKind.ImportEqualsDeclaration ? i.moduleReference.expression
|
||||
: i.initializer.arguments[0]);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function forEachImportInStatement(statement: Statement, cb: (importNode: SupportedImport) => void): void {
|
||||
function forEachImportInStatement(statement: Statement, cb: (importNode: SupportedImport) => void): void {
|
||||
if (isImportDeclaration(statement)) {
|
||||
if (isStringLiteral(statement.moduleSpecifier)) cb(statement as SupportedImport);
|
||||
}
|
||||
@ -547,8 +542,7 @@ function isExported(sourceFile: SourceFile, decl: TopLevelDeclarationStatement,
|
||||
getNamesToExportInCommonJS(decl).some(name => sourceFile.symbol.exports!.has(escapeLeadingUnderscores(name)));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function deleteUnusedImports(sourceFile: SourceFile, importDecl: SupportedImport, changes: textChanges.ChangeTracker, isUnused: (name: Identifier) => boolean): void {
|
||||
function deleteUnusedImports(sourceFile: SourceFile, importDecl: SupportedImport, changes: textChanges.ChangeTracker, isUnused: (name: Identifier) => boolean): void {
|
||||
if (importDecl.kind === SyntaxKind.ImportDeclaration && importDecl.importClause) {
|
||||
const { name, namedBindings } = importDecl.importClause;
|
||||
if ((!name || isUnused(name)) && (!namedBindings || namedBindings.kind === SyntaxKind.NamedImports && namedBindings.elements.length !== 0 && namedBindings.elements.every(e => isUnused(e.name)))) {
|
||||
@ -638,8 +632,7 @@ function getNamesToExportInCommonJS(decl: TopLevelDeclarationStatement): readonl
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function filterImport(i: SupportedImport, moduleSpecifier: StringLiteralLike, keep: (name: Identifier) => boolean): SupportedImportStatement | undefined {
|
||||
function filterImport(i: SupportedImport, moduleSpecifier: StringLiteralLike, keep: (name: Identifier) => boolean): SupportedImportStatement | undefined {
|
||||
switch (i.kind) {
|
||||
case SyntaxKind.ImportDeclaration: {
|
||||
const clause = i.importClause;
|
||||
@ -685,13 +678,11 @@ function filterBindingName(name: BindingName, keep: (name: Identifier) => boolea
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function nameOfTopLevelDeclaration(d: TopLevelDeclaration): Identifier | undefined {
|
||||
function nameOfTopLevelDeclaration(d: TopLevelDeclaration): Identifier | undefined {
|
||||
return isExpressionStatement(d) ? tryCast(d.expression.left.name, isIdentifier) : tryCast(d.name, isIdentifier);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getTopLevelDeclarationStatement(d: TopLevelDeclaration): TopLevelDeclarationStatement {
|
||||
function getTopLevelDeclarationStatement(d: TopLevelDeclaration): TopLevelDeclarationStatement {
|
||||
switch (d.kind) {
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return d.parent.parent;
|
||||
@ -704,8 +695,7 @@ export function getTopLevelDeclarationStatement(d: TopLevelDeclaration): TopLeve
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function addExportToChanges(sourceFile: SourceFile, decl: TopLevelDeclarationStatement, name: Identifier, changes: textChanges.ChangeTracker, useEs6Exports: boolean): void {
|
||||
function addExportToChanges(sourceFile: SourceFile, decl: TopLevelDeclarationStatement, name: Identifier, changes: textChanges.ChangeTracker, useEs6Exports: boolean): void {
|
||||
if (isExported(sourceFile, decl, useEs6Exports, name)) return;
|
||||
if (useEs6Exports) {
|
||||
if (!isExpressionStatement(decl)) changes.insertExportModifier(sourceFile, decl);
|
||||
@ -1025,8 +1015,7 @@ function isVariableDeclarationInImport(decl: VariableDeclaration) {
|
||||
!!decl.initializer && isRequireCall(decl.initializer, /*requireStringLiteralLikeArgument*/ true);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isTopLevelDeclaration(node: Node): node is TopLevelDeclaration {
|
||||
function isTopLevelDeclaration(node: Node): node is TopLevelDeclaration {
|
||||
return isNonVariableTopLevelDeclaration(node) && isSourceFile(node.parent) || isVariableDeclaration(node) && isSourceFile(node.parent.parent.parent);
|
||||
}
|
||||
function sourceFileOfTopLevelDeclaration(node: TopLevelDeclaration): Node {
|
||||
|
||||
@ -30,7 +30,6 @@ import {
|
||||
ConditionalExpression,
|
||||
contains,
|
||||
ContextFlags,
|
||||
createPrinterWithRemoveCommentsOmitTrailingSemicolon,
|
||||
createRange,
|
||||
createScanner,
|
||||
createTextSpan,
|
||||
@ -53,7 +52,6 @@ import {
|
||||
DoStatement,
|
||||
ElementAccessExpression,
|
||||
EmitFlags,
|
||||
EmitHint,
|
||||
emitModuleKindIsNonNodeESM,
|
||||
emptyArray,
|
||||
EndOfFileToken,
|
||||
@ -177,7 +175,6 @@ import {
|
||||
isFunctionExpression,
|
||||
isFunctionLike,
|
||||
isGetAccessorDeclaration,
|
||||
isGlobalScopeAugmentation,
|
||||
isHeritageClause,
|
||||
isIdentifier,
|
||||
isIdentifierPart,
|
||||
@ -649,8 +646,7 @@ export function climbPastPropertyAccess(node: Node) {
|
||||
return isRightSideOfPropertyAccess(node) ? node.parent : node;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function climbPastPropertyOrElementAccess(node: Node) {
|
||||
function climbPastPropertyOrElementAccess(node: Node) {
|
||||
return isRightSideOfPropertyAccess(node) || isArgumentExpressionOfElementAccess(node) ? node.parent : node;
|
||||
}
|
||||
|
||||
@ -1149,8 +1145,7 @@ export function findListItemInfo(node: Node): ListItemInfo | undefined {
|
||||
};
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile: SourceFile): boolean {
|
||||
function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile: SourceFile): boolean {
|
||||
return !!findChildOfKind(n, kind, sourceFile);
|
||||
}
|
||||
|
||||
@ -2008,8 +2003,7 @@ export function findPrecedingMatchingToken(token: Node, matchingTokenKind: Synta
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function removeOptionality(type: Type, isOptionalExpression: boolean, isOptionalChain: boolean) {
|
||||
function removeOptionality(type: Type, isOptionalExpression: boolean, isOptionalChain: boolean) {
|
||||
return isOptionalExpression ? type.getNonNullableType() :
|
||||
isOptionalChain ? type.getNonOptionalType() :
|
||||
type;
|
||||
@ -2398,8 +2392,7 @@ export function isTypeKeyword(kind: SyntaxKind): boolean {
|
||||
return contains(typeKeywords, kind);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isTypeKeywordToken(node: Node): node is Token<SyntaxKind.TypeKeyword> {
|
||||
function isTypeKeywordToken(node: Node): node is Token<SyntaxKind.TypeKeyword> {
|
||||
return node.kind === SyntaxKind.TypeKeyword;
|
||||
}
|
||||
|
||||
@ -2872,8 +2865,7 @@ function getDisplayPartWriter(): DisplayPartsSymbolWriter {
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function symbolPart(text: string, symbol: Symbol) {
|
||||
function symbolPart(text: string, symbol: Symbol) {
|
||||
return displayPart(text, displayPartKind(symbol));
|
||||
|
||||
function displayPartKind(symbol: Symbol): SymbolDisplayPartKind {
|
||||
@ -2958,13 +2950,11 @@ export function typeParameterNamePart(text: string) {
|
||||
return displayPart(text, SymbolDisplayPartKind.typeParameterName);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function linkTextPart(text: string) {
|
||||
function linkTextPart(text: string) {
|
||||
return displayPart(text, SymbolDisplayPartKind.linkText);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function linkNamePart(text: string, target: Declaration): JSDocLinkDisplayPart {
|
||||
function linkNamePart(text: string, target: Declaration): JSDocLinkDisplayPart {
|
||||
return {
|
||||
text,
|
||||
kind: SymbolDisplayPartKind[SymbolDisplayPartKind.linkName],
|
||||
@ -2975,8 +2965,7 @@ export function linkNamePart(text: string, target: Declaration): JSDocLinkDispla
|
||||
};
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function linkPart(text: string) {
|
||||
function linkPart(text: string) {
|
||||
return displayPart(text, SymbolDisplayPartKind.link);
|
||||
}
|
||||
|
||||
@ -3090,15 +3079,6 @@ export function signatureToDisplayParts(typechecker: TypeChecker, signature: Sig
|
||||
});
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function nodeToDisplayParts(node: Node, enclosingDeclaration: Node): SymbolDisplayPart[] {
|
||||
const file = enclosingDeclaration.getSourceFile();
|
||||
return mapToDisplayParts(writer => {
|
||||
const printer = createPrinterWithRemoveCommentsOmitTrailingSemicolon();
|
||||
printer.writeNode(EmitHint.Unspecified, node, file, writer);
|
||||
});
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isImportOrExportSpecifierName(location: Node): location is Identifier {
|
||||
return !!location.parent && isImportOrExportSpecifier(location.parent) && location.parent.propertyName === location;
|
||||
@ -3251,7 +3231,7 @@ export function suppressLeadingTrivia(node: Node) {
|
||||
/**
|
||||
* Sets EmitFlags to suppress trailing trivia on the node.
|
||||
*
|
||||
* @internal
|
||||
* @internal @knipignore
|
||||
*/
|
||||
export function suppressTrailingTrivia(node: Node) {
|
||||
addEmitFlagsRecursively(node, EmitFlags.NoTrailingComments, getLastChild);
|
||||
@ -3490,8 +3470,7 @@ function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind: SyntaxKind) {
|
||||
return kind === SyntaxKind.ModuleDeclaration;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function syntaxRequiresTrailingSemicolonOrASI(kind: SyntaxKind) {
|
||||
function syntaxRequiresTrailingSemicolonOrASI(kind: SyntaxKind) {
|
||||
return kind === SyntaxKind.VariableStatement
|
||||
|| kind === SyntaxKind.ExpressionStatement
|
||||
|| kind === SyntaxKind.DoStatement
|
||||
@ -3509,8 +3488,7 @@ export function syntaxRequiresTrailingSemicolonOrASI(kind: SyntaxKind) {
|
||||
|| kind === SyntaxKind.ExportAssignment;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export const syntaxMayBeASICandidate = or(
|
||||
const syntaxMayBeASICandidate = or(
|
||||
syntaxRequiresTrailingCommaOrSemicolonOrASI,
|
||||
syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI,
|
||||
syntaxRequiresTrailingModuleBlockOrSemicolonOrASI,
|
||||
@ -3650,8 +3628,7 @@ export function tryAndIgnoreErrors<T>(cb: () => T): T | undefined {
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function tryIOAndConsumeErrors<T>(host: unknown, toApply: ((...a: any[]) => T) | undefined, ...args: any[]) {
|
||||
function tryIOAndConsumeErrors<T>(host: unknown, toApply: ((...a: any[]) => T) | undefined, ...args: any[]) {
|
||||
return tryAndIgnoreErrors(() => toApply && toApply.apply(host, args));
|
||||
}
|
||||
|
||||
@ -3683,8 +3660,7 @@ export function findPackageJson(directory: string, host: LanguageServiceHost): s
|
||||
return packageJson;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getPackageJsonsVisibleToFile(fileName: string, host: LanguageServiceHost): readonly ProjectPackageJsonInfo[] {
|
||||
function getPackageJsonsVisibleToFile(fileName: string, host: LanguageServiceHost): readonly ProjectPackageJsonInfo[] {
|
||||
if (!host.fileExists) {
|
||||
return [];
|
||||
}
|
||||
@ -3922,8 +3898,7 @@ export function isInsideNodeModules(fileOrDirectory: string): boolean {
|
||||
return contains(getPathComponents(fileOrDirectory), "node_modules");
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isDiagnosticWithLocation(diagnostic: Diagnostic): diagnostic is DiagnosticWithLocation {
|
||||
function isDiagnosticWithLocation(diagnostic: Diagnostic): diagnostic is DiagnosticWithLocation {
|
||||
return diagnostic.file !== undefined && diagnostic.start !== undefined && diagnostic.length !== undefined;
|
||||
}
|
||||
|
||||
@ -4058,8 +4033,7 @@ export function getDefaultLikeExportNameFromDeclaration(symbol: Symbol): string
|
||||
});
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getSymbolParentOrFail(symbol: Symbol) {
|
||||
function getSymbolParentOrFail(symbol: Symbol) {
|
||||
return Debug.checkDefined(
|
||||
symbol.parent,
|
||||
`Symbol parent was undefined. Flags: ${Debug.formatSymbolFlags(symbol.flags)}. ` +
|
||||
@ -4146,22 +4120,6 @@ export function startsWithUnderscore(name: string): boolean {
|
||||
return name.charCodeAt(0) === CharacterCodes._;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isGlobalDeclaration(declaration: Declaration) {
|
||||
return !isNonGlobalDeclaration(declaration);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isNonGlobalDeclaration(declaration: Declaration) {
|
||||
const sourceFile = declaration.getSourceFile();
|
||||
// If the file is not a module, the declaration is global
|
||||
if (!sourceFile.externalModuleIndicator && !sourceFile.commonJsModuleIndicator) {
|
||||
return false;
|
||||
}
|
||||
// If the file is a module written in TypeScript, it still might be in a `declare global` augmentation
|
||||
return isInJSFile(declaration) || !findAncestor(declaration, d => isModuleDeclaration(d) && isGlobalScopeAugmentation(d));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function isDeprecatedDeclaration(decl: Declaration) {
|
||||
return !!(getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & ModifierFlags.Deprecated);
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
/* Generated file to emulate the compiler namespace. */
|
||||
|
||||
export * from "../../harness/_namespaces/compiler.js";
|
||||
Loading…
x
Reference in New Issue
Block a user