Skip to content
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

Add missing type declaration for getCombinedSourcemap #3431

Merged
merged 3 commits into from Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/05-plugin-development.md
Expand Up @@ -478,7 +478,7 @@ Structurally equivalent to `this.warn`, except that it will also abort the bundl

#### `this.getCombinedSourcemap() => SourceMap`

Get the combined source maps of all previous plugins. This context function can only be used in [`transform`](guide/en/#transform) plugin hook.
Get the combined source maps of all previous plugins. This context function can only be used in the [`transform`](guide/en/#transform) plugin hook.

#### `this.getFileName(referenceId: string) => string`

Expand Down
6 changes: 5 additions & 1 deletion src/rollup/types.d.ts
Expand Up @@ -228,10 +228,14 @@ type LoadResult = SourceDescription | string | null | undefined;

export type LoadHook = (this: PluginContext, id: string) => Promise<LoadResult> | LoadResult;

export interface TransformPluginContext extends PluginContext {
getCombinedSourcemap: () => SourceMap;
}

export type TransformResult = string | null | undefined | SourceDescription;

export type TransformHook = (
this: PluginContext,
this: TransformPluginContext,
code: string,
id: string
) => Promise<TransformResult> | TransformResult;
Expand Down
3 changes: 2 additions & 1 deletion src/utils/transform.ts
Expand Up @@ -10,6 +10,7 @@ import {
RollupWarning,
SourceDescription,
TransformModuleJSON,
TransformPluginContext,
TransformResult
} from '../rollup/types';
import { collapseSourcemap } from './collapseSourcemaps';
Expand Down Expand Up @@ -81,7 +82,7 @@ export default function transform(
'transform',
[curSource, id],
transformReducer,
(pluginContext, plugin) => {
(pluginContext, plugin): TransformPluginContext => {
curPlugin = plugin;
return {
...pluginContext,
Expand Down