Skip to content

Commit 15f5fad

Browse files
committed
Add types for an Input.error()
1 parent 43bd2df commit 15f5fad

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

lib/input.d.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ProcessOptions } from './postcss.js'
1+
import { CssSyntaxError, ProcessOptions } from './postcss.js'
22
import PreviousMap from './previous-map.js'
33

44
export interface FilePosition {
@@ -147,4 +147,32 @@ export default class Input {
147147
* @param offset Source offset.
148148
*/
149149
fromOffset(offset: number): { line: number; col: number } | null
150+
151+
/**
152+
* Returns `CssSyntaxError` with information about the error and its position
153+
*
154+
* @param message Error message.
155+
* @param line The line number in the input or a position that is part of a range.
156+
* @param column The column number in the input or a position that is part of a range.
157+
* @param opts Object contains `plugin` key with PostCSS plugin name, if error came from a plugin.
158+
* @return `CssSyntaxError`
159+
*/
160+
error(
161+
message: string,
162+
line:
163+
| number
164+
| {
165+
offset?: number
166+
line: number
167+
column: number
168+
},
169+
column?:
170+
| number
171+
| {
172+
offset?: number
173+
line: number
174+
column: number
175+
},
176+
opts?: { plugin?: CssSyntaxError['plugin'] }
177+
): CssSyntaxError
150178
}

0 commit comments

Comments
 (0)