Skip to content

Commit 725bda8

Browse files
Merge branch 'master' into stringLiteralTypes
2 parents ebc47d5 + 302db0a commit 725bda8

312 files changed

Lines changed: 16912 additions & 745 deletions

File tree

Some content is hidden

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

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
language: node_js
22

33
node_js:
4+
- '4'
45
- '0.10'
56

6-
sudo: false
7+
sudo: false

lib/lib.core.es6.d.ts

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3965,34 +3965,7 @@ interface ObjectConstructor {
39653965
* Copy the values of all of the enumerable own properties from one or more source objects to a
39663966
* target object. Returns the target object.
39673967
* @param target The target object to copy to.
3968-
* @param source The source object from which to copy properties.
3969-
*/
3970-
assign<T, U>(target: T, source: U): T & U;
3971-
3972-
/**
3973-
* Copy the values of all of the enumerable own properties from one or more source objects to a
3974-
* target object. Returns the target object.
3975-
* @param target The target object to copy to.
3976-
* @param source1 The first source object from which to copy properties.
3977-
* @param source2 The second source object from which to copy properties.
3978-
*/
3979-
assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
3980-
3981-
/**
3982-
* Copy the values of all of the enumerable own properties from one or more source objects to a
3983-
* target object. Returns the target object.
3984-
* @param target The target object to copy to.
3985-
* @param source1 The first source object from which to copy properties.
3986-
* @param source2 The second source object from which to copy properties.
3987-
* @param source3 The third source object from which to copy properties.
3988-
*/
3989-
assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
3990-
3991-
/**
3992-
* Copy the values of all of the enumerable own properties from one or more source objects to a
3993-
* target object. Returns the target object.
3994-
* @param target The target object to copy to.
3995-
* @param sources One or more source objects from which to copy properties
3968+
* @param sources One or more source objects to copy properties from.
39963969
*/
39973970
assign(target: any, ...sources: any[]): any;
39983971

src/compiler/binder.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,9 @@ namespace ts {
185185
function declareSymbol(symbolTable: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol {
186186
Debug.assert(!hasDynamicName(node));
187187

188+
let isDefaultExport = node.flags & NodeFlags.Default;
188189
// The exported symbol for an export default function/class node is always named "default"
189-
let name = node.flags & NodeFlags.Default && parent ? "default" : getDeclarationName(node);
190+
let name = isDefaultExport && parent ? "default" : getDeclarationName(node);
190191

191192
let symbol: Symbol;
192193
if (name !== undefined) {
@@ -227,6 +228,13 @@ namespace ts {
227228
let message = symbol.flags & SymbolFlags.BlockScopedVariable
228229
? Diagnostics.Cannot_redeclare_block_scoped_variable_0
229230
: Diagnostics.Duplicate_identifier_0;
231+
232+
forEach(symbol.declarations, declaration => {
233+
if (declaration.flags & NodeFlags.Default) {
234+
message = Diagnostics.A_module_cannot_have_multiple_default_exports;
235+
}
236+
});
237+
230238
forEach(symbol.declarations, declaration => {
231239
file.bindDiagnostics.push(createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration)));
232240
});

src/compiler/checker.ts

Lines changed: 145 additions & 76 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ namespace ts {
7777
"system": ModuleKind.System,
7878
"umd": ModuleKind.UMD,
7979
"es6": ModuleKind.ES6,
80+
"es2015": ModuleKind.ES2015,
8081
},
8182
description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6,
8283
paramType: Diagnostics.KIND,
@@ -205,7 +206,12 @@ namespace ts {
205206
{
206207
name: "target",
207208
shortName: "t",
208-
type: { "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5, "es6": ScriptTarget.ES6 },
209+
type: {
210+
"es3": ScriptTarget.ES3,
211+
"es5": ScriptTarget.ES5,
212+
"es6": ScriptTarget.ES6,
213+
"es2015": ScriptTarget.ES2015,
214+
},
209215
description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental,
210216
paramType: Diagnostics.VERSION,
211217
error: Diagnostics.Argument_for_target_option_must_be_ES3_ES5_or_ES6
@@ -222,11 +228,6 @@ namespace ts {
222228
type: "boolean",
223229
description: Diagnostics.Watch_input_files,
224230
},
225-
{
226-
name: "experimentalAsyncFunctions",
227-
type: "boolean",
228-
description: Diagnostics.Enables_experimental_support_for_ES7_async_functions
229-
},
230231
{
231232
name: "experimentalDecorators",
232233
type: "boolean",
@@ -389,15 +390,15 @@ namespace ts {
389390
catch (e) {
390391
return { error: createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) };
391392
}
392-
return parseConfigFileText(fileName, text);
393+
return parseConfigFileTextToJson(fileName, text);
393394
}
394395

395396
/**
396397
* Parse the text of the tsconfig.json file
397398
* @param fileName The path to the config file
398399
* @param jsonText The text of the config file
399400
*/
400-
export function parseConfigFileText(fileName: string, jsonText: string): { config?: any; error?: Diagnostic } {
401+
export function parseConfigFileTextToJson(fileName: string, jsonText: string): { config?: any; error?: Diagnostic } {
401402
try {
402403
return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} };
403404
}
@@ -412,7 +413,7 @@ namespace ts {
412413
* @param basePath A root directory to resolve relative path entries in the config
413414
* file to. e.g. outDir
414415
*/
415-
export function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine {
416+
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine {
416417
let errors: Diagnostic[] = [];
417418

418419
return {

src/compiler/core.ts

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,12 @@ namespace ts {
437437
}
438438

439439
export function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain {
440-
Debug.assert(!headChain.next);
441-
headChain.next = tailChain;
440+
let lastChain = headChain;
441+
while (lastChain.next) {
442+
lastChain = lastChain.next;
443+
}
444+
445+
lastChain.next = tailChain;
442446
return headChain;
443447
}
444448

@@ -700,6 +704,9 @@ namespace ts {
700704
}
701705

702706
export function getBaseFileName(path: string) {
707+
if (!path) {
708+
return undefined;
709+
}
703710
let i = path.lastIndexOf(directorySeparator);
704711
return i < 0 ? path : path.substring(i + 1);
705712
}
@@ -722,6 +729,23 @@ namespace ts {
722729
* List of supported extensions in order of file resolution precedence.
723730
*/
724731
export const supportedExtensions = [".ts", ".tsx", ".d.ts"];
732+
/**
733+
* List of extensions that will be used to look for external modules.
734+
* This list is kept separate from supportedExtensions to for cases when we'll allow to include .js files in compilation,
735+
* but still would like to load only TypeScript files as modules
736+
*/
737+
export const moduleFileExtensions = supportedExtensions;
738+
739+
export function isSupportedSourceFileName(fileName: string) {
740+
if (!fileName) { return false; }
741+
742+
for (let extension of supportedExtensions) {
743+
if (fileExtensionIs(fileName, extension)) {
744+
return true;
745+
}
746+
}
747+
return false;
748+
}
725749

726750
const extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"];
727751
export function removeFileExtension(path: string): string {
@@ -817,4 +841,14 @@ namespace ts {
817841
Debug.assert(false, message);
818842
}
819843
}
820-
}
844+
845+
export function copyListRemovingItem<T>(item: T, list: T[]) {
846+
let copiedList: T[] = [];
847+
for (var i = 0, len = list.length; i < len; i++) {
848+
if (list[i] !== item) {
849+
copiedList.push(list[i]);
850+
}
851+
}
852+
return copiedList;
853+
}
854+
}

src/compiler/diagnosticMessages.json

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -783,10 +783,6 @@
783783
"category": "Error",
784784
"code": 1245
785785
},
786-
"Experimental support for async functions is a feature that is subject to change in a future release. Specify '--experimentalAsyncFunctions' to remove this warning.": {
787-
"category": "Error",
788-
"code": 1246
789-
},
790786

791787
"'with' statements are not allowed in an async function block.": {
792788
"category": "Error",
@@ -800,6 +796,10 @@
800796
"category": "Error",
801797
"code": 1311
802798
},
799+
"'=' can only be used in an object literal property inside a destructuring assignment.": {
800+
"category": "Error",
801+
"code": 1312
802+
},
803803
"Duplicate identifier '{0}'.": {
804804
"category": "Error",
805805
"code": 2300
@@ -1656,6 +1656,10 @@
16561656
"category": "Error",
16571657
"code": 2527
16581658
},
1659+
"A module cannot have multiple default exports.": {
1660+
"category": "Error",
1661+
"code": 2528
1662+
},
16591663
"JSX element attributes type '{0}' must be an object type.": {
16601664
"category": "Error",
16611665
"code": 2600
@@ -2274,10 +2278,6 @@
22742278
"category": "Message",
22752279
"code": 6066
22762280
},
2277-
"Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower.": {
2278-
"category": "Message",
2279-
"code": 6067
2280-
},
22812281
"Enables experimental support for ES7 async functions.": {
22822282
"category": "Message",
22832283
"code": 6068
@@ -2469,5 +2469,13 @@
24692469
"A constructor cannot contain a 'super' call when its class extends 'null'": {
24702470
"category": "Error",
24712471
"code": 17005
2472+
},
2473+
"An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.": {
2474+
"category": "Error",
2475+
"code": 17006
2476+
},
2477+
"A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.": {
2478+
"category": "Error",
2479+
"code": 17007
24722480
}
24732481
}

0 commit comments

Comments
 (0)