Skip to content

Merge master 08/22 #10487

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 73 commits into from
Aug 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
dfee3de
Add test case for #8229
sheetalkamat Apr 21, 2016
90d347e
Do not report errors during contextual typecheck
sheetalkamat Apr 21, 2016
34f7f2c
Handle the scenario when let [a=undefined]=[]
sheetalkamat Apr 22, 2016
ad56220
Instantiate contextual this parameters if needed
sandersn Jul 14, 2016
78f807c
Test that contextually typed generic this parameters are instantiated
sandersn Jul 14, 2016
448a480
Don't allow `.ts` to appear in an import
Jul 12, 2016
a8c05a9
Add specific error message for unwanted '.ts' extension
Jul 12, 2016
95e391e
Allow `await` in a simple unary expression
Jul 22, 2016
bc5c7b6
More tests
Jul 22, 2016
275dbc7
Forbid `await await`
Jul 22, 2016
52fd033
Allow `await await`
Jul 25, 2016
2821d98
Merge branch 'master' into no_ts_extension
Aug 2, 2016
0f134ed
Improve error message
Aug 2, 2016
359c8b1
Don't allow ".d.ts" extension in an import either.
Aug 3, 2016
3de8c22
Merge branch 'master' into no_ts_extension
Aug 15, 2016
2eb159e
Rename 'find' functions
Aug 15, 2016
02f908a
Merge branch 'master' into noImplicitAnyDestructuring
sheetalkamat Aug 16, 2016
271ffc8
Merge branch 'master' into instantiate-this-for-contextually-typed-ty…
sandersn Aug 17, 2016
0f483d6
Assign and instantiate contextual this type if not present
sandersn Aug 17, 2016
aa834d7
JSDoc supports null, undefined and never types
sandersn Aug 17, 2016
164beb3
Update baselines in jsDocParsing unit tests
sandersn Aug 17, 2016
d24afc2
Return non-JsDocComment children
zhengbli Aug 18, 2016
8fc17af
Move supportedTypescriptExtensionsWithDtsFirst next to supportedTypeS…
Aug 18, 2016
952d2fe
Fix comment
Aug 18, 2016
a621c09
Merge pull request #8241 from Microsoft/noImplicitAnyDestructuring
mhegazy Aug 18, 2016
03dcdda
Treat special property access symbol differently
Aug 19, 2016
297cb50
Merge branch 'master' into no_ts_extension
Aug 19, 2016
b452469
Fix tests
Aug 19, 2016
b482fa5
Merge branch 'master' into cast_of_await
Aug 19, 2016
19cde06
Merge pull request #9890 from Microsoft/cast_of_await
Aug 19, 2016
d2d5d42
Merge pull request #9646 from Microsoft/no_ts_extension
Aug 19, 2016
7f6e36c
Update shim version to be 2.1 (#10424)
yuit Aug 19, 2016
0168ab2
Check return code paths on getters (#10102)
weswigham Aug 19, 2016
da6d951
Remove extraneous arguments from harness's runBaseline (#10419)
weswigham Aug 19, 2016
6c60e5b
Remove needless call to basename
RyanCavanaugh Aug 19, 2016
def29f6
Merge pull request #10439 from RyanCavanaugh/fixJakeBaselineAccept
RyanCavanaugh Aug 19, 2016
8ad2744
Refactor baseliners out of compiler runner (#10440)
weswigham Aug 19, 2016
057357b
CR feedback
Aug 19, 2016
a5bb13f
fix broken tests
Aug 19, 2016
a531b87
Pass in baselineOpts into types baselines so that RWC baselines can b…
yuit Aug 20, 2016
d8ab098
Merge pull request #10426 from zhengbli/9518
zhengbli Aug 20, 2016
eeec775
Add more test for 10426
zhengbli Aug 21, 2016
794d3e9
routine update of dom libs
zhengbli Aug 21, 2016
66f6f9b
Merge pull request #10458 from zhengbli/betterTestForModuleExportDOc
zhengbli Aug 21, 2016
e445e01
Add test for jsdoc syntactic classification for function declaration
zhengbli Aug 21, 2016
6d2323b
Simplify implementation
zhengbli Aug 21, 2016
84386f9
Tolerate certain errors in tsconfig.json
zhengbli Aug 21, 2016
b207417
Add test for configFile error tolerance
zhengbli Aug 21, 2016
a8ab52f
Use TS parser to tolerate more errors in tsconfig.json
zhengbli Aug 21, 2016
582d8b8
Implement tuple types as type references to synthesized generic types
ahejlsberg Aug 21, 2016
7d82c22
Add comments + minor changes
ahejlsberg Aug 21, 2016
2e8d11e
Accept new baselines
ahejlsberg Aug 22, 2016
05fef61
Add .types extension
Aug 22, 2016
4e56fc0
Properly guard for undefined in getTypeReferenceArity
ahejlsberg Aug 22, 2016
2c814f4
Add jsdoc nullable union test case to fourslash
sandersn Aug 22, 2016
bb6c6fd
Merge pull request #10478 from Microsoft/fixtypesRWC
mhegazy Aug 22, 2016
2013058
Fix class/interface merging issue + lint error
ahejlsberg Aug 22, 2016
92eb8df
Allow "typings" in a package.json to be missing its extension (but al…
Aug 22, 2016
ec1f6b1
Merge pull request #10480 from Microsoft/typings_extension_is_optional
Aug 22, 2016
a013759
Merge pull request #10399 from Microsoft/jsdoc-never-undefined-null-t…
sandersn Aug 22, 2016
5aafc2c
Contextually type this in getDeclFromSig, not checkThisExpr
sandersn Aug 22, 2016
4a58e68
Update parser comment with es7 grammar (#10459)
yuit Aug 22, 2016
3fb0840
Merge pull request #10466 from Microsoft/tupleTypeReferences
ahejlsberg Aug 22, 2016
6f722b0
Merge pull request #10441 from zhengbli/routineUpdate819
zhengbli Aug 22, 2016
d133b0e
Merge pull request #10407 from zhengbli/fixJsDocSyntacticClassification
mhegazy Aug 22, 2016
edbeab0
Merge pull request #10418 from zhengbli/tolerateConfigError
zhengbli Aug 22, 2016
046b55e
allowSyntheticDefaultImports resolves to modules instead of variables
sandersn Aug 22, 2016
fc1d6a8
Rename getContextuallyTypedThisParameter to getContextualThisParameter
sandersn Aug 22, 2016
36130ff
Fix 10472: Invalid emitted code for await expression (#10483)
yuit Aug 22, 2016
f028fa3
Merge pull request #9746 from Microsoft/instantiate-this-for-contextu…
sandersn Aug 22, 2016
93de502
Merge pull request #10486 from Microsoft/allowSyntheticDefaultImports…
sandersn Aug 22, 2016
5990da0
Merge branch 'master' into mergeMaster_08/22
Aug 22, 2016
5fbb820
Merge branch 'master' into mergeMaster_08/22
Aug 23, 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 Gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ function restoreSavedNodeEnv() {
process.env.NODE_ENV = savedNodeEnv;
}

let testTimeout = 20000;
let testTimeout = 40000;
function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: (e?: any) => void) {
const lintFlag = cmdLineOptions["lint"];
cleanTestDirs((err) => {
Expand Down
235 changes: 128 additions & 107 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1817,6 +1817,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
else if (node.parent.kind === SyntaxKind.ConditionalExpression && (<ConditionalExpression>node.parent).condition === node) {
return true;
}
else if (node.parent.kind === SyntaxKind.PrefixUnaryExpression || node.parent.kind === SyntaxKind.DeleteExpression ||
node.parent.kind === SyntaxKind.TypeOfExpression || node.parent.kind === SyntaxKind.VoidExpression) {
return true;
}

return false;
}
Expand Down
56 changes: 39 additions & 17 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ namespace ts {
// Note: it is not actually necessary to save/restore the context flags here. That's
// because the saving/restoring of these flags happens naturally through the recursive
// descent nature of our parser. However, we still store this here just so we can
// assert that that invariant holds.
// assert that invariant holds.
const saveContextFlags = contextFlags;

// If we're only looking ahead, then tell the scanner to only lookahead as well.
Expand Down Expand Up @@ -2765,7 +2765,7 @@ namespace ts {
// Note: for ease of implementation we treat productions '2' and '3' as the same thing.
// (i.e. they're both BinaryExpressions with an assignment operator in it).

// First, do the simple check if we have a YieldExpression (production '5').
// First, do the simple check if we have a YieldExpression (production '6').
if (isYieldExpression()) {
return parseYieldExpression();
}
Expand Down Expand Up @@ -3373,24 +3373,40 @@ namespace ts {
}

/**
* Parse ES7 unary expression and await expression
* Parse ES7 exponential expression and await expression
*
* ES7 ExponentiationExpression:
* 1) UnaryExpression[?Yield]
* 2) UpdateExpression[?Yield] ** ExponentiationExpression[?Yield]
*
* ES7 UnaryExpression:
* 1) SimpleUnaryExpression[?yield]
* 2) IncrementExpression[?yield] ** UnaryExpression[?yield]
*/
function parseUnaryExpressionOrHigher(): UnaryExpression | BinaryExpression {
if (isAwaitExpression()) {
return parseAwaitExpression();
}

if (isIncrementExpression()) {
/**
* ES7 UpdateExpression:
* 1) LeftHandSideExpression[?Yield]
* 2) LeftHandSideExpression[?Yield][no LineTerminator here]++
* 3) LeftHandSideExpression[?Yield][no LineTerminator here]--
* 4) ++UnaryExpression[?Yield]
* 5) --UnaryExpression[?Yield]
*/
if (isUpdateExpression()) {
const incrementExpression = parseIncrementExpression();
return token() === SyntaxKind.AsteriskAsteriskToken ?
<BinaryExpression>parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) :
incrementExpression;
}

/**
* ES7 UnaryExpression:
* 1) UpdateExpression[?yield]
* 2) delete UpdateExpression[?yield]
* 3) void UpdateExpression[?yield]
* 4) typeof UpdateExpression[?yield]
* 5) + UpdateExpression[?yield]
* 6) - UpdateExpression[?yield]
* 7) ~ UpdateExpression[?yield]
* 8) ! UpdateExpression[?yield]
*/
const unaryOperator = token();
const simpleUnaryExpression = parseSimpleUnaryExpression();
if (token() === SyntaxKind.AsteriskAsteriskToken) {
Expand All @@ -3408,8 +3424,8 @@ namespace ts {
/**
* Parse ES7 simple-unary expression or higher:
*
* ES7 SimpleUnaryExpression:
* 1) IncrementExpression[?yield]
* ES7 UnaryExpression:
* 1) UpdateExpression[?yield]
* 2) delete UnaryExpression[?yield]
* 3) void UnaryExpression[?yield]
* 4) typeof UnaryExpression[?yield]
Expand All @@ -3432,13 +3448,15 @@ namespace ts {
return parseTypeOfExpression();
case SyntaxKind.VoidKeyword:
return parseVoidExpression();
case SyntaxKind.AwaitKeyword:
return parseAwaitExpression();
case SyntaxKind.LessThanToken:
// This is modified UnaryExpression grammar in TypeScript
// UnaryExpression (modified):
// < type > UnaryExpression
return parseTypeAssertion();
case SyntaxKind.AwaitKeyword:
if (isAwaitExpression()) {
return parseAwaitExpression();
}
default:
return parseIncrementExpression();
}
Expand All @@ -3447,14 +3465,14 @@ namespace ts {
/**
* Check if the current token can possibly be an ES7 increment expression.
*
* ES7 IncrementExpression:
* ES7 UpdateExpression:
* LeftHandSideExpression[?Yield]
* LeftHandSideExpression[?Yield][no LineTerminator here]++
* LeftHandSideExpression[?Yield][no LineTerminator here]--
* ++LeftHandSideExpression[?Yield]
* --LeftHandSideExpression[?Yield]
*/
function isIncrementExpression(): boolean {
function isUpdateExpression(): boolean {
// This function is called inside parseUnaryExpression to decide
// whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly
switch (token()) {
Expand All @@ -3465,6 +3483,7 @@ namespace ts {
case SyntaxKind.DeleteKeyword:
case SyntaxKind.TypeOfKeyword:
case SyntaxKind.VoidKeyword:
case SyntaxKind.AwaitKeyword:
return false;
case SyntaxKind.LessThanToken:
// If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression
Expand Down Expand Up @@ -5893,6 +5912,9 @@ namespace ts {
case SyntaxKind.BooleanKeyword:
case SyntaxKind.SymbolKeyword:
case SyntaxKind.VoidKeyword:
case SyntaxKind.NullKeyword:
case SyntaxKind.UndefinedKeyword:
case SyntaxKind.NeverKeyword:
return parseTokenNode<JSDocType>();
case SyntaxKind.StringLiteral:
case SyntaxKind.NumericLiteral:
Expand Down
6 changes: 4 additions & 2 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,8 +721,10 @@ namespace ts {
const typesFile = tryReadTypesSection(packageJsonPath, candidate, state);
if (typesFile) {
const onlyRecordFailures = !directoryProbablyExists(getDirectoryPath(typesFile), state.host);
// The package.json "typings" property must specify the file with extension, so just try that exact filename.
const result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures, state);
// A package.json "typings" may specify an exact filename, or may choose to omit an extension.
const result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures, state) ||
tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures, state);

if (result) {
return result;
}
Expand Down
12 changes: 5 additions & 7 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ namespace ts {
JSDocPropertyTag,
JSDocTypeLiteral,
JSDocLiteralType,
JSDocNullKeyword,
JSDocUndefinedKeyword,
JSDocNeverKeyword,

// Synthesized list
SyntaxList,
Expand Down Expand Up @@ -383,7 +386,7 @@ namespace ts {
FirstJSDocNode = JSDocTypeExpression,
LastJSDocNode = JSDocLiteralType,
FirstJSDocTagNode = JSDocComment,
LastJSDocTagNode = JSDocLiteralType
LastJSDocTagNode = JSDocNeverKeyword
}

export const enum NodeFlags {
Expand Down Expand Up @@ -2263,7 +2266,7 @@ namespace ts {
Class = 1 << 15, // Class
Interface = 1 << 16, // Interface
Reference = 1 << 17, // Generic type reference
Tuple = 1 << 18, // Tuple
Tuple = 1 << 18, // Synthesized generic tuple type
Union = 1 << 19, // Union (T | U)
Intersection = 1 << 20, // Intersection (T & U)
Anonymous = 1 << 21, // Anonymous
Expand Down Expand Up @@ -2385,11 +2388,6 @@ namespace ts {
instantiations: Map<TypeReference>; // Generic instantiation cache
}

export interface TupleType extends ObjectType {
elementTypes: Type[]; // Element types
thisType?: Type; // This-type of tuple (only needed for tuples that are constraints of type parameters)
}

export interface UnionOrIntersectionType extends Type {
types: Type[]; // Constituent types
/* @internal */
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ namespace ts {
return node.kind >= SyntaxKind.FirstJSDocNode && node.kind <= SyntaxKind.LastJSDocNode;
}

export function isJSDocTag(node: Node) {
return node.kind >= SyntaxKind.FirstJSDocTagNode && node.kind <= SyntaxKind.LastJSDocTagNode;
}

export function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFile): number {
if (nodeIsMissing(node) || !node.decorators) {
return getTokenPosOfNode(node, sourceFile);
Expand Down
12 changes: 6 additions & 6 deletions src/harness/rwcRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ namespace RWC {


it("has the expected emitted code", () => {
Harness.Baseline.runBaseline(baseName + ".output.js", () => {
Harness.Baseline.runBaseline(`${baseName}.output.js`, () => {
return Harness.Compiler.collateOutputs(compilerResult.files);
}, baselineOpts);
});

it("has the expected declaration file content", () => {
Harness.Baseline.runBaseline(baseName + ".d.ts", () => {
Harness.Baseline.runBaseline(`${baseName}.d.ts`, () => {
if (!compilerResult.declFilesCode.length) {
return null;
}
Expand All @@ -174,7 +174,7 @@ namespace RWC {
});

it("has the expected source maps", () => {
Harness.Baseline.runBaseline(baseName + ".map", () => {
Harness.Baseline.runBaseline(`${baseName}.map`, () => {
if (!compilerResult.sourceMaps.length) {
return null;
}
Expand All @@ -192,7 +192,7 @@ namespace RWC {
});*/

it("has the expected errors", () => {
Harness.Baseline.runBaseline(baseName + ".errors.txt", () => {
Harness.Baseline.runBaseline(`${baseName}.errors.txt`, () => {
if (compilerResult.errors.length === 0) {
return null;
}
Expand All @@ -207,7 +207,7 @@ namespace RWC {
// declaration file errors as part of the baseline.
it("has the expected errors in generated declaration files", () => {
if (compilerOptions.declaration && !compilerResult.errors.length) {
Harness.Baseline.runBaseline(baseName + ".dts.errors.txt", () => {
Harness.Baseline.runBaseline(`${baseName}.dts.errors.txt`, () => {
const declFileCompilationResult = Harness.Compiler.compileDeclarationFiles(
inputFiles, otherFiles, compilerResult, /*harnessSettings*/ undefined, compilerOptions, currentDirectory);

Expand All @@ -223,7 +223,7 @@ namespace RWC {
});

it("has the expected types", () => {
Harness.Compiler.doTypeAndSymbolBaseline(baseName, compilerResult, inputFiles
Harness.Compiler.doTypeAndSymbolBaseline(`${baseName}.types`, compilerResult, inputFiles
.concat(otherFiles)
.filter(file => !!compilerResult.program.getSourceFile(file.unitName))
.filter(e => !Harness.isDefaultLibraryFile(e.unitName)), baselineOpts);
Expand Down
24 changes: 5 additions & 19 deletions src/harness/unittests/jsDocParsing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -767,33 +767,19 @@ namespace ts {
parsesCorrectly(
"{null}",
`{
"kind": "JSDocTypeReference",
"kind": "NullKeyword",
"pos": 1,
"end": 5,
"name": {
"kind": "Identifier",
"pos": 1,
"end": 5,
"originalKeywordKind": "NullKeyword",
"text": "null"
}
"end": 5
}`);
});

it("keyword3", () => {
parsesCorrectly(
"{undefined}",
`{
"kind": "JSDocTypeReference",
"kind": "UndefinedKeyword",
"pos": 1,
"end": 10,
"name": {
"kind": "Identifier",
"pos": 1,
"end": 10,
"originalKeywordKind": "UndefinedKeyword",
"text": "undefined"
}
"end": 10
}`);
});

Expand Down Expand Up @@ -2379,4 +2365,4 @@ namespace ts {
});
});
});
}
}
20 changes: 20 additions & 0 deletions src/harness/unittests/tsconfigParsing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,5 +181,25 @@ namespace ts {
["/d.ts", "/folder/e.ts"]
);
});

it("parse and re-emit tsconfig.json file with diagnostics", () => {
const content = `{
"compilerOptions": {
"allowJs": true
"outDir": "bin"
}
"files": ["file1.ts"]
}`;
const { configJsonObject, diagnostics } = parseAndReEmitConfigJSONFile(content);
const expectedResult = {
compilerOptions: {
allowJs: true,
outDir: "bin"
},
files: ["file1.ts"]
};
assert.isTrue(diagnostics.length === 2);
assert.equal(JSON.stringify(configJsonObject), JSON.stringify(expectedResult));
});
});
}
18 changes: 18 additions & 0 deletions src/harness/unittests/tsserverProjectSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,5 +623,23 @@ namespace ts {
checkNumberOfConfiguredProjects(projectService, 1);
checkNumberOfInferredProjects(projectService, 0);
});

it("should tolerate config file errors and still try to build a project", () => {
const configFile: FileOrFolder = {
path: "/a/b/tsconfig.json",
content: `{
"compilerOptions": {
"target": "es6",
"allowAnything": true
},
"someOtherProperty": {}
}`
};
const host = new TestServerHost(/*useCaseSensitiveFileNames*/ false, getExecutingFilePathFromLibFile(libFile), "/", [commonFile1, commonFile2, libFile, configFile]);
const projectService = new server.ProjectService(host, nullLogger);
projectService.openClientFile(commonFile1.path);
checkNumberOfConfiguredProjects(projectService, 1);
checkConfiguredProjectRootFiles(projectService.configuredProjects[0], [commonFile1.path, commonFile2.path]);
});
});
}
Loading