refactor thrift-parser wrapper

This commit is contained in:
Rinat Arsaev 2018-09-26 23:22:52 +03:00
parent fa2397dbd7
commit 82d86f5972
7 changed files with 16 additions and 23 deletions

View File

@ -1,2 +1,3 @@
package.json
package-lock.json
package-lock.json
node_modules

View File

@ -1,6 +1,6 @@
language: node_js
node_js:
- "10"
- "10"
cache:
directories:
- "node_modules"
directories:
- "node_modules"

View File

@ -1,5 +1,5 @@
import path = require("path");
import thriftPraser = require("./thriftParser");
import thriftPraser from "./thriftParser";
import BaseCompiler from "./BaseCompiler";
import ServiceCompiler from "./ServiceCompiler";
import { File, CompileOptions } from "./types";

11
src/thriftParser.d.ts vendored
View File

@ -1,11 +0,0 @@
/// <reference types="node" />
import { JsonAST } from "./ast";
interface ThriftFileParsingError extends Error {
messgae: string;
name: "THRIFT_FILE_PARSING_ERROR";
}
declare function parser(str: string | Buffer): JsonAST;
export = parser;

View File

@ -1,6 +0,0 @@
// thrift-parser have some type-definition problems
// we will not use it directly until they publish the new version
// in this way, we can import our "correct" d.ts file
// https://github.com/eleme/thrift-parser/commit/bb998c2836f20ee8dc431be38164c4d193320f87
const parser = require("thrift-parser");
module.exports = parser;

9
src/thriftParser.ts Normal file
View File

@ -0,0 +1,9 @@
import thriftParser from "thrift-parser";
import { JsonAST } from "./ast";
export interface ThriftFileParsingError extends Error {
messgae: string;
name: "THRIFT_FILE_PARSING_ERROR";
}
export default thriftParser as { (str: string | Buffer): JsonAST };

View File

@ -1,5 +1,5 @@
import BaseCompiler from "../src/BaseCompiler";
import thriftPraser = require("../src/thriftParser");
import thriftPraser from "../src/thriftParser";
import * as sinon from "sinon";
import * as chai from "chai";
import * as fs from "fs";