-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Feature Request: dynamic import with type parameter #43669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
++ |
Interesting idea, but thereβs already an easier way to do this. Each plugin package can augment an interface from the main lib: // foo-plugin:
import { App } from 'libxxx';
// Add 'foo-plugin' member to `PluginConfig` already declared in 'libxxx'
declare module 'libxxx' {
interface PluginConfig {
'foo-plugin': Config;
}
}
interface Config {
bar: string;
}
// ... You can find lots of examples of this on DefinitelyTyped, e.g. for Express middleware packages. See how express-boom patches a property onto expressβs |
@andrewbranch I know, but in your case, it seems that we have to import all the 'foo-plugin's into our config file, which is quite annoying...... // xxx.config.ts
import { AppConfig } from 'libxxx'
// if we didn't do this, ide would not show proper code hints
import {} from 'foo-plugin'
import {} from 'bar-plugin'
import {} from 'baz-plugin'
export default {
plugins: {
'foo-plugin': { bar: 'baz' },
},
} as AppConfig |
Thatβs a good point. I would suggest putting them in the |
I think you might have mistyped the number on the second one? But yeah, duplicate of #26139 at least in terms of the answer. |
Fixed to #42482. |
Oh I see. It there possibility to introduce this feature in the future, or as is said in #26139 it was hard to fix? |
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Suggestion
π Search Terms
dynamic import
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
Support dynamic import() with type parameter.
π Motivating Example
Assuming we are developing a framework which implements a CLI that accept such config file:
will be equal to
The foo-plugin package can be like this:
But we can't get code hints from
plugins
, because we do not have typings support for dynamic imports.π» Use Cases
The text was updated successfully, but these errors were encountered: