Effect CommunityEC
Effect Community2y ago
2 replies
adrian_g

Configuring editor\LSP for namespaced imports in TypeScript

Question for anyone using namespaced imports for modules in your own projects. Like, for example, the Counter.ts from docs for Ref (https://github.com/Effect-TS/website/blob/32eba481084855c7e92dc021b733c50bc35323fc/content/docs/400-guides/600-state-management/100-ref.mdx#L26).

Is there a way to configure an editor\LSP so that auto import of Counter from another file adds:

import * as Counter from "./Counter"


instead of:

import { Counter } from './Counter'


?
Like here: https://github.com/Effect-TS/website/blob/32eba481084855c7e92dc021b733c50bc35323fc/content/docs/400-guides/600-state-management/100-ref.mdx#L57

I found this tsc plugin: https://github.com/unsplash/ts-namespace-import-plugin but it requires explicitly listing all modules which should be imported this way, and does't do relative imports (https://github.com/unsplash/ts-namespace-import-plugin/issues/13)

Thanks!
Was this page helpful?