Skip to content

Commit d724517

Browse files
author
Arthur Ozga
committed
Merge branch 'master' into interfaceFixes
2 parents b9ae36c + a2fb5f9 commit d724517

File tree

228 files changed

+2454
-1496
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

228 files changed

+2454
-1496
lines changed

.mailmap

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,45 @@ zhongsp <[email protected]> # Patrick Zhong
172172
T18970237136 <[email protected]> # @T18970237136
173173
174174
bootstraponline <[email protected]> # @bootstraponline
175-
yortus <[email protected]> # @yortus
175+
yortus <[email protected]> # @yortus
176+
András Parditka <[email protected]>
177+
Anton Khlynovskiy <[email protected]>
178+
Charly POLY <[email protected]>
179+
Cotton Hou <[email protected]>
180+
Ethan Resnick <[email protected]>
181+
Marius Schulz <[email protected]>
182+
Mattias Buelens <[email protected]>
183+
Myles Megyesi <[email protected]>
184+
Tim Lancina <[email protected]>
185+
Aaron Holmes <[email protected]> Aaron Holmes <[email protected]>
186+
Akshar Patel <[email protected]>
187+
Ali Sabzevari <[email protected]>
188+
Aliaksandr Radzivanovich <[email protected]>
189+
BuildTools <[email protected]> # Franklin Tse
190+
ChogyDan <[email protected]> # Daniel Hollocher
191+
Daniel Rosenwasser <[email protected]> Daniel Rosenwasser <[email protected]>
192+
David Kmenta <[email protected]>
193+
E020873 <[email protected]> # Nicolas Henry
194+
Elisée Maurer <[email protected]>
195+
Emilio García-Pumarino <[email protected]> dashaus <[email protected]>
196+
Guilherme Oenning <[email protected]>
197+
Herrington Darkholme <[email protected]>
198+
Ivo Gabe de Wolff <[email protected]>
199+
Joey Wilson <[email protected]>
200+
Jonathon Smith <[email protected]>
201+
Juan Luis Boya García <[email protected]>
202+
Kagami Sascha Rosylight <[email protected]>
203+
Lucien Greathouse <[email protected]>
204+
Martin Vseticka <[email protected]>
205+
Mattias Buelens <[email protected]>
206+
Michael Bromley <[email protected]>
207+
Paul Jolly <[email protected]>
208+
Perry Jiang <[email protected]>
209+
Peter Burns <[email protected]>
210+
Robert Coie <[email protected]>
211+
Thomas Loubiou <[email protected]>
212+
Tim Perry <[email protected]>
213+
Vidar Tonaas Fauske <[email protected]>
214+
Viktor Zozulyak <[email protected]>
215+
rix <[email protected]> # Richard Sentino
216+
rohitverma007 <[email protected]> # Rohit Verma

AUTHORS.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
TypeScript is authored by:
2+
* Aaron Holmes
23
* Abubaker Bashir
34
* Adam Freidin
45
* Adi Dahiya
56
* Ahmad Farid
7+
* Akshar Patel
68
* Alex Eagle
79
* Alexander Kuvaev
810
* Alexander Rusakov
11+
* Ali Sabzevari
12+
* Aliaksandr Radzivanovich
913
* Anatoly Ressin
1014
* Anders Hejlsberg
1115
* Andrej Baran
1216
* Andrew Z Allen
17+
* András Parditka
1318
* Andy Hanson
1419
* Anil Anar
20+
* Anton Khlynovskiy
1521
* Anton Tolmachev
1622
* Arnav Singh
1723
* Arthur Ozga
@@ -27,16 +33,20 @@ TypeScript is authored by:
2733
* Brett Mayen
2834
* Bryan Forbes
2935
* Caitlin Potter
36+
* Charly POLY
3037
* Chris Bubernak
3138
* Christophe Vidal
3239
* Chuck Jazdzewski
3340
* Colby Russell
3441
* Colin Snover
42+
* Cotton Hou
3543
* Cyrus Najmabadi
3644
* Dafrok Zhang
3745
* Dan Corder
3846
* Dan Quirk
47+
* Daniel Hollocher
3948
* Daniel Rosenwasser
49+
* David Kmenta
4050
* David Li
4151
* David Souther
4252
* Denis Nedelyaev
@@ -45,21 +55,26 @@ TypeScript is authored by:
4555
* Dirk Holtwick
4656
* Dom Chen
4757
* Doug Ilijev
58+
* Elisée Maurer
59+
* Emilio García-Pumarino
4860
* Eric Tsang
4961
* Erik Edrosa
62+
* Ethan Resnick
5063
* Ethan Rubio
5164
* Evan Martin
5265
* Evan Sebastian
5366
* Eyas Sharaiha
5467
* Fabian Cook
5568
* @falsandtru
5669
* Frank Wallis
70+
* Franklin Tse
5771
* František Žiacik
5872
* Gabe Moothart
5973
* Gabriel Isenberg
6074
* Gilad Peleg
6175
* Godfrey Chan
6276
* Graeme Wicksted
77+
* Guilherme Oenning
6378
* Guillaume Salles
6479
* Guy Bedford
6580
* Harald Niesche
@@ -78,12 +93,14 @@ TypeScript is authored by:
7893
* Jeffrey Morlan
7994
* Jesse Schalken
8095
* Jiri Tobisek
96+
* Joey Wilson
8197
* Johannes Rieken
8298
* John Vilk
8399
* Jonathan Bond-Caron
84100
* Jonathan Park
85101
* Jonathan Toland
86102
* Jonathan Turner
103+
* Jonathon Smith
87104
* Josh Abernathy
88105
* Josh Kalderimis
89106
* Josh Soref
@@ -102,15 +119,21 @@ TypeScript is authored by:
102119
* Lucien Greathouse
103120
* Lukas Elmer
104121
* Marin Marinov
122+
* Marius Schulz
105123
* Martin Vseticka
106124
* Masahiro Wakame
107125
* Matt McCutchen
126+
* Mattias Buelens
127+
* Mattias Buelens
108128
* Max Deepfield
109129
* Micah Zoltu
110130
* Michael
131+
* Michael Bromley
111132
* Mohamed Hegazy
133+
* Myles Megyesi
112134
* Nathan Shively-Sanders
113135
* Nathan Yee
136+
* Nicolas Henry
114137
* Nima Zahedi
115138
* Noah Chen
116139
* Noj Vek
@@ -119,9 +142,12 @@ TypeScript is authored by:
119142
* Omer Sheikh
120143
* Oskar Segersva¨rd
121144
* Patrick Zhong
145+
* Paul Jolly
122146
* Paul van Brenk
123147
* @pcbro
124148
* Pedro Maltez
149+
* Perry Jiang
150+
* Peter Burns
125151
* Philip Bulley
126152
* Piero Cangianiello
127153
* @piloopin
@@ -130,6 +156,9 @@ TypeScript is authored by:
130156
* Punya Biswal
131157
* Rado Kirov
132158
* Richard Knoll
159+
* Richard Sentino
160+
* Robert Coie
161+
* Rohit Verma
133162
* Ron Buckton
134163
* Rostislav Galimsky
135164
* Rowan Wyborn
@@ -152,7 +181,9 @@ TypeScript is authored by:
152181
* @T18970237136
153182
* Tarik Ozket
154183
* Tetsuharu Ohzeki
184+
* Thomas Loubiou
155185
* Tien Hoanhtien
186+
* Tim Lancina
156187
* Tim Perry
157188
* Tim Viiding-Spader
158189
* Tingan Ho
@@ -161,6 +192,8 @@ TypeScript is authored by:
161192
* Tomas Grubliauskas
162193
* Torben Fitschen
163194
* TruongSinh Tran-Nguyen
195+
* Vidar Tonaas Fauske
196+
* Viktor Zozulyak
164197
* Vilic Vane
165198
* Vladimir Matveev
166199
* Wesley Wigham

Jakefile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ var harnessSources = harnessCoreSources.concat([
262262
"convertToBase64.ts",
263263
"transpile.ts",
264264
"reuseProgramStructure.ts",
265+
"textStorage.ts",
265266
"cachingInServerLSHost.ts",
266267
"moduleResolution.ts",
267268
"tsconfigParsing.ts",

src/compiler/checker.ts

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,7 +2671,7 @@ namespace ts {
26712671
}
26722672
Debug.assert(bindingElement.kind === SyntaxKind.BindingElement);
26732673
if (bindingElement.propertyName) {
2674-
writer.writeSymbol(getTextOfNode(bindingElement.propertyName), bindingElement.symbol);
2674+
writer.writeProperty(getTextOfNode(bindingElement.propertyName));
26752675
writePunctuation(writer, SyntaxKind.ColonToken);
26762676
writeSpace(writer);
26772677
}
@@ -10443,33 +10443,37 @@ namespace ts {
1044310443
return baseConstructorType === nullWideningType;
1044410444
}
1044510445

10446+
function checkThisBeforeSuper(node: Node, container: Node, diagnosticMessage: DiagnosticMessage) {
10447+
const containingClassDecl = <ClassDeclaration>container.parent;
10448+
const baseTypeNode = getClassExtendsHeritageClauseElement(containingClassDecl);
10449+
10450+
// If a containing class does not have extends clause or the class extends null
10451+
// skip checking whether super statement is called before "this" accessing.
10452+
if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) {
10453+
const superCall = getSuperCallInConstructor(<ConstructorDeclaration>container);
10454+
10455+
// We should give an error in the following cases:
10456+
// - No super-call
10457+
// - "this" is accessing before super-call.
10458+
// i.e super(this)
10459+
// this.x; super();
10460+
// We want to make sure that super-call is done before accessing "this" so that
10461+
// "this" is not accessed as a parameter of the super-call.
10462+
if (!superCall || superCall.end > node.pos) {
10463+
// In ES6, super inside constructor of class-declaration has to precede "this" accessing
10464+
error(node, diagnosticMessage);
10465+
}
10466+
}
10467+
}
10468+
1044610469
function checkThisExpression(node: Node): Type {
1044710470
// Stop at the first arrow function so that we can
1044810471
// tell whether 'this' needs to be captured.
1044910472
let container = getThisContainer(node, /* includeArrowFunctions */ true);
1045010473
let needToCaptureLexicalThis = false;
1045110474

1045210475
if (container.kind === SyntaxKind.Constructor) {
10453-
const containingClassDecl = <ClassDeclaration>container.parent;
10454-
const baseTypeNode = getClassExtendsHeritageClauseElement(containingClassDecl);
10455-
10456-
// If a containing class does not have extends clause or the class extends null
10457-
// skip checking whether super statement is called before "this" accessing.
10458-
if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) {
10459-
const superCall = getSuperCallInConstructor(<ConstructorDeclaration>container);
10460-
10461-
// We should give an error in the following cases:
10462-
// - No super-call
10463-
// - "this" is accessing before super-call.
10464-
// i.e super(this)
10465-
// this.x; super();
10466-
// We want to make sure that super-call is done before accessing "this" so that
10467-
// "this" is not accessed as a parameter of the super-call.
10468-
if (!superCall || superCall.end > node.pos) {
10469-
// In ES6, super inside constructor of class-declaration has to precede "this" accessing
10470-
error(node, Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class);
10471-
}
10472-
}
10476+
checkThisBeforeSuper(node, container, Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class);
1047310477
}
1047410478

1047510479
// Now skip arrow functions to get the "real" owner of 'this'.
@@ -10617,6 +10621,10 @@ namespace ts {
1061710621
return unknownType;
1061810622
}
1061910623

10624+
if (!isCallExpression && container.kind === SyntaxKind.Constructor) {
10625+
checkThisBeforeSuper(node, container, Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class);
10626+
}
10627+
1062010628
if ((getModifierFlags(container) & ModifierFlags.Static) || isCallExpression) {
1062110629
nodeCheckFlag = NodeCheckFlags.SuperStatic;
1062210630
}
@@ -13505,13 +13513,14 @@ namespace ts {
1350513513
const containingClass = getContainingClass(node);
1350613514
if (containingClass) {
1350713515
const containingType = getTypeOfNode(containingClass);
13508-
const baseTypes = getBaseTypes(<InterfaceType>containingType);
13509-
if (baseTypes.length) {
13516+
let baseTypes = getBaseTypes(containingType as InterfaceType);
13517+
while (baseTypes.length) {
1351013518
const baseType = baseTypes[0];
1351113519
if (modifiers & ModifierFlags.Protected &&
1351213520
baseType.symbol === declaration.parent.symbol) {
1351313521
return true;
1351413522
}
13523+
baseTypes = getBaseTypes(baseType as InterfaceType);
1351513524
}
1351613525
}
1351713526
if (modifiers & ModifierFlags.Private) {
@@ -16237,7 +16246,7 @@ namespace ts {
1623716246
return undefined;
1623816247
}
1623916248

16240-
const onfulfilledParameterType = getTypeWithFacts(getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)), TypeFacts.NEUndefined);
16249+
const onfulfilledParameterType = getTypeWithFacts(getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)), TypeFacts.NEUndefinedOrNull);
1624116250
if (isTypeAny(onfulfilledParameterType)) {
1624216251
return undefined;
1624316252
}
@@ -16731,6 +16740,14 @@ namespace ts {
1673116740
}
1673216741
}
1673316742

16743+
function isRemovedPropertyFromObjectSpread(node: Node) {
16744+
if (isBindingElement(node) && isObjectBindingPattern(node.parent)) {
16745+
const lastElement = lastOrUndefined(node.parent.elements);
16746+
return lastElement !== node && !!lastElement.dotDotDotToken;
16747+
}
16748+
return false;
16749+
}
16750+
1673416751
function errorUnusedLocal(node: Node, name: string) {
1673516752
if (isIdentifierThatStartsWithUnderScore(node)) {
1673616753
const declaration = getRootDeclaration(node.parent);
@@ -16740,7 +16757,10 @@ namespace ts {
1674016757
return;
1674116758
}
1674216759
}
16743-
error(node, Diagnostics._0_is_declared_but_never_used, name);
16760+
16761+
if (!isRemovedPropertyFromObjectSpread(node.kind === SyntaxKind.Identifier ? node.parent : node)) {
16762+
error(node, Diagnostics._0_is_declared_but_never_used, name);
16763+
}
1674416764
}
1674516765

1674616766
function parameterNameStartsWithUnderscore(parameterName: DeclarationName) {

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -549,14 +549,7 @@ namespace ts {
549549

550550
/* @internal */
551551
export function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]) {
552-
const key = trimString((value || "")).toLowerCase();
553-
const map = opt.type;
554-
if (key in map) {
555-
return map[key];
556-
}
557-
else {
558-
errors.push(createCompilerDiagnosticForInvalidCustomType(opt));
559-
}
552+
return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors);
560553
}
561554

562555
/* @internal */

src/compiler/core.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -863,24 +863,6 @@ namespace ts {
863863
return result;
864864
}
865865

866-
/**
867-
* Reduce the properties defined on a map-like (but not from its prototype chain).
868-
*
869-
* NOTE: This is intended for use with MapLike<T> objects. For Map<T> objects, use
870-
* reduceProperties instead as it offers better performance.
871-
*
872-
* @param map The map-like to reduce
873-
* @param callback An aggregation function that is called for each entry in the map
874-
* @param initial The initial value for the reduction.
875-
*/
876-
export function reduceOwnProperties<T, U>(map: MapLike<T>, callback: (aggregate: U, value: T, key: string) => U, initial: U): U {
877-
let result = initial;
878-
for (const key in map) if (hasOwnProperty.call(map, key)) {
879-
result = callback(result, map[key], String(key));
880-
}
881-
return result;
882-
}
883-
884866
/**
885867
* Performs a shallow equality comparison of the contents of two map-likes.
886868
*

src/compiler/declarationEmitter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ namespace ts {
194194
writer.writeSpace = writer.write;
195195
writer.writeStringLiteral = writer.writeLiteral;
196196
writer.writeParameter = writer.write;
197+
writer.writeProperty = writer.write;
197198
writer.writeSymbol = writer.write;
198199
setWriter(writer);
199200
}

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3165,6 +3165,10 @@
31653165
"category": "Error",
31663166
"code": 17010
31673167
},
3168+
"'super' must be called before accessing a property of 'super' in the constructor of a derived class.": {
3169+
"category": "Error",
3170+
"code": 17011
3171+
},
31683172

31693173
"Circularity detected while resolving configuration: {0}": {
31703174
"category": "Error",

0 commit comments

Comments
 (0)