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 types for an Input.error() #1811

Merged
merged 1 commit into from Jan 6, 2023
Merged
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
30 changes: 29 additions & 1 deletion lib/input.d.ts
@@ -1,4 +1,4 @@
import { ProcessOptions } from './postcss.js'
import { CssSyntaxError, ProcessOptions } from './postcss.js'
import PreviousMap from './previous-map.js'

export interface FilePosition {
Expand Down Expand Up @@ -147,4 +147,32 @@ export default class Input {
* @param offset Source offset.
*/
fromOffset(offset: number): { line: number; col: number } | null

/**
* Returns `CssSyntaxError` with information about the error and its position
*
* @param message Error message.
* @param line The line number in the input or a position that is part of a range.
* @param column The column number in the input or a position that is part of a range.
* @param opts Object contains `plugin` key with PostCSS plugin name, if error came from a plugin.
* @return `CssSyntaxError`
*/
error(
message: string,
line:
| number
| {
offset?: number
line: number
column: number
},
column?:
| number
| {
offset?: number
line: number
column: number
},
opts?: { plugin?: CssSyntaxError['plugin'] }
): CssSyntaxError
}