From 6c336639839fa326521ed80c8727eed351abcbb0 Mon Sep 17 00:00:00 2001 From: Jesus David Garcia Gomez Date: Tue, 22 Aug 2017 13:10:37 -0700 Subject: [PATCH] Build: Generate files `d.ts` Related #432 --- src/lib/sonar.ts | 4 ++-- tests/helpers/connectors.ts | 3 +++ tests/helpers/test-server.ts | 12 +++++------- tsconfig.json | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/lib/sonar.ts b/src/lib/sonar.ts index 8a5ad01f5f1..b89116118f8 100644 --- a/src/lib/sonar.ts +++ b/src/lib/sonar.ts @@ -16,7 +16,7 @@ import { EventEmitter2 as EventEmitter } from 'eventemitter2'; import { debug as d } from './utils/debug'; import { getSeverity } from './config/config-rules'; -import { IAsyncHTMLElement, IConnector, IConnectorBuilder, IConfig, IEvent, IProblem, IProblemLocation, IRule, IRuleBuilder, IRuleConfigList, IPlugin, RuleConfig, Severity, URL } from './types'; // eslint-disable-line no-unused-vars +import { IAsyncHTMLElement, IConnector, IConnectorBuilder, INetworkData, IConfig, IEvent, IProblem, IProblemLocation, IRule, IRuleBuilder, IRuleConfigList, IPlugin, RuleConfig, Severity, URL } from './types'; // eslint-disable-line no-unused-vars import * as logger from './utils/logging'; import * as resourceLoader from './utils/resource-loader'; import normalizeRules from './utils/normalize-rules'; @@ -223,7 +223,7 @@ export class Sonar extends EventEmitter { debug(`Rules loaded: ${this.rules.size}`); } - public fetchContent(target: string | url.Url, headers: object) { + public fetchContent(target: string | url.Url, headers: object): Promise { return this.connector.fetchContent(target, headers); } diff --git a/tests/helpers/connectors.ts b/tests/helpers/connectors.ts index 42431bdf64b..ae377092fa3 100644 --- a/tests/helpers/connectors.ts +++ b/tests/helpers/connectors.ts @@ -1,3 +1,6 @@ +// We need to import this interface to generate the definition of this file +import { IConnectorBuilder } from '../../src/lib/types'; // eslint-disable-line no-unused-vars + import cdpBuilder from '../../src/lib/connectors/cdp/cdp'; import jsdomBuilder from '../../src/lib/connectors/jsdom/jsdom'; diff --git a/tests/helpers/test-server.ts b/tests/helpers/test-server.ts index 5eca38e7daf..7c2fa989811 100644 --- a/tests/helpers/test-server.ts +++ b/tests/helpers/test-server.ts @@ -11,13 +11,13 @@ import * as express from 'express'; import * as onHeaders from 'on-headers'; import { promisify } from 'util'; -type ServerConfiguration = string | object; //eslint-disable-line +export type ServerConfiguration = string | object; //eslint-disable-line const startPort = 3000; const maxPort = 65535; /** A testing server for Sonar rules */ -class Server { +export class Server { private _app; private _server: https.Server | http.Server; private _port: number = startPort; @@ -166,10 +166,8 @@ class Server { } /** Returns a testing server */ -const createServer = (isHTTPS?: boolean) => { - const server = new Server(isHTTPS); +export const createServer = (isHTTPS?: boolean) => { + const a = new Server(isHTTPS); - return server; + return a; }; - -export { createServer, Server }; diff --git a/tsconfig.json b/tsconfig.json index c47dff1efd3..7abb77e15f3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,10 @@ { "compilerOptions": { - "allowJs": true, "alwaysStrict": true, "module": "commonjs", "sourceMap": true, "target": "esnext", + "declaration": true, "lib": [ "es2017", "esnext",