This question already has answers here:
Is it possible to export * as foo in typescript
(2个答案)
去年关闭。
以以下文件夹结构为例:
我的问题:
有没有一种方法可以将
但是不幸的是,没有一种方法可以重命名出口并将出口包装起来。
(2个答案)
去年关闭。
以以下文件夹结构为例:
example.ts
outer/
|--- inner/
|--- index.ts
|--- file1.ts
|--- file2.ts
|--- index.ts
file1.ts
的内容export class FileOneClass{/**/}
export interface IFileOneInterface{/**/}
file2.ts
的内容:export class FileTwoClass{/**/}
export interface IFileTwoInterface{/**/}
outer/inner/index.ts
的内容:export { FileOneClass, IFileOneInterface } from "./file1.ts"
export { FileTwoClass, IFileTwoInterface } from "./file2.ts"
outer/index.ts
的内容:import * as InnerImport from "./inner";
export const Inner = InnerImport;
example.ts
的内容:import { Inner } from "./outer"
function exampleUsage(){
console.log(Inner.FileOneClass)
console.log(Inner.FileOneInterface)
console.log(Inner.FileTwoClass)
console.log(Inner.FileTwoInterface)
}
我的问题:
有没有一种方法可以将
outer/index.ts
中的export语句写入一行?// Ugly:
import * as InnerImport from "./inner";
export const Inner = InnerImport;
// Desired is something like this:
export * as Inner from "./inner"; // This line leads to a error!
最佳答案
好吧,当然(开个玩笑):
import * as InnerImport from "./inner"; export const Inner = InnerImport;
但是不幸的是,没有一种方法可以重命名出口并将出口包装起来。
关于javascript - 是否可以单行通配通配符? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55105690/