diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 3ce5f905a6f97..2cad3b8acc377 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4199,23 +4199,20 @@ namespace ts { pos++; } - if (start < pos) { - const textRange: TextRange = { pos: -1, end: -1 }; - if (start === 0) textRange.pos = modifiers.pos; - if (pos === modifiers.length - 1) textRange.end = modifiers.end; - emitNodeListItems( - emit, - node, - modifiers, - lastMode === "modifiers" ? ListFormat.Modifiers : ListFormat.Decorators, - /*parenthesizerRule*/ undefined, - start, - pos - start, - /*hasTrailingComma*/ false, - textRange); - start = pos; - } - + const textRange: TextRange = { pos: -1, end: -1 }; + if (start === 0) textRange.pos = modifiers.pos; + if (pos === modifiers.length - 1) textRange.end = modifiers.end; + emitNodeListItems( + emit, + node, + modifiers, + lastMode === "modifiers" ? ListFormat.Modifiers : ListFormat.Decorators, + /*parenthesizerRule*/ undefined, + start, + pos - start, + /*hasTrailingComma*/ false, + textRange); + start = pos; lastMode = mode; pos++; } diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index eba9432328dc4..b9a3a4b826573 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -1557,11 +1557,11 @@ namespace ts { return some(statements, isScopeMarker); } - function ensureModifiers(node: T): readonly NonNullable[number][] | undefined { + function ensureModifiers(node: T): readonly Modifier[] | undefined { const currentFlags = getEffectiveModifierFlags(node); const newFlags = ensureModifierFlags(node); if (currentFlags === newFlags) { - return visitNodes(node.modifiers, n => tryCast(n, isModifier), isModifier); + return visitArray(node.modifiers, n => tryCast(n, isModifier), isModifier); } return factory.createModifiersFromModifierFlags(newFlags); } diff --git a/src/compiler/transformers/utilities.ts b/src/compiler/transformers/utilities.ts index 1d221af407493..bbe8f165919bf 100644 --- a/src/compiler/transformers/utilities.ts +++ b/src/compiler/transformers/utilities.ts @@ -467,7 +467,7 @@ namespace ts { } const { firstAccessor, secondAccessor, getAccessor, setAccessor } = getAllAccessorDeclarations(parent.members, accessor); - const firstAccessorWithDecorators = + const firstAccessorWithDecorators = hasDecorators(firstAccessor) ? firstAccessor : secondAccessor && hasDecorators(secondAccessor) ? secondAccessor : undefined; diff --git a/src/compiler/visitorPublic.ts b/src/compiler/visitorPublic.ts index 3eccc86706660..619348685efbc 100644 --- a/src/compiler/visitorPublic.ts +++ b/src/compiler/visitorPublic.ts @@ -116,8 +116,8 @@ namespace ts { } /* @internal */ - export function visitArray(nodes: readonly T[] | undefined, visitor: Visitor | undefined, test: (node: Node) => node is T, start?: number, count?: number): readonly T[] | undefined { - if (nodes === undefined || visitor === undefined) { + export function visitArray(nodes: readonly T[] | undefined, visitor: Visitor, test: (node: Node) => node is U, start?: number, count?: number): readonly U[] | undefined { + if (nodes === undefined) { return nodes; } @@ -131,7 +131,7 @@ namespace ts { count = length - start; } - return visitArrayWorker(nodes, visitor, test, start, count); + return visitArrayWorker(nodes, visitor, test, start, count) as readonly U[]; } /* @internal */ diff --git a/src/services/codefixes/convertToAsyncFunction.ts b/src/services/codefixes/convertToAsyncFunction.ts index a245f0aff4943..8b7282ee5f102 100644 --- a/src/services/codefixes/convertToAsyncFunction.ts +++ b/src/services/codefixes/convertToAsyncFunction.ts @@ -83,8 +83,6 @@ namespace ts.codefix { } const pos = skipTrivia(sourceFile.text, moveRangePastModifiers(functionToConvert).pos); - // const pos = functionToConvert.modifiers?.end ?? functionToConvert.getStart(sourceFile); - // const options = functionToConvert.modifiers ? { prefix: " " } : { suffix: " " }; changes.insertModifierAt(sourceFile, pos, SyntaxKind.AsyncKeyword, { suffix: " " }); for (const returnStatement of returnStatements) { diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index 5fef40f415cb4..c27f60772fd57 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -24,7 +24,7 @@ { "path": "../typingsInstallerCore", "prepend": true }, { "path": "../deprecatedCompat", "prepend": true }, { "path": "../harness", "prepend": true }, - { "path": "../loggedIO", "prepend": true }, + { "path": "../loggedIO", "prepend": true } ], "files": [