mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-07 23:08:20 -06:00
Add deprecation warnings to deprecated public functions
This commit is contained in:
parent
9595d72b44
commit
2d2329bc66
@ -284,17 +284,6 @@ namespace ts {
|
||||
updateBundle,
|
||||
createImmediatelyInvokedFunctionExpression,
|
||||
createImmediatelyInvokedArrowFunction,
|
||||
createComma,
|
||||
createLessThan,
|
||||
createAssignment,
|
||||
createStrictEquality,
|
||||
createStrictInequality,
|
||||
createAdd,
|
||||
createSubtract,
|
||||
createPostfixIncrement,
|
||||
createLogicalAnd,
|
||||
createLogicalOr,
|
||||
createLogicalNot,
|
||||
createVoidZero,
|
||||
createExportDefault,
|
||||
createExternalModuleExport
|
||||
@ -488,4 +477,379 @@ namespace ts {
|
||||
export function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: readonly TypeNode[] | undefined, expression: Expression) {
|
||||
return factory.updateExpressionWithTypeArguments(node, expression, typeArguments);
|
||||
}
|
||||
|
||||
export function createComma(left: Expression, right: Expression): Expression {
|
||||
return factory.createComma(left, right);
|
||||
}
|
||||
|
||||
export function createLessThan(left: Expression, right: Expression): Expression {
|
||||
return factory.createLessThan(left, right);
|
||||
}
|
||||
|
||||
export function createAssignment(left: Expression, right: Expression): BinaryExpression {
|
||||
return factory.createAssignment(left, right);
|
||||
}
|
||||
|
||||
export function createStrictEquality(left: Expression, right: Expression): BinaryExpression {
|
||||
return factory.createStrictEquality(left, right);
|
||||
}
|
||||
|
||||
export function createStrictInequality(left: Expression, right: Expression): BinaryExpression {
|
||||
return factory.createStrictInequality(left, right);
|
||||
}
|
||||
|
||||
export function createAdd(left: Expression, right: Expression): BinaryExpression {
|
||||
return factory.createAdd(left, right);
|
||||
}
|
||||
|
||||
export function createSubtract(left: Expression, right: Expression): BinaryExpression {
|
||||
return factory.createSubtract(left, right);
|
||||
}
|
||||
|
||||
export function createLogicalAnd(left: Expression, right: Expression): BinaryExpression {
|
||||
return factory.createLogicalAnd(left, right);
|
||||
}
|
||||
|
||||
export function createLogicalOr(left: Expression, right: Expression): BinaryExpression {
|
||||
return factory.createLogicalOr(left, right);
|
||||
}
|
||||
|
||||
export function createPostfixIncrement(operand: Expression): PostfixUnaryExpression {
|
||||
return factory.createPostfixIncrement(operand);
|
||||
}
|
||||
|
||||
export function createLogicalNot(operand: Expression): PrefixUnaryExpression {
|
||||
return factory.createLogicalNot(operand);
|
||||
}
|
||||
|
||||
Debug.deprecateProperties(ts, [
|
||||
"createNodeArray",
|
||||
"createNumericLiteral",
|
||||
"createBigIntLiteral",
|
||||
"createStringLiteral",
|
||||
"createStringLiteralFromNode",
|
||||
"createRegularExpressionLiteral",
|
||||
"createLoopVariable",
|
||||
"createUniqueName",
|
||||
"createOptimisticUniqueName",
|
||||
"createFileLevelUniqueName",
|
||||
"createToken",
|
||||
"createSuper",
|
||||
"createThis",
|
||||
"createNull",
|
||||
"createTrue",
|
||||
"createFalse",
|
||||
"createModifier",
|
||||
"createModifiersFromModifierFlags",
|
||||
"createQualifiedName",
|
||||
"updateQualifiedName",
|
||||
"createComputedPropertyName",
|
||||
"updateComputedPropertyName",
|
||||
"createTypeParameterDeclaration",
|
||||
"updateTypeParameterDeclaration",
|
||||
"createDecorator",
|
||||
"updateDecorator",
|
||||
"createCallSignature",
|
||||
"updateCallSignature",
|
||||
"createConstructSignature",
|
||||
"updateConstructSignature",
|
||||
"updateIndexSignature",
|
||||
"createKeywordTypeNode",
|
||||
"createTypePredicateNode",
|
||||
"updateTypePredicateNode",
|
||||
"createTypeReferenceNode",
|
||||
"updateTypeReferenceNode",
|
||||
"createFunctionTypeNode",
|
||||
"updateFunctionTypeNode",
|
||||
"createConstructorTypeNode",
|
||||
"updateConstructorTypeNode",
|
||||
"createTypeQueryNode",
|
||||
"updateTypeQueryNode",
|
||||
"createTypeLiteralNode",
|
||||
"updateTypeLiteralNode",
|
||||
"createArrayTypeNode",
|
||||
"updateArrayTypeNode",
|
||||
"createTupleTypeNode",
|
||||
"updateTupleTypeNode",
|
||||
"createOptionalTypeNode",
|
||||
"updateOptionalTypeNode",
|
||||
"createRestTypeNode",
|
||||
"updateRestTypeNode",
|
||||
"createUnionTypeNode",
|
||||
"updateUnionTypeNode",
|
||||
"createIntersectionTypeNode",
|
||||
"updateIntersectionTypeNode",
|
||||
"createConditionalTypeNode",
|
||||
"updateConditionalTypeNode",
|
||||
"createInferTypeNode",
|
||||
"updateInferTypeNode",
|
||||
"createImportTypeNode",
|
||||
"updateImportTypeNode",
|
||||
"createParenthesizedType",
|
||||
"updateParenthesizedType",
|
||||
"createThisTypeNode",
|
||||
"updateTypeOperatorNode",
|
||||
"createIndexedAccessTypeNode",
|
||||
"updateIndexedAccessTypeNode",
|
||||
"createMappedTypeNode",
|
||||
"updateMappedTypeNode",
|
||||
"createLiteralTypeNode",
|
||||
"updateLiteralTypeNode",
|
||||
"createObjectBindingPattern",
|
||||
"updateObjectBindingPattern",
|
||||
"createArrayBindingPattern",
|
||||
"updateArrayBindingPattern",
|
||||
"createBindingElement",
|
||||
"updateBindingElement",
|
||||
"updateArrayLiteral",
|
||||
"createObjectLiteral",
|
||||
"updateObjectLiteral",
|
||||
"createPropertyAccess",
|
||||
"updatePropertyAccess",
|
||||
"createElementAccess",
|
||||
"updateElementAccess",
|
||||
"createCall",
|
||||
"updateCall",
|
||||
"createNew",
|
||||
"updateNew",
|
||||
"createTypeAssertion",
|
||||
"updateTypeAssertion",
|
||||
"createParen",
|
||||
"updateParen",
|
||||
"createFunctionExpression",
|
||||
"updateFunctionExpression",
|
||||
"createArrowFunction",
|
||||
"updateArrowFunction",
|
||||
"createDelete",
|
||||
"updateDelete",
|
||||
"createTypeOf",
|
||||
"updateTypeOf",
|
||||
"createVoid",
|
||||
"updateVoid",
|
||||
"createAwait",
|
||||
"updateAwait",
|
||||
"createPrefix",
|
||||
"updatePrefix",
|
||||
"createPostfix",
|
||||
"updatePostfix",
|
||||
"createBinary",
|
||||
"updateBinary",
|
||||
"updateConditional",
|
||||
"createTemplateExpression",
|
||||
"updateTemplateExpression",
|
||||
"createTemplateHead",
|
||||
"createTemplateMiddle",
|
||||
"createTemplateTail",
|
||||
"createNoSubstitutionTemplateLiteral",
|
||||
"updateYield",
|
||||
"createSpread",
|
||||
"updateSpread",
|
||||
"createOmittedExpression",
|
||||
"createAsExpression",
|
||||
"updateAsExpression",
|
||||
"createNonNullExpression",
|
||||
"updateNonNullExpression",
|
||||
"createMetaProperty",
|
||||
"updateMetaProperty",
|
||||
"createTemplateSpan",
|
||||
"updateTemplateSpan",
|
||||
"createSemicolonClassElement",
|
||||
"createBlock",
|
||||
"updateBlock",
|
||||
"createVariableStatement",
|
||||
"updateVariableStatement",
|
||||
"createEmptyStatement",
|
||||
"createExpressionStatement",
|
||||
"updateExpressionStatement",
|
||||
"createIf",
|
||||
"updateIf",
|
||||
"createDo",
|
||||
"updateDo",
|
||||
"createWhile",
|
||||
"updateWhile",
|
||||
"createFor",
|
||||
"updateFor",
|
||||
"createForIn",
|
||||
"updateForIn",
|
||||
"createForOf",
|
||||
"updateForOf",
|
||||
"createContinue",
|
||||
"updateContinue",
|
||||
"createBreak",
|
||||
"updateBreak",
|
||||
"createReturn",
|
||||
"updateReturn",
|
||||
"createWith",
|
||||
"updateWith",
|
||||
"createSwitch",
|
||||
"updateSwitch",
|
||||
"createLabel",
|
||||
"updateLabel",
|
||||
"createThrow",
|
||||
"updateThrow",
|
||||
"createTry",
|
||||
"updateTry",
|
||||
"createDebuggerStatement",
|
||||
"createVariableDeclaration",
|
||||
"updateVariableDeclaration",
|
||||
"createVariableDeclarationList",
|
||||
"updateVariableDeclarationList",
|
||||
"createFunctionDeclaration",
|
||||
"updateFunctionDeclaration",
|
||||
"createClassDeclaration",
|
||||
"updateClassDeclaration",
|
||||
"createInterfaceDeclaration",
|
||||
"updateInterfaceDeclaration",
|
||||
"createTypeAliasDeclaration",
|
||||
"updateTypeAliasDeclaration",
|
||||
"createEnumDeclaration",
|
||||
"updateEnumDeclaration",
|
||||
"createModuleDeclaration",
|
||||
"updateModuleDeclaration",
|
||||
"createModuleBlock",
|
||||
"updateModuleBlock",
|
||||
"createCaseBlock",
|
||||
"updateCaseBlock",
|
||||
"createNamespaceExportDeclaration",
|
||||
"updateNamespaceExportDeclaration",
|
||||
"createImportEqualsDeclaration",
|
||||
"updateImportEqualsDeclaration",
|
||||
"createImportDeclaration",
|
||||
"updateImportDeclaration",
|
||||
"createImportClause",
|
||||
"updateImportClause",
|
||||
"createNamespaceImport",
|
||||
"updateNamespaceImport",
|
||||
"createNamedImports",
|
||||
"updateNamedImports",
|
||||
"createImportSpecifier",
|
||||
"updateImportSpecifier",
|
||||
"createExportAssignment",
|
||||
"updateExportAssignment",
|
||||
"createExportDeclaration",
|
||||
"updateExportDeclaration",
|
||||
"createNamedExports",
|
||||
"updateNamedExports",
|
||||
"createExportSpecifier",
|
||||
"updateExportSpecifier",
|
||||
"createExternalModuleReference",
|
||||
"updateExternalModuleReference",
|
||||
"createJSDocTypeExpression",
|
||||
"createJSDocTypeTag",
|
||||
"createJSDocReturnTag",
|
||||
"createJSDocThisTag",
|
||||
"createJSDocComment",
|
||||
"createJsxElement",
|
||||
"updateJsxElement",
|
||||
"createJsxSelfClosingElement",
|
||||
"updateJsxSelfClosingElement",
|
||||
"createJsxOpeningElement",
|
||||
"updateJsxOpeningElement",
|
||||
"createJsxClosingElement",
|
||||
"updateJsxClosingElement",
|
||||
"createJsxFragment",
|
||||
"createJsxText",
|
||||
"updateJsxText",
|
||||
"createJsxOpeningFragment",
|
||||
"createJsxJsxClosingFragment",
|
||||
"updateJsxFragment",
|
||||
"createJsxAttribute",
|
||||
"updateJsxAttribute",
|
||||
"createJsxAttributes",
|
||||
"updateJsxAttributes",
|
||||
"createJsxSpreadAttribute",
|
||||
"updateJsxSpreadAttribute",
|
||||
"createJsxExpression",
|
||||
"updateJsxExpression",
|
||||
"createCaseClause",
|
||||
"updateCaseClause",
|
||||
"createDefaultClause",
|
||||
"updateDefaultClause",
|
||||
"createHeritageClause",
|
||||
"updateHeritageClause",
|
||||
"createCatchClause",
|
||||
"updateCatchClause",
|
||||
"createPropertyAssignment",
|
||||
"updatePropertyAssignment",
|
||||
"createShorthandPropertyAssignment",
|
||||
"updateShorthandPropertyAssignment",
|
||||
"createSpreadAssignment",
|
||||
"updateSpreadAssignment",
|
||||
"createEnumMember",
|
||||
"updateEnumMember",
|
||||
"createNotEmittedStatement",
|
||||
"createEndOfDeclarationMarker",
|
||||
"createMergeDeclarationMarker",
|
||||
"createPartiallyEmittedExpression",
|
||||
"updatePartiallyEmittedExpression",
|
||||
"createCommaList",
|
||||
"updateCommaList",
|
||||
"createBundle",
|
||||
"updateBundle",
|
||||
"createImmediatelyInvokedFunctionExpression",
|
||||
"createImmediatelyInvokedArrowFunction",
|
||||
"createVoidZero",
|
||||
"createExportDefault",
|
||||
"createExternalModuleExport",
|
||||
"createIdentifier",
|
||||
"createTempVariable",
|
||||
"getGeneratedNameForNode",
|
||||
"createIndexSignature",
|
||||
"createMethodSignature",
|
||||
"updateMethodSignature",
|
||||
"createTypeOperatorNode",
|
||||
"createTaggedTemplate",
|
||||
"updateTaggedTemplate",
|
||||
"createConditional",
|
||||
"createYield",
|
||||
"createClassExpression",
|
||||
"updateClassExpression",
|
||||
"createPropertySignature",
|
||||
"updatePropertySignature",
|
||||
"createExpressionWithTypeArguments",
|
||||
"updateExpressionWithTypeArguments",
|
||||
"createComma",
|
||||
"createLessThan",
|
||||
"createAssignment",
|
||||
"createStrictEquality",
|
||||
"createStrictInequality",
|
||||
"createAdd",
|
||||
"createSubtract",
|
||||
"createLogicalAnd",
|
||||
"createLogicalOr",
|
||||
"createPostfixIncrement",
|
||||
"createLogicalNot",
|
||||
"createArrayLiteral",
|
||||
], {
|
||||
message: "Please use `factory.{0}` or the factory supplied by your transformation context instead."
|
||||
});
|
||||
|
||||
Debug.deprecateProperties(ts, [
|
||||
"createParameter",
|
||||
"updateParameter",
|
||||
"createProperty",
|
||||
"updateProperty",
|
||||
"createMethod",
|
||||
"updateMethod",
|
||||
"createConstructor",
|
||||
"updateConstructor",
|
||||
"createGetAccessor",
|
||||
"updateGetAccessor",
|
||||
"createSetAccessor",
|
||||
"updateSetAccessor",
|
||||
], {
|
||||
message: "Please use `factory.{0}Declaration` or the factory supplied by your transformation context instead."
|
||||
});
|
||||
|
||||
Debug.deprecateProperty(ts, "createStatement", {
|
||||
message: "Please use `factory.createExpressionStatement` or the factory supplied by your transformation context instead."
|
||||
});
|
||||
|
||||
Debug.deprecateProperty(ts, "updateStatement", {
|
||||
message: "Please use `factory.updateExpressionStatement` or the factory supplied by your transformation context instead."
|
||||
});
|
||||
|
||||
Debug.deprecateProperty(ts, "updateSourceFileNode", {
|
||||
message: "Please use `factory.updateSourceFile` or the factory supplied by your transformation context instead."
|
||||
});
|
||||
}
|
||||
@ -35,11 +35,6 @@ namespace ts {
|
||||
entries(): Iterator<[string, T]>;
|
||||
}
|
||||
|
||||
export interface MapConstructor {
|
||||
// tslint:disable-next-line:callable-types
|
||||
new <T>(): Map<T>;
|
||||
}
|
||||
|
||||
/** ES6 Map interface. */
|
||||
export interface Map<T> extends ReadonlyMap<T> {
|
||||
set(key: string, value: T): this;
|
||||
@ -47,6 +42,11 @@ namespace ts {
|
||||
clear(): void;
|
||||
}
|
||||
|
||||
export interface MapConstructor {
|
||||
// tslint:disable-next-line:callable-types
|
||||
new <T>(): Map<T>;
|
||||
}
|
||||
|
||||
/** ES6 Iterator type. */
|
||||
export interface Iterator<T> {
|
||||
next(): { value: T, done?: false } | { value: never, done: true };
|
||||
|
||||
@ -1,8 +1,61 @@
|
||||
/* @internal */
|
||||
namespace ts {
|
||||
export enum LogLevel {
|
||||
Off,
|
||||
Error,
|
||||
Warning,
|
||||
Info,
|
||||
Verbose
|
||||
}
|
||||
|
||||
export interface LoggingHost {
|
||||
log(level: LogLevel, s: string): void;
|
||||
}
|
||||
|
||||
export interface DeprecationOptions {
|
||||
message?: string;
|
||||
error?: boolean;
|
||||
since?: string;
|
||||
until?: string;
|
||||
}
|
||||
|
||||
export namespace Debug {
|
||||
export let currentAssertionLevel = AssertionLevel.None;
|
||||
export let currentLogLevel = LogLevel.Warning;
|
||||
export let isDebugging = false;
|
||||
export let loggingHost: LoggingHost | undefined;
|
||||
|
||||
export function shouldLog(level: LogLevel): boolean {
|
||||
return currentLogLevel <= level;
|
||||
}
|
||||
|
||||
function logMessage(level: LogLevel, s: string): void {
|
||||
if (loggingHost && shouldLog(level)) {
|
||||
loggingHost.log(level, s);
|
||||
}
|
||||
}
|
||||
|
||||
export function log(s: string): void {
|
||||
logMessage(LogLevel.Info, s);
|
||||
}
|
||||
|
||||
export namespace log {
|
||||
export function error(s: string): void {
|
||||
logMessage(LogLevel.Error, s);
|
||||
}
|
||||
|
||||
export function warn(s: string): void {
|
||||
logMessage(LogLevel.Warning, s);
|
||||
}
|
||||
|
||||
export function log(s: string): void {
|
||||
logMessage(LogLevel.Info, s);
|
||||
}
|
||||
|
||||
export function trace(s: string): void {
|
||||
logMessage(LogLevel.Verbose, s);
|
||||
}
|
||||
}
|
||||
|
||||
export function shouldAssert(level: AssertionLevel): boolean {
|
||||
return currentAssertionLevel >= level;
|
||||
@ -68,12 +121,13 @@ namespace ts {
|
||||
return fail(`${message} ${detail}`, stackCrawlMark || assertNever);
|
||||
}
|
||||
|
||||
export function getFunctionName(func: AnyFunction) {
|
||||
export function getFunctionName(func: AnyFunction): string {
|
||||
if (typeof func !== "function") {
|
||||
return "";
|
||||
}
|
||||
else if (func.hasOwnProperty("name")) {
|
||||
return (<any>func).name;
|
||||
const name = (<any>func).name || "";
|
||||
return "" + name;
|
||||
}
|
||||
else {
|
||||
const text = Function.prototype.toString.call(func);
|
||||
@ -258,5 +312,64 @@ namespace ts {
|
||||
|
||||
isDebugInfoEnabled = true;
|
||||
}
|
||||
|
||||
export function createDeprecation(name: string, options: DeprecationOptions & { error: true }): () => never;
|
||||
export function createDeprecation(name: string, options?: DeprecationOptions): () => void;
|
||||
export function createDeprecation(name: string, options: DeprecationOptions = {}) {
|
||||
let formattedMessage = options.error ? "DeprecationError: " : "DeprecationWarning: ";
|
||||
formattedMessage += `'${name}' ${options.since ? `has been deprecated since ${options.since}` : "is deprecated"}`;
|
||||
formattedMessage += options.error ? " and can no longer be used." : options.until ? ` and will no longer be usable after ${options.until}.` : ".";
|
||||
formattedMessage += options.message ? ` ${formatStringFromArgs(options.message, [name], 0)}` : "";
|
||||
let hasWrittenDeprecation = false;
|
||||
return handleDeprecation;
|
||||
|
||||
function handleDeprecation(): void {
|
||||
if (options.error) return fail(formattedMessage, handleDeprecation);
|
||||
if (hasWrittenDeprecation) return;
|
||||
hasWrittenDeprecation = true;
|
||||
log.warn(formattedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
function wrapFunction<F extends (...args: any[]) => any>(deprecation: () => void, func: F): F {
|
||||
return function (this: unknown) {
|
||||
deprecation();
|
||||
return func.apply(this, arguments);
|
||||
} as F;
|
||||
}
|
||||
|
||||
function wrapAccessor(deprecation: () => void, desc: PropertyDescriptor) {
|
||||
const newDesc: PropertyDescriptor = { enumerable: desc.enumerable, configurable: desc.configurable };
|
||||
if (desc.get) newDesc.get = wrapFunction(deprecation, desc.get);
|
||||
if (desc.set) newDesc.set = wrapFunction(deprecation, desc.set);
|
||||
return newDesc;
|
||||
}
|
||||
|
||||
function wrapValue(deprecation: () => void, desc: PropertyDescriptor) {
|
||||
const newDesc: PropertyDescriptor = { enumerable: desc.enumerable, configurable: desc.configurable };
|
||||
let value = desc.value;
|
||||
newDesc.get = () => { deprecation(); return value; };
|
||||
if (desc.writable) newDesc.set = _value => { deprecation(); value = _value; };
|
||||
return newDesc;
|
||||
}
|
||||
|
||||
export function deprecateProperties<T, K extends Extract<MatchingKeys<T, (...args: any[]) => any>, string>>(ns: T, keys: K[], options?: DeprecationOptions) {
|
||||
for (const key of keys) {
|
||||
deprecateProperty(ns, key, options);
|
||||
}
|
||||
}
|
||||
|
||||
export function deprecateProperty<T, K extends Extract<MatchingKeys<T, (...args: any[]) => any>, string>>(ns: T, key: K, options?: DeprecationOptions) {
|
||||
const desc = Object.getOwnPropertyDescriptor(ns, key);
|
||||
if (!desc) return;
|
||||
const deprecation = createDeprecation(key, options);
|
||||
const newDesc = desc.get || desc.set ? wrapAccessor(deprecation, desc) : wrapValue(deprecation, desc);
|
||||
Object.defineProperty(ns, key, newDesc);
|
||||
}
|
||||
|
||||
export function deprecateFunction<F extends (...args: any[]) => any>(func: F, options?: DeprecationOptions): F {
|
||||
const deprecation = createDeprecation(getFunctionName(func), options);
|
||||
return wrapFunction(deprecation, func);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -339,7 +339,7 @@ namespace ts {
|
||||
emittedExpression.typeArguments,
|
||||
emittedExpression.arguments
|
||||
);
|
||||
return factory.recreateOuterExpressions(expression, updated, OuterExpressionKinds.PartiallyEmittedExpressions);
|
||||
return factory.restoreOuterExpressions(expression, updated, OuterExpressionKinds.PartiallyEmittedExpressions);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6958,7 +6958,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseUnknownTag(start: number, tagName: Identifier) {
|
||||
return finishNode(factory.createJSDocTag(tagName), start);
|
||||
return finishNode(factory.createJSDocUnknownTag(tagName), start);
|
||||
}
|
||||
|
||||
function addTag(tag: JSDocTag | undefined): void {
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
/*@internal*/
|
||||
namespace ts {
|
||||
type MatchingKeys<T, TMatch, K extends keyof T = keyof T> = K extends (T[K] extends TMatch ? K : never) ? K : never;
|
||||
type TryExcludeVoid<T> = [T] extends [void] ? void : Exclude<T, void>;
|
||||
type Replace<T, Match, Replace> = T extends Match ? Replace : T;
|
||||
type Promised<T> = T extends PromiseLike<infer U> ? U : T;
|
||||
|
||||
@ -18,8 +18,8 @@ namespace ts {
|
||||
/* @internal */
|
||||
namespace ts {
|
||||
// Shims
|
||||
export const Map: MapConstructor = requireShim("./mapShim.js", "createMapShim"); // tslint:disable-line variable-name
|
||||
export const Promise: PromiseConstructor = requireShim("./promiseShim.js", "createPromiseShim"); // tslint:disable-line variable-name
|
||||
export const Map: MapConstructor = tryGetNativeMap() || requireShim("./mapShim.js", "createMapShim"); // tslint:disable-line variable-name
|
||||
export const Promise: PromiseConstructor = tryGetNativePromise() || requireShim("./promiseShim.js", "createPromiseShim"); // tslint:disable-line variable-name
|
||||
|
||||
function requireShim<K extends string, C>(shimPath: string, shimFactory: K) {
|
||||
type ShimModule = Record<K, () => C>;
|
||||
|
||||
@ -921,17 +921,17 @@ namespace ts {
|
||||
tscWatchDirectory === "RecursiveDirectoryUsingDynamicPriorityPolling" ?
|
||||
createWatchDirectoryUsing(dynamicPollingWatchFile || createDynamicPriorityPollingWatchFile({ getModifiedTime, setTimeout })) :
|
||||
watchDirectoryUsingFsWatch;
|
||||
const watchDirectoryRecursively = createRecursiveDirectoryWatcher({
|
||||
const watchDirectoryRecursively = memoize(() => createRecursiveDirectoryWatcher({
|
||||
useCaseSensitiveFileNames,
|
||||
directoryExists,
|
||||
getAccessibleSortedChildDirectories: path => getAccessibleFileSystemEntries(path).directories,
|
||||
watchDirectory,
|
||||
realpath
|
||||
});
|
||||
}));
|
||||
|
||||
return (directoryName, callback, recursive) => {
|
||||
if (recursive) {
|
||||
return watchDirectoryRecursively(directoryName, callback);
|
||||
return watchDirectoryRecursively()(directoryName, callback);
|
||||
}
|
||||
return watchDirectory(directoryName, callback);
|
||||
};
|
||||
|
||||
@ -494,7 +494,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function makeArrayAssignmentPattern(factory: NodeFactory, elements: BindingOrAssignmentElement[]) {
|
||||
return factory.createArrayLiteral(map(elements, factory.getConverters().convertToArrayAssignmentElement));
|
||||
return factory.createArrayLiteral(map(elements, factory.converters.convertToArrayAssignmentElement));
|
||||
}
|
||||
|
||||
function makeObjectBindingPattern(factory: NodeFactory, elements: BindingOrAssignmentElement[]) {
|
||||
@ -503,7 +503,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function makeObjectAssignmentPattern(factory: NodeFactory, elements: BindingOrAssignmentElement[]) {
|
||||
return factory.createObjectLiteral(map(elements, factory.getConverters().convertToObjectAssignmentElement));
|
||||
return factory.createObjectLiteral(map(elements, factory.converters.convertToObjectAssignmentElement));
|
||||
}
|
||||
|
||||
function makeBindingElement(factory: NodeFactory, name: Identifier) {
|
||||
|
||||
@ -3691,11 +3691,11 @@ namespace ts {
|
||||
|
||||
// Recreate any outer parentheses or partially-emitted expressions to preserve source map
|
||||
// and comment locations.
|
||||
return factory.recreateOuterExpressions(node.expression,
|
||||
factory.recreateOuterExpressions(variable.initializer,
|
||||
factory.recreateOuterExpressions(aliasAssignment && aliasAssignment.right,
|
||||
return factory.restoreOuterExpressions(node.expression,
|
||||
factory.restoreOuterExpressions(variable.initializer,
|
||||
factory.restoreOuterExpressions(aliasAssignment && aliasAssignment.right,
|
||||
factory.updateCall(call,
|
||||
factory.recreateOuterExpressions(call.expression,
|
||||
factory.restoreOuterExpressions(call.expression,
|
||||
factory.updateFunctionExpression(
|
||||
func,
|
||||
/*modifiers*/ undefined,
|
||||
|
||||
@ -16,10 +16,6 @@ namespace ts {
|
||||
hoistVariableDeclaration
|
||||
} = context;
|
||||
|
||||
const {
|
||||
getConverters: converters,
|
||||
} = factory;
|
||||
|
||||
const resolver = context.getEmitResolver();
|
||||
const compilerOptions = context.getCompilerOptions();
|
||||
const languageVersion = getEmitScriptTarget(compilerOptions);
|
||||
@ -375,7 +371,7 @@ namespace ts {
|
||||
const variables = getInitializedVariables(node);
|
||||
if (variables.length === 0) {
|
||||
if (hasReceiver) {
|
||||
return visitNode(converters().convertToAssignmentElementTarget(node.declarations[0].name), visitor, isExpression);
|
||||
return visitNode(factory.converters.convertToAssignmentElementTarget(node.declarations[0].name), visitor, isExpression);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@ -403,7 +399,7 @@ namespace ts {
|
||||
function transformInitializedVariable(node: VariableDeclaration) {
|
||||
const converted = setSourceMapRange(
|
||||
factory.createAssignment(
|
||||
converters().convertToAssignmentElementTarget(node.name),
|
||||
factory.converters.convertToAssignmentElementTarget(node.name),
|
||||
node.initializer!
|
||||
),
|
||||
node
|
||||
@ -510,7 +506,7 @@ namespace ts {
|
||||
|
||||
const declarations = endLexicalEnvironment();
|
||||
if (some(declarations)) {
|
||||
const block = converters().convertToFunctionBlock(expression);
|
||||
const block = factory.converters.convertToFunctionBlock(expression);
|
||||
result = factory.updateBlock(block, setTextRange(factory.createNodeArray(concatenate(declarations, block.statements)), block.statements));
|
||||
}
|
||||
else {
|
||||
@ -531,7 +527,7 @@ namespace ts {
|
||||
return factory.updateBlock(body, visitNodes(body.statements, asyncBodyVisitor, isStatement, start));
|
||||
}
|
||||
else {
|
||||
return converters().convertToFunctionBlock(visitNode(body, asyncBodyVisitor, isConciseBody));
|
||||
return factory.converters.convertToFunctionBlock(visitNode(body, asyncBodyVisitor, isConciseBody));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -14,7 +14,6 @@ namespace ts {
|
||||
hoistVariableDeclaration
|
||||
} = context;
|
||||
|
||||
const converters = factory.getConverters;
|
||||
const resolver = context.getEmitResolver();
|
||||
const compilerOptions = context.getCompilerOptions();
|
||||
const languageVersion = getEmitScriptTarget(compilerOptions);
|
||||
@ -830,7 +829,7 @@ namespace ts {
|
||||
addRange(statements, appendObjectRestAssignmentsIfNeeded(/*statements*/ undefined, node));
|
||||
const leadingStatements = endLexicalEnvironment();
|
||||
if (statementOffset > 0 || some(statements) || some(leadingStatements)) {
|
||||
const block = converters().convertToFunctionBlock(body, /*multiLine*/ true);
|
||||
const block = factory.converters.convertToFunctionBlock(body, /*multiLine*/ true);
|
||||
insertStatementsAfterStandardPrologue(statements, leadingStatements);
|
||||
addRange(statements, block.statements.slice(statementOffset));
|
||||
return factory.updateBlock(block, setTextRange(factory.createNodeArray(statements), block.statements));
|
||||
|
||||
@ -20,10 +20,10 @@
|
||||
"diagnosticInformationMap.generated.ts",
|
||||
"scanner.ts",
|
||||
"utilities.ts",
|
||||
"factory/baseNodeFactory.ts",
|
||||
"factory/parenthesizerRules.ts",
|
||||
"factory/converters.ts",
|
||||
"factory/base.ts",
|
||||
"factory/factory.ts",
|
||||
"factory/nodeConverters.ts",
|
||||
"factory/nodeFactory.ts",
|
||||
"factory/emitNode.ts",
|
||||
"factory/emitHelpers.ts",
|
||||
"factory/nodeTests.ts",
|
||||
|
||||
@ -5913,8 +5913,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface NodeFactory {
|
||||
/* @internal */ getParenthesizerRules(): ParenthesizerRules;
|
||||
/* @internal */ getConverters(): NodeConverters;
|
||||
/* @internal */ readonly parenthesizer: ParenthesizerRules;
|
||||
/* @internal */ readonly converters: NodeConverters;
|
||||
createNodeArray<T extends Node>(elements?: readonly T[], hasTrailingComma?: boolean): NodeArray<T>;
|
||||
|
||||
/**
|
||||
@ -6037,7 +6037,6 @@ namespace ts {
|
||||
updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): CallSignatureDeclaration;
|
||||
createConstructSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration;
|
||||
updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): ConstructSignatureDeclaration;
|
||||
/* @internal */ createSignatureDeclaration<T extends SignatureDeclaration>(kind: T["kind"], typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): T;
|
||||
createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
|
||||
/* @internal */ createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): IndexSignatureDeclaration; // tslint:disable-line unified-signatures
|
||||
updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration;
|
||||
@ -6305,7 +6304,7 @@ namespace ts {
|
||||
/* @internal */ createJSDocEnumTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression): JSDocEnumTag;
|
||||
/* @internal */ createJSDocParameterTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string): JSDocParameterTag;
|
||||
/* @internal */ createJSDocPropertyTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string): JSDocPropertyTag;
|
||||
/* @internal */ createJSDocTag(tagName: Identifier): JSDocTag;
|
||||
/* @internal */ createJSDocUnknownTag(tagName: Identifier): JSDocUnknownTag;
|
||||
/* @internal */ createJSDocComment(comment?: string | undefined, tags?: NodeArray<JSDocTag> | undefined): JSDoc;
|
||||
|
||||
//
|
||||
@ -6387,6 +6386,44 @@ namespace ts {
|
||||
createBundle(sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle;
|
||||
updateBundle(node: Bundle, sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle;
|
||||
|
||||
//
|
||||
// Common operators
|
||||
//
|
||||
|
||||
createComma(left: Expression, right: Expression): BinaryExpression;
|
||||
createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment;
|
||||
createAssignment(left: Expression, right: Expression): AssignmentExpression<EqualsToken>;
|
||||
createLogicalOr(left: Expression, right: Expression): BinaryExpression;
|
||||
createLogicalAnd(left: Expression, right: Expression): BinaryExpression;
|
||||
createBitwiseOr(left: Expression, right: Expression): BinaryExpression;
|
||||
createBitwiseXor(left: Expression, right: Expression): BinaryExpression;
|
||||
createBitwiseAnd(left: Expression, right: Expression): BinaryExpression;
|
||||
createStrictEquality(left: Expression, right: Expression): BinaryExpression;
|
||||
createStrictInequality(left: Expression, right: Expression): BinaryExpression;
|
||||
createEquality(left: Expression, right: Expression): BinaryExpression;
|
||||
createInequality(left: Expression, right: Expression): BinaryExpression;
|
||||
createLessThan(left: Expression, right: Expression): BinaryExpression;
|
||||
createLessThanEquals(left: Expression, right: Expression): BinaryExpression;
|
||||
createGreaterThan(left: Expression, right: Expression): BinaryExpression;
|
||||
createGreaterThanEquals(left: Expression, right: Expression): BinaryExpression;
|
||||
createLeftShift(left: Expression, right: Expression): BinaryExpression;
|
||||
createRightShift(left: Expression, right: Expression): BinaryExpression;
|
||||
createUnsignedRightShift(left: Expression, right: Expression): BinaryExpression;
|
||||
createAdd(left: Expression, right: Expression): BinaryExpression;
|
||||
createSubtract(left: Expression, right: Expression): BinaryExpression;
|
||||
createMultiply(left: Expression, right: Expression): BinaryExpression;
|
||||
createDivide(left: Expression, right: Expression): BinaryExpression;
|
||||
createModulo(left: Expression, right: Expression): BinaryExpression;
|
||||
createExponent(left: Expression, right: Expression): BinaryExpression;
|
||||
createPrefixPlus(operand: Expression): PrefixUnaryExpression;
|
||||
createPrefixMinus(operand: Expression): PrefixUnaryExpression;
|
||||
createPrefixIncrement(operand: Expression): PrefixUnaryExpression;
|
||||
createPrefixDecrement(operand: Expression): PrefixUnaryExpression;
|
||||
createBitwiseNot(operand: Expression): PrefixUnaryExpression;
|
||||
createLogicalNot(operand: Expression): PrefixUnaryExpression;
|
||||
createPostfixIncrement(operand: Expression): PostfixUnaryExpression;
|
||||
createPostfixDecrement(operand: Expression): PostfixUnaryExpression;
|
||||
|
||||
//
|
||||
// Compound Nodes
|
||||
//
|
||||
@ -6395,21 +6432,13 @@ namespace ts {
|
||||
createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression;
|
||||
createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): CallExpression;
|
||||
createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression;
|
||||
createComma(left: Expression, right: Expression): Expression;
|
||||
createLessThan(left: Expression, right: Expression): Expression;
|
||||
createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment;
|
||||
createAssignment(left: Expression, right: Expression): BinaryExpression;
|
||||
createStrictEquality(left: Expression, right: Expression): BinaryExpression;
|
||||
createStrictInequality(left: Expression, right: Expression): BinaryExpression;
|
||||
createAdd(left: Expression, right: Expression): BinaryExpression;
|
||||
createSubtract(left: Expression, right: Expression): BinaryExpression;
|
||||
createPostfixIncrement(operand: Expression): PostfixUnaryExpression;
|
||||
createLogicalAnd(left: Expression, right: Expression): BinaryExpression;
|
||||
createLogicalOr(left: Expression, right: Expression): BinaryExpression;
|
||||
createLogicalNot(operand: Expression): PrefixUnaryExpression;
|
||||
|
||||
|
||||
createVoidZero(): VoidExpression;
|
||||
createExportDefault(expression: Expression): ExportAssignment;
|
||||
createExternalModuleExport(exportName: Identifier): ExportDeclaration;
|
||||
|
||||
/* @internal */ createSignatureDeclaration<T extends SignatureDeclaration>(kind: T["kind"], typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): T;
|
||||
/* @internal */ createTypeCheck(value: Expression, tag: TypeOfTag): Expression;
|
||||
/* @internal */ createMethodCall(object: Expression, methodName: string | Identifier, argumentsList: readonly Expression[]): CallExpression;
|
||||
/* @internal */ createGlobalMethodCall(globalObjectName: string, globalMethodName: string, argumentsList: readonly Expression[]): CallExpression;
|
||||
@ -6490,8 +6519,7 @@ namespace ts {
|
||||
// Utilities
|
||||
//
|
||||
|
||||
// TODO(rbuckton): Rename to `restoreOuterExpressions`.
|
||||
recreateOuterExpressions(outerExpression: Expression | undefined, innerExpression: Expression, kinds?: OuterExpressionKinds): Expression;
|
||||
restoreOuterExpressions(outerExpression: Expression | undefined, innerExpression: Expression, kinds?: OuterExpressionKinds): Expression;
|
||||
/* @internal */ restoreEnclosingLabel(node: Statement, outermostLabeledStatement: LabeledStatement | undefined, afterRestoreLabelCallback?: (node: LabeledStatement) => void): Statement;
|
||||
/* @internal */ createUseStrictPrologue(): PrologueDirective;
|
||||
/**
|
||||
|
||||
@ -192,7 +192,7 @@ namespace ts {
|
||||
const updated = visitNode(node, visitor, isConciseBody);
|
||||
const declarations = endLexicalEnvironment();
|
||||
if (some(declarations)) {
|
||||
const block = factory.getConverters().convertToFunctionBlock(updated);
|
||||
const block = factory.converters.convertToFunctionBlock(updated);
|
||||
const statements = mergeLexicalEnvironment(block.statements, declarations);
|
||||
return factory.updateBlock(block, statements);
|
||||
}
|
||||
|
||||
@ -483,7 +483,7 @@ namespace ts.codefix {
|
||||
getSynthesizedDeepClones(fn.typeParameters),
|
||||
getSynthesizedDeepClones(fn.parameters),
|
||||
getSynthesizedDeepClone(fn.type),
|
||||
factory.getConverters().convertToFunctionBlock(getSynthesizedDeepClone(fn.body!)));
|
||||
factory.converters.convertToFunctionBlock(getSynthesizedDeepClone(fn.body!)));
|
||||
}
|
||||
|
||||
function classExpressionToDeclaration(name: string | undefined, additionalModifiers: ReadonlyArray<Modifier>, cls: ClassExpression): ClassDeclaration {
|
||||
|
||||
@ -225,6 +225,12 @@ function handleTestConfig() {
|
||||
}
|
||||
|
||||
function beginTests() {
|
||||
ts.Debug.loggingHost = {
|
||||
log(_level: ts.LogLevel, s: string) {
|
||||
console.log(s || "");
|
||||
}
|
||||
};
|
||||
|
||||
if (ts.Debug.isDebugging) {
|
||||
ts.Debug.enableDebugInfo();
|
||||
}
|
||||
|
||||
@ -446,6 +446,12 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
ts.Debug.loggingHost = {
|
||||
log(_level: ts.LogLevel, s: string) {
|
||||
ts.sys.write(`${s || ""}${ts.sys.newLine}`);
|
||||
}
|
||||
};
|
||||
|
||||
if (ts.Debug.isDebugging) {
|
||||
ts.Debug.enableDebugInfo();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user