668bbc64ff
* Preserve the variable name when exporting an arrow or anonymous function This allows the browser or node to properly name the (arrow) function * Updated tests to reflect previous change * Remove duplicated comment * Transforms variable.initializer using moduleExpressionElementVisitor * PR feedback: rbuckton - Use isArrowFunction and isFunctionExpression * PR feedback: rbuckton - Consider ClassExpresion, they can also be named based on the variable.
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
//// [tests/cases/compiler/declarationEmitComputedNameCausesImportToBePainted.ts] ////
|
|
|
|
//// [context.ts]
|
|
export const Key = Symbol();
|
|
export interface Context {
|
|
[Key]: string;
|
|
}
|
|
//// [index.ts]
|
|
import { Key, Context } from "./context";
|
|
|
|
export const context: Context = {
|
|
[Key]: 'bar',
|
|
}
|
|
|
|
export const withContext = ({ [Key]: value }: Context) => value;
|
|
|
|
//// [context.js]
|
|
"use strict";
|
|
exports.__esModule = true;
|
|
exports.Key = void 0;
|
|
exports.Key = Symbol();
|
|
//// [index.js]
|
|
"use strict";
|
|
var _a;
|
|
exports.__esModule = true;
|
|
exports.withContext = exports.context = void 0;
|
|
var context_1 = require("./context");
|
|
exports.context = (_a = {},
|
|
_a[context_1.Key] = 'bar',
|
|
_a);
|
|
var withContext = function (_a) {
|
|
var _b = context_1.Key, value = _a[_b];
|
|
return value;
|
|
};
|
|
exports.withContext = withContext;
|
|
|
|
|
|
//// [context.d.ts]
|
|
export declare const Key: unique symbol;
|
|
export interface Context {
|
|
[Key]: string;
|
|
}
|
|
//// [index.d.ts]
|
|
import { Key, Context } from "./context";
|
|
export declare const context: Context;
|
|
export declare const withContext: ({ [Key]: value }: Context) => string;
|