Skip to content

Commit 69118cd

Browse files
author
Arthur Ozga
committed
Merge branch 'master' into interfaceFixes
* resolved conflicts with 4/ interface for codefixes
2 parents 389959a + 52ec508 commit 69118cd

File tree

118 files changed

+6190
-4264
lines changed

Some content is hidden

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

118 files changed

+6190
-4264
lines changed

Jakefile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ task("importDefinitelyTypedTests", [importDefinitelyTypedTestsJs], function () {
649649

650650
// Local target to build the compiler and services
651651
var tscFile = path.join(builtLocalDirectory, compilerFilename);
652-
compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false);
652+
compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false, { noMapRoot: true });
653653

654654
var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
655655
var servicesFileInBrowserTest = path.join(builtLocalDirectory, "typescriptServicesInBrowserTest.js");

issue_template.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->
33
<!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->
44

5-
**TypeScript Version:** 2.0.3 / nightly (2.1.0-dev.201xxxxx)
5+
**TypeScript Version:** 2.1.1 / nightly (2.2.0-dev.201xxxxx)
66

77
**Code**
88

@@ -13,4 +13,4 @@
1313

1414
**Expected behavior:**
1515

16-
**Actual behavior:**
16+
**Actual behavior:**

src/compiler/binder.ts

Lines changed: 99 additions & 51 deletions
Large diffs are not rendered by default.

src/compiler/checker.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ namespace ts {
108108
getEmitResolver,
109109
getExportsOfModule: getExportsOfModuleAsArray,
110110
getAmbientModules,
111-
112111
getJsxElementAttributesType,
113112
getJsxIntrinsicTagNames,
114113
isOptionalParameter,
114+
tryGetMemberInModuleExports,
115115
tryFindAmbientModuleWithoutAugmentations: moduleName => {
116116
// we deliberately exclude augmentations
117117
// since we are only interested in declarations of the module itself
@@ -1489,6 +1489,13 @@ namespace ts {
14891489
return symbolsToArray(getExportsOfModule(moduleSymbol));
14901490
}
14911491

1492+
function tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined {
1493+
const symbolTable = getExportsOfModule(moduleSymbol);
1494+
if (symbolTable) {
1495+
return symbolTable[memberName];
1496+
}
1497+
}
1498+
14921499
function getExportsOfSymbol(symbol: Symbol): SymbolTable {
14931500
return symbol.flags & SymbolFlags.Module ? getExportsOfModule(symbol) : symbol.exports || emptySymbols;
14941501
}
@@ -3040,7 +3047,7 @@ namespace ts {
30403047
}
30413048

30423049
function isComputedNonLiteralName(name: PropertyName): boolean {
3043-
return name.kind === SyntaxKind.ComputedPropertyName && !isStringOrNumericLiteral((<ComputedPropertyName>name).expression.kind);
3050+
return name.kind === SyntaxKind.ComputedPropertyName && !isStringOrNumericLiteral((<ComputedPropertyName>name).expression);
30443051
}
30453052

30463053
function getRestType(source: Type, properties: PropertyName[], symbol: Symbol): Type {
@@ -3091,7 +3098,7 @@ namespace ts {
30913098
}
30923099
const literalMembers: PropertyName[] = [];
30933100
for (const element of pattern.elements) {
3094-
if (element.kind !== SyntaxKind.OmittedExpression && !(element as BindingElement).dotDotDotToken) {
3101+
if (!(element as BindingElement).dotDotDotToken) {
30953102
literalMembers.push(element.propertyName || element.name as Identifier);
30963103
}
30973104
}
@@ -4504,6 +4511,8 @@ namespace ts {
45044511
const members: SymbolTable = createMap<Symbol>();
45054512
let stringIndexInfo: IndexInfo;
45064513
let numberIndexInfo: IndexInfo;
4514+
// Resolve upfront such that recursive references see an empty object type.
4515+
setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, undefined, undefined);
45074516
// In { [P in K]: T }, we refer to P as the type parameter type, K as the constraint type,
45084517
// and T as the template type.
45094518
const typeParameter = getTypeParameterFromMappedType(type);
@@ -8944,7 +8953,7 @@ namespace ts {
89448953
return type;
89458954
}
89468955

8947-
function getTypeOfDestructuredProperty(type: Type, name: Identifier | LiteralExpression | ComputedPropertyName) {
8956+
function getTypeOfDestructuredProperty(type: Type, name: PropertyName) {
89488957
const text = getTextOfPropertyName(name);
89498958
return getTypeOfPropertyOfType(type, text) ||
89508959
isNumericLiteralName(text) && getIndexTypeOfType(type, IndexKind.Number) ||
@@ -14238,9 +14247,7 @@ namespace ts {
1423814247
}
1423914248
}
1424014249
else if (property.kind === SyntaxKind.SpreadAssignment) {
14241-
if (property.expression.kind !== SyntaxKind.Identifier) {
14242-
error(property.expression, Diagnostics.An_object_rest_element_must_be_an_identifier);
14243-
}
14250+
checkReferenceExpression(property.expression, Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access);
1424414251
}
1424514252
else {
1424614253
error(property, Diagnostics.Property_assignment_expected);
@@ -14761,7 +14768,7 @@ namespace ts {
1476114768
function checkDeclarationInitializer(declaration: VariableLikeDeclaration) {
1476214769
const type = checkExpressionCached(declaration.initializer);
1476314770
return getCombinedNodeFlags(declaration) & NodeFlags.Const ||
14764-
getCombinedModifierFlags(declaration) & ModifierFlags.Readonly ||
14771+
getCombinedModifierFlags(declaration) & ModifierFlags.Readonly && !isParameterPropertyDeclaration(declaration) ||
1476514772
isTypeAssertion(declaration.initializer) ? type : getWidenedLiteralType(type);
1476614773
}
1476714774

@@ -19649,7 +19656,7 @@ namespace ts {
1964919656

1965019657
function isNameOfModuleOrEnumDeclaration(node: Identifier) {
1965119658
const parent = node.parent;
19652-
return isModuleOrEnumDeclaration(parent) && node === parent.name;
19659+
return parent && isModuleOrEnumDeclaration(parent) && node === parent.name;
1965319660
}
1965419661

1965519662
// When resolved as an expression identifier, if the given node references an exported entity, return the declaration

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ namespace ts {
884884
function tryExtendsName(extendedConfig: string): [string[], string[], string[], CompilerOptions] {
885885
// If the path isn't a rooted or relative path, don't try to resolve it (we reserve the right to special case module-id like paths in the future)
886886
if (!(isRootedDiskPath(extendedConfig) || startsWith(normalizeSlashes(extendedConfig), "./") || startsWith(normalizeSlashes(extendedConfig), "../"))) {
887-
errors.push(createCompilerDiagnostic(Diagnostics.The_path_in_an_extends_options_must_be_relative_or_rooted));
887+
errors.push(createCompilerDiagnostic(Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig));
888888
return;
889889
}
890890
let extendedConfigPath = toPath(extendedConfig, basePath, getCanonicalFileName);

src/compiler/core.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ namespace ts {
571571
*/
572572
export function append<T>(to: T[] | undefined, value: T | undefined): T[] | undefined {
573573
if (value === undefined) return to;
574-
if (to === undefined) to = [];
574+
if (to === undefined) return [value];
575575
to.push(value);
576576
return to;
577577
}
@@ -592,6 +592,16 @@ namespace ts {
592592
return to;
593593
}
594594

595+
/**
596+
* Stable sort of an array. Elements equal to each other maintain their relative position in the array.
597+
*/
598+
export function stableSort<T>(array: T[], comparer: (x: T, y: T) => Comparison = compareValues) {
599+
return array
600+
.map((_, i) => i) // create array of indices
601+
.sort((x, y) => comparer(array[x], array[y]) || compareValues(x, y)) // sort indices by value then position
602+
.map(i => array[i]); // get sorted array
603+
}
604+
595605
export function rangeEquals<T>(array1: T[], array2: T[], pos: number, end: number) {
596606
while (pos < end) {
597607
if (array1[pos] !== array2[pos]) {
@@ -816,6 +826,13 @@ namespace ts {
816826
}
817827
}
818828

829+
export function appendProperty<T>(map: Map<T>, key: string | number, value: T): Map<T> {
830+
if (key === undefined || value === undefined) return map;
831+
if (map === undefined) map = createMap<T>();
832+
map[key] = value;
833+
return map;
834+
}
835+
819836
export function assign<T1 extends MapLike<{}>, T2, T3>(t: T1, arg1: T2, arg2: T3): T1 & T2 & T3;
820837
export function assign<T1 extends MapLike<{}>, T2>(t: T1, arg1: T2): T1 & T2;
821838
export function assign<T1 extends MapLike<{}>>(t: T1, ...args: any[]): any;
@@ -1374,6 +1391,14 @@ namespace ts {
13741391
getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015 ? ModuleKind.ES2015 : ModuleKind.CommonJS;
13751392
}
13761393

1394+
export function getEmitModuleResolutionKind(compilerOptions: CompilerOptions) {
1395+
let moduleResolution = compilerOptions.moduleResolution;
1396+
if (moduleResolution === undefined) {
1397+
moduleResolution = getEmitModuleKind(compilerOptions) === ModuleKind.CommonJS ? ModuleResolutionKind.NodeJs : ModuleResolutionKind.Classic;
1398+
}
1399+
return moduleResolution;
1400+
}
1401+
13771402
/* @internal */
13781403
export function hasZeroOrOneAsteriskCharacter(str: string): boolean {
13791404
let seenAsterisk = false;
@@ -2092,6 +2117,17 @@ namespace ts {
20922117
}
20932118

20942119
/** Remove an item from an array, moving everything to its right one space left. */
2120+
export function orderedRemoveItem<T>(array: T[], item: T): boolean {
2121+
for (let i = 0; i < array.length; i++) {
2122+
if (array[i] === item) {
2123+
orderedRemoveItemAt(array, i);
2124+
return true;
2125+
}
2126+
}
2127+
return false;
2128+
}
2129+
2130+
/** Remove an item by index from an array, moving everything to its right one space left. */
20952131
export function orderedRemoveItemAt<T>(array: T[], index: number): void {
20962132
// This seems to be faster than either `array.splice(i, 1)` or `array.copyWithin(i, i+ 1)`.
20972133
for (let i = index; i < array.length - 1; i++) {

src/compiler/diagnosticMessages.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,7 @@
19911991
"category": "Error",
19921992
"code": 2700
19931993
},
1994-
"An object rest element must be an identifier.": {
1994+
"The target of an object rest assignment must be a variable or a property access.": {
19951995
"category": "Error",
19961996
"code": 2701
19971997
},
@@ -3142,7 +3142,7 @@
31423142
"category": "Error",
31433143
"code": 18000
31443144
},
3145-
"The path in an 'extends' options must be relative or rooted.": {
3145+
"A path in an 'extends' option must be relative or rooted, but '{0}' is not.": {
31463146
"category": "Error",
31473147
"code": 18001
31483148
},
@@ -3190,5 +3190,17 @@
31903190
"Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated.": {
31913191
"category": "Error",
31923192
"code": 90010
3193+
},
3194+
"Import {0} from {1}": {
3195+
"category": "Message",
3196+
"code": 90013
3197+
},
3198+
"Change {0} to {1}": {
3199+
"category": "Message",
3200+
"code": 90014
3201+
},
3202+
"Add {0} to existing import declaration from {1}": {
3203+
"category": "Message",
3204+
"code": 90015
31933205
}
31943206
}

0 commit comments

Comments
 (0)