Skip to content

Commit 8dc25db

Browse files
committed
Merge branch 'builder' into tsserverEventChangedFiles
2 parents 92f6611 + 60e2e68 commit 8dc25db

File tree

3,718 files changed

+8696
-7879
lines changed

Some content is hidden

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

3,718 files changed

+8696
-7879
lines changed

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ Jakefile.js
1616
.gitattributes
1717
.settings/
1818
.travis.yml
19-
.vscode/
19+
.vscode/
20+
test.config

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "typescript",
33
"author": "Microsoft Corp.",
44
"homepage": "http://typescriptlang.org/",
5-
"version": "2.5.0",
5+
"version": "2.6.0",
66
"license": "Apache-2.0",
77
"description": "TypeScript is a language for application scale JavaScript development",
88
"keywords": [

src/compiler/checker.ts

Lines changed: 49 additions & 46 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ namespace ts {
11161116
if (option && !isString(option.type)) {
11171117
const customOption = <CommandLineOptionOfCustomType>option;
11181118
// Validate custom option type
1119-
if (!customOption.type.has(text)) {
1119+
if (!customOption.type.has(text.toLowerCase())) {
11201120
errors.push(
11211121
createDiagnosticForInvalidCustomType(
11221122
customOption,
@@ -1822,7 +1822,7 @@ namespace ts {
18221822
return value;
18231823
}
18241824
else if (!isString(option.type)) {
1825-
return option.type.get(value);
1825+
return option.type.get(isString(value) ? value.toLowerCase() : value);
18261826
}
18271827
return normalizeNonListOptionValue(option, basePath, value);
18281828
}

src/compiler/core.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace ts {
55
// WARNING: The script `configureNightly.ts` uses a regexp to parse out these values.
66
// If changing the text in this section, be sure to test `configureNightly` too.
7-
export const versionMajorMinor = "2.5";
7+
export const versionMajorMinor = "2.6";
88
/** The version of the TypeScript compiler release */
99
export const version = `${versionMajorMinor}.0`;
1010
}
@@ -1573,16 +1573,20 @@ namespace ts {
15731573
}
15741574

15751575
export function normalizePath(path: string): string {
1576+
return normalizePathAndParts(path).path;
1577+
}
1578+
1579+
export function normalizePathAndParts(path: string): { path: string, parts: string[] } {
15761580
path = normalizeSlashes(path);
15771581
const rootLength = getRootLength(path);
15781582
const root = path.substr(0, rootLength);
1579-
const normalized = getNormalizedParts(path, rootLength);
1580-
if (normalized.length) {
1581-
const joinedParts = root + normalized.join(directorySeparator);
1582-
return pathEndsWithDirectorySeparator(path) ? joinedParts + directorySeparator : joinedParts;
1583+
const parts = getNormalizedParts(path, rootLength);
1584+
if (parts.length) {
1585+
const joinedParts = root + parts.join(directorySeparator);
1586+
return { path: pathEndsWithDirectorySeparator(path) ? joinedParts + directorySeparator : joinedParts, parts };
15831587
}
15841588
else {
1585-
return root;
1589+
return { path: root, parts };
15861590
}
15871591
}
15881592

src/compiler/declarationEmitter.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,6 @@ namespace ts {
349349
errorNameNode = declaration.name;
350350
const format = TypeFormatFlags.UseTypeOfFunction |
351351
TypeFormatFlags.WriteClassExpressionAsTypeLiteral |
352-
TypeFormatFlags.UseTypeAliasValue |
353352
(shouldUseResolverType ? TypeFormatFlags.AddUndefined : 0);
354353
resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, format, writer);
355354
errorNameNode = undefined;
@@ -368,7 +367,7 @@ namespace ts {
368367
resolver.writeReturnTypeOfSignatureDeclaration(
369368
signature,
370369
enclosingDeclaration,
371-
TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue | TypeFormatFlags.WriteClassExpressionAsTypeLiteral,
370+
TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.WriteClassExpressionAsTypeLiteral,
372371
writer);
373372
errorNameNode = undefined;
374373
}
@@ -633,7 +632,7 @@ namespace ts {
633632
resolver.writeTypeOfExpression(
634633
expr,
635634
enclosingDeclaration,
636-
TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue | TypeFormatFlags.WriteClassExpressionAsTypeLiteral,
635+
TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.WriteClassExpressionAsTypeLiteral,
637636
writer);
638637
write(";");
639638
writeLine();

src/compiler/moduleNameResolver.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ namespace ts {
201201
let resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined;
202202
if (resolved) {
203203
if (!options.preserveSymlinks) {
204-
resolved = realpath(resolved, host, traceEnabled);
204+
resolved = realPath(resolved, host, traceEnabled);
205205
}
206206

207207
if (traceEnabled) {
@@ -741,20 +741,21 @@ namespace ts {
741741

742742
let resolvedValue = resolved.value;
743743
if (!compilerOptions.preserveSymlinks) {
744-
resolvedValue = resolvedValue && { ...resolved.value, path: realpath(resolved.value.path, host, traceEnabled), extension: resolved.value.extension };
744+
resolvedValue = resolvedValue && { ...resolved.value, path: realPath(resolved.value.path, host, traceEnabled), extension: resolved.value.extension };
745745
}
746746
// For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files.
747747
return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
748748
}
749749
else {
750-
const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
750+
const { path: candidate, parts } = normalizePathAndParts(combinePaths(containingDirectory, moduleName));
751751
const resolved = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state, /*considerPackageJson*/ true);
752-
return resolved && toSearchResult({ resolved, isExternalLibraryImport: false });
752+
// Treat explicit "node_modules" import as an external library import.
753+
return resolved && toSearchResult({ resolved, isExternalLibraryImport: contains(parts, "node_modules") });
753754
}
754755
}
755756
}
756757

757-
function realpath(path: string, host: ModuleResolutionHost, traceEnabled: boolean): string {
758+
function realPath(path: string, host: ModuleResolutionHost, traceEnabled: boolean): string {
758759
if (!host.realpath) {
759760
return path;
760761
}

src/compiler/transformers/es2015.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ namespace ts {
840840
outer.end = skipTrivia(currentText, node.pos);
841841
setEmitFlags(outer, EmitFlags.NoComments);
842842

843-
return createParen(
843+
const result = createParen(
844844
createCall(
845845
outer,
846846
/*typeArguments*/ undefined,
@@ -849,6 +849,8 @@ namespace ts {
849849
: []
850850
)
851851
);
852+
addSyntheticLeadingComment(result, SyntaxKind.MultiLineCommentTrivia, "* @class ");
853+
return result;
852854
}
853855

854856
/**

src/compiler/transformers/ts.ts

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,17 @@ namespace ts {
151151
break;
152152
}
153153

154-
recordEmittedDeclarationInScope(node);
154+
// Record these declarations provided that they have a name.
155+
if ((node as ClassDeclaration | FunctionDeclaration).name) {
156+
recordEmittedDeclarationInScope(node as ClassDeclaration | FunctionDeclaration);
157+
}
158+
else {
159+
// These nodes should always have names unless they are default-exports;
160+
// however, class declaration parsing allows for undefined names, so syntactically invalid
161+
// programs may also have an undefined name.
162+
Debug.assert(node.kind === SyntaxKind.ClassDeclaration || hasModifier(node, ModifierFlags.Default));
163+
}
164+
155165
break;
156166
}
157167
}
@@ -2639,36 +2649,33 @@ namespace ts {
26392649
/**
26402650
* Records that a declaration was emitted in the current scope, if it was the first
26412651
* declaration for the provided symbol.
2642-
*
2643-
* NOTE: if there is ever a transformation above this one, we may not be able to rely
2644-
* on symbol names.
26452652
*/
2646-
function recordEmittedDeclarationInScope(node: Node) {
2647-
const name = node.symbol && node.symbol.escapedName;
2648-
if (name) {
2649-
if (!currentScopeFirstDeclarationsOfName) {
2650-
currentScopeFirstDeclarationsOfName = createUnderscoreEscapedMap<Node>();
2651-
}
2653+
function recordEmittedDeclarationInScope(node: FunctionDeclaration | ClassDeclaration | ModuleDeclaration | EnumDeclaration) {
2654+
if (!currentScopeFirstDeclarationsOfName) {
2655+
currentScopeFirstDeclarationsOfName = createUnderscoreEscapedMap<Node>();
2656+
}
26522657

2653-
if (!currentScopeFirstDeclarationsOfName.has(name)) {
2654-
currentScopeFirstDeclarationsOfName.set(name, node);
2655-
}
2658+
const name = declaredNameInScope(node);
2659+
if (!currentScopeFirstDeclarationsOfName.has(name)) {
2660+
currentScopeFirstDeclarationsOfName.set(name, node);
26562661
}
26572662
}
26582663

26592664
/**
2660-
* Determines whether a declaration is the first declaration with the same name emitted
2661-
* in the current scope.
2665+
* Determines whether a declaration is the first declaration with
2666+
* the same name emitted in the current scope.
26622667
*/
2663-
function isFirstEmittedDeclarationInScope(node: Node) {
2668+
function isFirstEmittedDeclarationInScope(node: ModuleDeclaration | EnumDeclaration) {
26642669
if (currentScopeFirstDeclarationsOfName) {
2665-
const name = node.symbol && node.symbol.escapedName;
2666-
if (name) {
2667-
return currentScopeFirstDeclarationsOfName.get(name) === node;
2668-
}
2670+
const name = declaredNameInScope(node);
2671+
return currentScopeFirstDeclarationsOfName.get(name) === node;
26692672
}
2673+
return true;
2674+
}
26702675

2671-
return false;
2676+
function declaredNameInScope(node: FunctionDeclaration | ClassDeclaration | ModuleDeclaration | EnumDeclaration): __String {
2677+
Debug.assertNode(node.name, isIdentifier);
2678+
return (node.name as Identifier).escapedText;
26722679
}
26732680

26742681
/**
@@ -2746,7 +2753,7 @@ namespace ts {
27462753
return createNotEmittedStatement(node);
27472754
}
27482755

2749-
Debug.assert(isIdentifier(node.name), "TypeScript module should have an Identifier name.");
2756+
Debug.assertNode(node.name, isIdentifier, "A TypeScript namespace should have an Identifier name.");
27502757
enableSubstitutionForNamespaceExports();
27512758

27522759
const statements: Statement[] = [];

src/compiler/types.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2569,6 +2569,15 @@ namespace ts {
25692569
getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
25702570
getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined;
25712571
getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol | undefined;
2572+
/**
2573+
* If a symbol is a local symbol with an associated exported symbol, returns the exported symbol.
2574+
* Otherwise returns its input.
2575+
* For example, at `export type T = number;`:
2576+
* - `getSymbolAtLocation` at the location `T` will return the exported symbol for `T`.
2577+
* - But the result of `getSymbolsInScope` will contain the *local* symbol for `T`, not the exported symbol.
2578+
* - Calling `getExportSymbolOfSymbol` on that local symbol will return the exported symbol.
2579+
*/
2580+
getExportSymbolOfSymbol(symbol: Symbol): Symbol;
25722581
getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined;
25732582
getTypeAtLocation(node: Node): Type;
25742583
getTypeFromTypeNode(node: TypeNode): Type;
@@ -2709,11 +2718,12 @@ namespace ts {
27092718
UseFullyQualifiedType = 1 << 8, // Write out the fully qualified type name (eg. Module.Type, instead of Type)
27102719
InFirstTypeArgument = 1 << 9, // Writing first type argument of the instantiated type
27112720
InTypeAlias = 1 << 10, // Writing type in type alias declaration
2712-
UseTypeAliasValue = 1 << 11, // Serialize the type instead of using type-alias. This is needed when we emit declaration file.
27132721
SuppressAnyReturnType = 1 << 12, // If the return type is any-like, don't offer a return type.
27142722
AddUndefined = 1 << 13, // Add undefined to types of initialized, non-optional parameters
27152723
WriteClassExpressionAsTypeLiteral = 1 << 14, // Write a type literal instead of (Anonymous class)
27162724
InArrayType = 1 << 15, // Writing an array element type
2725+
UseAliasDefinedOutsideCurrentScope = 1 << 16, // For a `type T = ... ` defined in a different file, write `T` instead of its value,
2726+
// even though `T` can't be accessed in the current scope.
27172727
}
27182728

27192729
export const enum SymbolFormatFlags {
@@ -2922,7 +2932,7 @@ namespace ts {
29222932

29232933
export interface Symbol {
29242934
flags: SymbolFlags; // Symbol flags
2925-
escapedName: __String; // Name of symbol
2935+
escapedName: __String; // Name of symbol
29262936
declarations?: Declaration[]; // Declarations associated with this symbol
29272937
valueDeclaration?: Declaration; // First value declaration of the symbol
29282938
members?: SymbolTable; // Class, interface or literal instance members
@@ -3127,7 +3137,7 @@ namespace ts {
31273137
/* @internal */
31283138
ContainsObjectLiteral = 1 << 22, // Type is or contains object literal type
31293139
/* @internal */
3130-
ContainsAnyFunctionType = 1 << 23, // Type is or contains object literal type
3140+
ContainsAnyFunctionType = 1 << 23, // Type is or contains the anyFunctionType
31313141
NonPrimitive = 1 << 24, // intrinsic object type
31323142
/* @internal */
31333143
JsxAttributes = 1 << 25, // Jsx attributes type
@@ -3962,12 +3972,7 @@ namespace ts {
39623972
export interface ResolvedModule {
39633973
/** Path of the file the module was resolved to. */
39643974
resolvedFileName: string;
3965-
/**
3966-
* Denotes if 'resolvedFileName' is isExternalLibraryImport and thus should be a proper external module:
3967-
* - be a .d.ts file
3968-
* - use top level imports\exports
3969-
* - don't use tripleslash references
3970-
*/
3975+
/** True if `resolvedFileName` comes from `node_modules`. */
39713976
isExternalLibraryImport?: boolean;
39723977
}
39733978

0 commit comments

Comments
 (0)