Open
Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Stencil Version
4.29.2
Current Behavior
The type definition for the transform method of a Plugin incorrectly defines the return value as:
Promise<PluginTransformResults> | PluginTransformResults | string;
Expected Behavior
Based on the code the definitions should be something more like:
export interface Plugin {
name?: string;
pluginType?: string;
load?: (id: string, context: PluginCtx) => Promise<string> | string;
resolveId?: (importee: string, importer: string, context: PluginCtx) => Promise<string> | string;
transform?: (
sourceText: string,
id: string,
context: PluginCtx,
) => Promise<PluginTransformResults> | PluginTransformResults;
}
export type PluginTransformResults = PluginTransformationDescriptor | string | null;
export interface PluginTransformationDescriptor {
code?: string;
map?: string;
id?: string;
diagnostics?: Diagnostic[];
dependencies?: string[];
}
System Info
System: node 20.18.0
Platform: windows (10.0.26100)
CPU Model: AMD Ryzen 9 9950X 16-Core Processor (32 cpus)
Compiler: C:\Users\user\Documents\GitHub\stencil-type-declaration-bug\node_modules\@stencil\core\compiler\stencil.js
Build: 1744045416
Stencil: 4.29.2
TypeScript: 5.5.4
Rollup: 4.34.9
Parse5: 7.2.1
jQuery: 4.0.0-pre
Terser: 5.37.0
Steps to Reproduce
- Create a plugin with a transform method that returns null
- Observe the Typescript language server getting mad at you
Code Reproduction URL
Additional Information
I am willing to make a PR addressing this issue assuming it's an issue that the maintainers think needs addressing and that they think needs addressing in this way.
Metadata
Metadata
Assignees
Labels
No labels