Fix System module export import = (#49788)

* Add more SystemJS test case

* Fix System module `export import =`

* Update test case
This commit is contained in:
magic-akari
2022-08-10 07:31:02 +08:00
committed by GitHub
parent e5b400c162
commit abc2a350e6
5 changed files with 94 additions and 0 deletions

View File

@@ -466,6 +466,20 @@ namespace ts {
factory.createAssignment(importVariableName, parameterName)
)
);
if (hasSyntacticModifier(entry, ModifierFlags.Export)) {
statements.push(
factory.createExpressionStatement(
factory.createCallExpression(
exportFunction,
/*typeArguments*/ undefined,
[
factory.createStringLiteral(idText(importVariableName)),
parameterName,
]
)
)
);
}
break;
case SyntaxKind.ExportDeclaration:

View File

@@ -0,0 +1,43 @@
//// [tests/cases/compiler/systemModule18.ts] ////
//// [react.ts]
export function createElement() {}
export function lazy() {}
export function useState() {}
//// [index.ts]
export import React = require("./react.js");
//// [react.js]
System.register([], function (exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
function createElement() { }
exports_1("createElement", createElement);
function lazy() { }
exports_1("lazy", lazy);
function useState() { }
exports_1("useState", useState);
return {
setters: [],
execute: function () {
}
};
});
//// [index.js]
System.register(["./react.js"], function (exports_1, context_1) {
"use strict";
var React;
var __moduleName = context_1 && context_1.id;
return {
setters: [
function (React_1) {
React = React_1;
exports_1("React", React_1);
}
],
execute: function () {
}
};
});

View File

@@ -0,0 +1,14 @@
=== tests/cases/compiler/index.ts ===
export import React = require("./react.js");
>React : Symbol(React, Decl(index.ts, 0, 0))
=== tests/cases/compiler/react.ts ===
export function createElement() {}
>createElement : Symbol(createElement, Decl(react.ts, 0, 0))
export function lazy() {}
>lazy : Symbol(lazy, Decl(react.ts, 0, 34))
export function useState() {}
>useState : Symbol(useState, Decl(react.ts, 1, 25))

View File

@@ -0,0 +1,14 @@
=== tests/cases/compiler/index.ts ===
export import React = require("./react.js");
>React : typeof React
=== tests/cases/compiler/react.ts ===
export function createElement() {}
>createElement : () => void
export function lazy() {}
>lazy : () => void
export function useState() {}
>useState : () => void

View File

@@ -0,0 +1,9 @@
// @module: system
// @filename: react.ts
export function createElement() {}
export function lazy() {}
export function useState() {}
// @filename: index.ts
export import React = require("./react.js");