-
Notifications
You must be signed in to change notification settings - Fork 26
Description
The transform function in the sass plugin returns null early if certain conditions aren't met (e.g., when the plugin is not to be used or the input is not a string). However, the declared return type of the function is Promise<d.PluginTransformResults>, and returning null directly contradicts this type expectation.
This type mismatch can lead to runtime errors or issues with static type checking in TypeScript, especially when consuming code assumes that transform always returns a Promise. The correct approach would be to return Promise.resolve(null) if null is an acceptable value by the plugin system, or better yet, adjust the return type to Promise<d.PluginTransformResults | null> if null is intentionally valid.
Suggested Fix:
transform(sourceText: string, fileName: string, context: d.PluginCtx): Promise<d.PluginTransformResults>
to:
transform(sourceText: string, fileName: string, context: d.PluginCtx): Promise<d.PluginTransformResults | null>
This will make the function's return behavior consistent and avoid potential type errors during usage.