Skip to content

Commit

Permalink
feat: Upgrade to code-block-writer 10.1.0.
Browse files Browse the repository at this point in the history
This version is slightly faster.
  • Loading branch information
dsherret committed Nov 23, 2019
1 parent 6758eb4 commit 5eaf5ff
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 53 deletions.
11 changes: 10 additions & 1 deletion packages/ts-morph/lib/ts-morph.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { errors, ts } from "@ts-morph/common";
import { errors, ts, StandardizedFilePath } from "@ts-morph/common";

/**
* Represents a file system that can be interacted with.
Expand Down Expand Up @@ -12484,6 +12484,15 @@ export declare class CodeBlockWriter {
* will combine the internal array into a string.
*/
iterateLastChars<T>(action: (char: string, index: number) => T | undefined): T | undefined;
/**
* Iterates over the writer character char codes in reverse order. The iteration stops when a non-null or
* undefined value is returned from the action. The returned value is then returned by the method.
*
* @remarks It is much more efficient to use this method rather than `#toString()` since `#toString()`
* will combine the internal array into a string. Additionally, this is slightly more efficient that
* `iterateLastChars` as this won't allocate a string per character.
*/
iterateLastCharCodes<T>(action: (charCode: number, index: number) => T | undefined): T | undefined;
/**
* Gets the writer's text.
*/
Expand Down
6 changes: 2 additions & 4 deletions packages/ts-morph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@
"refactor": "ts-node --transpile-only scripts/refactor",
"output-wrapped-nodes": "ts-node --transpile-only scripts/generation/outputWrappedNodesInfo",
"package": "yarn build",
"publish-code-verification": "yarn code-verification && yarn ensure-no-declaration-file-errors && yarn ensure-declaration-files-not-changed",
"publish-code-verification": "yarn code-verification && yarn ensure-no-declaration-file-errors",
"code-verification": "ts-node --transpile-only scripts/verification/main ensure-structures-match-classes ensure-overload-structures-match ensure-array-inputs-readonly ensure-classes-implement-structure-methods ensure-mixin-not-applied-multiple-times validate-public-api-class-member-names validate-compiler-node-to-wrapped-type validate-code-fences",
"ensure-structures-match-classes": "ts-node --transpile-only scripts/verification/main ensure-structures-match-classes",
"ensure-overload-structures-match": "ts-node --transpile-only scripts/verification/main ensure-overload-structures-match",
"ensure-no-project-compile-errors": "ts-node --transpile-only scripts/verification/ensureNoProjectCompileErrors",
"ensure-no-declaration-file-errors": "ts-node --transpile-only scripts/verification/ensureNoDeclarationFileErrors",
"ensure-declaration-files-not-changed": "ts-node --transpile-only scripts/verification/ensureDeclarationFilesNotChanged",
"ensure-array-inputs-readonly": "ts-node --transpile-only scripts/verification/main ensure-array-inputs-readonly",
"ensure-or-throw-exists": "ts-node --transpile-only scripts/verification/main ensure-or-throw-exists",
"overwrite-declaration-files": "yarn build:declarations && shx cp -rf dist-declarations/ts-morph.d.ts lib/ts-morph.d.ts",
"type-check-docs": "ts-node --transpile-only scripts/typeCheckDocumentation.ts"
},
"repository": "git+https://github.com/dsherret/ts-morph.git",
Expand Down Expand Up @@ -71,7 +69,7 @@
"dependencies": {
"@dsherret/to-absolute-glob": "^2.0.2",
"@ts-morph/common": "~0.2.0",
"code-block-writer": "^10.0.0"
"code-block-writer": "^10.1.0"
},
"devDependencies": {
"@types/chai": "^4.2.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function createDeclarationFile() {
log("Adding getParent methods...");
addGetParentMethods();
log("Moving file...");
mainFile.move("ts-morph.d.ts");
mainFile.move("../lib/ts-morph.d.ts", { overwrite: true });
finishLog(lastDateTime!);

await Promise.all([mainFile.save()]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function getDeclarationFileStatements(mainFile: tsMorph.SourceFile) {
// add imports the typescript compiler api and code block writer files
statements.push({
kind: tsMorph.StructureKind.ImportDeclaration,
namedImports: ["errors", "ts"],
namedImports: ["errors", "ts", "StandardizedFilePath"],
moduleSpecifier: "@ts-morph/common"
});

Expand Down

This file was deleted.

4 changes: 4 additions & 0 deletions packages/ts-morph/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ code-block-writer@^10.0.0:
version "10.0.0"
resolved "https://registry.yarnpkg.com/code-block-writer/-/code-block-writer-10.0.0.tgz#d98a94b7ffb3ae9f9c02b531a3f5184ac7c0dbe3"

code-block-writer@^10.1.0:
version "10.1.0"
resolved "https://registry.yarnpkg.com/code-block-writer/-/code-block-writer-10.1.0.tgz#54fc410ebef2af836d9c2314ac40af7d7b37eee9"

color-convert@^1.9.0:
version "1.9.3"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
Expand Down

0 comments on commit 5eaf5ff

Please sign in to comment.