feat: add declarations for fork-ts-checker-webpack-plugin (#25494)

This commit is contained in:
JounQin
2018-05-03 23:53:11 +08:00
committed by Andy
parent 5ba9632d85
commit f7235908a0
4 changed files with 152 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
import { Configuration } from 'webpack';
import * as ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
let config: Configuration = {
plugins: [
new ForkTsCheckerWebpackPlugin()
]
};
config = {
plugins: [
new ForkTsCheckerWebpackPlugin({})
]
};
config = {
plugins: [
new ForkTsCheckerWebpackPlugin({
vue: true
})
]
};
export default config;

View File

@@ -0,0 +1,104 @@
// Type definitions for fork-ts-checker-webpack-plugin 0.4
// Project: https://github.com/Realytics/fork-ts-checker-webpack-plugin#readme
// Definitions by: JounQin <https://github.com/JounQin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node" />
import { RuleFailure } from 'tslint';
import { Diagnostic } from 'typescript';
import { Plugin } from 'webpack';
declare namespace ForkTsCheckerWebpackPlugin {
type ErrorType = 'diagnostic' | 'lint';
type Severity = 'error' | 'warning';
interface NormalizedMessageJson {
type: ErrorType;
code: string | number;
severity: Severity;
content: string;
file: string;
line: number;
character: number;
}
class NormalizedMessage {
static TYPE_DIAGNOSTIC: ErrorType;
static TYPE_LINT: ErrorType;
static SEVERITY_ERROR: Severity;
static SEVERITY_WARNING: Severity;
type: ErrorType;
code: string | number;
severity: Severity;
content: string;
file: string;
line: number;
character: number;
constructor(data: NormalizedMessageJson);
static createFromDiagnostic(diagnostic: Diagnostic): NormalizedMessage;
static createFromLint(lint: RuleFailure): NormalizedMessage;
static createFromJSON(json: NormalizedMessageJson): NormalizedMessage;
static compare(
messageA: NormalizedMessage,
messageB: NormalizedMessage,
): number;
static equals(
messageA: NormalizedMessage,
messageB: NormalizedMessage,
): boolean;
static deduplicate(messages: NormalizedMessage[]): NormalizedMessage[];
static compareTypes(typeA: ErrorType, typeB: ErrorType): number;
static compareSeverities(
severityA: Severity,
severityB: Severity,
): number;
static compareOptionalStrings(stringA: string, stringB: string): number;
static compareNumbers(numberA: number, numberB: number): number;
toJSON(): NormalizedMessageJson;
getType(): ErrorType;
isDiagnosticType(): boolean;
isLintType(): boolean;
getCode(): string | number;
getFormattedCode(): string | number;
getSeverity(): Severity;
isErrorSeverity(): boolean;
isWarningSeverity(): boolean;
getContent(): string;
getFile(): string;
getLine(): number;
getCharacter(): number;
}
type Formatter = (message: NormalizedMessage, useColors: boolean) => string;
interface Options {
tsconfig?: string;
tslint?: string | true;
watch?: string | string[];
async?: boolean;
ignoreDiagnostics?: number[];
ignoreLints?: string[];
colors?: boolean;
logger?: Console;
formatter?: 'default' | 'codeframe' | Formatter;
formatterOptions?: {
highlightCode?: boolean
linesAbove?: number
linesBelow?: number
forceColor?: boolean
};
silent?: boolean;
checkSyntacticErrors?: boolean;
memoryLimit?: number;
workers?: number;
vue?: boolean;
}
}
declare class ForkTsCheckerWebpackPlugin extends Plugin {
constructor(options?: ForkTsCheckerWebpackPlugin.Options);
}
export = ForkTsCheckerWebpackPlugin;

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"fork-ts-checker-webpack-plugin-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }