diff --git a/packages/eslint-plugin/src/rules/space-infix-ops.ts b/packages/eslint-plugin/src/rules/space-infix-ops.ts index a38b57825f2..ff6e15ac340 100644 --- a/packages/eslint-plugin/src/rules/space-infix-ops.ts +++ b/packages/eslint-plugin/src/rules/space-infix-ops.ts @@ -142,7 +142,14 @@ export default util.createRule({ const types = typeAnnotation.types; types.forEach(type => { - const operator = sourceCode.getTokenBefore(type); + const skipFunctionParenthesis = + type.type === TSESTree.AST_NODE_TYPES.TSFunctionType + ? util.isNotOpeningParenToken + : 0; + const operator = sourceCode.getTokenBefore( + type, + skipFunctionParenthesis, + ); if (operator != null && UNIONS.includes(operator.value)) { const prev = sourceCode.getTokenBefore(operator); diff --git a/packages/eslint-plugin/tests/rules/space-infix-ops.test.ts b/packages/eslint-plugin/tests/rules/space-infix-ops.test.ts index 5ad92555d88..72f71d00358 100644 --- a/packages/eslint-plugin/tests/rules/space-infix-ops.test.ts +++ b/packages/eslint-plugin/tests/rules/space-infix-ops.test.ts @@ -69,6 +69,46 @@ ruleTester.run('space-infix-ops', rule, { type Test = string & boolean; `, }, + { + code: ` + type Test = string | (() => void); + `, + }, + { + code: ` + type Test = string & (() => void); + `, + }, + { + code: ` + type Test = string | (((() => void))); + `, + }, + { + code: ` + type Test = string & (((() => void))); + `, + }, + { + code: ` + type Test = (() => boolean) | (() => void); + `, + }, + { + code: ` + type Test = (() => boolean) & (() => void); + `, + }, + { + code: ` + type Test = (((() => boolean))) | (((() => void))); + `, + }, + { + code: ` + type Test = (((() => boolean))) & (((() => void))); + `, + }, { code: ` class Test { @@ -83,6 +123,34 @@ ruleTester.run('space-infix-ops', rule, { } `, }, + { + code: ` + class Test { + private value:number | (() => void) = 1; + } + `, + }, + { + code: ` + class Test { + private value:number & (() => void) = 1; + } + `, + }, + { + code: ` + class Test { + private value:number | (((() => void))) = 1; + } + `, + }, + { + code: ` + class Test { + private value:number & (((() => void))) = 1; + } + `, + }, { code: ` type Test = @@ -97,6 +165,62 @@ ruleTester.run('space-infix-ops', rule, { & boolean; `, }, + { + code: ` + type Test = + | string + | (() => void); + `, + }, + { + code: ` + type Test = + & string + & (() => void); + `, + }, + { + code: ` + type Test = + | (() => boolean) + | (() => void); + `, + }, + { + code: ` + type Test = + & (() => boolean) + & (() => void); + `, + }, + { + code: ` + type Test = + | string + | (((() => void))); + `, + }, + { + code: ` + type Test = + & string + & (((() => void))); + `, + }, + { + code: ` + type Test = + | (((() => boolean))) + | (((() => void))); + `, + }, + { + code: ` + type Test = + & (((() => boolean))) + & (((() => void))); + `, + }, { code: ` interface Test { @@ -115,6 +239,42 @@ ruleTester.run('space-infix-ops', rule, { } `, }, + { + code: ` + interface Test { + prop: + & string + & (() => void); + } + `, + }, + { + code: ` + interface Test { + prop: + | string + | (() => void); + } + `, + }, + { + code: ` + interface Test { + prop: + & string + & (((() => void))); + } + `, + }, + { + code: ` + interface Test { + prop: + | string + | (((() => void))); + } + `, + }, { code: ` interface Test { @@ -136,11 +296,63 @@ ruleTester.run('space-infix-ops', rule, { } `, }, + { + code: ` + interface Test { + props: string | (() => void); + } + `, + }, + { + code: ` + interface Test { + props: string & (() => void); + } + `, + }, + { + code: ` + interface Test { + props: (() => boolean) & (() => void); + } + `, + }, + { + code: ` + interface Test { + props: string | (((() => void))); + } + `, + }, + { + code: ` + interface Test { + props: string & (((() => void))); + } + `, + }, + { + code: ` + interface Test { + props: (((() => boolean))) & (((() => void))); + } + `, + }, { code: ` const x: string & number; `, }, + { + code: ` + const x: string & (() => void); + `, + }, + { + code: ` + const x: string & (((() => void))); + `, + }, { code: ` class Test { @@ -155,70 +367,1284 @@ ruleTester.run('space-infix-ops', rule, { }, { code: ` - function bar(): string & number {} + function bar(): string & number {} + `, + }, + ], + invalid: [ + { + code: ` + enum Test { + A= 2, + B = 1, + } + `, + output: ` + enum Test { + A = 2, + B = 1, + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 12, + line: 3, + }, + ], + }, + { + code: ` + enum Test { + KEY1= "value1", + KEY2 = "value2", + } + `, + output: ` + enum Test { + KEY1 = "value1", + KEY2 = "value2", + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 15, + line: 3, + }, + ], + }, + { + code: ` + enum Test { + A =2, + B = 1, + } + `, + output: ` + enum Test { + A = 2, + B = 1, + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 13, + line: 3, + }, + ], + }, + { + code: ` + class Test { + public readonly value= 2; + } + `, + output: ` + class Test { + public readonly value = 2; + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 32, + line: 3, + }, + ], + }, + { + code: ` + class Test { + public readonly value =2; + } + `, + output: ` + class Test { + public readonly value = 2; + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 33, + line: 3, + }, + ], + }, + { + code: ` + type Test= string | number; + `, + output: ` + type Test = string | number; + `, + errors: [ + { + messageId: 'missingSpace', + column: 18, + line: 2, + }, + ], + }, + { + code: ` + type Test= (() => void) | number; + `, + output: ` + type Test = (() => void) | number; + `, + errors: [ + { + messageId: 'missingSpace', + column: 18, + line: 2, + }, + ], + }, + { + code: ` + type Test= (((() => void))) | number; + `, + output: ` + type Test = (((() => void))) | number; + `, + errors: [ + { + messageId: 'missingSpace', + column: 18, + line: 2, + }, + ], + }, + { + code: ` + type Test =string | number; + `, + output: ` + type Test = string | number; + `, + errors: [ + { + messageId: 'missingSpace', + column: 19, + line: 2, + }, + ], + }, + { + code: ` + type Test =(() => void) | number; + `, + output: ` + type Test = (() => void) | number; + `, + errors: [ + { + messageId: 'missingSpace', + column: 19, + line: 2, + }, + ], + }, + { + code: ` + type Test =(((() => void))) | number; + `, + output: ` + type Test = (((() => void))) | number; + `, + errors: [ + { + messageId: 'missingSpace', + column: 19, + line: 2, + }, + ], + }, + { + code: ` + type Test = string| number; + `, + output: ` + type Test = string | number; + `, + errors: [ + { + messageId: 'missingSpace', + column: 27, + line: 2, + }, + ], + }, + { + code: ` + type Test = string |number; + `, + output: ` + type Test = string | number; + `, + errors: [ + { + messageId: 'missingSpace', + column: 28, + line: 2, + }, + ], + }, + { + code: ` + type Test = string| (() => void); + `, + output: ` + type Test = string | (() => void); + `, + errors: [ + { + messageId: 'missingSpace', + column: 27, + line: 2, + }, + ], + }, + { + code: ` + type Test = string| (((() => void))); + `, + output: ` + type Test = string | (((() => void))); + `, + errors: [ + { + messageId: 'missingSpace', + column: 27, + line: 2, + }, + ], + }, + { + code: ` + type Test = string |(() => void); + `, + output: ` + type Test = string | (() => void); + `, + errors: [ + { + messageId: 'missingSpace', + column: 28, + line: 2, + }, + ], + }, + { + code: ` + type Test = string |(((() => void))); + `, + output: ` + type Test = string | (((() => void))); + `, + errors: [ + { + messageId: 'missingSpace', + column: 28, + line: 2, + }, + ], + }, + { + code: ` + type Test = string &number; + `, + output: ` + type Test = string & number; + `, + errors: [ + { + messageId: 'missingSpace', + column: 28, + line: 2, + }, + ], + }, + { + code: ` + type Test = string& number; + `, + output: ` + type Test = string & number; + `, + errors: [ + { + messageId: 'missingSpace', + column: 27, + line: 2, + }, + ], + }, + { + code: ` + type Test = string &(() => void); + `, + output: ` + type Test = string & (() => void); + `, + errors: [ + { + messageId: 'missingSpace', + column: 28, + line: 2, + }, + ], + }, + { + code: ` + type Test = string &(((() => void))); + `, + output: ` + type Test = string & (((() => void))); + `, + errors: [ + { + messageId: 'missingSpace', + column: 28, + line: 2, + }, + ], + }, + { + code: ` + type Test = string& (() => void); + `, + output: ` + type Test = string & (() => void); + `, + errors: [ + { + messageId: 'missingSpace', + column: 27, + line: 2, + }, + ], + }, + { + code: ` + type Test = string& (((() => void))); + `, + output: ` + type Test = string & (((() => void))); + `, + errors: [ + { + messageId: 'missingSpace', + column: 27, + line: 2, + }, + ], + }, + { + code: ` + type Test = (() => boolean)| (() => void); + `, + output: ` + type Test = (() => boolean) | (() => void); + `, + errors: [ + { + messageId: 'missingSpace', + column: 36, + line: 2, + }, + ], + }, + { + code: ` + type Test = (((() => boolean)))| (((() => void))); + `, + output: ` + type Test = (((() => boolean))) | (((() => void))); + `, + errors: [ + { + messageId: 'missingSpace', + column: 40, + line: 2, + }, + ], + }, + { + code: ` + type Test = (() => boolean)& (() => void); + `, + output: ` + type Test = (() => boolean) & (() => void); + `, + errors: [ + { + messageId: 'missingSpace', + column: 36, + line: 2, + }, + ], + }, + { + code: ` + type Test = (((() => boolean)))& (((() => void))); + `, + output: ` + type Test = (((() => boolean))) & (((() => void))); + `, + errors: [ + { + messageId: 'missingSpace', + column: 40, + line: 2, + }, + ], + }, + { + code: ` + type Test = (() => boolean)|(() => void); + `, + output: ` + type Test = (() => boolean) | (() => void); + `, + errors: [ + { + messageId: 'missingSpace', + column: 36, + line: 2, + }, + ], + }, + { + code: ` + type Test = (((() => boolean)))|(((() => void))); + `, + output: ` + type Test = (((() => boolean))) | (((() => void))); + `, + errors: [ + { + messageId: 'missingSpace', + column: 40, + line: 2, + }, + ], + }, + { + code: ` + type Test = (() => boolean)&(() => void); + `, + output: ` + type Test = (() => boolean) & (() => void); + `, + errors: [ + { + messageId: 'missingSpace', + column: 36, + line: 2, + }, + ], + }, + { + code: ` + type Test = (((() => boolean)))&(((() => void))); + `, + output: ` + type Test = (((() => boolean))) & (((() => void))); + `, + errors: [ + { + messageId: 'missingSpace', + column: 40, + line: 2, + }, + ], + }, + { + code: ` + type Test = + |string + | number; + `, + output: ` + type Test = + | string + | number; + `, + errors: [ + { + messageId: 'missingSpace', + column: 9, + line: 3, + }, + ], + }, + { + code: ` + type Test = + |string + | (() => void); + `, + output: ` + type Test = + | string + | (() => void); + `, + errors: [ + { + messageId: 'missingSpace', + column: 9, + line: 3, + }, + ], + }, + { + code: ` + type Test = + |string + | (((() => void))); + `, + output: ` + type Test = + | string + | (((() => void))); + `, + errors: [ + { + messageId: 'missingSpace', + column: 9, + line: 3, + }, + ], + }, + { + code: ` + type Test = + &string + & number; + `, + output: ` + type Test = + & string + & number; + `, + errors: [ + { + messageId: 'missingSpace', + column: 9, + line: 3, + }, + ], + }, + { + code: ` + type Test = + &string + & (() => void); + `, + output: ` + type Test = + & string + & (() => void); + `, + errors: [ + { + messageId: 'missingSpace', + column: 9, + line: 3, + }, + ], + }, + { + code: ` + type Test = + &string + & (((() => void))); + `, + output: ` + type Test = + & string + & (((() => void))); + `, + errors: [ + { + messageId: 'missingSpace', + column: 9, + line: 3, + }, + ], + }, + { + code: ` + interface Test { + prop: string| number; + } + `, + output: ` + interface Test { + prop: string | number; + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 23, + line: 3, + }, + ], + }, + { + code: ` + interface Test { + prop: string| (() => void); + } + `, + output: ` + interface Test { + prop: string | (() => void); + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 23, + line: 3, + }, + ], + }, + { + code: ` + interface Test { + prop: string| (((() => void))); + } + `, + output: ` + interface Test { + prop: string | (((() => void))); + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 23, + line: 3, + }, + ], + }, + { + code: ` + interface Test { + prop: string |number; + } + `, + output: ` + interface Test { + prop: string | number; + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 24, + line: 3, + }, + ], + }, + { + code: ` + interface Test { + prop: string |(() => void); + } + `, + output: ` + interface Test { + prop: string | (() => void); + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 24, + line: 3, + }, + ], + }, + { + code: ` + interface Test { + prop: string |(((() => void))); + } + `, + output: ` + interface Test { + prop: string | (((() => void))); + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 24, + line: 3, + }, + ], + }, + { + code: ` + interface Test { + prop: (() => boolean) |(() => void); + } + `, + output: ` + interface Test { + prop: (() => boolean) | (() => void); + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 33, + line: 3, + }, + ], + }, + { + code: ` + interface Test { + prop: (((() => boolean))) |(((() => void))); + } + `, + output: ` + interface Test { + prop: (((() => boolean))) | (((() => void))); + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 37, + line: 3, + }, + ], + }, + { + code: ` + interface Test { + prop: string &number; + } + `, + output: ` + interface Test { + prop: string & number; + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 24, + line: 3, + }, + ], + }, + { + code: ` + interface Test { + prop: string &(() => void); + } + `, + output: ` + interface Test { + prop: string & (() => void); + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 24, + line: 3, + }, + ], + }, + { + code: ` + interface Test { + prop: string &(((() => void))); + } + `, + output: ` + interface Test { + prop: string & (((() => void))); + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 24, + line: 3, + }, + ], + }, + { + code: ` + interface Test { + prop: string& number; + } + `, + output: ` + interface Test { + prop: string & number; + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 23, + line: 3, + }, + ], + }, + { + code: ` + interface Test { + prop: string& (() => void); + } + `, + output: ` + interface Test { + prop: string & (() => void); + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 23, + line: 3, + }, + ], + }, + { + code: ` + interface Test { + prop: string& (((() => void))); + } + `, + output: ` + interface Test { + prop: string & (((() => void))); + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 23, + line: 3, + }, + ], + }, + { + code: ` + interface Test { + prop: + |string + | number; + } + `, + output: ` + interface Test { + prop: + | string + | number; + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 13, + line: 4, + }, + ], + }, + { + code: ` + interface Test { + prop: + |string + | (() => void); + } + `, + output: ` + interface Test { + prop: + | string + | (() => void); + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 13, + line: 4, + }, + ], + }, + { + code: ` + interface Test { + prop: + |string + | (((() => void))); + } + `, + output: ` + interface Test { + prop: + | string + | (((() => void))); + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 13, + line: 4, + }, + ], + }, + { + code: ` + interface Test { + prop: + &string + & number; + } + `, + output: ` + interface Test { + prop: + & string + & number; + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 13, + line: 4, + }, + ], + }, + { + code: ` + interface Test { + prop: + &string + & (() => void); + } + `, + output: ` + interface Test { + prop: + & string + & (() => void); + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 13, + line: 4, + }, + ], + }, + { + code: ` + interface Test { + prop: + &string + & (((() => void))); + } + `, + output: ` + interface Test { + prop: + & string + & (((() => void))); + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 13, + line: 4, + }, + ], + }, + { + code: ` + const x: string &number; + `, + output: ` + const x: string & number; + `, + errors: [ + { + messageId: 'missingSpace', + column: 25, + line: 2, + }, + ], + }, + { + code: ` + const x: string &(() => void); + `, + output: ` + const x: string & (() => void); + `, + errors: [ + { + messageId: 'missingSpace', + column: 25, + line: 2, + }, + ], + }, + { + code: ` + const x: string &(((() => void))); + `, + output: ` + const x: string & (((() => void))); + `, + errors: [ + { + messageId: 'missingSpace', + column: 25, + line: 2, + }, + ], + }, + { + code: ` + const x: string& number; + `, + output: ` + const x: string & number; + `, + errors: [ + { + messageId: 'missingSpace', + column: 24, + line: 2, + }, + ], + }, + { + code: ` + const x: string& (() => void); + `, + output: ` + const x: string & (() => void); + `, + errors: [ + { + messageId: 'missingSpace', + column: 24, + line: 2, + }, + ], + }, + { + code: ` + const x: string& (((() => void))); + `, + output: ` + const x: string & (((() => void))); + `, + errors: [ + { + messageId: 'missingSpace', + column: 24, + line: 2, + }, + ], + }, + { + code: ` + const x: string| number; + `, + output: ` + const x: string | number; + `, + errors: [ + { + messageId: 'missingSpace', + column: 24, + line: 2, + }, + ], + }, + { + code: ` + const x: string| (() => void); + `, + output: ` + const x: string | (() => void); + `, + errors: [ + { + messageId: 'missingSpace', + column: 24, + line: 2, + }, + ], + }, + { + code: ` + const x: string| (((() => void))); + `, + output: ` + const x: string | (((() => void))); + `, + errors: [ + { + messageId: 'missingSpace', + column: 24, + line: 2, + }, + ], + }, + { + code: ` + class Test { + value: string |number; + } + `, + output: ` + class Test { + value: string | number; + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 25, + line: 3, + }, + ], + }, + { + code: ` + class Test { + value: string |(() => void); + } + `, + output: ` + class Test { + value: string | (() => void); + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 25, + line: 3, + }, + ], + }, + { + code: ` + class Test { + value: string |(((() => void))); + } + `, + output: ` + class Test { + value: string | (((() => void))); + } + `, + errors: [ + { + messageId: 'missingSpace', + column: 25, + line: 3, + }, + ], + }, + { + code: ` + class Test { + value: string& number; + } + `, + output: ` + class Test { + value: string & number; + } `, + errors: [ + { + messageId: 'missingSpace', + column: 24, + line: 3, + }, + ], }, - ], - invalid: [ { code: ` - enum Test { - A= 2, - B = 1, + class Test { + value: string& (() => void); } `, output: ` - enum Test { - A = 2, - B = 1, + class Test { + value: string & (() => void); } `, errors: [ { messageId: 'missingSpace', - column: 12, + column: 24, line: 3, }, ], }, { code: ` - enum Test { - KEY1= "value1", - KEY2 = "value2", + class Test { + value: string& (((() => void))); } `, output: ` - enum Test { - KEY1 = "value1", - KEY2 = "value2", + class Test { + value: string & (((() => void))); } `, errors: [ { messageId: 'missingSpace', - column: 15, + column: 24, line: 3, }, ], }, { code: ` - enum Test { - A =2, - B = 1, + class Test { + value: string| number; } `, output: ` - enum Test { - A = 2, - B = 1, + class Test { + value: string | number; } `, errors: [ { messageId: 'missingSpace', - column: 13, + column: 24, line: 3, }, ], @@ -226,18 +1652,18 @@ ruleTester.run('space-infix-ops', rule, { { code: ` class Test { - public readonly value= 2; + value: string| (() => void); } `, output: ` class Test { - public readonly value = 2; + value: string | (() => void); } `, errors: [ { messageId: 'missingSpace', - column: 32, + column: 24, line: 3, }, ], @@ -245,490 +1671,438 @@ ruleTester.run('space-infix-ops', rule, { { code: ` class Test { - public readonly value =2; + value: string| (((() => void))); } `, output: ` class Test { - public readonly value = 2; + value: string | (((() => void))); } `, errors: [ { messageId: 'missingSpace', - column: 33, + column: 24, line: 3, }, ], }, { code: ` - type Test= string | number; + function foo() {} `, output: ` - type Test = string | number; + function foo() {} `, errors: [ { messageId: 'missingSpace', - column: 18, + column: 39, line: 2, }, ], }, { code: ` - type Test =string | number; + function foo void)>() {} `, output: ` - type Test = string | number; + function foo void)>() {} `, errors: [ { messageId: 'missingSpace', - column: 19, + column: 39, line: 2, }, ], }, { code: ` - type Test = string| number; + function foo void)))>() {} `, output: ` - type Test = string | number; + function foo void)))>() {} `, errors: [ { messageId: 'missingSpace', - column: 27, + column: 39, line: 2, }, ], }, { code: ` - type Test = string |number; + function foo() {} `, output: ` - type Test = string | number; + function foo() {} `, errors: [ { messageId: 'missingSpace', - column: 28, + column: 38, line: 2, }, ], }, { code: ` - type Test = string &number; + function foo void)>() {} `, output: ` - type Test = string & number; + function foo void)>() {} `, errors: [ { messageId: 'missingSpace', - column: 28, + column: 38, line: 2, }, ], }, { code: ` - type Test = string& number; + function foo void)))>() {} `, output: ` - type Test = string & number; + function foo void)))>() {} `, errors: [ { messageId: 'missingSpace', - column: 27, + column: 38, line: 2, }, ], }, { code: ` - type Test = - |string - | number; + function foo() {} `, output: ` - type Test = - | string - | number; + function foo() {} `, errors: [ { messageId: 'missingSpace', - column: 9, - line: 3, + column: 39, + line: 2, }, ], }, { code: ` - type Test = - &string - & number; + function foo void)>() {} `, output: ` - type Test = - & string - & number; + function foo void)>() {} `, errors: [ { messageId: 'missingSpace', - column: 9, - line: 3, + column: 39, + line: 2, }, ], }, { code: ` - interface Test { - prop: string| number; - } + function foo void)))>() {} `, output: ` - interface Test { - prop: string | number; - } + function foo void)))>() {} `, errors: [ { messageId: 'missingSpace', - column: 23, - line: 3, + column: 39, + line: 2, }, ], }, { code: ` - interface Test { - prop: string |number; - } + function foo() {} `, output: ` - interface Test { - prop: string | number; - } + function foo() {} `, errors: [ { messageId: 'missingSpace', - column: 24, - line: 3, + column: 38, + line: 2, }, ], }, { code: ` - interface Test { - prop: string &number; - } + function foo void)>() {} `, output: ` - interface Test { - prop: string & number; - } + function foo void)>() {} `, errors: [ { messageId: 'missingSpace', - column: 24, - line: 3, + column: 38, + line: 2, }, ], }, { code: ` - interface Test { - prop: string& number; - } + function foo void)))>() {} `, output: ` - interface Test { - prop: string & number; - } + function foo void)))>() {} `, errors: [ { messageId: 'missingSpace', - column: 23, - line: 3, + column: 38, + line: 2, }, ], }, { code: ` - interface Test { - prop: - |string - | number; - } + function bar(): string &number {} `, output: ` - interface Test { - prop: - | string - | number; - } + function bar(): string & number {} `, errors: [ { messageId: 'missingSpace', - column: 13, - line: 4, + column: 32, + line: 2, }, ], }, { code: ` - interface Test { - prop: - &string - & number; - } + function bar(): string &(() => void) {} `, output: ` - interface Test { - prop: - & string - & number; - } + function bar(): string & (() => void) {} `, errors: [ { messageId: 'missingSpace', - column: 13, - line: 4, + column: 32, + line: 2, }, ], }, { code: ` - const x: string &number; + function bar(): string &(((() => void))) {} `, output: ` - const x: string & number; + function bar(): string & (((() => void))) {} `, errors: [ { messageId: 'missingSpace', - column: 25, + column: 32, line: 2, }, ], }, { code: ` - const x: string& number; + function bar(): string& number {} `, output: ` - const x: string & number; + function bar(): string & number {} `, errors: [ { messageId: 'missingSpace', - column: 24, + column: 31, line: 2, }, ], }, { code: ` - const x: string| number; + function bar(): string& (() => void) {} `, output: ` - const x: string | number; + function bar(): string & (() => void) {} `, errors: [ { messageId: 'missingSpace', - column: 24, + column: 31, line: 2, }, ], }, { code: ` - class Test { - value: string |number; - } + function bar(): string& (((() => void))) {} `, output: ` - class Test { - value: string | number; - } + function bar(): string & (((() => void))) {} `, errors: [ { messageId: 'missingSpace', - column: 25, - line: 3, + column: 31, + line: 2, }, ], }, { code: ` - class Test { - value: string& number; - } + function bar(): string |number {} `, output: ` - class Test { - value: string & number; - } + function bar(): string | number {} `, errors: [ { messageId: 'missingSpace', - column: 24, - line: 3, + column: 32, + line: 2, }, ], }, { code: ` - class Test { - value: string| number; - } + function bar(): string |(() => void) {} `, output: ` - class Test { - value: string | number; - } + function bar(): string | (() => void) {} `, errors: [ { messageId: 'missingSpace', - column: 24, - line: 3, + column: 32, + line: 2, }, ], }, { code: ` - function foo() {} + function bar(): string |(((() => void))) {} `, output: ` - function foo() {} + function bar(): string | (((() => void))) {} `, errors: [ { messageId: 'missingSpace', - column: 39, + column: 32, line: 2, }, ], }, { code: ` - function foo() {} + function bar(): string| number {} `, output: ` - function foo() {} + function bar(): string | number {} `, errors: [ { messageId: 'missingSpace', - column: 38, + column: 31, line: 2, }, ], }, { code: ` - function foo() {} + function bar(): string| (() => void) {} `, output: ` - function foo() {} + function bar(): string | (() => void) {} `, errors: [ { messageId: 'missingSpace', - column: 39, + column: 31, line: 2, }, ], }, { code: ` - function foo() {} + function bar(): string| (((() => void))) {} `, output: ` - function foo() {} + function bar(): string | (((() => void))) {} `, errors: [ { messageId: 'missingSpace', - column: 38, + column: 31, line: 2, }, ], }, { code: ` - function bar(): string &number {} + function bar(): (() => boolean)| (() => void) {} `, output: ` - function bar(): string & number {} + function bar(): (() => boolean) | (() => void) {} `, errors: [ { messageId: 'missingSpace', - column: 32, + column: 40, line: 2, }, ], }, { code: ` - function bar(): string& number {} + function bar(): (((() => boolean)))| (((() => void))) {} `, output: ` - function bar(): string & number {} + function bar(): (((() => boolean))) | (((() => void))) {} `, errors: [ { messageId: 'missingSpace', - column: 31, + column: 44, line: 2, }, ], }, { code: ` - function bar(): string |number {} + function bar(): (() => boolean)& (() => void) {} `, output: ` - function bar(): string | number {} + function bar(): (() => boolean) & (() => void) {} `, errors: [ { messageId: 'missingSpace', - column: 32, + column: 40, line: 2, }, ], }, { code: ` - function bar(): string| number {} + function bar(): (((() => boolean)))& (((() => void))) {} `, output: ` - function bar(): string | number {} + function bar(): (((() => boolean))) & (((() => void))) {} `, errors: [ { messageId: 'missingSpace', - column: 31, + column: 44, line: 2, }, ], pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy