'python import { p.* } from "./app" in typescript

I was wandering if there is an equivalent to this code in python import { p.* } from "./app" in typescript

currently I am achiving it like this but this is tedious work and it does not even work for all functions:

import { p as p5 } from "./app";

const translate = p5.translate;
const rotate = p5.rotate;
const fill = p5.fill;
const strokeWeight = p5.strokeWeight;
const stroke = p5.stroke;

export { translate, rotate, fill, strokeWeight, stroke }


Solution 1:[1]

No. There is no wildcard import feature in TypeScript (or ECMAScript).

Instead of the "tedious work" of those re-exports, you should use an editor/IDE that can deal with adding import statements, so you don't need to do it by hand.

Solution 2:[2]

You can use object destruction in export statements, so this should work, which is a bit cleaner:

export const { translate, rotate, fill, stroke } from './app'

A cleaner option would be to have a file that has everything you want to export from it as a separate file, and use export * from in here instead, like so:

// p.js
export { translate, rotate, ... } // use the same consts you would do in './app'
// other.js
export * from './p'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 AKX
Solution 2 casraf