Skip to content

Commit 78f2593

Browse files
committed
Merge branch 'master' into release-2.0
2 parents c7c3158 + b8963ba commit 78f2593

File tree

10 files changed

+95
-5
lines changed

10 files changed

+95
-5
lines changed

lib/tsserver.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46785,6 +46785,7 @@ var ts;
4678546785
if (objectLikeContainer.kind === 171) {
4678646786
isNewIdentifierLocation = true;
4678746787
typeForObject = typeChecker.getContextualType(objectLikeContainer);
46788+
typeForObject = typeForObject && typeForObject.getNonNullableType();
4678846789
existingMembers = objectLikeContainer.properties;
4678946790
}
4679046791
else if (objectLikeContainer.kind === 167) {

lib/tsserverlibrary.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46785,6 +46785,7 @@ var ts;
4678546785
if (objectLikeContainer.kind === 171) {
4678646786
isNewIdentifierLocation = true;
4678746787
typeForObject = typeChecker.getContextualType(objectLikeContainer);
46788+
typeForObject = typeForObject && typeForObject.getNonNullableType();
4678846789
existingMembers = objectLikeContainer.properties;
4678946790
}
4679046791
else if (objectLikeContainer.kind === 167) {

lib/typescript.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41058,6 +41058,21 @@ var ts;
4105841058
emitSignatureParameters(ctor);
4105941059
}
4106041060
else {
41061+
// The ES2015 spec specifies in 14.5.14. Runtime Semantics: ClassDefinitionEvaluation:
41062+
// If constructor is empty, then
41063+
// If ClassHeritag_eopt is present and protoParent is not null, then
41064+
// Let constructor be the result of parsing the source text
41065+
// constructor(...args) { super (...args);}
41066+
// using the syntactic grammar with the goal symbol MethodDefinition[~Yield].
41067+
// Else,
41068+
// Let constructor be the result of parsing the source text
41069+
// constructor( ){ }
41070+
// using the syntactic grammar with the goal symbol MethodDefinition[~Yield].
41071+
//
41072+
// While we could emit the '...args' rest parameter, certain later tools in the pipeline might
41073+
// downlevel the '...args' portion less efficiently by naively copying the contents of 'arguments' to an array.
41074+
// Instead, we'll avoid using a rest parameter and spread into the super call as
41075+
// 'super(...arguments)' instead of 'super(...args)', as you can see below.
4106141076
write("()");
4106241077
}
4106341078
}
@@ -41092,6 +41107,7 @@ var ts;
4109241107
write("_super.apply(this, arguments);");
4109341108
}
4109441109
else {
41110+
// See comment above on using '...arguments' instead of '...args'.
4109541111
write("super(...arguments);");
4109641112
}
4109741113
emitEnd(baseTypeElement);
@@ -55629,7 +55645,10 @@ var ts;
5562955645
// We are completing on contextual types, but may also include properties
5563055646
// other than those within the declared type.
5563155647
isNewIdentifierLocation = true;
55648+
// If the object literal is being assigned to something of type 'null | { hello: string }',
55649+
// it clearly isn't trying to satisfy the 'null' type. So we grab the non-nullable type if possible.
5563255650
typeForObject = typeChecker.getContextualType(objectLikeContainer);
55651+
typeForObject = typeForObject && typeForObject.getNonNullableType();
5563355652
existingMembers = objectLikeContainer.properties;
5563455653
}
5563555654
else if (objectLikeContainer.kind === 167 /* ObjectBindingPattern */) {
@@ -55640,7 +55659,7 @@ var ts;
5564055659
// We don't want to complete using the type acquired by the shape
5564155660
// of the binding pattern; we are only interested in types acquired
5564255661
// through type declaration or inference.
55643-
// Also proceed if rootDeclaration is parameter and if its containing function expression\arrow function is contextually typed -
55662+
// Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed -
5564455663
// type of parameter will flow in from the contextual type of the function
5564555664
var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type);
5564655665
if (!canGetType && rootDeclaration.kind === 142 /* Parameter */) {

lib/typescriptServices.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41058,6 +41058,21 @@ var ts;
4105841058
emitSignatureParameters(ctor);
4105941059
}
4106041060
else {
41061+
// The ES2015 spec specifies in 14.5.14. Runtime Semantics: ClassDefinitionEvaluation:
41062+
// If constructor is empty, then
41063+
// If ClassHeritag_eopt is present and protoParent is not null, then
41064+
// Let constructor be the result of parsing the source text
41065+
// constructor(...args) { super (...args);}
41066+
// using the syntactic grammar with the goal symbol MethodDefinition[~Yield].
41067+
// Else,
41068+
// Let constructor be the result of parsing the source text
41069+
// constructor( ){ }
41070+
// using the syntactic grammar with the goal symbol MethodDefinition[~Yield].
41071+
//
41072+
// While we could emit the '...args' rest parameter, certain later tools in the pipeline might
41073+
// downlevel the '...args' portion less efficiently by naively copying the contents of 'arguments' to an array.
41074+
// Instead, we'll avoid using a rest parameter and spread into the super call as
41075+
// 'super(...arguments)' instead of 'super(...args)', as you can see below.
4106141076
write("()");
4106241077
}
4106341078
}
@@ -41092,6 +41107,7 @@ var ts;
4109241107
write("_super.apply(this, arguments);");
4109341108
}
4109441109
else {
41110+
// See comment above on using '...arguments' instead of '...args'.
4109541111
write("super(...arguments);");
4109641112
}
4109741113
emitEnd(baseTypeElement);
@@ -55629,7 +55645,10 @@ var ts;
5562955645
// We are completing on contextual types, but may also include properties
5563055646
// other than those within the declared type.
5563155647
isNewIdentifierLocation = true;
55648+
// If the object literal is being assigned to something of type 'null | { hello: string }',
55649+
// it clearly isn't trying to satisfy the 'null' type. So we grab the non-nullable type if possible.
5563255650
typeForObject = typeChecker.getContextualType(objectLikeContainer);
55651+
typeForObject = typeForObject && typeForObject.getNonNullableType();
5563355652
existingMembers = objectLikeContainer.properties;
5563455653
}
5563555654
else if (objectLikeContainer.kind === 167 /* ObjectBindingPattern */) {
@@ -55640,7 +55659,7 @@ var ts;
5564055659
// We don't want to complete using the type acquired by the shape
5564155660
// of the binding pattern; we are only interested in types acquired
5564255661
// through type declaration or inference.
55643-
// Also proceed if rootDeclaration is parameter and if its containing function expression\arrow function is contextually typed -
55662+
// Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed -
5564455663
// type of parameter will flow in from the contextual type of the function
5564555664
var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type);
5564655665
if (!canGetType && rootDeclaration.kind === 142 /* Parameter */) {

scripts/ior.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference path="../src/harness/external/node.d.ts" />
1+
/// <reference types="node"/>
22

33
import fs = require('fs');
44
import path = require('path');

src/compiler/emitter.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5311,6 +5311,21 @@ const _super = (function (geti, seti) {
53115311
emitSignatureParameters(ctor);
53125312
}
53135313
else {
5314+
// The ES2015 spec specifies in 14.5.14. Runtime Semantics: ClassDefinitionEvaluation:
5315+
// If constructor is empty, then
5316+
// If ClassHeritag_eopt is present and protoParent is not null, then
5317+
// Let constructor be the result of parsing the source text
5318+
// constructor(...args) { super (...args);}
5319+
// using the syntactic grammar with the goal symbol MethodDefinition[~Yield].
5320+
// Else,
5321+
// Let constructor be the result of parsing the source text
5322+
// constructor( ){ }
5323+
// using the syntactic grammar with the goal symbol MethodDefinition[~Yield].
5324+
//
5325+
// While we could emit the '...args' rest parameter, certain later tools in the pipeline might
5326+
// downlevel the '...args' portion less efficiently by naively copying the contents of 'arguments' to an array.
5327+
// Instead, we'll avoid using a rest parameter and spread into the super call as
5328+
// 'super(...arguments)' instead of 'super(...args)', as you can see below.
53145329
write("()");
53155330
}
53165331
}
@@ -5349,6 +5364,7 @@ const _super = (function (geti, seti) {
53495364
write("_super.apply(this, arguments);");
53505365
}
53515366
else {
5367+
// See comment above on using '...arguments' instead of '...args'.
53525368
write("super(...arguments);");
53535369
}
53545370
emitEnd(baseTypeElement);

src/compiler/program.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace ts {
66
/** The version of the TypeScript compiler release */
7+
78
export const version = "2.0.2";
89

910
const emptyArray: any[] = [];

src/harness/rwcRunner.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ namespace RWC {
198198
}
199199
// Do not include the library in the baselines to avoid noise
200200
const baselineFiles = inputFiles.concat(otherFiles).filter(f => !Harness.isDefaultLibraryFile(f.unitName));
201-
return Harness.Compiler.getErrorBaseline(baselineFiles, compilerResult.errors);
201+
const errors = compilerResult.errors.filter(e => !Harness.isDefaultLibraryFile(e.file.fileName));
202+
return Harness.Compiler.getErrorBaseline(baselineFiles, errors);
202203
}, false, baselineOpts);
203204
});
204205

src/services/services.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3789,7 +3789,11 @@ namespace ts {
37893789
// other than those within the declared type.
37903790
isNewIdentifierLocation = true;
37913791

3792+
// If the object literal is being assigned to something of type 'null | { hello: string }',
3793+
// it clearly isn't trying to satisfy the 'null' type. So we grab the non-nullable type if possible.
37923794
typeForObject = typeChecker.getContextualType(<ObjectLiteralExpression>objectLikeContainer);
3795+
typeForObject = typeForObject && typeForObject.getNonNullableType();
3796+
37933797
existingMembers = (<ObjectLiteralExpression>objectLikeContainer).properties;
37943798
}
37953799
else if (objectLikeContainer.kind === SyntaxKind.ObjectBindingPattern) {
@@ -3801,7 +3805,7 @@ namespace ts {
38013805
// We don't want to complete using the type acquired by the shape
38023806
// of the binding pattern; we are only interested in types acquired
38033807
// through type declaration or inference.
3804-
// Also proceed if rootDeclaration is parameter and if its containing function expression\arrow function is contextually typed -
3808+
// Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed -
38053809
// type of parameter will flow in from the contextual type of the function
38063810
let canGetType = !!(rootDeclaration.initializer || rootDeclaration.type);
38073811
if (!canGetType && rootDeclaration.kind === SyntaxKind.Parameter) {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
// @strictNullChecks: true
4+
////interface Thing {
5+
//// hello: number;
6+
//// world: string;
7+
////}
8+
////
9+
////declare function funcA(x : Thing): void;
10+
////declare function funcB(x?: Thing): void;
11+
////declare function funcC(x : Thing | null): void;
12+
////declare function funcD(x : Thing | undefined): void;
13+
////declare function funcE(x : Thing | null | undefined): void;
14+
////declare function funcF(x?: Thing | null | undefined): void;
15+
////
16+
////funcA({ /*A*/ });
17+
////funcB({ /*B*/ });
18+
////funcC({ /*C*/ });
19+
////funcD({ /*D*/ });
20+
////funcE({ /*E*/ });
21+
////funcF({ /*F*/ });
22+
23+
24+
for (const marker of test.markers()) {
25+
goTo.position(marker.position);
26+
verify.completionListContains("hello");
27+
verify.completionListContains("world");
28+
}

0 commit comments

Comments
 (0)