Skip to content

Commit 1217ca7

Browse files
author
Arthur Ozga
committed
Merge branch 'master' into ImplementMissingThis
2 parents 2c3369e + 359823b commit 1217ca7

19 files changed

+194
-92
lines changed

src/compiler/transformers/esnext.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,12 @@ namespace ts {
357357
const values = createAsyncValuesHelper(context, expression, /*location*/ node.expression);
358358
const next = createYield(
359359
/*asteriskToken*/ undefined,
360-
createArrayLiteral([
361-
createLiteral("await"),
362-
createCall(createPropertyAccess(iterator, "next" ), /*typeArguments*/ undefined, [])
363-
])
360+
enclosingFunctionFlags & FunctionFlags.Generator
361+
? createArrayLiteral([
362+
createLiteral("await"),
363+
createCall(createPropertyAccess(iterator, "next" ), /*typeArguments*/ undefined, [])
364+
])
365+
: createCall(createPropertyAccess(iterator, "next" ), /*typeArguments*/ undefined, [])
364366
);
365367

366368
hoistVariableDeclaration(errorRecord);
@@ -431,10 +433,12 @@ namespace ts {
431433
createStatement(
432434
createYield(
433435
/*asteriskToken*/ undefined,
434-
createArrayLiteral([
435-
createLiteral("await"),
436-
createFunctionCall(returnMethod, iterator, [])
437-
])
436+
enclosingFunctionFlags & FunctionFlags.Generator
437+
? createArrayLiteral([
438+
createLiteral("await"),
439+
createFunctionCall(returnMethod, iterator, [])
440+
])
441+
: createFunctionCall(returnMethod, iterator, [])
438442
)
439443
)
440444
),
@@ -872,6 +876,7 @@ namespace ts {
872876
scoped: false,
873877
text: `
874878
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
879+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
875880
var g = generator.apply(thisArg, _arguments || []), q = [], c, i;
876881
return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i;
877882
function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }
@@ -932,6 +937,7 @@ namespace ts {
932937
scoped: false,
933938
text: `
934939
var __asyncValues = (this && this.__asyncIterator) || function (o) {
940+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
935941
var m = o[Symbol.asyncIterator];
936942
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator]();
937943
};

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3035,6 +3035,33 @@ namespace ts.projectSystem {
30353035
const inferredProject = projectService.inferredProjects[0];
30363036
assert.isTrue(inferredProject.containsFile(<server.NormalizedPath>file1.path));
30373037
});
3038+
3039+
it("should be able to handle @types if input file list is empty", () => {
3040+
const f = {
3041+
path: "/a/app.ts",
3042+
content: "let x = 1"
3043+
};
3044+
const config = {
3045+
path: "/a/tsconfig.json",
3046+
content: JSON.stringify({
3047+
compiler: {},
3048+
files: []
3049+
})
3050+
};
3051+
const t1 = {
3052+
path: "/a/node_modules/@types/typings/index.d.ts",
3053+
content: `export * from "./lib"`
3054+
};
3055+
const t2 = {
3056+
path: "/a/node_modules/@types/typings/lib.d.ts",
3057+
content: `export const x: number`
3058+
};
3059+
const host = createServerHost([f, config, t1, t2], { currentDirectory: getDirectoryPath(f.path) });
3060+
const projectService = createProjectService(host);
3061+
3062+
projectService.openClientFile(f.path);
3063+
projectService.checkNumberOfProjects({ configuredProjects: 1, inferredProjects: 1 });
3064+
});
30383065
});
30393066

30403067
describe("reload", () => {

src/lib/es5.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ interface ObjectConstructor {
140140
* Creates an object that has the specified prototype or that has null prototype.
141141
* @param o Object to use as a prototype. May be null.
142142
*/
143-
create<T extends object>(o: T | null): T | object;
143+
create(o: object | null): any;
144144

145145
/**
146146
* Creates an object that has the specified prototype, and that optionally contains specified properties.

src/server/editorServices.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,9 +948,9 @@ namespace ts.server {
948948

949949
private openConfigFile(configFileName: NormalizedPath, clientFileName?: string): OpenConfigFileResult {
950950
const conversionResult = this.convertConfigFileContentToProjectOptions(configFileName);
951-
const projectOptions = conversionResult.success
951+
const projectOptions: ProjectOptions = conversionResult.success
952952
? conversionResult.projectOptions
953-
: { files: [], compilerOptions: {} };
953+
: { files: [], compilerOptions: {}, typeAcquisition: { enable: false } };
954954
const project = this.createAndAddConfiguredProject(configFileName, projectOptions, conversionResult.configFileErrors, clientFileName);
955955
return {
956956
success: conversionResult.success,

src/server/protocol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ namespace ts.server.protocol {
820820
* Represents a file in external project.
821821
* External project is project whose set of files, compilation options and open\close state
822822
* is maintained by the client (i.e. if all this data come from .csproj file in Visual Studio).
823-
* External project will exist even if all files in it are closed and should be closed explicity.
823+
* External project will exist even if all files in it are closed and should be closed explicitly.
824824
* If external project includes one or more tsconfig.json/jsconfig.json files then tsserver will
825825
* create configured project for every config file but will maintain a link that these projects were created
826826
* as a result of opening external project so they should be removed once external project is closed.

src/server/session.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,9 @@ namespace ts.server {
14121412
}
14131413

14141414
private getCodeFixes(args: protocol.CodeFixRequestArgs, simplifiedResult: boolean): protocol.CodeAction[] | CodeAction[] {
1415+
if (args.errorCodes.length === 0) {
1416+
return undefined;
1417+
}
14151418
const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args);
14161419

14171420
const scriptInfo = project.getScriptInfoForNormalizedPath(file);

tests/baselines/reference/assigningFromObjectToAnythingElse.errors.txt

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
tests/cases/compiler/assigningFromObjectToAnythingElse.ts(3,1): error TS2322: Type 'Object' is not assignable to type 'RegExp'.
22
The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?
33
Property 'exec' is missing in type 'Object'.
4-
tests/cases/compiler/assigningFromObjectToAnythingElse.ts(5,5): error TS2322: Type 'object | Object' is not assignable to type 'String'.
5-
Type 'object' is not assignable to type 'String'.
6-
Property 'charAt' is missing in type '{}'.
7-
tests/cases/compiler/assigningFromObjectToAnythingElse.ts(6,5): error TS2322: Type 'object | Number' is not assignable to type 'String'.
8-
Type 'object' is not assignable to type 'String'.
4+
tests/cases/compiler/assigningFromObjectToAnythingElse.ts(5,17): error TS2346: Supplied parameters do not match any signature of call target.
5+
tests/cases/compiler/assigningFromObjectToAnythingElse.ts(6,17): error TS2346: Supplied parameters do not match any signature of call target.
96
tests/cases/compiler/assigningFromObjectToAnythingElse.ts(8,5): error TS2322: Type 'Object' is not assignable to type 'Error'.
107
The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?
118
Property 'name' is missing in type 'Object'.
@@ -21,14 +18,11 @@ tests/cases/compiler/assigningFromObjectToAnythingElse.ts(8,5): error TS2322: Ty
2118
!!! error TS2322: Property 'exec' is missing in type 'Object'.
2219

2320
var a: String = Object.create<Object>("");
24-
~
25-
!!! error TS2322: Type 'object | Object' is not assignable to type 'String'.
26-
!!! error TS2322: Type 'object' is not assignable to type 'String'.
27-
!!! error TS2322: Property 'charAt' is missing in type '{}'.
21+
~~~~~~~~~~~~~~~~~~~~~~~~~
22+
!!! error TS2346: Supplied parameters do not match any signature of call target.
2823
var c: String = Object.create<Number>(1);
29-
~
30-
!!! error TS2322: Type 'object | Number' is not assignable to type 'String'.
31-
!!! error TS2322: Type 'object' is not assignable to type 'String'.
24+
~~~~~~~~~~~~~~~~~~~~~~~~
25+
!!! error TS2346: Supplied parameters do not match any signature of call target.
3226

3327
var w: Error = new Object();
3428
~

tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class C9 extends B9 {
6262

6363
//// [C1.js]
6464
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
65+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
6566
var g = generator.apply(thisArg, _arguments || []), q = [], c, i;
6667
return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i;
6768
function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }
@@ -81,6 +82,7 @@ class C1 {
8182
}
8283
//// [C2.js]
8384
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
85+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
8486
var g = generator.apply(thisArg, _arguments || []), q = [], c, i;
8587
return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i;
8688
function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }
@@ -101,6 +103,7 @@ class C2 {
101103
}
102104
//// [C3.js]
103105
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
106+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
104107
var g = generator.apply(thisArg, _arguments || []), q = [], c, i;
105108
return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i;
106109
function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }
@@ -126,6 +129,7 @@ var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
126129
function verb(n, f) { return function (v) { return { value: ["delegate", (o[n] || f).call(o, v)], done: false }; }; }
127130
};
128131
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
132+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
129133
var g = generator.apply(thisArg, _arguments || []), q = [], c, i;
130134
return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i;
131135
function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }
@@ -146,6 +150,7 @@ class C4 {
146150
}
147151
//// [C5.js]
148152
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
153+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
149154
var g = generator.apply(thisArg, _arguments || []), q = [], c, i;
150155
return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i;
151156
function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }
@@ -171,6 +176,7 @@ class C5 {
171176
}
172177
//// [C6.js]
173178
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
179+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
174180
var g = generator.apply(thisArg, _arguments || []), q = [], c, i;
175181
return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i;
176182
function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }
@@ -191,6 +197,7 @@ class C6 {
191197
}
192198
//// [C7.js]
193199
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
200+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
194201
var g = generator.apply(thisArg, _arguments || []), q = [], c, i;
195202
return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i;
196203
function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }
@@ -211,6 +218,7 @@ class C7 {
211218
}
212219
//// [C8.js]
213220
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
221+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
214222
var g = generator.apply(thisArg, _arguments || []), q = [], c, i;
215223
return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i;
216224
function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }
@@ -233,6 +241,7 @@ class C8 {
233241
}
234242
//// [C9.js]
235243
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
244+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
236245
var g = generator.apply(thisArg, _arguments || []), q = [], c, i;
237246
return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i;
238247
function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }

0 commit comments

Comments
 (0)