diff --git a/src/compiler/core.ts b/src/compiler/core.ts index fab736de008..cfa677be3ea 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -23,34 +23,6 @@ namespace ts { export const emptyMap: ReadonlyESMap = new Map(); export const emptySet: ReadonlySet = new Set(); - /** - * Create a new map. - * @deprecated Use `new Map()` instead. - */ - export function createMap(): ESMap; - export function createMap(): ESMap; - export function createMap(): ESMap { - return new Map(); - } - - /** - * Create a new map from a template object is provided, the map will copy entries from it. - * @deprecated Use `new Map(getEntries(template))` instead. - */ - export function createMapFromTemplate(template: MapLike): ESMap { - const map: ESMap = new Map(); - - // Copies keys/values from template. Note that for..in will not throw if - // template is undefined, and instead will just exit the loop. - for (const key in template) { - if (hasOwnProperty.call(template, key)) { - map.set(key, template[key]); - } - } - - return map; - } - export function length(array: readonly any[] | undefined): number { return array ? array.length : 0; } diff --git a/src/compiler/debug.ts b/src/compiler/debug.ts index 705ab949899..5d22b0fe798 100644 --- a/src/compiler/debug.ts +++ b/src/compiler/debug.ts @@ -171,12 +171,6 @@ namespace ts { return value; } - /** - * @deprecated Use `checkDefined` to check whether a value is defined inline. Use `assertIsDefined` to check whether - * a value is defined at the statement level. - */ - export const assertDefined = checkDefined; - export function assertEachIsDefined(value: NodeArray, message?: string, stackCrawlMark?: AnyFunction): asserts value is NodeArray; export function assertEachIsDefined(value: readonly T[], message?: string, stackCrawlMark?: AnyFunction): asserts value is readonly NonNullable[]; export function assertEachIsDefined(value: readonly T[], message?: string, stackCrawlMark?: AnyFunction) { @@ -190,12 +184,6 @@ namespace ts { return value; } - /** - * @deprecated Use `checkEachDefined` to check whether the elements of an array are defined inline. Use `assertEachIsDefined` to check whether - * the elements of an array are defined at the statement level. - */ - export const assertEachDefined = checkEachDefined; - export function assertNever(member: never, message = "Illegal value:", stackCrawlMark?: AnyFunction): never { const detail = typeof member === "object" && hasProperty(member, "kind") && hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind((member as Node).kind) : JSON.stringify(member); return fail(`${message} ${detail}`, stackCrawlMark || assertNever); diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index 963ce75441f..cbe3aa339e1 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -6387,7 +6387,7 @@ namespace ts { sourceMapText = mapTextOrStripInternal as string; } const node = oldFileOfCurrentEmit ? - parseOldFileOfCurrentEmit(Debug.assertDefined(bundleFileInfo)) : + parseOldFileOfCurrentEmit(Debug.checkDefined(bundleFileInfo)) : parseUnparsedSourceFile(bundleFileInfo, stripInternal, length); node.fileName = fileName; node.sourceMapPath = sourceMapPath; @@ -6587,13 +6587,13 @@ namespace ts { }; node.javascriptPath = declarationTextOrJavascriptPath; node.javascriptMapPath = javascriptMapPath; - node.declarationPath = Debug.assertDefined(javascriptMapTextOrDeclarationPath); + node.declarationPath = Debug.checkDefined(javascriptMapTextOrDeclarationPath); node.declarationMapPath = declarationMapPath; node.buildInfoPath = declarationMapTextOrBuildInfoPath; Object.defineProperties(node, { javascriptText: { get() { return definedTextGetter(declarationTextOrJavascriptPath); } }, javascriptMapText: { get() { return textGetter(javascriptMapPath); } }, // TODO:: if there is inline sourceMap in jsFile, use that - declarationText: { get() { return definedTextGetter(Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } }, + declarationText: { get() { return definedTextGetter(Debug.checkDefined(javascriptMapTextOrDeclarationPath)); } }, declarationMapText: { get() { return textGetter(declarationMapPath); } }, // TODO:: if there is inline sourceMap in dtsFile, use that buildInfo: { get() { return getAndCacheBuildInfo(() => textGetter(declarationMapTextOrBuildInfoPath)); } } }); diff --git a/src/compiler/resolutionCache.ts b/src/compiler/resolutionCache.ts index 60d5e0ba244..e06d81ca4c9 100644 --- a/src/compiler/resolutionCache.ts +++ b/src/compiler/resolutionCache.ts @@ -619,7 +619,7 @@ namespace ts { ) { if (resolution.refCount) { resolution.refCount++; - Debug.assertDefined(resolution.files); + Debug.assertIsDefined(resolution.files); } else { resolution.refCount = 1; @@ -696,7 +696,7 @@ namespace ts { filePath: Path, getResolutionWithResolvedFileName: GetResolutionWithResolvedFileName, ) { - unorderedRemoveItem(Debug.assertDefined(resolution.files), filePath); + unorderedRemoveItem(Debug.checkDefined(resolution.files), filePath); resolution.refCount!--; if (resolution.refCount) { return; @@ -798,7 +798,7 @@ namespace ts { for (const resolution of resolutions) { if (resolution.isInvalidated || !canInvalidate(resolution)) continue; resolution.isInvalidated = invalidated = true; - for (const containingFilePath of Debug.assertDefined(resolution.files)) { + for (const containingFilePath of Debug.checkDefined(resolution.files)) { (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new Set())).add(containingFilePath); // When its a file with inferred types resolution, invalidate type reference directive resolution hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || endsWith(containingFilePath, inferredTypesContainingFile); diff --git a/src/compiler/transformers/es2018.ts b/src/compiler/transformers/es2018.ts index 846fd992ff2..153f8ec63af 100644 --- a/src/compiler/transformers/es2018.ts +++ b/src/compiler/transformers/es2018.ts @@ -282,7 +282,7 @@ namespace ts { function visitYieldExpression(node: YieldExpression) { if (enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator) { if (node.asteriskToken) { - const expression = visitNode(Debug.assertDefined(node.expression), visitor, isExpression); + const expression = visitNode(Debug.checkDefined(node.expression), visitor, isExpression); return setOriginalNode( setTextRange( diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index 2394e25a354..c54f79c9f66 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -48,11 +48,11 @@ namespace ts { return existing.name; } if (!currentFileState.utilizedImplicitRuntimeImports) { - currentFileState.utilizedImplicitRuntimeImports = createMap(); + currentFileState.utilizedImplicitRuntimeImports = new Map(); } let specifierSourceImports = currentFileState.utilizedImplicitRuntimeImports.get(importSource); if (!specifierSourceImports) { - specifierSourceImports = createMap(); + specifierSourceImports = new Map(); currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports); } const generatedName = factory.createUniqueName(`_${name}`, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel | GeneratedIdentifierFlags.AllowNameSubstitution); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b75a5ac9439..5afcd961b7e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1609,7 +1609,7 @@ namespace ts { export interface TypePredicateNode extends TypeNode { readonly kind: SyntaxKind.TypePredicate; readonly parent: SignatureDeclaration | JSDocTypeExpression; - readonly assertsModifier?: AssertsToken; + readonly assertsModifier?: AssertsKeyword; readonly parameterName: Identifier | ThisTypeNode; readonly type?: TypeNode; } @@ -1702,7 +1702,7 @@ namespace ts { export interface MappedTypeNode extends TypeNode, Declaration { readonly kind: SyntaxKind.MappedType; - readonly readonlyToken?: ReadonlyToken | PlusToken | MinusToken; + readonly readonlyToken?: ReadonlyKeyword | PlusToken | MinusToken; readonly typeParameter: TypeParameterDeclaration; readonly nameType?: TypeNode; readonly questionToken?: QuestionToken | PlusToken | MinusToken; @@ -2756,7 +2756,7 @@ namespace ts { export interface ForOfStatement extends IterationStatement { readonly kind: SyntaxKind.ForOfStatement; - readonly awaitModifier?: AwaitKeywordToken; + readonly awaitModifier?: AwaitKeyword; readonly initializer: ForInitializer; readonly expression: Expression; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 9c706c6f618..a24f61a93fa 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -20,21 +20,6 @@ namespace ts { return undefined; } - /** - * Create a new escaped identifier map. - * @deprecated Use `new Map<__String, T>()` instead. - */ - export function createUnderscoreEscapedMap(): UnderscoreEscapedMap { - return new Map<__String, T>(); - } - - /** - * @deprecated Use `!!map?.size` instead - */ - export function hasEntries(map: ReadonlyCollection | undefined): map is ReadonlyCollection { - return !!map && !!map.size; - } - export function createSymbolTable(symbols?: readonly Symbol[]): SymbolTable { const result = new Map<__String, Symbol>(); if (symbols) { @@ -6994,18 +6979,6 @@ namespace ts { return { min, max }; } - /** @deprecated Use `ReadonlySet` instead. */ - export type ReadonlyNodeSet = ReadonlySet; - - /** @deprecated Use `Set` instead. */ - export type NodeSet = Set; - - /** @deprecated Use `ReadonlyMap` instead. */ - export type ReadonlyNodeMap = ReadonlyESMap; - - /** @deprecated Use `Map` instead. */ - export type NodeMap = ESMap; - export function rangeOfNode(node: Node): TextRange { return { pos: getTokenPosOfNode(node), end: node.end }; } diff --git a/src/server/session.ts b/src/server/session.ts index a503509f07b..5c1e5203fb1 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -2112,7 +2112,7 @@ namespace ts.server { private getFullNavigateToItems(args: protocol.NavtoRequestArgs): CombineOutputResult { const { currentFileOnly, searchValue, maxResultCount, projectFileName } = args; if (currentFileOnly) { - Debug.assertDefined(args.file); + Debug.assertIsDefined(args.file); const { file, project } = this.getFileAndProject(args as protocol.FileRequestArgs); return [{ project, result: project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, file) }]; } diff --git a/src/services/codefixes/fixImplicitThis.ts b/src/services/codefixes/fixImplicitThis.ts index 91758428c8b..743db5c7f35 100644 --- a/src/services/codefixes/fixImplicitThis.ts +++ b/src/services/codefixes/fixImplicitThis.ts @@ -26,9 +26,9 @@ namespace ts.codefix { if (!isFunctionDeclaration(fn) && !isFunctionExpression(fn)) return undefined; if (!isSourceFile(getThisContainer(fn, /*includeArrowFunctions*/ false))) { // 'this' is defined outside, convert to arrow function - const fnKeyword = Debug.assertDefined(findChildOfKind(fn, SyntaxKind.FunctionKeyword, sourceFile)); + const fnKeyword = Debug.checkDefined(findChildOfKind(fn, SyntaxKind.FunctionKeyword, sourceFile)); const { name } = fn; - const body = Debug.assertDefined(fn.body); // Should be defined because the function contained a 'this' expression + const body = Debug.checkDefined(fn.body); // Should be defined because the function contained a 'this' expression if (isFunctionExpression(fn)) { if (name && FindAllReferences.Core.isSymbolReferencedInFile(name, checker, sourceFile, body)) { // Function expression references itself. To fix we would have to extract it to a const. diff --git a/src/testRunner/unittests/tsserver/autoImportProvider.ts b/src/testRunner/unittests/tsserver/autoImportProvider.ts index 9d197884929..f05d06f4842 100644 --- a/src/testRunner/unittests/tsserver/autoImportProvider.ts +++ b/src/testRunner/unittests/tsserver/autoImportProvider.ts @@ -326,7 +326,7 @@ namespace ts.projectSystem { }; function updateFile(path: string, newText: string) { - Debug.assertDefined(files.find(f => f.path === path)); + Debug.assertIsDefined(files.find(f => f.path === path)); session.executeCommandSeq({ command: protocol.CommandTypes.ApplyChangedToOpenFiles, arguments: { @@ -339,7 +339,7 @@ namespace ts.projectSystem { } function findAllReferences(file: string, line: number, offset: number) { - Debug.assertDefined(files.find(f => f.path === file)); + Debug.assertIsDefined(files.find(f => f.path === file)); session.executeCommandSeq({ command: protocol.CommandTypes.References, arguments: { diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 2ea26a94f1b..752f6b892bb 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -897,7 +897,7 @@ declare namespace ts { export interface TypePredicateNode extends TypeNode { readonly kind: SyntaxKind.TypePredicate; readonly parent: SignatureDeclaration | JSDocTypeExpression; - readonly assertsModifier?: AssertsToken; + readonly assertsModifier?: AssertsKeyword; readonly parameterName: Identifier | ThisTypeNode; readonly type?: TypeNode; } @@ -968,7 +968,7 @@ declare namespace ts { } export interface MappedTypeNode extends TypeNode, Declaration { readonly kind: SyntaxKind.MappedType; - readonly readonlyToken?: ReadonlyToken | PlusToken | MinusToken; + readonly readonlyToken?: ReadonlyKeyword | PlusToken | MinusToken; readonly typeParameter: TypeParameterDeclaration; readonly nameType?: TypeNode; readonly questionToken?: QuestionToken | PlusToken | MinusToken; @@ -1465,7 +1465,7 @@ declare namespace ts { } export interface ForOfStatement extends IterationStatement { readonly kind: SyntaxKind.ForOfStatement; - readonly awaitModifier?: AwaitKeywordToken; + readonly awaitModifier?: AwaitKeyword; readonly initializer: ForInitializer; readonly expression: Expression; } diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 022504652a9..a9d7e9c449b 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -897,7 +897,7 @@ declare namespace ts { export interface TypePredicateNode extends TypeNode { readonly kind: SyntaxKind.TypePredicate; readonly parent: SignatureDeclaration | JSDocTypeExpression; - readonly assertsModifier?: AssertsToken; + readonly assertsModifier?: AssertsKeyword; readonly parameterName: Identifier | ThisTypeNode; readonly type?: TypeNode; } @@ -968,7 +968,7 @@ declare namespace ts { } export interface MappedTypeNode extends TypeNode, Declaration { readonly kind: SyntaxKind.MappedType; - readonly readonlyToken?: ReadonlyToken | PlusToken | MinusToken; + readonly readonlyToken?: ReadonlyKeyword | PlusToken | MinusToken; readonly typeParameter: TypeParameterDeclaration; readonly nameType?: TypeNode; readonly questionToken?: QuestionToken | PlusToken | MinusToken; @@ -1465,7 +1465,7 @@ declare namespace ts { } export interface ForOfStatement extends IterationStatement { readonly kind: SyntaxKind.ForOfStatement; - readonly awaitModifier?: AwaitKeywordToken; + readonly awaitModifier?: AwaitKeyword; readonly initializer: ForInitializer; readonly expression: Expression; }