Incomplete or Incorrect null Return Type in transform Method

Open
#620 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
sass, typescript

Research direction

Locate the sass plugin's transform method and inspect its declared return type alongside the early null returns. Check the plugin system's expected transform result and existing type-checking coverage, then make the return behavior and type agree and verify the relevant checks pass.

Written by the indexing model from the issue text.

Description

Help Wanted

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.

Dominant language
TypeScript
Stars
83
Forks
25
Avg merge
1h 39m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stenciljs/sass

All issues in stenciljs/sass

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.