Skip to content

importHelpers is not work at some code #45971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bluelovers opened this issue Sep 20, 2021 · 2 comments
Closed

importHelpers is not work at some code #45971

bluelovers opened this issue Sep 20, 2021 · 2 comments

Comments

@bluelovers
Copy link
Contributor

Bug Report

🔎 Search Terms

🕗 Version & Regression Information

  • This is a crash
  • This changed between versions ______ and _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

⏯ Playground Link

https://www.typescriptlang.org/play?importHelpers=true&module=1&allowSyntheticDefaultImports=true#code/KYDwDg9gTgLgBAMwK4DsDGMCWEVysARyU3wCVgBnCAGwDdgBhaYACgEoAuOCmKTFAOYBYAFABvUQEh8MJFFwok1anACGFNSgCeogL6jRoSLESoM2XJgC2xmAFEQvVQB4AKnFAxgKACYbV2gB8LCiqVsBcPHyCnHAAClAQVpgUwG6BohIi0sCy8nDWtiz4RCTA5FR0jMzsbHqiQA

💻 Code

export function requireResolveCore(): string
{
	return null as any
}

export function importExtra<T extends any>(name: string): Promise<T>
{
	return import(requireResolveCore())
}

🙁 Actual behavior

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.importExtra = exports.requireResolveCore = void 0;
function requireResolveCore() {
    return null;
}
exports.requireResolveCore = requireResolveCore;
function importExtra(name) {
    return Promise.resolve().then(() => __importStar(require(requireResolveCore())));
}
exports.importExtra = importExtra;

🙂 Expected behavior

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.importExtra = exports.requireResolveCore = void 0;
const tslib_1 = require("tslib");
function requireResolveCore() {
    return null;
}
exports.requireResolveCore = requireResolveCore;
function importExtra(name) {
    return Promise.resolve().then(() => (0, tslib_1.__importStar)(require(requireResolveCore())));
}
exports.importExtra = importExtra;
@MartinJohns
Copy link
Contributor

Simplified:

const f = import("" as string)

@MartinJohns
Copy link
Contributor

Sounds like a duplicate of #27415.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants