Skip to content

Commit

Permalink
PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuckton committed Jun 6, 2022
1 parent 67dec37 commit d6e4576
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 26 deletions.
31 changes: 14 additions & 17 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/transformers/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1557,11 +1557,11 @@ namespace ts {
return some(statements, isScopeMarker);
}

function ensureModifiers<T extends HasModifiers>(node: T): readonly NonNullable<T["modifiers"]>[number][] | undefined {
function ensureModifiers<T extends HasModifiers>(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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/transformers/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/visitorPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ namespace ts {
}

/* @internal */
export function visitArray<T extends Node>(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<T extends Node, U extends T>(nodes: readonly T[] | undefined, visitor: Visitor, test: (node: Node) => node is U, start?: number, count?: number): readonly U[] | undefined {
if (nodes === undefined) {
return nodes;
}

Expand All @@ -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 */
Expand Down
2 changes: 0 additions & 2 deletions src/services/codefixes/convertToAsyncFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down

0 comments on commit d6e4576

Please sign in to comment.