Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a89c055

Browse filesBrowse files
authored
Merge pull request microsoft#19578 from amcasey/GH19395
Don't pass synthesized node to typeToTypeNode
2 parents 5e0c71e + 1f93526 commit a89c055
Copy full SHA for a89c055

3 files changed

+38-1Lines changed: 38 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/compiler/checker.ts‎

Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,18 +2444,21 @@ namespace ts {
24442444
function createNodeBuilder() {
24452445
return {
24462446
typeToTypeNode: (type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => {
2447+
Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & NodeFlags.Synthesized) === 0);
24472448
const context = createNodeBuilderContext(enclosingDeclaration, flags);
24482449
const resultingNode = typeToTypeNodeHelper(type, context);
24492450
const result = context.encounteredError ? undefined : resultingNode;
24502451
return result;
24512452
},
24522453
indexInfoToIndexSignatureDeclaration: (indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => {
2454+
Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & NodeFlags.Synthesized) === 0);
24532455
const context = createNodeBuilderContext(enclosingDeclaration, flags);
24542456
const resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context);
24552457
const result = context.encounteredError ? undefined : resultingNode;
24562458
return result;
24572459
},
24582460
signatureToSignatureDeclaration: (signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => {
2461+
Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & NodeFlags.Synthesized) === 0);
24592462
const context = createNodeBuilderContext(enclosingDeclaration, flags);
24602463
const resultingNode = signatureToSignatureDeclarationHelper(signature, kind, context);
24612464
const result = context.encounteredError ? undefined : resultingNode;
Collapse file

‎src/services/refactors/extractSymbol.ts‎

Copy file name to clipboardExpand all lines: src/services/refactors/extractSymbol.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ namespace ts.refactor.extractSymbol {
730730
let type = checker.getTypeOfSymbolAtLocation(usage.symbol, usage.node);
731731
// Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {"
732732
type = checker.getBaseTypeOfLiteralType(type);
733-
typeNode = checker.typeToTypeNode(type, node, NodeBuilderFlags.NoTruncation);
733+
typeNode = checker.typeToTypeNode(type, scope, NodeBuilderFlags.NoTruncation);
734734
}
735735

736736
const paramDecl = createParameter(
Collapse file
+34Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// Repro https://github.com/Microsoft/TypeScript/issues/19395
4+
5+
// @Filename: test.ts
6+
//// export const b = 2;
7+
//// interface Interface { }
8+
////
9+
//// async function handle(i: Interface) {
10+
//// /*a*/const x = 3, y = i;/*b*/
11+
//// }
12+
// @Filename: library.d.ts
13+
//// export as namespace NS;
14+
//// export const a = 1;
15+
16+
17+
goTo.select('a', 'b')
18+
edit.applyRefactor({
19+
refactorName: "Extract Symbol",
20+
actionName: "function_scope_1",
21+
actionDescription: "Extract to function in module scope",
22+
newContent:
23+
`export const b = 2;
24+
interface Interface { }
25+
26+
async function handle(i: Interface) {
27+
/*RENAME*/newFunction(i);
28+
}
29+
30+
function newFunction(i: Interface) {
31+
const x = 3, y = i;
32+
}
33+
`
34+
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.