Skip to content

Commit

Permalink
chore: Fix compile errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Nov 21, 2020
1 parent 916ffb4 commit 7c524ec
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SyntaxKind } from "@ts-morph/common";
import { expect } from "chai";
import { ClassDeclaration } from "../../../../compiler";
import { ClassDeclarationSpecificStructure, ClassLikeDeclarationBaseSpecificStructure, ClassDeclarationStructure, InterfaceDeclarationStructure,
TypeParameterDeclarationStructure, StructureKind } from "../../../../structures";
StructureKind, OptionalKind } from "../../../../structures";
import { getInfoFromText, getInfoFromTextWithDescendant, OptionalKindAndTrivia, OptionalTrivia, fillStructures } from "../../testHelpers";

describe(nameof(ClassDeclaration), () => {
Expand All @@ -28,7 +28,7 @@ describe(nameof(ClassDeclaration), () => {
describe(nameof<ClassDeclaration>(c => c.set), () => {
function doTest(
startingCode: string,
structure: OptionalKindAndTrivia<ClassDeclarationSpecificStructure & ClassLikeDeclarationBaseSpecificStructure>,
structure: OptionalKind<ClassDeclarationSpecificStructure & ClassLikeDeclarationBaseSpecificStructure>,
expectedCode: string,
) {
const { firstChild, sourceFile } = getInfoFromText<ClassDeclaration>(startingCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe(nameof(ConstructorDeclaration), () => {
});

describe(nameof<ConstructorDeclaration>(n => n.set), () => {
function doTest(startingCode: string, structure: OptionalKindAndTrivia<ConstructorDeclarationSpecificStructure>, expectedCode: string) {
function doTest(startingCode: string, structure: OptionalKind<ConstructorDeclarationSpecificStructure>, expectedCode: string) {
const { firstChild, sourceFile } = getInfoFromText<ClassDeclaration>(startingCode);
const ctor = firstChild.getConstructors()[0];
ctor.set(structure);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ describe(nameof(MethodDeclaration), () => {
});

describe(nameof<MethodDeclaration>(m => m.set), () => {
function doTest(startingCode: string, structure: OptionalKindAndTrivia<MethodDeclarationSpecificStructure>, expectedCode: string) {
function doTest(startingCode: string, structure: OptionalKind<MethodDeclarationSpecificStructure>, expectedCode: string) {
const { firstChild, sourceFile } = getInfoFromText<ClassDeclaration>(startingCode);
const method = firstChild.getInstanceMethods()[0];
method.set(structure);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ describe(nameof(EnumDeclaration), () => {
});

describe(nameof<EnumDeclaration>(n => n.set), () => {
function doTest(startingCode: string, structure: OptionalKindAndTrivia<EnumDeclarationSpecificStructure>, expectedCode: string) {
const { firstChild, sourceFile } = getInfoFromText<EnumDeclaration>(startingCode);
function doTest(startingCode: string, structure: OptionalKind<EnumDeclarationSpecificStructure>, expectedCode: string) {
const { firstChild } = getInfoFromText<EnumDeclaration>(startingCode);
firstChild.set(structure);
expect(firstChild.getText()).to.equal(expectedCode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe(nameof(FunctionDeclaration), () => {
});

describe(nameof<FunctionDeclaration>(f => f.set), () => {
function doTest(startingCode: string, structure: OptionalKindAndTrivia<FunctionDeclarationSpecificStructure>, expectedCode: string) {
function doTest(startingCode: string, structure: OptionalKind<FunctionDeclarationSpecificStructure>, expectedCode: string) {
const { sourceFile } = getInfoFromText(startingCode);
sourceFile.getFunctions()[0].set(structure);
expect(sourceFile.getText()).to.equal(expectedCode);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from "chai";
import { InterfaceDeclaration } from "../../../../compiler";
import { InterfaceDeclarationStructure, InterfaceDeclarationSpecificStructure, TypeParameterDeclarationStructure, StructureKind } from "../../../../structures";
import { InterfaceDeclarationStructure, InterfaceDeclarationSpecificStructure, TypeParameterDeclarationStructure, StructureKind, OptionalKind } from "../../../../structures";
import { getInfoFromText, OptionalKindAndTrivia, OptionalTrivia, fillStructures } from "../../testHelpers";

describe(nameof(InterfaceDeclaration), () => {
Expand Down Expand Up @@ -57,7 +57,7 @@ describe(nameof(InterfaceDeclaration), () => {
});

describe(nameof<InterfaceDeclaration>(d => d.set), () => {
function doTest(startingCode: string, structure: OptionalKindAndTrivia<InterfaceDeclarationSpecificStructure>, expectedCode: string) {
function doTest(startingCode: string, structure: OptionalKind<InterfaceDeclarationSpecificStructure>, expectedCode: string) {
const { firstChild } = getInfoFromText<InterfaceDeclaration>(startingCode);
firstChild.set(structure);
expect(firstChild.getText()).to.equal(expectedCode);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect } from "chai";
import { NamespaceDeclaration, NamespaceDeclarationKind, VariableDeclarationKind } from "../../../../compiler";
import { errors } from "@ts-morph/common";
import { NamespaceDeclarationStructure, NamespaceDeclarationSpecificStructure, StructureKind } from "../../../../structures";
import { getInfoFromText, OptionalKindAndTrivia, fillStructures, OptionalTrivia } from "../../testHelpers";
import { NamespaceDeclarationStructure, NamespaceDeclarationSpecificStructure, StructureKind, OptionalKind } from "../../../../structures";
import { getInfoFromText, fillStructures, OptionalTrivia } from "../../testHelpers";

describe(nameof(NamespaceDeclaration), () => {
describe(nameof<NamespaceDeclaration>(d => d.getName), () => {
Expand Down Expand Up @@ -217,7 +217,7 @@ describe(nameof(NamespaceDeclaration), () => {
});

it("should modify when changed", () => {
const structure: OptionalKindAndTrivia<MakeRequired<NamespaceDeclarationSpecificStructure>> = {
const structure: OptionalKind<MakeRequired<NamespaceDeclarationSpecificStructure>> = {
declarationKind: NamespaceDeclarationKind.Module,
};
doTest("namespace Identifier {\n}", structure, "module Identifier {\n}");
Expand Down
8 changes: 4 additions & 4 deletions packages/ts-morph/src/tests/compiler/testHelpers/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Structure, StructureKind } from "../../../structures";

export type OptionalKindAndTrivia<T extends Structure & { kind?: StructureKind; }> =
& Omit<T, "kind" | "leadingTrivia" | "trailingTrivia">
& Partial<Pick<T, "kind" | "leadingTrivia" | "trailingTrivia">>;
& Partial<Pick<T, "kind" | "leadingTrivia" | "trailingTrivia">>
& Omit<T, "kind" | "leadingTrivia" | "trailingTrivia">;

export type OptionalTrivia<T extends Structure> =
& Omit<T, "leadingTrivia" | "trailingTrivia">
& Partial<Pick<T, "leadingTrivia" | "trailingTrivia">>;
& Partial<Pick<T, "leadingTrivia" | "trailingTrivia">>
& Omit<T, "leadingTrivia" | "trailingTrivia">;

0 comments on commit 7c524ec

Please sign in to comment.