Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Really fix type parameter of applyWithFunction #2660

Merged
merged 5 commits into from
Aug 14, 2017
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix type error on undefined union
  • Loading branch information
ajafff committed Aug 14, 2017
commit 4ac711a2eee3a7998eb0a2d759914e8c67d6cd3c
4 changes: 3 additions & 1 deletion src/language/rule/abstractRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import * as ts from "typescript";
import { IWalker, WalkContext } from "../walker";
import { IOptions, IRule, IRuleMetadata, RuleFailure, RuleSeverity } from "./rule";

export type NoInfer<T> = T & {[K in keyof T]: T[K]};

export abstract class AbstractRule implements IRule {
public static metadata: IRuleMetadata;
protected readonly ruleArguments: any[];
Expand Down Expand Up @@ -48,7 +50,7 @@ export abstract class AbstractRule implements IRule {
}

protected applyWithFunction(sourceFile: ts.SourceFile, walkFn: (ctx: WalkContext<void>) => void): RuleFailure[];
protected applyWithFunction<T>(sourceFile: ts.SourceFile, walkFn: (ctx: WalkContext<T>) => void, options: {} & T): RuleFailure[];
protected applyWithFunction<T>(sourceFile: ts.SourceFile, walkFn: (ctx: WalkContext<T>) => void, options: NoInfer<T>): RuleFailure[];
protected applyWithFunction<T>(sourceFile: ts.SourceFile, walkFn: (ctx: WalkContext<T | void>) => void, options?: T): RuleFailure[] {
const ctx = new WalkContext(sourceFile, this.ruleName, options);
walkFn(ctx);
Expand Down