forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick PR microsoft#49814 into release-4.8
Component commits: e2d22fa Unify default import resolution across specifier target codepaths b341699 Merge main into branch cf010b5 Use differing type aliases, per request
- Loading branch information
1 parent
565a444
commit 13280de
Showing
15 changed files
with
1,348 additions
and
62 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
67 changes: 67 additions & 0 deletions
67
tests/baselines/reference/esModuleInteropDefaultImports.errors.txt
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,67 @@ | ||
tests/cases/compiler/b.ts(15,1): error TS2349: This expression is not callable. | ||
Type 'typeof import("tests/cases/compiler/mod")' has no call signatures. | ||
tests/cases/compiler/b.ts(16,1): error TS2349: This expression is not callable. | ||
Type 'typeof import("tests/cases/compiler/mod")' has no call signatures. | ||
tests/cases/compiler/b.ts(17,1): error TS2349: This expression is not callable. | ||
Type 'typeof import("tests/cases/compiler/mod")' has no call signatures. | ||
tests/cases/compiler/b.ts(18,1): error TS2349: This expression is not callable. | ||
Type 'typeof import("tests/cases/compiler/mod")' has no call signatures. | ||
tests/cases/compiler/b.ts(19,6): error TS2349: This expression is not callable. | ||
Type 'typeof import("tests/cases/compiler/mod")' has no call signatures. | ||
tests/cases/compiler/b.ts(20,6): error TS2349: This expression is not callable. | ||
Type 'typeof import("tests/cases/compiler/mod")' has no call signatures. | ||
|
||
|
||
==== tests/cases/compiler/mod.ts (0 errors) ==== | ||
declare function fun(): void; | ||
export default fun; | ||
==== tests/cases/compiler/a.ts (0 errors) ==== | ||
import mod = require("./mod"); | ||
export = mod; | ||
==== tests/cases/compiler/b.ts (6 errors) ==== | ||
import a from "./a"; | ||
import { default as b } from "./a"; | ||
import c, { default as d } from "./a"; | ||
import * as self from "./b"; | ||
export { default } from "./a"; | ||
export { default as def } from "./a"; | ||
|
||
a === b; | ||
b === c; | ||
c === d; | ||
d === self.default; | ||
self.default === self.def; | ||
|
||
// should all fail | ||
a(); | ||
~ | ||
!!! error TS2349: This expression is not callable. | ||
!!! error TS2349: Type 'typeof import("tests/cases/compiler/mod")' has no call signatures. | ||
b(); | ||
~ | ||
!!! error TS2349: This expression is not callable. | ||
!!! error TS2349: Type 'typeof import("tests/cases/compiler/mod")' has no call signatures. | ||
c(); | ||
~ | ||
!!! error TS2349: This expression is not callable. | ||
!!! error TS2349: Type 'typeof import("tests/cases/compiler/mod")' has no call signatures. | ||
d(); | ||
~ | ||
!!! error TS2349: This expression is not callable. | ||
!!! error TS2349: Type 'typeof import("tests/cases/compiler/mod")' has no call signatures. | ||
self.default(); | ||
~~~~~~~ | ||
!!! error TS2349: This expression is not callable. | ||
!!! error TS2349: Type 'typeof import("tests/cases/compiler/mod")' has no call signatures. | ||
self.def(); | ||
~~~ | ||
!!! error TS2349: This expression is not callable. | ||
!!! error TS2349: Type 'typeof import("tests/cases/compiler/mod")' has no call signatures. | ||
|
||
// should all work | ||
a.default(); | ||
b.default(); | ||
c.default(); | ||
d.default(); | ||
self.default.default(); | ||
self.def.default(); |
103 changes: 103 additions & 0 deletions
103
tests/baselines/reference/esModuleInteropDefaultImports.js
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,103 @@ | ||
//// [tests/cases/compiler/esModuleInteropDefaultImports.ts] //// | ||
|
||
//// [mod.ts] | ||
declare function fun(): void; | ||
export default fun; | ||
//// [a.ts] | ||
import mod = require("./mod"); | ||
export = mod; | ||
//// [b.ts] | ||
import a from "./a"; | ||
import { default as b } from "./a"; | ||
import c, { default as d } from "./a"; | ||
import * as self from "./b"; | ||
export { default } from "./a"; | ||
export { default as def } from "./a"; | ||
|
||
a === b; | ||
b === c; | ||
c === d; | ||
d === self.default; | ||
self.default === self.def; | ||
|
||
// should all fail | ||
a(); | ||
b(); | ||
c(); | ||
d(); | ||
self.default(); | ||
self.def(); | ||
|
||
// should all work | ||
a.default(); | ||
b.default(); | ||
c.default(); | ||
d.default(); | ||
self.default.default(); | ||
self.def.default(); | ||
|
||
//// [mod.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports["default"] = fun; | ||
//// [a.js] | ||
"use strict"; | ||
var mod = require("./mod"); | ||
module.exports = mod; | ||
//// [b.js] | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
exports.__esModule = true; | ||
exports.def = exports["default"] = void 0; | ||
var a_1 = __importDefault(require("./a")); | ||
var a_2 = __importDefault(require("./a")); | ||
var a_3 = __importDefault(require("./a")); | ||
var self = __importStar(require("./b")); | ||
var a_4 = require("./a"); | ||
__createBinding(exports, a_4, "default"); | ||
var a_5 = require("./a"); | ||
__createBinding(exports, a_5, "default", "def"); | ||
a_1["default"] === a_2["default"]; | ||
a_2["default"] === a_3["default"]; | ||
a_3["default"] === a_3["default"]; | ||
a_3["default"] === self["default"]; | ||
self["default"] === self.def; | ||
// should all fail | ||
(0, a_1["default"])(); | ||
(0, a_2["default"])(); | ||
(0, a_3["default"])(); | ||
(0, a_3["default"])(); | ||
self["default"](); | ||
self.def(); | ||
// should all work | ||
a_1["default"]["default"](); | ||
a_2["default"]["default"](); | ||
a_3["default"]["default"](); | ||
a_3["default"]["default"](); | ||
self["default"]["default"](); | ||
self.def["default"](); |
Oops, something went wrong.