8000 Code review comments · creatio/TypeScript@c3cfebf · GitHub
[go: up one dir, main page]

Skip to content

Commit c3cfebf

Browse files
committed
Code review comments
1 parent 7680cdf commit c3cfebf

18 files changed

+101
-102
lines changed

src/compiler/checker.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,16 +2192,16 @@ namespace ts {
21922192
}
21932193

21942194
function buildBindingPatternDisplay(bindingPattern: BindingPattern, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) {
2195-
// We have to explicitly emit square bracket and bracket because these tokens are not store inside the node.
2195+
// We have to explicitly emit square bracket and bracket because these tokens are not stored inside the node.
21962196
if (bindingPattern.kind === SyntaxKind.ObjectBindingPattern) {
21972197
writePunctuation(writer, SyntaxKind.OpenBraceToken);
2198-
buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, enclosingDeclaration, flags, symbolStack, buildBindingElementDisplay);
2198+
buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, e => buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack));
21992199
writePunctuation(writer, SyntaxKind.CloseBraceToken);
22002200
}
22012201
else if (bindingPattern.kind === SyntaxKind.ArrayBindingPattern) {
22022202
writePunctuation(writer, SyntaxKind.OpenBracketToken);
22032203
const elements = bindingPattern.elements;
2204-
buildDisplayForCommaSeparatedList(elements, writer, enclosingDeclaration, flags, symbolStack, buildBindingElementDisplay);
2204+
buildDisplayForCommaSeparatedList(elements, writer, e => buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack));
22052205
if (elements && elements.hasTrailingComma) {
22062206
writePunctuation(writer, SyntaxKind.CommaToken);
22072207
}
@@ -2217,35 +2217,34 @@ namespace ts {
22172217
if (bindingElement.propertyName) {
22182218
writer.writeSymbol(getTextOfNode(bindingElement.propertyName), bindingElement.symbol);
22192219
writePunctuation(writer, SyntaxKind.ColonToken);
2220+
writeSpace(writer);
22202221
}
2221-
if (bindingElement.name) {
2222-
if (isBindingPattern(bindingElement.name)) {
2223-
buildBindingPatternDisplay(<BindingPattern>bindingElement.name, writer, enclosingDeclaration, flags, symbolStack);
2224-
}
2225-
else {
2226-
if (bindingElement.dotDotDotToken) {
2227-
writePunctuation(writer, SyntaxKind.DotDotDotToken);
2228-
}
2229-
appendSymbolNameOnly(bindingElement.symbol, writer);
2222+
if (isBindingPattern(bindingElement.name)) {
2223+
buildBindingPatternDisplay(<BindingPattern>bindingElement.name, writer, enclosingDeclaration, flags, symbolStack);
2224+
}
2225+
else {
2226+
if (bindingElement.dotDotDotToken) {
2227+
writePunctuation(writer, SyntaxKind.DotDotDotToken);
22302228
}
2229+
appendSymbolNameOnly(bindingElement.symbol, writer);
22312230
}
22322231
}
22332232

22342233
function buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) {
22352234
if (typeParameters && typeParameters.length) {
22362235
writePunctuation(writer, SyntaxKind.LessThanToken);
2237-
buildDisplayForCommaSeparatedList(typeParameters, writer, enclosingDeclaration, flags, symbolStack, buildTypeParameterDisplay);
2236+
buildDisplayForCommaSeparatedList(typeParameters, writer, p => buildTypeParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack));
22382237
writePunctuation(writer, SyntaxKind.GreaterThanToken);
22392238
}
22402239
}
22412240

2242-
function buildDisplayForCommaSeparatedList<T>(list: T[], writer: SymbolWriter, enclosingDeclaration: Node, flags: TypeFormatFlags, symbolStack: Symbol[], action: (item: T, writer: SymbolWriter, enclosingDeclaration: Node, flags: TypeFormatFlags, symbolStack: Symbol[]) => void) {
2241+
function buildDisplayForCommaSeparatedList<T>(list: T[], writer: SymbolWriter, action: (item: T) => void) {
22432242
for (let i = 0; i < list.length; i++) {
22442243
if (i > 0) {
22452244
writePunctuation(writer, SyntaxKind.CommaToken);
22462245
writeSpace(writer);
22472246
}
2248-
action(list[i], writer, enclosingDeclaration, flags, symbolStack);
2247+
action(list[i]);
22492248
}
22502249
}
22512250

tests/baselines/reference/arrowFunctionExpressions.types

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ var p6 = ({ a }) => { };
8888
>a : any
8989

9090
var p7 = ({ a: { b } }) => { };
91-
>p7 : ({a:{b}}: { a: { b: any; }; }) => void
92-
>({ a: { b } }) => { } : ({a:{b}}: { a: { b: any; }; }) => void
91+
>p7 : ({a: {b}}: { a: { b: any; }; }) => void
92+
>({ a: { b } }) => { } : ({a: {b}}: { a: { b: any; }; }) => void
9393
>a : any
9494
>b : any
9595

@@ -100,8 +100,8 @@ var p8 = ({ a = 1 }) => { };
100100
>1 : number
101101

102102
var p9 = ({ a: { b = 1 } = { b: 1 } }) => { };
103-
>p9 : ({a:{b}}: { a?: { b?: number; }; }) => void
104-
>({ a: { b = 1 } = { b: 1 } }) => { } : ({a:{b}}: { a?: { b?: number; }; }) => void
103+
>p9 : ({a: {b}}: { a?: { b?: number; }; }) => void
104+
>({ a: { b = 1 } = { b: 1 } }) => { } : ({a: {b}}: { a?: { b?: number; }; }) => void
105105
>a : any
106106
>b : number
107107
>1 : number

tests/baselines/reference/declarationEmitDestructuring1.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function bar({a1, b1, c1}: { a1: number, b1: boolean, c1: string }): void { }
2121
>c1 : string
2222

2323
function baz({a2, b2: {b1, c1}}: { a2: number, b2: { b1: boolean, c1: string } }): void { }
24-
>baz : ({a2, b2:{b1, c1}}: { a2: number; b2: { b1: boolean; c1: string; }; }) => void
24+
>baz : ({a2, b2: {b1, c1}}: { a2: number; b2: { b1: boolean; c1: string; }; }) => void
2525
>a2 : number
2626
>b2 : any
2727
>b1 : boolean

tests/baselines/reference/declarationEmit_bindingPatters.js renamed to tests/baselines/reference/declarationEmit_bindingPatterns.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
//// [declarationEmit_bindingPatters.ts]
1+
//// [declarationEmit_bindingPatterns.ts]
22

33
const k = ({x: z = 'y'}) => { }
44

55
var a;
66
function f({} = a, [] = a, { p: {} = a} = a) {
77
}
88

9-
//// [declarationEmit_bindingPatters.js]
9+
//// [declarationEmit_bindingPatterns.js]
1010
var k = function (_a) {
1111
var _b = _a.x, z = _b === void 0 ? 'y' : _b;
1212
};
@@ -18,8 +18,8 @@ function f(_a, _b, _c) {
1818
}
1919

2020

21-
//// [declarationEmit_bindingPatters.d.ts]
22-
declare const k: ({x:z}: {
21+
//// [declarationEmit_bindingPatterns.d.ts]
22+
declare const k: ({x: z}: {
2323
x?: string;
2424
}) => void;
2525
declare var a: any;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
=== tests/cases/compiler/declarationEmit_bindingPatterns.ts ===
2+
3+
const k = ({x: z = 'y'}) => { }
4+
>k : Symbol(k, Decl(declarationEmit_bindingPatterns.ts, 1, 5))
5+
>x : Symbol(x)
6+
>z : Symbol(z, Decl(declarationEmit_bindingPatterns.ts, 1, 12))
7+
8+
var a;
9+
>a : Symbol(a, Decl(declarationEmit_bindingPatterns.ts, 3, 3))
10+
11+
function f({} = a, [] = a, { p: {} = a} = a) {
12+
>f : Symbol(f, Decl(declarationEmit_bindingPatterns.ts, 3, 6))
13+
>a : Symbol(a, Decl(declarationEmit_bindingPatterns.ts, 3, 3))
14+
>a : Symbol(a, Decl(declarationEmit_bindingPatterns.ts, 3, 3))
15+
>a : Symbol(a, Decl(declarationEmit_bindingPatterns.ts, 3, 3))
16+
>a : Symbol(a, Decl(declarationEmit_bindingPatterns.ts, 3, 3))
17+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
=== tests/cases/compiler/declarationEmit_bindingPatterns.ts ===
2+
3+
const k = ({x: z = 'y'}) => { }
4+
>k : ({x: z}: { x?: string; }) => void
5+
>({x: z = 'y'}) => { } : ({x: z}: { x?: string; }) => void
6+
>x : any
7+
>z : string
8+
>'y' : string
9+
10+
var a;
11+
>a : any
12+
13+
function f({} = a, [] = a, { p: {} = a} = a) {
14+
>f : ({}?: any, []?: any, {p: {}}?: any) => void
15+
>a : any
16+
>a : any
17+
>p : any
18+
>a : any
19+
>a : any
20+
}

tests/baselines/reference/declarationEmit_bindingPatters.symbols

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/baselines/reference/declarationEmit_bindingPatters.types

Lines changed: 0 additions & 20 deletions
This file was deleted.

tests/baselines/reference/destructuringInFunctionType.types

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type T3 = ([{ a: b }, { b: a }]);
4040
>a : a
4141

4242
type F3 = ([{ a: b }, { b: a }]) => void;
43-
>F3 : ([{a:b}, {b:a}]: [{ a: any; }, { b: any; }]) => void
43+
>F3 : ([{a: b}, {b: a}]: [{ a: any; }, { b: any; }]) => void
4444
>a : any
4545
>b : any
4646
>b : any
@@ -53,13 +53,13 @@ type T4 = ([{ a: [b, c] }]);
5353
>c : c
5454

5555
type F4 = ([{ a: [b, c] }]) => void;
56-
>F4 : ([{a:[b, c]}]: [{ a: [any, any]; }]) => void
56+
>F4 : ([{a: [b, c]}]: [{ a: [any, any]; }]) => void
5757
>a : any
5858
>b : any
5959
>c : any
6060

6161
type C1 = new ([{ a: [b, c] }]) => void;
62-
>C1 : new ([{a:[b, c]}]: [{ a: [any, any]; }]) => void
62+
>C1 : new ([{a: [b, c]}]: [{ a: [any, any]; }]) => void
6363
>a : any
6464
>b : any
6565
>c : any

tests/baselines/reference/destructuringWithLiteralInitializers.types

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ f6({ x: 1, y: 1 });
170170

171171
// (arg?: { a: { x?: number, y?: number } }) => void
172172
function f7({ a: { x = 0, y = 0 } } = { a: {} }) { }
173-
>f7 : ({a:{x, y}}?: { a: { x?: number; y?: number; }; }) => void
173+
>f7 : ({a: {x, y}}?: { a: { x?: number; y?: number; }; }) => void
174174
>a : any
175175
>x : number
176176
>0 : number
@@ -182,18 +182,18 @@ function f7({ a: { x = 0, y = 0 } } = { a: {} }) { }
182182

183183
f7();
184184
>f7() : void
185-
>f7 : ({a:{x, y}}?: { a: { x?: number; y?: number; }; }) => void
185+
>f7 : ({a: {x, y}}?: { a: { x?: number; y?: number; }; }) => void
186186

187187
f7({ a: {} });
188188
>f7({ a: {} }) : void
189-
>f7 : ({a:{x, y}}?: { a: { x?: number; y?: number; }; }) => void
189+
>f7 : ({a: {x, y}}?: { a: { x?: number; y?: number; }; }) => void
190190
>{ a: {} } : { a: {}; }
191191
>a : {}
192192
>{} : {}
193193

194194
f7({ a: { x: 1 } });
195195
>f7({ a: { x: 1 } }) : void
196-
>f7 : ({a:{x, y}}?: { a: { x?: number; y?: number; }; }) => void
196+
>f7 : ({a: {x, y}}?: { a: { x?: number; y?: number; }; }) => void
197197
>{ a: { x: 1 } } : { a: { x: number; }; }
198198
>a : { x: number; }
199199
>{ x: 1 } : { x: number; }
@@ -202,7 +202,7 @@ f7({ a: { x: 1 } });
202202

203203
f7({ a: { y: 1 } });
204204
>f7({ a: { y: 1 } }) : void
205-
>f7 : ({a:{x, y}}?: { a: { x?: number; y?: number; }; }) => void
205+
>f7 : ({a: {x, y}}?: { a: { x?: number; y?: number; }; }) => void
206206
>{ a: { y: 1 } } : { a: { y: number; }; }
207207
>a : { y: number; }
208208
>{ y: 1 } : { y: number; }
@@ -211,7 +211,7 @@ f7({ a: { y: 1 } });
211211

212212
f7({ a: { x: 1, y: 1 } });
213213
>f7({ a: { x: 1, y: 1 } }) : void
214-
>f7 : ({a:{x, y}}?: { a: { x?: number; y?: number; }; }) => void
214+
>f7 : ({a: {x, y}}?: { a: { x?: number; y?: number; }; }) => void
215215
>{ a: { x: 1, y: 1 } } : { a: { x: number; y: number; }; }
216216
>a : { x: number; y: number; }
217217
>{ x: 1, y: 1 } : { x: number; y: number; }

0 commit comments

Comments
 (0)
0