-
In my codebase, I have several interfaces that act like an index to a bunch of types: export interface CCAPIs {
[Symbol.iterator](): Iterator<CCAPI>;
// AUTO GENERATION BELOW
"Alarm Sensor": import("../cc/AlarmSensorCC").AlarmSensorCCAPI;
Association: import("../cc/AssociationCC").AssociationCCAPI;
"Association Group Information":
import("../cc/AssociationGroupInfoCC").AssociationGroupInfoCCAPI;
// ... lots more
} The build process currently contains 3 steps:
I'd like to eliminate step 2, so I can build the entire project with a single export interface CCAPIs {
[Symbol.iterator](): Iterator<CCAPI>;
// The other properties magically appear in IntelliSense and type definitions
} Is a program transformer what I need? And do I need an additional language server plugin that does the same? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello! Sorry for the delay. It sounds like a Program Transformer could help. A program transformer is essentially middleware for One of the main reasons to use one is if you want to generate code that gets automatically added to the Program if it isn't already built. I've done this in many instances. We actually use that for ts-patch itself, also. Here's an example: https://github.com/nonara/ts-patch/blob/master/projects/patch/plugin.ts As for a language service plugin, I don't see a reason why you would need one, but I may not know the full scope of what you're trying to do. Hope that helps! |
Beta Was this translation helpful? Give feedback.
Hello! Sorry for the delay.
It sounds like a Program Transformer could help. A program transformer is essentially middleware for
createProgram
. You can use this to intercept the tsc process and have it perform any number of steps before returning a Program instance.One of the main reasons to use one is if you want to generate code that gets automatically added to the Program if it isn't already built. I've done this in many instances. We actually use that for ts-patch itself, also.
Here's an example:
https://github.com/nonara/ts-patch/blob/master/projects/patch/plugin.ts
As for a language service plugin, I don't see a reason why you would need one, but I may not know the full scope of wh…