diff --git a/types/kythe/index.d.ts b/types/kythe/index.d.ts new file mode 100644 index 0000000000..634bbd8b20 --- /dev/null +++ b/types/kythe/index.d.ts @@ -0,0 +1,43 @@ +// Type definitions for non-npm package Kythe 0.0 +// Project: https://github.com/kythe/kythe +// Definitions by: Ayaz Hafiz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * A VName (Vector Name) for a node in the Kythe schema consists of: + * - `signature`: a unique, opaque signature for a node + * - `corpus`: a collection of related files the node is defined in + * - `root`: a label denoting a distinct subset of the corpus + * - `path`: the relative path of the file containing the node + * - `language`: programming language the node belongs to + */ +export interface VName { + signature: string; + corpus: string; + root: string; + path: string; + language: string; +} + +/** + * An Entry in the Kythe schema is either a Fact or an Edge that describes at least one node. + */ +export interface Entry { + source: VName; + label: string; +} + +/** + * A Fact is an Entry that also has a fact `value`. + */ +export interface Fact extends Entry { + value: string; +} + +/** + * An Edge is an Entry that also has a `target` and an edge `kind`. + */ +export interface Edge extends Entry { + target: VName; + kind: string; +} diff --git a/types/kythe/kythe-tests.ts b/types/kythe/kythe-tests.ts new file mode 100644 index 0000000000..030ae2d8f8 --- /dev/null +++ b/types/kythe/kythe-tests.ts @@ -0,0 +1,40 @@ +import { VName, Fact, Edge } from "kythe"; + +const vname: VName = { + signature: "sig#0", + corpus: "types", + root: "", + path: "tests", + language: "typescript", +}; + +const fact: Fact = { + source: vname, + label: "fact", + value: "complete", +}; + +const edge: Edge = { + source: vname, + target: vname, + kind: "edge", + label: "fact", +}; + +const incompleteVName: VName = { // $ExpectError + signature: "sig#0", + root: "", + language: "typescript" +}; + +const incompleteFact: Fact = { + source: vname, + label: "incomplete", + kind: "notEdge", // $ExpectError +}; + +const incompleteEdge: Edge = { + source: vname, + target: vname, + value: "notFact", // $ExpectError +}; diff --git a/types/kythe/tsconfig.json b/types/kythe/tsconfig.json new file mode 100644 index 0000000000..233e9f9a1a --- /dev/null +++ b/types/kythe/tsconfig.json @@ -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", + "kythe-tests.ts" + ] +} diff --git a/types/kythe/tslint.json b/types/kythe/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/kythe/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }