Skip to content

Merge master into release branch 06/30 #9447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 45 commits into from
Jul 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
6e415cc
Merge branch 'master' of https://github.com/Microsoft/TypeScript
saschanaz Jun 25, 2016
9dfcb44
do not format comma/closeparen in jsxelement
saschanaz Jun 25, 2016
378c6b5
format jsx expression
saschanaz Jun 26, 2016
cbfbfe1
make rules optional
saschanaz Jun 27, 2016
0b6ba96
Remove upper boilerplate from issue template
RyanCavanaugh Jun 27, 2016
8bf3d54
Merge pull request #7075 from Microsoft/loadJsFromModules
billti Jun 28, 2016
8ddba28
Update issue_template.md
RyanCavanaugh Jun 28, 2016
6be7d9c
Merge pull request #9380 from Microsoft/update-template
RyanCavanaugh Jun 28, 2016
3ea2cdd
Merge pull request #8 from Microsoft/master
zspitz Jun 28, 2016
6e984eb
new options should be optional for compatibility
saschanaz Jun 28, 2016
6ff91b8
Add getCurrentDirectory to ServerHost
zhengbli Jun 28, 2016
d5cad23
Add nullchecks for typeRoots, remove getCurrentDirectory from ServerH…
zhengbli Jun 28, 2016
ec02077
Merge pull request #9361 from SaschaNaz/noFormatInJsxElement
mhegazy Jun 28, 2016
3fdaf19
VarDate interface and relevant Date.prototype members
zspitz Jun 28, 2016
a91978e
Merge pull request #9393 from zspitz/MSActiveXExtensions
mhegazy Jun 28, 2016
50177b1
Merge pull request #9396 from zhengbli/fix9186
zhengbli Jun 28, 2016
29107e6
Fix 9363: Object destructuring broken-variables are bound to the wron…
yuit Jun 28, 2016
8ff873e
Fix crash in async functions when targetting ES5.
sandersn Jun 28, 2016
ddadb47
Add This type to lib
zhengbli Jun 28, 2016
27e66b0
getVarDate should be on the Date interface
zspitz Jun 28, 2016
47bee47
Merge pull request #9401 from zhengbli/addThisToLib
zhengbli Jun 28, 2016
b524795
Merge pull request #9405 from zspitz/patch-1
mhegazy Jun 29, 2016
5f8cf1a
Don't emit source files found under node_modules
billti Jun 29, 2016
c5e680c
Destructuring assignment removes undefined from type when default val…
sandersn Jun 29, 2016
7232513
Add nullcheck when calculating indentations for implort clause
zhengbli Jun 29, 2016
adca770
Add test
zhengbli Jun 29, 2016
5a45c44
Dont load JavaScript if types packages are present
billti Jun 30, 2016
d8047b6
Renamed API
billti Jun 30, 2016
7b77f6b
Merge pull request #9397 from Microsoft/fix-crash-in-async-and-no-imp…
sandersn Jun 30, 2016
5f6e25c
Use checkExpression, not checkExpressionCached
sandersn Jun 30, 2016
0535d55
Show "<unknown>" if the name of a declaration is unavailable
Jun 30, 2016
4195eb3
Parse `export default async function` as a declaration
Jun 29, 2016
de0f64b
Merge branch 'master' into mergemaster
Jun 30, 2016
573bfec
Merge remote-tracking branch 'upstream/master' into dontEmitNodeModules
billti Jun 30, 2016
07d7ec3
Merge pull request #9422 from Microsoft/allow-destructuring-assignmen…
mhegazy Jun 30, 2016
594ad64
Merge pull request #9442 from Microsoft/navigation_bar_nameless_names…
Jun 30, 2016
ae4bb62
Merge pull request #9445 from Microsoft/export_default_async_function
Jun 30, 2016
494fada
Merge pull request #9426 from zhengbli/fix9411
zhengbli Jun 30, 2016
5e4f13f
Removed one error to avoid full path issues
billti Jun 30, 2016
9564707
Merge branch 'master' into mergemaster_0630
Jun 30, 2016
9429176
Merge branch 'release-2.0'
mhegazy Jul 1, 2016
d64ab2f
Fix incorrectly-saved quote symbols in ThirdPartyNoticeText.txt
dilijev Jul 1, 2016
a0c1084
Merge pull request #9461 from dilijev/patch-1
mhegazy Jul 1, 2016
613e2d3
Merge pull request #9421 from Microsoft/dontEmitNodeModules
billti Jul 1, 2016
94072ae
Merge branch 'master' into mergemaster_0630
Jul 1, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ThirdPartyNoticeText.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Third Party Code Components
--------------------------------------------

------------------- DefinitelyTyped --------------------
This file is based on or incorporates material from the projects listed below (collectively ?Third Party Code?). Microsoft is not the original author of the Third Party Code. The original copyright notice and the license, under which Microsoft received such Third Party Code, are set forth below. Such licenses and notices are provided for informational purposes only. Microsoft, not the third party, licenses the Third Party Code to you under the terms set forth in the EULA for the Microsoft Product. Microsoft reserves all other rights not expressly granted under this agreement, whether by implication, estoppel or otherwise.
This file is based on or incorporates material from the projects listed below (collectively "Third Party Code"). Microsoft is not the original author of the Third Party Code. The original copyright notice and the license, under which Microsoft received such Third Party Code, are set forth below. Such licenses and notices are provided for informational purposes only. Microsoft, not the third party, licenses the Third Party Code to you under the terms set forth in the EULA for the Microsoft Product. Microsoft reserves all other rights not expressly granted under this agreement, whether by implication, estoppel or otherwise.
DefinitelyTyped
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Expand Down
8 changes: 7 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12544,6 +12544,12 @@ namespace ts {
if (exprOrAssignment.kind === SyntaxKind.ShorthandPropertyAssignment) {
const prop = <ShorthandPropertyAssignment>exprOrAssignment;
if (prop.objectAssignmentInitializer) {
// In strict null checking mode, if a default value of a non-undefined type is specified, remove
// undefined from the final type.
if (strictNullChecks &&
!(getCombinedTypeFlags(checkExpression(prop.objectAssignmentInitializer)) & TypeFlags.Undefined)) {
sourceType = getTypeWithFacts(sourceType, TypeFacts.NEUndefined);
}
checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper);
}
target = (<ShorthandPropertyAssignment>exprOrAssignment).name;
Expand Down Expand Up @@ -15450,7 +15456,7 @@ namespace ts {

function isUnwrappedReturnTypeVoidOrAny(func: FunctionLikeDeclaration, returnType: Type): boolean {
const unwrappedReturnType = isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType;
return maybeTypeOfKind(unwrappedReturnType, TypeFlags.Void | TypeFlags.Any);
return unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, TypeFlags.Void | TypeFlags.Any);
}

function checkReturnStatement(node: ReturnStatement) {
Expand Down
10 changes: 5 additions & 5 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1155,12 +1155,12 @@ namespace ts {
if (token === SyntaxKind.ExportKeyword) {
nextToken();
if (token === SyntaxKind.DefaultKeyword) {
return lookAhead(nextTokenIsClassOrFunction);
return lookAhead(nextTokenIsClassOrFunctionOrAsync);
}
return token !== SyntaxKind.AsteriskToken && token !== SyntaxKind.AsKeyword && token !== SyntaxKind.OpenBraceToken && canFollowModifier();
}
if (token === SyntaxKind.DefaultKeyword) {
return nextTokenIsClassOrFunction();
return nextTokenIsClassOrFunctionOrAsync();
}
if (token === SyntaxKind.StaticKeyword) {
nextToken();
Expand All @@ -1182,9 +1182,9 @@ namespace ts {
|| isLiteralPropertyName();
}

function nextTokenIsClassOrFunction(): boolean {
function nextTokenIsClassOrFunctionOrAsync(): boolean {
nextToken();
return token === SyntaxKind.ClassKeyword || token === SyntaxKind.FunctionKeyword;
return token === SyntaxKind.ClassKeyword || token === SyntaxKind.FunctionKeyword || token === SyntaxKind.AsyncKeyword;
}

// True if positioned at the start of a list element
Expand Down Expand Up @@ -5070,7 +5070,7 @@ namespace ts {
* In such situations, 'permitInvalidConstAsModifier' should be set to true.
*/
function parseModifiers(permitInvalidConstAsModifier?: boolean): ModifiersArray {
let flags = 0;
let flags: NodeFlags = 0;
let modifiers: ModifiersArray;
while (true) {
const modifierStart = scanner.getStartPos();
Expand Down
37 changes: 22 additions & 15 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -779,13 +779,18 @@ namespace ts {
while (true) {
const baseName = getBaseFileName(directory);
if (baseName !== "node_modules") {
const result =
// first: try to load module as-is
loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) ||
// second: try to load module from the scope '@types'
loadModuleFromNodeModulesFolder(combinePaths("@types", moduleName), directory, failedLookupLocations, state);
if (result) {
return result;
// Try to load source from the package
const packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state);
if (packageResult && hasTypeScriptFileExtension(packageResult)) {
// Always prefer a TypeScript (.ts, .tsx, .d.ts) file shipped with the package
return packageResult;
}
else {
// Else prefer a types package over non-TypeScript results (e.g. JavaScript files)
const typesResult = loadModuleFromNodeModulesFolder(combinePaths("@types", moduleName), directory, failedLookupLocations, state);
if (typesResult || packageResult) {
return typesResult || packageResult;
}
}
}

Expand Down Expand Up @@ -1097,7 +1102,7 @@ namespace ts {
const modulesWithElidedImports: Map<boolean> = {};

// Track source files that are JavaScript files found by searching under node_modules, as these shouldn't be compiled.
const jsFilesFoundSearchingNodeModules: Map<boolean> = {};
const sourceFilesFoundSearchingNodeModules: Map<boolean> = {};

const start = new Date().getTime();

Expand Down Expand Up @@ -1378,7 +1383,7 @@ namespace ts {
getSourceFile: program.getSourceFile,
getSourceFileByPath: program.getSourceFileByPath,
getSourceFiles: program.getSourceFiles,
getFilesFromNodeModules: () => jsFilesFoundSearchingNodeModules,
isSourceFileFromExternalLibrary: (file: SourceFile) => !!lookUp(sourceFilesFoundSearchingNodeModules, file.path),
writeFile: writeFileCallback || (
(fileName, data, writeByteOrderMark, onError, sourceFiles) => host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles)),
isEmitBlocked,
Expand Down Expand Up @@ -2066,15 +2071,17 @@ namespace ts {
// - noResolve is falsy
// - module name comes from the list of imports
// - it's not a top level JavaScript module that exceeded the search max
const isJsFileUnderNodeModules = resolution && resolution.isExternalLibraryImport &&
hasJavaScriptFileExtension(resolution.resolvedFileName);
const isFromNodeModulesSearch = resolution && resolution.isExternalLibraryImport;
const isJsFileFromNodeModules = isFromNodeModulesSearch && hasJavaScriptFileExtension(resolution.resolvedFileName);

if (isJsFileUnderNodeModules) {
jsFilesFoundSearchingNodeModules[resolvedPath] = true;
if (isFromNodeModulesSearch) {
sourceFilesFoundSearchingNodeModules[resolvedPath] = true;
}
if (isJsFileFromNodeModules) {
currentNodeModulesJsDepth++;
}

const elideImport = isJsFileUnderNodeModules && currentNodeModulesJsDepth > maxNodeModulesJsDepth;
const elideImport = isJsFileFromNodeModules && currentNodeModulesJsDepth > maxNodeModulesJsDepth;
const shouldAddFile = resolution && !options.noResolve && i < file.imports.length && !elideImport;

if (elideImport) {
Expand All @@ -2089,7 +2096,7 @@ namespace ts {
file.imports[i].end);
}

if (isJsFileUnderNodeModules) {
if (isJsFileFromNodeModules) {
currentNodeModulesJsDepth--;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ namespace ts {
}

export interface ModifiersArray extends NodeArray<Modifier> {
flags: number;
flags: NodeFlags;
}

// @kind(SyntaxKind.AbstractKeyword)
Expand Down
8 changes: 3 additions & 5 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace ts {
getSourceFiles(): SourceFile[];

/* @internal */
getFilesFromNodeModules(): Map<boolean>;
isSourceFileFromExternalLibrary(file: SourceFile): boolean;

getCommonSourceDirectory(): string;
getCanonicalFileName(fileName: string): string;
Expand Down Expand Up @@ -2277,10 +2277,9 @@ namespace ts {
}
else {
const sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile];
const nodeModulesFiles = host.getFilesFromNodeModules();
for (const sourceFile of sourceFiles) {
// Don't emit if source file is a declaration file, or was located under node_modules
if (!isDeclarationFile(sourceFile) && !lookUp(nodeModulesFiles, sourceFile.path)) {
if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) {
onSingleFileEmit(host, sourceFile);
}
}
Expand Down Expand Up @@ -2314,10 +2313,9 @@ namespace ts {
function onBundledEmit(host: EmitHost) {
// Can emit only sources that are not declaration file and are either non module code or module with
// --module or --target es6 specified. Files included by searching under node_modules are also not emitted.
const nodeModulesFiles = host.getFilesFromNodeModules();
const bundledSources = filter(host.getSourceFiles(),
sourceFile => !isDeclarationFile(sourceFile) &&
!lookUp(nodeModulesFiles, sourceFile.path) &&
!host.isSourceFileFromExternalLibrary(sourceFile) &&
(!isExternalModule(sourceFile) ||
!!getEmitModuleKind(options)));
if (bundledSources.length) {
Expand Down
Loading