File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -36,18 +36,20 @@ type FileCache = {
3636 removeEntry : ( absoluteFilepath : string ) => void ;
3737} ;
3838
39+ type RuleFuncArgs = ( string | number | boolean | RegExp | string [ ] ) [ ] ;
40+
3941// Note: With strict function types enabled, function signatures are checked contravariantly.
4042// This means that it would not be possible for rule authors to narrow the message function
4143// parameters to e.g. just `string`. Declaring the type for rule message functions through
4244// method declarations tricks TypeScript into bivariant signature checking. More details can
4345// be found here: https://stackoverflow.com/questions/52667959/what-is-the-purpose-of-bivariancehack-in-typescript-types.
4446// and in the original discussion: https://github.com/stylelint/stylelint/pull/6147#issuecomment-1155337016.
4547type RuleMessageFunc = {
46- bivariance ( ...args : ( string | number | boolean | RegExp | string [ ] ) [ ] ) : string ;
48+ bivariance ( ...args : RuleFuncArgs ) : string ;
4749} [ 'bivariance' ] ;
4850
4951type RuleSeverityFunc = {
50- bivariance ( ...args : ( string | number | boolean | RegExp | string [ ] ) [ ] ) : stylelint . Severity | null ;
52+ bivariance ( ...args : RuleFuncArgs ) : stylelint . Severity | null ;
5153} [ 'bivariance' ] ;
5254
5355type RuleOptionsPossibleFunc = ( value : unknown ) => boolean ;
You can’t perform that action at this time.
0 commit comments