mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-10 21:07:52 -05:00
646
bin/tsc.js
646
bin/tsc.js
File diff suppressed because it is too large
Load Diff
1254
bin/tsserver.js
1254
bin/tsserver.js
File diff suppressed because it is too large
Load Diff
54
bin/typescript.d.ts
vendored
54
bin/typescript.d.ts
vendored
@@ -124,16 +124,16 @@ declare module "typescript" {
|
||||
VoidKeyword = 99,
|
||||
WhileKeyword = 100,
|
||||
WithKeyword = 101,
|
||||
AsKeyword = 102,
|
||||
ImplementsKeyword = 103,
|
||||
InterfaceKeyword = 104,
|
||||
LetKeyword = 105,
|
||||
PackageKeyword = 106,
|
||||
PrivateKeyword = 107,
|
||||
ProtectedKeyword = 108,
|
||||
PublicKeyword = 109,
|
||||
StaticKeyword = 110,
|
||||
YieldKeyword = 111,
|
||||
ImplementsKeyword = 102,
|
||||
InterfaceKeyword = 103,
|
||||
LetKeyword = 104,
|
||||
PackageKeyword = 105,
|
||||
PrivateKeyword = 106,
|
||||
ProtectedKeyword = 107,
|
||||
PublicKeyword = 108,
|
||||
StaticKeyword = 109,
|
||||
YieldKeyword = 110,
|
||||
AsKeyword = 111,
|
||||
AnyKeyword = 112,
|
||||
BooleanKeyword = 113,
|
||||
ConstructorKeyword = 114,
|
||||
@@ -258,8 +258,8 @@ declare module "typescript" {
|
||||
LastReservedWord = 101,
|
||||
FirstKeyword = 66,
|
||||
LastKeyword = 125,
|
||||
FirstFutureReservedWord = 103,
|
||||
LastFutureReservedWord = 111,
|
||||
FirstFutureReservedWord = 102,
|
||||
LastFutureReservedWord = 110,
|
||||
FirstTypeNode = 141,
|
||||
LastTypeNode = 149,
|
||||
FirstPunctuation = 14,
|
||||
@@ -310,6 +310,7 @@ declare module "typescript" {
|
||||
}
|
||||
interface Identifier extends PrimaryExpression {
|
||||
text: string;
|
||||
originalKeywordKind?: SyntaxKind;
|
||||
}
|
||||
interface QualifiedName extends Node {
|
||||
left: EntityName;
|
||||
@@ -1181,6 +1182,34 @@ declare module "typescript" {
|
||||
function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean;
|
||||
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
|
||||
}
|
||||
declare module "typescript" {
|
||||
function getDefaultLibFileName(options: CompilerOptions): string;
|
||||
function textSpanEnd(span: TextSpan): number;
|
||||
function textSpanIsEmpty(span: TextSpan): boolean;
|
||||
function textSpanContainsPosition(span: TextSpan, position: number): boolean;
|
||||
function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean;
|
||||
function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean;
|
||||
function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan;
|
||||
function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean;
|
||||
function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean;
|
||||
function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean;
|
||||
function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan;
|
||||
function createTextSpan(start: number, length: number): TextSpan;
|
||||
function createTextSpanFromBounds(start: number, end: number): TextSpan;
|
||||
function textChangeRangeNewSpan(range: TextChangeRange): TextSpan;
|
||||
function textChangeRangeIsUnchanged(range: TextChangeRange): boolean;
|
||||
function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange;
|
||||
let unchangedTextChangeRange: TextChangeRange;
|
||||
/**
|
||||
* Called to merge all the changes that occurred across several versions of a script snapshot
|
||||
* into a single change. i.e. if a user keeps making successive edits to a script we will
|
||||
* have a text change from V1 to V2, V2 to V3, ..., Vn.
|
||||
*
|
||||
* This function will then merge those changes into a single change range valid between V1 and
|
||||
* Vn.
|
||||
*/
|
||||
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
|
||||
}
|
||||
declare module "typescript" {
|
||||
function getNodeConstructor(kind: SyntaxKind): new () => Node;
|
||||
function createNode(kind: SyntaxKind): Node;
|
||||
@@ -1260,7 +1289,6 @@ declare module "typescript" {
|
||||
getDocumentationComment(): SymbolDisplayPart[];
|
||||
}
|
||||
interface SourceFile {
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
|
||||
1449
bin/typescript.js
1449
bin/typescript.js
File diff suppressed because it is too large
Load Diff
54
bin/typescriptServices.d.ts
vendored
54
bin/typescriptServices.d.ts
vendored
@@ -124,16 +124,16 @@ declare module ts {
|
||||
VoidKeyword = 99,
|
||||
WhileKeyword = 100,
|
||||
WithKeyword = 101,
|
||||
AsKeyword = 102,
|
||||
ImplementsKeyword = 103,
|
||||
InterfaceKeyword = 104,
|
||||
LetKeyword = 105,
|
||||
PackageKeyword = 106,
|
||||
PrivateKeyword = 107,
|
||||
ProtectedKeyword = 108,
|
||||
PublicKeyword = 109,
|
||||
StaticKeyword = 110,
|
||||
YieldKeyword = 111,
|
||||
ImplementsKeyword = 102,
|
||||
InterfaceKeyword = 103,
|
||||
LetKeyword = 104,
|
||||
PackageKeyword = 105,
|
||||
PrivateKeyword = 106,
|
||||
ProtectedKeyword = 107,
|
||||
PublicKeyword = 108,
|
||||
StaticKeyword = 109,
|
||||
YieldKeyword = 110,
|
||||
AsKeyword = 111,
|
||||
AnyKeyword = 112,
|
||||
BooleanKeyword = 113,
|
||||
ConstructorKeyword = 114,
|
||||
@@ -258,8 +258,8 @@ declare module ts {
|
||||
LastReservedWord = 101,
|
||||
FirstKeyword = 66,
|
||||
LastKeyword = 125,
|
||||
FirstFutureReservedWord = 103,
|
||||
LastFutureReservedWord = 111,
|
||||
FirstFutureReservedWord = 102,
|
||||
LastFutureReservedWord = 110,
|
||||
FirstTypeNode = 141,
|
||||
LastTypeNode = 149,
|
||||
FirstPunctuation = 14,
|
||||
@@ -310,6 +310,7 @@ declare module ts {
|
||||
}
|
||||
interface Identifier extends PrimaryExpression {
|
||||
text: string;
|
||||
originalKeywordKind?: SyntaxKind;
|
||||
}
|
||||
interface QualifiedName extends Node {
|
||||
left: EntityName;
|
||||
@@ -1181,6 +1182,34 @@ declare module ts {
|
||||
function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean;
|
||||
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
|
||||
}
|
||||
declare module ts {
|
||||
function getDefaultLibFileName(options: CompilerOptions): string;
|
||||
function textSpanEnd(span: TextSpan): number;
|
||||
function textSpanIsEmpty(span: TextSpan): boolean;
|
||||
function textSpanContainsPosition(span: TextSpan, position: number): boolean;
|
||||
function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean;
|
||||
function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean;
|
||||
function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan;
|
||||
function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean;
|
||||
function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean;
|
||||
function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean;
|
||||
function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan;
|
||||
function createTextSpan(start: number, length: number): TextSpan;
|
||||
function createTextSpanFromBounds(start: number, end: number): TextSpan;
|
||||
function textChangeRangeNewSpan(range: TextChangeRange): TextSpan;
|
||||
function textChangeRangeIsUnchanged(range: TextChangeRange): boolean;
|
||||
function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange;
|
||||
let unchangedTextChangeRange: TextChangeRange;
|
||||
/**
|
||||
* Called to merge all the changes that occurred across several versions of a script snapshot
|
||||
* into a single change. i.e. if a user keeps making successive edits to a script we will
|
||||
* have a text change from V1 to V2, V2 to V3, ..., Vn.
|
||||
*
|
||||
* This function will then merge those changes into a single change range valid between V1 and
|
||||
* Vn.
|
||||
*/
|
||||
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
|
||||
}
|
||||
declare module ts {
|
||||
function getNodeConstructor(kind: SyntaxKind): new () => Node;
|
||||
function createNode(kind: SyntaxKind): Node;
|
||||
@@ -1260,7 +1289,6 @@ declare module ts {
|
||||
getDocumentationComment(): SymbolDisplayPart[];
|
||||
}
|
||||
interface SourceFile {
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -659,10 +659,6 @@ module ts {
|
||||
"\u0085": "\\u0085" // nextLine
|
||||
};
|
||||
|
||||
export function getDefaultLibFileName(options: CompilerOptions): string {
|
||||
return options.target === ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts";
|
||||
}
|
||||
|
||||
export interface ObjectAllocator {
|
||||
getNodeConstructor(kind: SyntaxKind): new () => Node;
|
||||
getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol;
|
||||
|
||||
@@ -271,7 +271,6 @@ module ts {
|
||||
};
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function getSpanOfTokenAtPosition(sourceFile: SourceFile, pos: number): TextSpan {
|
||||
let scanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.text);
|
||||
scanner.setTextPos(pos);
|
||||
@@ -408,7 +407,6 @@ module ts {
|
||||
|
||||
export let fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/
|
||||
|
||||
|
||||
// Warning: This has the same semantics as the forEach family of functions,
|
||||
// in that traversal terminates in the event that 'visitor' supplies a truthy value.
|
||||
export function forEachReturnStatement<T>(body: Block, visitor: (stmt: ReturnStatement) => T): T {
|
||||
@@ -439,7 +437,6 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function isVariableLike(node: Node): boolean {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
@@ -1151,218 +1148,7 @@ module ts {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function textSpanEnd(span: TextSpan) {
|
||||
return span.start + span.length
|
||||
}
|
||||
|
||||
export function textSpanIsEmpty(span: TextSpan) {
|
||||
return span.length === 0
|
||||
}
|
||||
|
||||
export function textSpanContainsPosition(span: TextSpan, position: number) {
|
||||
return position >= span.start && position < textSpanEnd(span);
|
||||
}
|
||||
|
||||
// Returns true if 'span' contains 'other'.
|
||||
export function textSpanContainsTextSpan(span: TextSpan, other: TextSpan) {
|
||||
return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span);
|
||||
}
|
||||
|
||||
export function textSpanOverlapsWith(span: TextSpan, other: TextSpan) {
|
||||
let overlapStart = Math.max(span.start, other.start);
|
||||
let overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other));
|
||||
return overlapStart < overlapEnd;
|
||||
}
|
||||
|
||||
export function textSpanOverlap(span1: TextSpan, span2: TextSpan) {
|
||||
let overlapStart = Math.max(span1.start, span2.start);
|
||||
let overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
|
||||
if (overlapStart < overlapEnd) {
|
||||
return createTextSpanFromBounds(overlapStart, overlapEnd);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan) {
|
||||
return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start
|
||||
}
|
||||
|
||||
export function textSpanIntersectsWith(span: TextSpan, start: number, length: number) {
|
||||
let end = start + length;
|
||||
return start <= textSpanEnd(span) && end >= span.start;
|
||||
}
|
||||
|
||||
export function textSpanIntersectsWithPosition(span: TextSpan, position: number) {
|
||||
return position <= textSpanEnd(span) && position >= span.start;
|
||||
}
|
||||
|
||||
export function textSpanIntersection(span1: TextSpan, span2: TextSpan) {
|
||||
let intersectStart = Math.max(span1.start, span2.start);
|
||||
let intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
|
||||
if (intersectStart <= intersectEnd) {
|
||||
return createTextSpanFromBounds(intersectStart, intersectEnd);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function createTextSpan(start: number, length: number): TextSpan {
|
||||
if (start < 0) {
|
||||
throw new Error("start < 0");
|
||||
}
|
||||
if (length < 0) {
|
||||
throw new Error("length < 0");
|
||||
}
|
||||
|
||||
return { start, length };
|
||||
}
|
||||
|
||||
export function createTextSpanFromBounds(start: number, end: number) {
|
||||
return createTextSpan(start, end - start);
|
||||
}
|
||||
|
||||
export function textChangeRangeNewSpan(range: TextChangeRange) {
|
||||
return createTextSpan(range.span.start, range.newLength);
|
||||
}
|
||||
|
||||
export function textChangeRangeIsUnchanged(range: TextChangeRange) {
|
||||
return textSpanIsEmpty(range.span) && range.newLength === 0;
|
||||
}
|
||||
|
||||
export function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange {
|
||||
if (newLength < 0) {
|
||||
throw new Error("newLength < 0");
|
||||
}
|
||||
|
||||
return { span, newLength };
|
||||
}
|
||||
|
||||
export let unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
|
||||
|
||||
/**
|
||||
* Called to merge all the changes that occurred across several versions of a script snapshot
|
||||
* into a single change. i.e. if a user keeps making successive edits to a script we will
|
||||
* have a text change from V1 to V2, V2 to V3, ..., Vn.
|
||||
*
|
||||
* This function will then merge those changes into a single change range valid between V1 and
|
||||
* Vn.
|
||||
*/
|
||||
export function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange {
|
||||
if (changes.length === 0) {
|
||||
return unchangedTextChangeRange;
|
||||
}
|
||||
|
||||
if (changes.length === 1) {
|
||||
return changes[0];
|
||||
}
|
||||
|
||||
// We change from talking about { { oldStart, oldLength }, newLength } to { oldStart, oldEnd, newEnd }
|
||||
// as it makes things much easier to reason about.
|
||||
let change0 = changes[0];
|
||||
|
||||
let oldStartN = change0.span.start;
|
||||
let oldEndN = textSpanEnd(change0.span);
|
||||
let newEndN = oldStartN + change0.newLength;
|
||||
|
||||
for (let i = 1; i < changes.length; i++) {
|
||||
let nextChange = changes[i];
|
||||
|
||||
// Consider the following case:
|
||||
// i.e. two edits. The first represents the text change range { { 10, 50 }, 30 }. i.e. The span starting
|
||||
// at 10, with length 50 is reduced to length 30. The second represents the text change range { { 30, 30 }, 40 }.
|
||||
// i.e. the span starting at 30 with length 30 is increased to length 40.
|
||||
//
|
||||
// 0 10 20 30 40 50 60 70 80 90 100
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// | /
|
||||
// | /----
|
||||
// T1 | /----
|
||||
// | /----
|
||||
// | /----
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// | \
|
||||
// | \
|
||||
// T2 | \
|
||||
// | \
|
||||
// | \
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// Merging these turns out to not be too difficult. First, determining the new start of the change is trivial
|
||||
// it's just the min of the old and new starts. i.e.:
|
||||
//
|
||||
// 0 10 20 30 40 50 60 70 80 90 100
|
||||
// ------------------------------------------------------------*------------------------------------------
|
||||
// | /
|
||||
// | /----
|
||||
// T1 | /----
|
||||
// | /----
|
||||
// | /----
|
||||
// ----------------------------------------$-------------------$------------------------------------------
|
||||
// . | \
|
||||
// . | \
|
||||
// T2 . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// ----------------------------------------------------------------------*--------------------------------
|
||||
//
|
||||
// (Note the dots represent the newly inferrred start.
|
||||
// Determining the new and old end is also pretty simple. Basically it boils down to paying attention to the
|
||||
// absolute positions at the asterixes, and the relative change between the dollar signs. Basically, we see
|
||||
// which if the two $'s precedes the other, and we move that one forward until they line up. in this case that
|
||||
// means:
|
||||
//
|
||||
// 0 10 20 30 40 50 60 70 80 90 100
|
||||
// --------------------------------------------------------------------------------*----------------------
|
||||
// | /
|
||||
// | /----
|
||||
// T1 | /----
|
||||
// | /----
|
||||
// | /----
|
||||
// ------------------------------------------------------------$------------------------------------------
|
||||
// . | \
|
||||
// . | \
|
||||
// T2 . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// ----------------------------------------------------------------------*--------------------------------
|
||||
//
|
||||
// In other words (in this case), we're recognizing that the second edit happened after where the first edit
|
||||
// ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started
|
||||
// that's the same as if we started at char 80 instead of 60.
|
||||
//
|
||||
// As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter
|
||||
// than pusing the first edit forward to match the second, we'll push the second edit forward to match the
|
||||
// first.
|
||||
//
|
||||
// In this case that means we have { oldStart: 10, oldEnd: 80, newEnd: 70 } or, in TextChangeRange
|
||||
// semantics: { { start: 10, length: 70 }, newLength: 60 }
|
||||
//
|
||||
// The math then works out as follows.
|
||||
// If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the
|
||||
// final result like so:
|
||||
//
|
||||
// {
|
||||
// oldStart3: Min(oldStart1, oldStart2),
|
||||
// oldEnd3 : Max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)),
|
||||
// newEnd3 : Max(newEnd2, newEnd2 + (newEnd1 - oldEnd2))
|
||||
// }
|
||||
|
||||
let oldStart1 = oldStartN;
|
||||
let oldEnd1 = oldEndN;
|
||||
let newEnd1 = newEndN;
|
||||
|
||||
let oldStart2 = nextChange.span.start;
|
||||
let oldEnd2 = textSpanEnd(nextChange.span);
|
||||
let newEnd2 = oldStart2 + nextChange.newLength;
|
||||
|
||||
oldStartN = Math.min(oldStart1, oldStart2);
|
||||
oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
|
||||
newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
|
||||
}
|
||||
|
||||
return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN);
|
||||
}
|
||||
|
||||
|
||||
export function nodeStartsNewLexicalEnvironment(n: Node): boolean {
|
||||
return isFunctionLike(n) || n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.SourceFile;
|
||||
}
|
||||
@@ -1379,7 +1165,6 @@ module ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function createDiagnosticCollection(): DiagnosticCollection {
|
||||
let nonFileDiagnostics: Diagnostic[] = [];
|
||||
let fileDiagnostics: Map<Diagnostic[]> = {};
|
||||
@@ -1854,3 +1639,220 @@ module ts {
|
||||
return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined;
|
||||
}
|
||||
}
|
||||
|
||||
module ts {
|
||||
export function getDefaultLibFileName(options: CompilerOptions): string {
|
||||
return options.target === ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts";
|
||||
}
|
||||
|
||||
export function textSpanEnd(span: TextSpan) {
|
||||
return span.start + span.length
|
||||
}
|
||||
|
||||
export function textSpanIsEmpty(span: TextSpan) {
|
||||
return span.length === 0
|
||||
}
|
||||
|
||||
export function textSpanContainsPosition(span: TextSpan, position: number) {
|
||||
return position >= span.start && position < textSpanEnd(span);
|
||||
}
|
||||
|
||||
// Returns true if 'span' contains 'other'.
|
||||
export function textSpanContainsTextSpan(span: TextSpan, other: TextSpan) {
|
||||
return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span);
|
||||
}
|
||||
|
||||
export function textSpanOverlapsWith(span: TextSpan, other: TextSpan) {
|
||||
let overlapStart = Math.max(span.start, other.start);
|
||||
let overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other));
|
||||
return overlapStart < overlapEnd;
|
||||
}
|
||||
|
||||
export function textSpanOverlap(span1: TextSpan, span2: TextSpan) {
|
||||
let overlapStart = Math.max(span1.start, span2.start);
|
||||
let overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
|
||||
if (overlapStart < overlapEnd) {
|
||||
return createTextSpanFromBounds(overlapStart, overlapEnd);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan) {
|
||||
return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start
|
||||
}
|
||||
|
||||
export function textSpanIntersectsWith(span: TextSpan, start: number, length: number) {
|
||||
let end = start + length;
|
||||
return start <= textSpanEnd(span) && end >= span.start;
|
||||
}
|
||||
|
||||
export function textSpanIntersectsWithPosition(span: TextSpan, position: number) {
|
||||
return position <= textSpanEnd(span) && position >= span.start;
|
||||
}
|
||||
|
||||
export function textSpanIntersection(span1: TextSpan, span2: TextSpan) {
|
||||
let intersectStart = Math.max(span1.start, span2.start);
|
||||
let intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2));
|
||||
if (intersectStart <= intersectEnd) {
|
||||
return createTextSpanFromBounds(intersectStart, intersectEnd);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function createTextSpan(start: number, length: number): TextSpan {
|
||||
if (start < 0) {
|
||||
throw new Error("start < 0");
|
||||
}
|
||||
if (length < 0) {
|
||||
throw new Error("length < 0");
|
||||
}
|
||||
|
||||
return { start, length };
|
||||
}
|
||||
|
||||
export function createTextSpanFromBounds(start: number, end: number) {
|
||||
return createTextSpan(start, end - start);
|
||||
}
|
||||
|
||||
export function textChangeRangeNewSpan(range: TextChangeRange) {
|
||||
return createTextSpan(range.span.start, range.newLength);
|
||||
}
|
||||
|
||||
export function textChangeRangeIsUnchanged(range: TextChangeRange) {
|
||||
return textSpanIsEmpty(range.span) && range.newLength === 0;
|
||||
}
|
||||
|
||||
export function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange {
|
||||
if (newLength < 0) {
|
||||
throw new Error("newLength < 0");
|
||||
}
|
||||
|
||||
return { span, newLength };
|
||||
}
|
||||
|
||||
export let unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
|
||||
|
||||
/**
|
||||
* Called to merge all the changes that occurred across several versions of a script snapshot
|
||||
* into a single change. i.e. if a user keeps making successive edits to a script we will
|
||||
* have a text change from V1 to V2, V2 to V3, ..., Vn.
|
||||
*
|
||||
* This function will then merge those changes into a single change range valid between V1 and
|
||||
* Vn.
|
||||
*/
|
||||
export function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange {
|
||||
if (changes.length === 0) {
|
||||
return unchangedTextChangeRange;
|
||||
}
|
||||
|
||||
if (changes.length === 1) {
|
||||
return changes[0];
|
||||
}
|
||||
|
||||
// We change from talking about { { oldStart, oldLength }, newLength } to { oldStart, oldEnd, newEnd }
|
||||
// as it makes things much easier to reason about.
|
||||
let change0 = changes[0];
|
||||
|
||||
let oldStartN = change0.span.start;
|
||||
let oldEndN = textSpanEnd(change0.span);
|
||||
let newEndN = oldStartN + change0.newLength;
|
||||
|
||||
for (let i = 1; i < changes.length; i++) {
|
||||
let nextChange = changes[i];
|
||||
|
||||
// Consider the following case:
|
||||
// i.e. two edits. The first represents the text change range { { 10, 50 }, 30 }. i.e. The span starting
|
||||
// at 10, with length 50 is reduced to length 30. The second represents the text change range { { 30, 30 }, 40 }.
|
||||
// i.e. the span starting at 30 with length 30 is increased to length 40.
|
||||
//
|
||||
// 0 10 20 30 40 50 60 70 80 90 100
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// | /
|
||||
// | /----
|
||||
// T1 | /----
|
||||
// | /----
|
||||
// | /----
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// | \
|
||||
// | \
|
||||
// T2 | \
|
||||
// | \
|
||||
// | \
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// Merging these turns out to not be too difficult. First, determining the new start of the change is trivial
|
||||
// it's just the min of the old and new starts. i.e.:
|
||||
//
|
||||
// 0 10 20 30 40 50 60 70 80 90 100
|
||||
// ------------------------------------------------------------*------------------------------------------
|
||||
// | /
|
||||
// | /----
|
||||
// T1 | /----
|
||||
// | /----
|
||||
// | /----
|
||||
// ----------------------------------------$-------------------$------------------------------------------
|
||||
// . | \
|
||||
// . | \
|
||||
// T2 . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// ----------------------------------------------------------------------*--------------------------------
|
||||
//
|
||||
// (Note the dots represent the newly inferrred start.
|
||||
// Determining the new and old end is also pretty simple. Basically it boils down to paying attention to the
|
||||
// absolute positions at the asterixes, and the relative change between the dollar signs. Basically, we see
|
||||
// which if the two $'s precedes the other, and we move that one forward until they line up. in this case that
|
||||
// means:
|
||||
//
|
||||
// 0 10 20 30 40 50 60 70 80 90 100
|
||||
// --------------------------------------------------------------------------------*----------------------
|
||||
// | /
|
||||
// | /----
|
||||
// T1 | /----
|
||||
// | /----
|
||||
// | /----
|
||||
// ------------------------------------------------------------$------------------------------------------
|
||||
// . | \
|
||||
// . | \
|
||||
// T2 . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// ----------------------------------------------------------------------*--------------------------------
|
||||
//
|
||||
// In other words (in this case), we're recognizing that the second edit happened after where the first edit
|
||||
// ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started
|
||||
// that's the same as if we started at char 80 instead of 60.
|
||||
//
|
||||
// As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter
|
||||
// than pusing the first edit forward to match the second, we'll push the second edit forward to match the
|
||||
// first.
|
||||
//
|
||||
// In this case that means we have { oldStart: 10, oldEnd: 80, newEnd: 70 } or, in TextChangeRange
|
||||
// semantics: { { start: 10, length: 70 }, newLength: 60 }
|
||||
//
|
||||
// The math then works out as follows.
|
||||
// If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the
|
||||
// final result like so:
|
||||
//
|
||||
// {
|
||||
// oldStart3: Min(oldStart1, oldStart2),
|
||||
// oldEnd3 : Max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)),
|
||||
// newEnd3 : Max(newEnd2, newEnd2 + (newEnd1 - oldEnd2))
|
||||
// }
|
||||
|
||||
let oldStart1 = oldStartN;
|
||||
let oldEnd1 = oldEndN;
|
||||
let newEnd1 = newEndN;
|
||||
|
||||
let oldStart2 = nextChange.span.start;
|
||||
let oldEnd2 = textSpanEnd(nextChange.span);
|
||||
let newEnd2 = oldStart2 + nextChange.newLength;
|
||||
|
||||
oldStartN = Math.min(oldStart1, oldStart2);
|
||||
oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
|
||||
newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
|
||||
}
|
||||
|
||||
return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN);
|
||||
}
|
||||
}
|
||||
@@ -28,9 +28,9 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
|
||||
var program = ts.createProgram(fileNames, options);
|
||||
>program : ts.Program, Symbol(program, Decl(APISample_compile.ts, 14, 7))
|
||||
>ts.createProgram(fileNames, options) : ts.Program
|
||||
>ts.createProgram : (rootNames: string[], options: ts.CompilerOptions, host?: ts.CompilerHost) => ts.Program, Symbol(ts.createProgram, Decl(typescript.d.ts, 1201, 113))
|
||||
>ts.createProgram : (rootNames: string[], options: ts.CompilerOptions, host?: ts.CompilerHost) => ts.Program, Symbol(ts.createProgram, Decl(typescript.d.ts, 1229, 113))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_compile.ts, 9, 20))
|
||||
>createProgram : (rootNames: string[], options: ts.CompilerOptions, host?: ts.CompilerHost) => ts.Program, Symbol(ts.createProgram, Decl(typescript.d.ts, 1201, 113))
|
||||
>createProgram : (rootNames: string[], options: ts.CompilerOptions, host?: ts.CompilerHost) => ts.Program, Symbol(ts.createProgram, Decl(typescript.d.ts, 1229, 113))
|
||||
>fileNames : string[], Symbol(fileNames, Decl(APISample_compile.ts, 13, 24))
|
||||
>options : ts.CompilerOptions, Symbol(options, Decl(APISample_compile.ts, 13, 44))
|
||||
|
||||
@@ -46,9 +46,9 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
|
||||
>ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics) : ts.Diagnostic[]
|
||||
>ts.getPreEmitDiagnostics(program).concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }, Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
|
||||
>ts.getPreEmitDiagnostics(program) : ts.Diagnostic[]
|
||||
>ts.getPreEmitDiagnostics : (program: ts.Program) => ts.Diagnostic[], Symbol(ts.getPreEmitDiagnostics, Decl(typescript.d.ts, 1199, 98))
|
||||
>ts.getPreEmitDiagnostics : (program: ts.Program) => ts.Diagnostic[], Symbol(ts.getPreEmitDiagnostics, Decl(typescript.d.ts, 1227, 98))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_compile.ts, 9, 20))
|
||||
>getPreEmitDiagnostics : (program: ts.Program) => ts.Diagnostic[], Symbol(ts.getPreEmitDiagnostics, Decl(typescript.d.ts, 1199, 98))
|
||||
>getPreEmitDiagnostics : (program: ts.Program) => ts.Diagnostic[], Symbol(ts.getPreEmitDiagnostics, Decl(typescript.d.ts, 1227, 98))
|
||||
>program : ts.Program, Symbol(program, Decl(APISample_compile.ts, 14, 7))
|
||||
>concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }, Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
|
||||
>emitResult.diagnostics : ts.Diagnostic[], Symbol(ts.EmitResult.diagnostics, Decl(typescript.d.ts, 820, 29))
|
||||
@@ -67,11 +67,11 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
|
||||
>line : number, Symbol(line, Decl(APISample_compile.ts, 20, 13))
|
||||
>character : number, Symbol(character, Decl(APISample_compile.ts, 20, 19))
|
||||
>diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start) : ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1262, 26))
|
||||
>diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1290, 26))
|
||||
>diagnostic.file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
|
||||
>diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_compile.ts, 19, 27))
|
||||
>file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
|
||||
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1262, 26))
|
||||
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1290, 26))
|
||||
>diagnostic.start : number, Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1063, 25))
|
||||
>diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_compile.ts, 19, 27))
|
||||
>start : number, Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1063, 25))
|
||||
@@ -79,9 +79,9 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
|
||||
var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
|
||||
>message : string, Symbol(message, Decl(APISample_compile.ts, 21, 11))
|
||||
>ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n') : string
|
||||
>ts.flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1200, 67))
|
||||
>ts.flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1228, 67))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_compile.ts, 9, 20))
|
||||
>flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1200, 67))
|
||||
>flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1228, 67))
|
||||
>diagnostic.messageText : string | ts.DiagnosticMessageChain, Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1065, 23))
|
||||
>diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_compile.ts, 19, 27))
|
||||
>messageText : string | ts.DiagnosticMessageChain, Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1065, 23))
|
||||
|
||||
@@ -22,7 +22,7 @@ export function delint(sourceFile: ts.SourceFile) {
|
||||
>delint : (sourceFile: ts.SourceFile) => void, Symbol(delint, Decl(APISample_linter.ts, 11, 33))
|
||||
>sourceFile : ts.SourceFile, Symbol(sourceFile, Decl(APISample_linter.ts, 13, 23))
|
||||
>ts : any, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>SourceFile : ts.SourceFile, Symbol(ts.SourceFile, Decl(typescript.d.ts, 740, 5), Decl(typescript.d.ts, 1261, 5))
|
||||
>SourceFile : ts.SourceFile, Symbol(ts.SourceFile, Decl(typescript.d.ts, 740, 5), Decl(typescript.d.ts, 1289, 5))
|
||||
|
||||
delintNode(sourceFile);
|
||||
>delintNode(sourceFile) : void
|
||||
@@ -33,7 +33,7 @@ export function delint(sourceFile: ts.SourceFile) {
|
||||
>delintNode : (node: ts.Node) => void, Symbol(delintNode, Decl(APISample_linter.ts, 14, 27))
|
||||
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 16, 24))
|
||||
>ts : any, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>Node : ts.Node, Symbol(ts.Node, Decl(typescript.d.ts, 296, 5), Decl(typescript.d.ts, 1221, 32))
|
||||
>Node : ts.Node, Symbol(ts.Node, Decl(typescript.d.ts, 296, 5), Decl(typescript.d.ts, 1249, 32))
|
||||
|
||||
switch (node.kind) {
|
||||
>node.kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
|
||||
@@ -219,9 +219,9 @@ export function delint(sourceFile: ts.SourceFile) {
|
||||
|
||||
ts.forEachChild(node, delintNode);
|
||||
>ts.forEachChild(node, delintNode) : void
|
||||
>ts.forEachChild : <T>(node: ts.Node, cbNode: (node: ts.Node) => T, cbNodeArray?: (nodes: ts.Node[]) => T) => T, Symbol(ts.forEachChild, Decl(typescript.d.ts, 1186, 48))
|
||||
>ts.forEachChild : <T>(node: ts.Node, cbNode: (node: ts.Node) => T, cbNodeArray?: (nodes: ts.Node[]) => T) => T, Symbol(ts.forEachChild, Decl(typescript.d.ts, 1214, 48))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>forEachChild : <T>(node: ts.Node, cbNode: (node: ts.Node) => T, cbNodeArray?: (nodes: ts.Node[]) => T) => T, Symbol(ts.forEachChild, Decl(typescript.d.ts, 1186, 48))
|
||||
>forEachChild : <T>(node: ts.Node, cbNode: (node: ts.Node) => T, cbNodeArray?: (nodes: ts.Node[]) => T) => T, Symbol(ts.forEachChild, Decl(typescript.d.ts, 1214, 48))
|
||||
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 16, 24))
|
||||
>delintNode : (node: ts.Node) => void, Symbol(delintNode, Decl(APISample_linter.ts, 14, 27))
|
||||
}
|
||||
@@ -230,20 +230,20 @@ export function delint(sourceFile: ts.SourceFile) {
|
||||
>report : (node: ts.Node, message: string) => void, Symbol(report, Decl(APISample_linter.ts, 48, 5))
|
||||
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 50, 20))
|
||||
>ts : any, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>Node : ts.Node, Symbol(ts.Node, Decl(typescript.d.ts, 296, 5), Decl(typescript.d.ts, 1221, 32))
|
||||
>Node : ts.Node, Symbol(ts.Node, Decl(typescript.d.ts, 296, 5), Decl(typescript.d.ts, 1249, 32))
|
||||
>message : string, Symbol(message, Decl(APISample_linter.ts, 50, 34))
|
||||
|
||||
let { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
||||
>line : number, Symbol(line, Decl(APISample_linter.ts, 51, 13))
|
||||
>character : number, Symbol(character, Decl(APISample_linter.ts, 51, 19))
|
||||
>sourceFile.getLineAndCharacterOfPosition(node.getStart()) : ts.LineAndCharacter
|
||||
>sourceFile.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1262, 26))
|
||||
>sourceFile.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1290, 26))
|
||||
>sourceFile : ts.SourceFile, Symbol(sourceFile, Decl(APISample_linter.ts, 13, 23))
|
||||
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1262, 26))
|
||||
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1290, 26))
|
||||
>node.getStart() : number
|
||||
>node.getStart : (sourceFile?: ts.SourceFile) => number, Symbol(ts.Node.getStart, Decl(typescript.d.ts, 1226, 53))
|
||||
>node.getStart : (sourceFile?: ts.SourceFile) => number, Symbol(ts.Node.getStart, Decl(typescript.d.ts, 1254, 53))
|
||||
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 50, 20))
|
||||
>getStart : (sourceFile?: ts.SourceFile) => number, Symbol(ts.Node.getStart, Decl(typescript.d.ts, 1226, 53))
|
||||
>getStart : (sourceFile?: ts.SourceFile) => number, Symbol(ts.Node.getStart, Decl(typescript.d.ts, 1254, 53))
|
||||
|
||||
console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`);
|
||||
>console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`) : any
|
||||
@@ -286,9 +286,9 @@ fileNames.forEach(fileName => {
|
||||
let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);
|
||||
>sourceFile : ts.SourceFile, Symbol(sourceFile, Decl(APISample_linter.ts, 59, 7))
|
||||
>ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true) : ts.SourceFile
|
||||
>ts.createSourceFile : (fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile, Symbol(ts.createSourceFile, Decl(typescript.d.ts, 1190, 62))
|
||||
>ts.createSourceFile : (fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile, Symbol(ts.createSourceFile, Decl(typescript.d.ts, 1218, 62))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>createSourceFile : (fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile, Symbol(ts.createSourceFile, Decl(typescript.d.ts, 1190, 62))
|
||||
>createSourceFile : (fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile, Symbol(ts.createSourceFile, Decl(typescript.d.ts, 1218, 62))
|
||||
>fileName : any, Symbol(fileName, Decl(APISample_linter.ts, 57, 18))
|
||||
>readFileSync(fileName).toString() : any
|
||||
>readFileSync(fileName).toString : any
|
||||
|
||||
@@ -19,9 +19,9 @@ const source = "let x: string = 'string'";
|
||||
let result = ts.transpile(source, { module: ts.ModuleKind.CommonJS });
|
||||
>result : string, Symbol(result, Decl(APISample_transform.ts, 13, 3))
|
||||
>ts.transpile(source, { module: ts.ModuleKind.CommonJS }) : string
|
||||
>ts.transpile : (input: string, compilerOptions?: ts.CompilerOptions, fileName?: string, diagnostics?: ts.Diagnostic[]) => string, Symbol(ts.transpile, Decl(typescript.d.ts, 1728, 5))
|
||||
>ts.transpile : (input: string, compilerOptions?: ts.CompilerOptions, fileName?: string, diagnostics?: ts.Diagnostic[]) => string, Symbol(ts.transpile, Decl(typescript.d.ts, 1756, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_transform.ts, 9, 6))
|
||||
>transpile : (input: string, compilerOptions?: ts.CompilerOptions, fileName?: string, diagnostics?: ts.Diagnostic[]) => string, Symbol(ts.transpile, Decl(typescript.d.ts, 1728, 5))
|
||||
>transpile : (input: string, compilerOptions?: ts.CompilerOptions, fileName?: string, diagnostics?: ts.Diagnostic[]) => string, Symbol(ts.transpile, Decl(typescript.d.ts, 1756, 5))
|
||||
>source : string, Symbol(source, Decl(APISample_transform.ts, 11, 5))
|
||||
>{ module: ts.ModuleKind.CommonJS } : { [x: string]: ts.ModuleKind; module: ts.ModuleKind; }
|
||||
>module : ts.ModuleKind, Symbol(module, Decl(APISample_transform.ts, 13, 35))
|
||||
|
||||
@@ -59,7 +59,7 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
const servicesHost: ts.LanguageServiceHost = {
|
||||
>servicesHost : ts.LanguageServiceHost, Symbol(servicesHost, Decl(APISample_watcher.ts, 23, 9))
|
||||
>ts : any, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
|
||||
>LanguageServiceHost : ts.LanguageServiceHost, Symbol(ts.LanguageServiceHost, Decl(typescript.d.ts, 1294, 5))
|
||||
>LanguageServiceHost : ts.LanguageServiceHost, Symbol(ts.LanguageServiceHost, Decl(typescript.d.ts, 1322, 5))
|
||||
>{ getScriptFileNames: () => rootFileNames, getScriptVersion: (fileName) => files[fileName] && files[fileName].version.toString(), getScriptSnapshot: (fileName) => { if (!fs.existsSync(fileName)) { return undefined; } return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString()); }, getCurrentDirectory: () => process.cwd(), getCompilationSettings: () => options, getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options), } : { getScriptFileNames: () => string[]; getScriptVersion: (fileName: string) => string; getScriptSnapshot: (fileName: string) => ts.IScriptSnapshot; getCurrentDirectory: () => any; getCompilationSettings: () => ts.CompilerOptions; getDefaultLibFileName: (options: ts.CompilerOptions) => string; }
|
||||
|
||||
getScriptFileNames: () => rootFileNames,
|
||||
@@ -103,11 +103,11 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
|
||||
return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString());
|
||||
>ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString()) : ts.IScriptSnapshot
|
||||
>ts.ScriptSnapshot.fromString : (text: string) => ts.IScriptSnapshot, Symbol(ts.ScriptSnapshot.fromString, Decl(typescript.d.ts, 1287, 27))
|
||||
>ts.ScriptSnapshot : typeof ts.ScriptSnapshot, Symbol(ts.ScriptSnapshot, Decl(typescript.d.ts, 1286, 5))
|
||||
>ts.ScriptSnapshot.fromString : (text: string) => ts.IScriptSnapshot, Symbol(ts.ScriptSnapshot.fromString, Decl(typescript.d.ts, 1315, 27))
|
||||
>ts.ScriptSnapshot : typeof ts.ScriptSnapshot, Symbol(ts.ScriptSnapshot, Decl(typescript.d.ts, 1314, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
|
||||
>ScriptSnapshot : typeof ts.ScriptSnapshot, Symbol(ts.ScriptSnapshot, Decl(typescript.d.ts, 1286, 5))
|
||||
>fromString : (text: string) => ts.IScriptSnapshot, Symbol(ts.ScriptSnapshot.fromString, Decl(typescript.d.ts, 1287, 27))
|
||||
>ScriptSnapshot : typeof ts.ScriptSnapshot, Symbol(ts.ScriptSnapshot, Decl(typescript.d.ts, 1314, 5))
|
||||
>fromString : (text: string) => ts.IScriptSnapshot, Symbol(ts.ScriptSnapshot.fromString, Decl(typescript.d.ts, 1315, 27))
|
||||
>fs.readFileSync(fileName).toString() : any
|
||||
>fs.readFileSync(fileName).toString : any
|
||||
>fs.readFileSync(fileName) : any
|
||||
@@ -136,9 +136,9 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
>(options) => ts.getDefaultLibFilePath(options) : (options: ts.CompilerOptions) => string
|
||||
>options : ts.CompilerOptions, Symbol(options, Decl(APISample_watcher.ts, 35, 32))
|
||||
>ts.getDefaultLibFilePath(options) : string
|
||||
>ts.getDefaultLibFilePath : (options: ts.CompilerOptions) => string, Symbol(ts.getDefaultLibFilePath, Decl(typescript.d.ts, 1736, 44))
|
||||
>ts.getDefaultLibFilePath : (options: ts.CompilerOptions) => string, Symbol(ts.getDefaultLibFilePath, Decl(typescript.d.ts, 1764, 44))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
|
||||
>getDefaultLibFilePath : (options: ts.CompilerOptions) => string, Symbol(ts.getDefaultLibFilePath, Decl(typescript.d.ts, 1736, 44))
|
||||
>getDefaultLibFilePath : (options: ts.CompilerOptions) => string, Symbol(ts.getDefaultLibFilePath, Decl(typescript.d.ts, 1764, 44))
|
||||
>options : ts.CompilerOptions, Symbol(options, Decl(APISample_watcher.ts, 35, 32))
|
||||
|
||||
};
|
||||
@@ -147,14 +147,14 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
const services = ts.createLanguageService(servicesHost, ts.createDocumentRegistry())
|
||||
>services : ts.LanguageService, Symbol(services, Decl(APISample_watcher.ts, 39, 9))
|
||||
>ts.createLanguageService(servicesHost, ts.createDocumentRegistry()) : ts.LanguageService
|
||||
>ts.createLanguageService : (host: ts.LanguageServiceHost, documentRegistry?: ts.DocumentRegistry) => ts.LanguageService, Symbol(ts.createLanguageService, Decl(typescript.d.ts, 1734, 97))
|
||||
>ts.createLanguageService : (host: ts.LanguageServiceHost, documentRegistry?: ts.DocumentRegistry) => ts.LanguageService, Symbol(ts.createLanguageService, Decl(typescript.d.ts, 1762, 97))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
|
||||
>createLanguageService : (host: ts.LanguageServiceHost, documentRegistry?: ts.DocumentRegistry) => ts.LanguageService, Symbol(ts.createLanguageService, Decl(typescript.d.ts, 1734, 97))
|
||||
>createLanguageService : (host: ts.LanguageServiceHost, documentRegistry?: ts.DocumentRegistry) => ts.LanguageService, Symbol(ts.createLanguageService, Decl(typescript.d.ts, 1762, 97))
|
||||
>servicesHost : ts.LanguageServiceHost, Symbol(servicesHost, Decl(APISample_watcher.ts, 23, 9))
|
||||
>ts.createDocumentRegistry() : ts.DocumentRegistry
|
||||
>ts.createDocumentRegistry : () => ts.DocumentRegistry, Symbol(ts.createDocumentRegistry, Decl(typescript.d.ts, 1732, 193))
|
||||
>ts.createDocumentRegistry : () => ts.DocumentRegistry, Symbol(ts.createDocumentRegistry, Decl(typescript.d.ts, 1760, 193))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
|
||||
>createDocumentRegistry : () => ts.DocumentRegistry, Symbol(ts.createDocumentRegistry, Decl(typescript.d.ts, 1732, 193))
|
||||
>createDocumentRegistry : () => ts.DocumentRegistry, Symbol(ts.createDocumentRegistry, Decl(typescript.d.ts, 1760, 193))
|
||||
|
||||
// Now let's watch the files
|
||||
rootFileNames.forEach(fileName => {
|
||||
@@ -231,16 +231,16 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
let output = services.getEmitOutput(fileName);
|
||||
>output : ts.EmitOutput, Symbol(output, Decl(APISample_watcher.ts, 64, 11))
|
||||
>services.getEmitOutput(fileName) : ts.EmitOutput
|
||||
>services.getEmitOutput : (fileName: string) => ts.EmitOutput, Symbol(ts.LanguageService.getEmitOutput, Decl(typescript.d.ts, 1338, 132))
|
||||
>services.getEmitOutput : (fileName: string) => ts.EmitOutput, Symbol(ts.LanguageService.getEmitOutput, Decl(typescript.d.ts, 1366, 132))
|
||||
>services : ts.LanguageService, Symbol(services, Decl(APISample_watcher.ts, 39, 9))
|
||||
>getEmitOutput : (fileName: string) => ts.EmitOutput, Symbol(ts.LanguageService.getEmitOutput, Decl(typescript.d.ts, 1338, 132))
|
||||
>getEmitOutput : (fileName: string) => ts.EmitOutput, Symbol(ts.LanguageService.getEmitOutput, Decl(typescript.d.ts, 1366, 132))
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 63, 22))
|
||||
|
||||
if (!output.emitSkipped) {
|
||||
>!output.emitSkipped : boolean
|
||||
>output.emitSkipped : boolean, Symbol(ts.EmitOutput.emitSkipped, Decl(typescript.d.ts, 1541, 34))
|
||||
>output.emitSkipped : boolean, Symbol(ts.EmitOutput.emitSkipped, Decl(typescript.d.ts, 1569, 34))
|
||||
>output : ts.EmitOutput, Symbol(output, Decl(APISample_watcher.ts, 64, 11))
|
||||
>emitSkipped : boolean, Symbol(ts.EmitOutput.emitSkipped, Decl(typescript.d.ts, 1541, 34))
|
||||
>emitSkipped : boolean, Symbol(ts.EmitOutput.emitSkipped, Decl(typescript.d.ts, 1569, 34))
|
||||
|
||||
console.log(`Emitting ${fileName}`);
|
||||
>console.log(`Emitting ${fileName}`) : any
|
||||
@@ -268,9 +268,9 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
output.outputFiles.forEach(o => {
|
||||
>output.outputFiles.forEach(o => { fs.writeFileSync(o.name, o.text, "utf8"); }) : void
|
||||
>output.outputFiles.forEach : (callbackfn: (value: ts.OutputFile, index: number, array: ts.OutputFile[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
|
||||
>output.outputFiles : ts.OutputFile[], Symbol(ts.EmitOutput.outputFiles, Decl(typescript.d.ts, 1540, 26))
|
||||
>output.outputFiles : ts.OutputFile[], Symbol(ts.EmitOutput.outputFiles, Decl(typescript.d.ts, 1568, 26))
|
||||
>output : ts.EmitOutput, Symbol(output, Decl(APISample_watcher.ts, 64, 11))
|
||||
>outputFiles : ts.OutputFile[], Symbol(ts.EmitOutput.outputFiles, Decl(typescript.d.ts, 1540, 26))
|
||||
>outputFiles : ts.OutputFile[], Symbol(ts.EmitOutput.outputFiles, Decl(typescript.d.ts, 1568, 26))
|
||||
>forEach : (callbackfn: (value: ts.OutputFile, index: number, array: ts.OutputFile[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
|
||||
>o => { fs.writeFileSync(o.name, o.text, "utf8"); } : (o: ts.OutputFile) => void
|
||||
>o : ts.OutputFile, Symbol(o, Decl(APISample_watcher.ts, 74, 35))
|
||||
@@ -280,12 +280,12 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
>fs.writeFileSync : any
|
||||
>fs : any, Symbol(fs, Decl(APISample_watcher.ts, 9, 11))
|
||||
>writeFileSync : any
|
||||
>o.name : string, Symbol(ts.OutputFile.name, Decl(typescript.d.ts, 1549, 26))
|
||||
>o.name : string, Symbol(ts.OutputFile.name, Decl(typescript.d.ts, 1577, 26))
|
||||
>o : ts.OutputFile, Symbol(o, Decl(APISample_watcher.ts, 74, 35))
|
||||
>name : string, Symbol(ts.OutputFile.name, Decl(typescript.d.ts, 1549, 26))
|
||||
>o.text : string, Symbol(ts.OutputFile.text, Decl(typescript.d.ts, 1551, 36))
|
||||
>name : string, Symbol(ts.OutputFile.name, Decl(typescript.d.ts, 1577, 26))
|
||||
>o.text : string, Symbol(ts.OutputFile.text, Decl(typescript.d.ts, 1579, 36))
|
||||
>o : ts.OutputFile, Symbol(o, Decl(APISample_watcher.ts, 74, 35))
|
||||
>text : string, Symbol(ts.OutputFile.text, Decl(typescript.d.ts, 1551, 36))
|
||||
>text : string, Symbol(ts.OutputFile.text, Decl(typescript.d.ts, 1579, 36))
|
||||
>"utf8" : string
|
||||
|
||||
});
|
||||
@@ -302,24 +302,24 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
>services.getCompilerOptionsDiagnostics() .concat(services.getSyntacticDiagnostics(fileName)) : ts.Diagnostic[]
|
||||
>services.getCompilerOptionsDiagnostics() .concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }, Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
|
||||
>services.getCompilerOptionsDiagnostics() : ts.Diagnostic[]
|
||||
>services.getCompilerOptionsDiagnostics : () => ts.Diagnostic[], Symbol(ts.LanguageService.getCompilerOptionsDiagnostics, Decl(typescript.d.ts, 1312, 63))
|
||||
>services.getCompilerOptionsDiagnostics : () => ts.Diagnostic[], Symbol(ts.LanguageService.getCompilerOptionsDiagnostics, Decl(typescript.d.ts, 1340, 63))
|
||||
>services : ts.LanguageService, Symbol(services, Decl(APISample_watcher.ts, 39, 9))
|
||||
>getCompilerOptionsDiagnostics : () => ts.Diagnostic[], Symbol(ts.LanguageService.getCompilerOptionsDiagnostics, Decl(typescript.d.ts, 1312, 63))
|
||||
>getCompilerOptionsDiagnostics : () => ts.Diagnostic[], Symbol(ts.LanguageService.getCompilerOptionsDiagnostics, Decl(typescript.d.ts, 1340, 63))
|
||||
|
||||
.concat(services.getSyntacticDiagnostics(fileName))
|
||||
>concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }, Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
|
||||
>services.getSyntacticDiagnostics(fileName) : ts.Diagnostic[]
|
||||
>services.getSyntacticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSyntacticDiagnostics, Decl(typescript.d.ts, 1310, 37))
|
||||
>services.getSyntacticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSyntacticDiagnostics, Decl(typescript.d.ts, 1338, 37))
|
||||
>services : ts.LanguageService, Symbol(services, Decl(APISample_watcher.ts, 39, 9))
|
||||
>getSyntacticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSyntacticDiagnostics, Decl(typescript.d.ts, 1310, 37))
|
||||
>getSyntacticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSyntacticDiagnostics, Decl(typescript.d.ts, 1338, 37))
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 79, 23))
|
||||
|
||||
.concat(services.getSemanticDiagnostics(fileName));
|
||||
>concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }, Symbol(Array.concat, Decl(lib.d.ts, 1025, 13), Decl(lib.d.ts, 1030, 46))
|
||||
>services.getSemanticDiagnostics(fileName) : ts.Diagnostic[]
|
||||
>services.getSemanticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSemanticDiagnostics, Decl(typescript.d.ts, 1311, 64))
|
||||
>services.getSemanticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSemanticDiagnostics, Decl(typescript.d.ts, 1339, 64))
|
||||
>services : ts.LanguageService, Symbol(services, Decl(APISample_watcher.ts, 39, 9))
|
||||
>getSemanticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSemanticDiagnostics, Decl(typescript.d.ts, 1311, 64))
|
||||
>getSemanticDiagnostics : (fileName: string) => ts.Diagnostic[], Symbol(ts.LanguageService.getSemanticDiagnostics, Decl(typescript.d.ts, 1339, 64))
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 79, 23))
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
@@ -333,9 +333,9 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
||||
>message : string, Symbol(message, Decl(APISample_watcher.ts, 85, 15))
|
||||
>ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n") : string
|
||||
>ts.flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1200, 67))
|
||||
>ts.flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1228, 67))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
|
||||
>flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1200, 67))
|
||||
>flattenDiagnosticMessageText : (messageText: string | ts.DiagnosticMessageChain, newLine: string) => string, Symbol(ts.flattenDiagnosticMessageText, Decl(typescript.d.ts, 1228, 67))
|
||||
>diagnostic.messageText : string | ts.DiagnosticMessageChain, Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1065, 23))
|
||||
>diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31))
|
||||
>messageText : string | ts.DiagnosticMessageChain, Symbol(ts.Diagnostic.messageText, Decl(typescript.d.ts, 1065, 23))
|
||||
@@ -350,11 +350,11 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
>line : number, Symbol(line, Decl(APISample_watcher.ts, 87, 21))
|
||||
>character : number, Symbol(character, Decl(APISample_watcher.ts, 87, 27))
|
||||
>diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start) : ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1262, 26))
|
||||
>diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1290, 26))
|
||||
>diagnostic.file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
|
||||
>diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31))
|
||||
>file : ts.SourceFile, Symbol(ts.Diagnostic.file, Decl(typescript.d.ts, 1062, 26))
|
||||
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1262, 26))
|
||||
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1290, 26))
|
||||
>diagnostic.start : number, Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1063, 25))
|
||||
>diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31))
|
||||
>start : number, Symbol(ts.Diagnostic.start, Decl(typescript.d.ts, 1063, 25))
|
||||
|
||||
Reference in New Issue
Block a user