Repository navigation
Closed
Description
Although neither reduce nor reduceRight method doesn't directly relate to the errors, looks like the errors (which were not discovered by gulp runtests-parallel) are caused by a bug of the compiler. For instance, the following function should return Statement[] when nodes is MutableNodeArray<Statement>, but actually returns Node[]. This is strange.
export function visitNodes<T extends Node>(nodes: NodeArray<T> | undefined, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray<T>;Looks like the errors indicate a bug of the compiler.
This issue is requested by Nathan Shively-Sanders (@sandersn) .
TypeScript Version: 3.7.x-dev.201xxxxx
Search Terms:
Code
Expected behavior:
pass
Actual behavior:
src/services/codefixes/helpers.ts:127:45 - error TS2345: Argument of type 'NodeArray<Node> | undefined' is not assignable to parameter of type 'NodeArray<Modifier> | undefined'.
Type 'NodeArray<Node>' is not assignable to type 'NodeArray<Modifier>'.
Type 'Node' is not assignable to type 'Modifier'.
Type 'Node' is not assignable to type 'Token<SyntaxKind.StaticKeyword>'.
Types of property 'kind' are incompatible.
Type 'SyntaxKind' is not assignable to type 'SyntaxKind.StaticKeyword'.
127 outputMethod(signature, getSynthesizedDeepClones(modifiers, /*includeTrivia*/ false), getSynthesizedDeepClone(name, /*includeTrivia*/ false));
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/services/refactors/extractSymbol.ts:1259:40 - error TS2345: Argument of type 'Node[]' is not assignable to parameter of type 'readonly Statement[]'.
Property '_statementBrand' is missing in type 'Node' but required in type 'Statement'.
1259 return { body: createBlock(rewrittenStatements, /*multiLine*/ true), returnValueProperty };
~~~~~~~~~~~~~~~~~~~
built/local/compiler.d.ts:2048:9
2048 _statementBrand: any;
~~~~~~~~~~~~~~~
'_statementBrand' is declared here.
https://travis-ci.org/microsoft/TypeScript/jobs/644727907#L419-L441
Playground Link:
Related Issues:
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScript
Activity
sandersn commentedon Jul 23, 2020
Repros in 3.8 but not in 4.0. Must have gotten fixed during one of the assignability, inference or overload resolution tweaks.
Aside: I never got a standalone repro; the most reliable method I found was to edit transformFunctionBody in extractSymbol in the following way: