I'm junior frontend developer
Currently, working on multilingual project with next.js + typescript
I'm trying to import type from each locale dynamically (kr, en)
Is it possible to type with dynamically imported type in TypeScript..?
So here's what I've tried
// @project/kr/foo
export enum foo {
KIMCHI = 'kimchi',
JOKBAL = 'jokbal'
}
// @project/en/foo
export enum foo {
CHEESE = 'cheese',
PIZZA = 'pizza'
}
// locale common component
const { foo } = require(`@project/${process.env.LOCALE}/foo`)
interface bar {
foo: typeof foo
}
With this, I get 'any' type for foo
If you know and tell me possible way to enable this, You'll be my savior..
Thank you :)
要在 typescript (.ts) 文件中导入:
import { foo } from "@project/en/foo";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.