Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default util.createRule({
const typeNode = node.typeParameters ?? node.id;
const fixes: TSESLint.RuleFix[] = [];

const firstToken = sourceCode.getFirstToken(node);
const firstToken = sourceCode.getTokenBefore(node.id);
if (firstToken) {
fixes.push(fixer.replaceText(firstToken, 'interface'));
fixes.push(
Expand Down Expand Up @@ -98,7 +98,7 @@ export default util.createRule({
const typeNode = node.typeParameters ?? node.id;
const fixes: TSESLint.RuleFix[] = [];

const firstToken = sourceCode.getFirstToken(node);
const firstToken = sourceCode.getTokenBefore(node.id);
if (firstToken) {
fixes.push(fixer.replaceText(firstToken, 'type'));
fixes.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,5 +305,51 @@ export default Test
},
],
},
{
// https://github.com/typescript-eslint/typescript-eslint/issues/4333
code: `
export declare type Test = {
foo: string;
bar: string;
};
`,
output: `
export declare interface Test {
foo: string;
bar: string;
}
`,
options: ['interface'],
errors: [
{
messageId: 'interfaceOverType',
line: 2,
column: 21,
},
],
},
{
// https://github.com/typescript-eslint/typescript-eslint/issues/4333
code: `
export declare interface Test {
foo: string;
bar: string;
}
`,
output: noFormat`
export declare type Test = {
foo: string;
bar: string;
}
`,
options: ['type'],
errors: [
{
messageId: 'typeOverInterface',
line: 2,
column: 26,
},
],
},
],
});