Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
chore: better type for compat-shim
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Apr 5, 2021
1 parent 290dd0e commit 8a9404b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/compat-shim.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import type * as Tslint from "tslint";

type LinterTslintV3 = (filePath: string, text: string, configuration: Tslint.ILinterOptions) => { lint: () => Tslint.LintResult[] }

/**
* Shim for TSLint v3 interoperability
* @param {Function} Linter TSLint v3 linter
* @return {Function} TSLint v4-compatible linter
*/
export function shim(Linter: Function): typeof Tslint.Linter {
function LinterShim(options) {
export function shim(Linter: LinterTslintV3): typeof Tslint.Linter {
function LinterShim(options: Tslint.ILinterOptions) {
this.options = options;
this.results = {};
}
Expand All @@ -17,9 +19,9 @@ export function shim(Linter: Function): typeof Tslint.Linter {
// Assign instance methods
LinterShim.prototype = {
...Linter.prototype,
lint(filePath, text, configuration) {
const options = { ...this.options, configuration };
const linter = new Linter(filePath, text, options);
lint(filePath: string, text: string, configuration: Tslint.ILinterOptions) {
const options : Tslint.ILinterOptions = { ...this.options, configuration };
const linter = new Linter(filePath, text, options) as ReturnType<LinterTslintV3>;
this.results = linter.lint();
},
getResult() {
Expand Down

0 comments on commit 8a9404b

Please sign in to comment.