Skip to content

Commit

Permalink
Merge pull request #1811 from hudochenkov/fix-input-types
Browse files Browse the repository at this point in the history
Add types for an Input.error()
  • Loading branch information
ai committed Jan 6, 2023
2 parents 43bd2df + 15f5fad commit 4ad96d1
Showing 1 changed file with 29 additions and 1 deletion.
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
}

0 comments on commit 4ad96d1

Please sign in to comment.