-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix parenthesization rules for yield
- Loading branch information
Showing
6 changed files
with
116 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//// [tests/cases/conformance/dynamicImport/importCallExpressionInUMD5.ts] //// | ||
|
||
//// [0.ts] | ||
export function foo() { return "foo"; } | ||
|
||
//// [1.ts] | ||
// https://github.com/microsoft/TypeScript/issues/36780 | ||
async function func() { | ||
const packageName = '.'; | ||
const packageJson = await import(packageName + '/package.json'); | ||
} | ||
|
||
|
||
//// [0.js] | ||
(function (factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") { | ||
var v = factory(require, exports); | ||
if (v !== undefined) module.exports = v; | ||
} | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.foo = void 0; | ||
function foo() { return "foo"; } | ||
exports.foo = foo; | ||
}); | ||
//// [1.js] | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
(function (factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") { | ||
var v = factory(require, exports); | ||
if (v !== undefined) module.exports = v; | ||
} | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
var __syncRequire = typeof module === "object" && typeof module.exports === "object"; | ||
// https://github.com/microsoft/TypeScript/issues/36780 | ||
function func() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
var _a; | ||
const packageName = '.'; | ||
const packageJson = yield (_a = packageName + '/package.json', __syncRequire ? Promise.resolve().then(() => require(_a)) : new Promise((resolve_1, reject_1) => { require([_a], resolve_1, reject_1); })); | ||
}); | ||
} | ||
}); |
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/importCallExpressionInUMD5.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
=== tests/cases/conformance/dynamicImport/0.ts === | ||
export function foo() { return "foo"; } | ||
>foo : Symbol(foo, Decl(0.ts, 0, 0)) | ||
|
||
=== tests/cases/conformance/dynamicImport/1.ts === | ||
// https://github.com/microsoft/TypeScript/issues/36780 | ||
async function func() { | ||
>func : Symbol(func, Decl(1.ts, 0, 0)) | ||
|
||
const packageName = '.'; | ||
>packageName : Symbol(packageName, Decl(1.ts, 2, 9)) | ||
|
||
const packageJson = await import(packageName + '/package.json'); | ||
>packageJson : Symbol(packageJson, Decl(1.ts, 3, 9)) | ||
>packageName : Symbol(packageName, Decl(1.ts, 2, 9)) | ||
} | ||
|
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/importCallExpressionInUMD5.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
=== tests/cases/conformance/dynamicImport/0.ts === | ||
export function foo() { return "foo"; } | ||
>foo : () => string | ||
>"foo" : "foo" | ||
|
||
=== tests/cases/conformance/dynamicImport/1.ts === | ||
// https://github.com/microsoft/TypeScript/issues/36780 | ||
async function func() { | ||
>func : () => Promise<void> | ||
|
||
const packageName = '.'; | ||
>packageName : "." | ||
>'.' : "." | ||
|
||
const packageJson = await import(packageName + '/package.json'); | ||
>packageJson : any | ||
>await import(packageName + '/package.json') : any | ||
>import(packageName + '/package.json') : Promise<any> | ||
>packageName + '/package.json' : string | ||
>packageName : "." | ||
>'/package.json' : "/package.json" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
tests/cases/conformance/dynamicImport/importCallExpressionInUMD5.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// @module: umd | ||
// @target: es2015 | ||
// @filename: 0.ts | ||
export function foo() { return "foo"; } | ||
|
||
// @filename: 1.ts | ||
|
||
// https://github.com/microsoft/TypeScript/issues/36780 | ||
async function func() { | ||
const packageName = '.'; | ||
const packageJson = await import(packageName + '/package.json'); | ||
} |