mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into conformanceDestructuringAssignment
This commit is contained in:
+406
-240
File diff suppressed because it is too large
Load Diff
+748
-506
File diff suppressed because it is too large
Load Diff
Vendored
+41
-13
@@ -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;
|
||||
|
||||
+865
-584
File diff suppressed because it is too large
Load Diff
Vendored
+41
-13
@@ -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;
|
||||
|
||||
+865
-584
File diff suppressed because it is too large
Load Diff
+152
-73
@@ -2197,25 +2197,7 @@ module ts {
|
||||
}
|
||||
else if (hasSpreadElement) {
|
||||
let unionOfElements = getUnionType(elementTypes);
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
// If the user has something like:
|
||||
//
|
||||
// function fun(...[a, ...b]) { }
|
||||
//
|
||||
// Normally, in ES6, the implied type of an array binding pattern with a rest element is
|
||||
// an iterable. However, there is a requirement in our type system that all rest
|
||||
// parameters be array types. To satisfy this, we have an exception to the rule that
|
||||
// says the type of an array binding pattern with a rest element is an array type
|
||||
// if it is *itself* in a rest parameter. It will still be compatible with a spreaded
|
||||
// iterable argument, but within the function it will be an array.
|
||||
let parent = pattern.parent;
|
||||
let isRestParameter = parent.kind === SyntaxKind.Parameter &&
|
||||
pattern === (<ParameterDeclaration>parent).name &&
|
||||
(<ParameterDeclaration>parent).dotDotDotToken !== undefined;
|
||||
return isRestParameter ? createArrayType(unionOfElements) : createIterableType(unionOfElements);
|
||||
}
|
||||
|
||||
return createArrayType(unionOfElements);
|
||||
return languageVersion >= ScriptTarget.ES6 ? createIterableType(unionOfElements) : createArrayType(unionOfElements);
|
||||
}
|
||||
|
||||
// If the pattern has at least one element, and no rest element, then it should imply a tuple type.
|
||||
@@ -2904,16 +2886,17 @@ module ts {
|
||||
}
|
||||
|
||||
function getPropertiesOfType(type: Type): Symbol[] {
|
||||
if (type.flags & TypeFlags.Union) {
|
||||
return getPropertiesOfUnionType(<UnionType>type);
|
||||
}
|
||||
return getPropertiesOfObjectType(getApparentType(type));
|
||||
type = getApparentType(type);
|
||||
return type.flags & TypeFlags.Union ? getPropertiesOfUnionType(<UnionType>type) : getPropertiesOfObjectType(type);
|
||||
}
|
||||
|
||||
// For a type parameter, return the base constraint of the type parameter. For the string, number,
|
||||
// boolean, and symbol primitive types, return the corresponding object types. Otherwise return the
|
||||
// type itself. Note that the apparent type of a union type is the union type itself.
|
||||
function getApparentType(type: Type): Type {
|
||||
if (type.flags & TypeFlags.Union) {
|
||||
type = getReducedTypeOfUnionType(<UnionType>type);
|
||||
}
|
||||
if (type.flags & TypeFlags.TypeParameter) {
|
||||
do {
|
||||
type = getConstraintOfTypeParameter(<TypeParameter>type);
|
||||
@@ -2986,27 +2969,27 @@ module ts {
|
||||
// necessary, maps primitive types and type parameters are to their apparent types, and augments with properties from
|
||||
// Object and Function as appropriate.
|
||||
function getPropertyOfType(type: Type, name: string): Symbol {
|
||||
type = getApparentType(type);
|
||||
if (type.flags & TypeFlags.ObjectType) {
|
||||
let resolved = resolveObjectOrUnionTypeMembers(type);
|
||||
if (hasProperty(resolved.members, name)) {
|
||||
let symbol = resolved.members[name];
|
||||
if (symbolIsValue(symbol)) {
|
||||
return symbol;
|
||||
}
|
||||
}
|
||||
if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) {
|
||||
let symbol = getPropertyOfObjectType(globalFunctionType, name);
|
||||
if (symbol) {
|
||||
return symbol;
|
||||
}
|
||||
}
|
||||
return getPropertyOfObjectType(globalObjectType, name);
|
||||
}
|
||||
if (type.flags & TypeFlags.Union) {
|
||||
return getPropertyOfUnionType(<UnionType>type, name);
|
||||
}
|
||||
if (!(type.flags & TypeFlags.ObjectType)) {
|
||||
type = getApparentType(type);
|
||||
if (!(type.flags & TypeFlags.ObjectType)) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
let resolved = resolveObjectOrUnionTypeMembers(type);
|
||||
if (hasProperty(resolved.members, name)) {
|
||||
let symbol = resolved.members[name];
|
||||
if (symbolIsValue(symbol)) {
|
||||
return symbol;
|
||||
}
|
||||
}
|
||||
if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) {
|
||||
let symbol = getPropertyOfObjectType(globalFunctionType, name);
|
||||
if (symbol) return symbol;
|
||||
}
|
||||
return getPropertyOfObjectType(globalObjectType, name);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getSignaturesOfObjectOrUnionType(type: Type, kind: SignatureKind): Signature[] {
|
||||
@@ -3581,6 +3564,10 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
// The noSubtypeReduction flag is there because it isn't possible to always do subtype reduction. The flag
|
||||
// is true when creating a union type from a type node and when instantiating a union type. In both of those
|
||||
// cases subtype reduction has to be deferred to properly support recursive union types. For example, a
|
||||
// type alias of the form "type Item = string | (() => Item)" cannot be reduced during its declaration.
|
||||
function getUnionType(types: Type[], noSubtypeReduction?: boolean): Type {
|
||||
if (types.length === 0) {
|
||||
return emptyObjectType;
|
||||
@@ -3605,10 +3592,19 @@ module ts {
|
||||
if (!type) {
|
||||
type = unionTypes[id] = <UnionType>createObjectType(TypeFlags.Union | getWideningFlagsOfTypes(sortedTypes));
|
||||
type.types = sortedTypes;
|
||||
type.reducedType = noSubtypeReduction ? undefined : type;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
function getReducedTypeOfUnionType(type: UnionType): Type {
|
||||
// If union type was created without subtype reduction, perform the deferred reduction now
|
||||
if (!type.reducedType) {
|
||||
type.reducedType = getUnionType(type.types, /*noSubtypeReduction*/ false);
|
||||
}
|
||||
return type.reducedType;
|
||||
}
|
||||
|
||||
function getTypeFromUnionTypeNode(node: UnionTypeNode): Type {
|
||||
let links = getNodeLinks(node);
|
||||
if (!links.resolvedType) {
|
||||
@@ -4002,6 +3998,7 @@ module ts {
|
||||
if (source === numberType && target.flags & TypeFlags.Enum) return Ternary.True;
|
||||
}
|
||||
}
|
||||
let saveErrorInfo = errorInfo;
|
||||
if (source.flags & TypeFlags.Union || target.flags & TypeFlags.Union) {
|
||||
if (relation === identityRelation) {
|
||||
if (source.flags & TypeFlags.Union && target.flags & TypeFlags.Union) {
|
||||
@@ -4040,25 +4037,34 @@ module ts {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else {
|
||||
let saveErrorInfo = errorInfo;
|
||||
if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (<TypeReference>source).target === (<TypeReference>target).target) {
|
||||
// We have type references to same target type, see if relationship holds for all type arguments
|
||||
if (result = typesRelatedTo((<TypeReference>source).typeArguments, (<TypeReference>target).typeArguments, reportErrors)) {
|
||||
return result;
|
||||
}
|
||||
else if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (<TypeReference>source).target === (<TypeReference>target).target) {
|
||||
// We have type references to same target type, see if relationship holds for all type arguments
|
||||
if (result = typesRelatedTo((<TypeReference>source).typeArguments, (<TypeReference>target).typeArguments, reportErrors)) {
|
||||
return result;
|
||||
}
|
||||
// Even if relationship doesn't hold for type arguments, it may hold in a structural comparison
|
||||
// Report structural errors only if we haven't reported any errors yet
|
||||
let reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo;
|
||||
// identity relation does not use apparent type
|
||||
let sourceOrApparentType = relation === identityRelation ? source : getApparentType(source);
|
||||
if (sourceOrApparentType.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType &&
|
||||
(result = objectTypeRelatedTo(sourceOrApparentType, <ObjectType>target, reportStructuralErrors))) {
|
||||
}
|
||||
|
||||
// Even if relationship doesn't hold for unions, type parameters, or generic type references,
|
||||
// it may hold in a structural comparison.
|
||||
// Report structural errors only if we haven't reported any errors yet
|
||||
let reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo;
|
||||
// identity relation does not use apparent type
|
||||
let sourceOrApparentType = relation === identityRelation ? source : getApparentType(source);
|
||||
if (sourceOrApparentType.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType) {
|
||||
if (result = objectTypeRelatedTo(sourceOrApparentType, <ObjectType>target, reportStructuralErrors)) {
|
||||
errorInfo = saveErrorInfo;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else if (source.flags & TypeFlags.TypeParameter && sourceOrApparentType.flags & TypeFlags.Union) {
|
||||
// We clear the errors first because the following check often gives a better error than
|
||||
// the union comparison above if it is applicable.
|
||||
errorInfo = saveErrorInfo;
|
||||
if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (reportErrors) {
|
||||
headMessage = headMessage || Diagnostics.Type_0_is_not_assignable_to_type_1;
|
||||
let sourceType = typeToString(source);
|
||||
@@ -5398,8 +5404,8 @@ module ts {
|
||||
// will be bound to non-arrow function that contain this arrow function. This results in inconsistent behavior.
|
||||
// To avoid that we will give an error to users if they use arguments objects in arrow function so that they
|
||||
// can explicitly bound arguments objects
|
||||
if (symbol === argumentsSymbol && getContainingFunction(node).kind === SyntaxKind.ArrowFunction) {
|
||||
error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression);
|
||||
if (symbol === argumentsSymbol && getContainingFunction(node).kind === SyntaxKind.ArrowFunction && languageVersion < ScriptTarget.ES6) {
|
||||
error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression);
|
||||
}
|
||||
|
||||
if (symbol.flags & SymbolFlags.Alias && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) {
|
||||
@@ -6011,14 +6017,38 @@ module ts {
|
||||
}
|
||||
let hasSpreadElement = false;
|
||||
let elementTypes: Type[] = [];
|
||||
let inDestructuringPattern = isAssignmentTarget(node);
|
||||
for (let e of elements) {
|
||||
let type = checkExpression(e, contextualMapper);
|
||||
elementTypes.push(type);
|
||||
if (inDestructuringPattern && e.kind === SyntaxKind.SpreadElementExpression) {
|
||||
// Given the following situation:
|
||||
// var c: {};
|
||||
// [...c] = ["", 0];
|
||||
//
|
||||
// c is represented in the tree as a spread element in an array literal.
|
||||
// But c really functions as a rest element, and its purpose is to provide
|
||||
// a contextual type for the right hand side of the assignment. Therefore,
|
||||
// instead of calling checkExpression on "...c", which will give an error
|
||||
// if c is not iterable/array-like, we need to act as if we are trying to
|
||||
// get the contextual element type from it. So we do something similar to
|
||||
// getContextualTypeForElementExpression, which will crucially not error
|
||||
// if there is no index type / iterated type.
|
||||
let restArrayType = checkExpression((<SpreadElementExpression>e).expression, contextualMapper);
|
||||
let restElementType = getIndexTypeOfType(restArrayType, IndexKind.Number) ||
|
||||
(languageVersion >= ScriptTarget.ES6 ? checkIteratedType(restArrayType, /*expressionForError*/ undefined) : undefined);
|
||||
|
||||
if (restElementType) {
|
||||
elementTypes.push(restElementType);
|
||||
}
|
||||
}
|
||||
else {
|
||||
let type = checkExpression(e, contextualMapper);
|
||||
elementTypes.push(type);
|
||||
}
|
||||
hasSpreadElement = hasSpreadElement || e.kind === SyntaxKind.SpreadElementExpression;
|
||||
}
|
||||
if (!hasSpreadElement) {
|
||||
let contextualType = getContextualType(node);
|
||||
if (contextualType && contextualTypeIsTupleLikeType(contextualType) || isAssignmentTarget(node)) {
|
||||
if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) {
|
||||
return createTupleType(elementTypes);
|
||||
}
|
||||
}
|
||||
@@ -7609,7 +7639,7 @@ module ts {
|
||||
// This elementType will be used if the specific property corresponding to this index is not
|
||||
// present (aka the tuple element property). This call also checks that the parentType is in
|
||||
// fact an iterable or array (depending on target language).
|
||||
let elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false);
|
||||
let elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false) || unknownType;
|
||||
let elements = node.elements;
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
let e = elements[i];
|
||||
@@ -7633,11 +7663,17 @@ module ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (i === elements.length - 1) {
|
||||
checkReferenceAssignment((<SpreadElementExpression>e).expression, createArrayType(elementType), contextualMapper);
|
||||
if (i < elements.length - 1) {
|
||||
error(e, Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern);
|
||||
}
|
||||
else {
|
||||
error(e, Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern);
|
||||
let restExpression = (<SpreadElementExpression>e).expression;
|
||||
if (restExpression.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>restExpression).operatorToken.kind === SyntaxKind.EqualsToken) {
|
||||
error((<BinaryExpression>restExpression).operatorToken, Diagnostics.A_rest_element_cannot_have_an_initializer);
|
||||
}
|
||||
else {
|
||||
checkDestructuringAssignment(restExpression, createArrayType(elementType), contextualMapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8097,10 +8133,11 @@ module ts {
|
||||
if (node.questionToken && isBindingPattern(node.name) && func.body) {
|
||||
error(node, Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature);
|
||||
}
|
||||
if (node.dotDotDotToken) {
|
||||
if (!isArrayType(getTypeOfSymbol(node.symbol))) {
|
||||
error(node, Diagnostics.A_rest_parameter_must_be_of_an_array_type);
|
||||
}
|
||||
|
||||
// Only check rest parameter type if it's not a binding pattern. Since binding patterns are
|
||||
// not allowed in a rest parameter, we already have an error from checkGrammarParameterList.
|
||||
if (node.dotDotDotToken && !isBindingPattern(node.name) && !isArrayType(getTypeOfSymbol(node.symbol))) {
|
||||
error(node, Diagnostics.A_rest_parameter_must_be_of_an_array_type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9403,6 +9440,10 @@ module ts {
|
||||
}
|
||||
|
||||
function checkIteratedTypeOrElementType(inputType: Type, errorNode: Node, allowStringInput: boolean): Type {
|
||||
if (inputType.flags & TypeFlags.Any) {
|
||||
return inputType;
|
||||
}
|
||||
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
return checkIteratedType(inputType, errorNode) || anyType;
|
||||
}
|
||||
@@ -10393,13 +10434,29 @@ module ts {
|
||||
function getFirstNonAmbientClassOrFunctionDeclaration(symbol: Symbol): Declaration {
|
||||
let declarations = symbol.declarations;
|
||||
for (let declaration of declarations) {
|
||||
if ((declaration.kind === SyntaxKind.ClassDeclaration || (declaration.kind === SyntaxKind.FunctionDeclaration && nodeIsPresent((<FunctionLikeDeclaration>declaration).body))) && !isInAmbientContext(declaration)) {
|
||||
if ((declaration.kind === SyntaxKind.ClassDeclaration ||
|
||||
(declaration.kind === SyntaxKind.FunctionDeclaration && nodeIsPresent((<FunctionLikeDeclaration>declaration).body))) &&
|
||||
!isInAmbientContext(declaration)) {
|
||||
return declaration;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function inSameLexicalScope(node1: Node, node2: Node) {
|
||||
let container1 = getEnclosingBlockScopeContainer(node1);
|
||||
let container2 = getEnclosingBlockScopeContainer(node2);
|
||||
if (isGlobalSourceFile(container1)) {
|
||||
return isGlobalSourceFile(container2);
|
||||
}
|
||||
else if (isGlobalSourceFile(container2)) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return container1 === container2;
|
||||
}
|
||||
}
|
||||
|
||||
function checkModuleDeclaration(node: ModuleDeclaration) {
|
||||
if (produceDiagnostics) {
|
||||
// Grammar checking
|
||||
@@ -10419,15 +10476,23 @@ module ts {
|
||||
&& symbol.declarations.length > 1
|
||||
&& !isInAmbientContext(node)
|
||||
&& isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation)) {
|
||||
let classOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
|
||||
if (classOrFunc) {
|
||||
if (getSourceFileOfNode(node) !== getSourceFileOfNode(classOrFunc)) {
|
||||
let firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
|
||||
if (firstNonAmbientClassOrFunc) {
|
||||
if (getSourceFileOfNode(node) !== getSourceFileOfNode(firstNonAmbientClassOrFunc)) {
|
||||
error(node.name, Diagnostics.A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged);
|
||||
}
|
||||
else if (node.pos < classOrFunc.pos) {
|
||||
else if (node.pos < firstNonAmbientClassOrFunc.pos) {
|
||||
error(node.name, Diagnostics.A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged);
|
||||
}
|
||||
}
|
||||
|
||||
// if the module merges with a class declaration in the same lexical scope,
|
||||
// we need to track this to ensure the correct emit.
|
||||
let mergedClass = getDeclarationOfKind(symbol, SyntaxKind.ClassDeclaration);
|
||||
if (mergedClass &&
|
||||
inSameLexicalScope(node, mergedClass)) {
|
||||
getNodeLinks(node).flags |= NodeCheckFlags.LexicalModuleMergesWithClass;
|
||||
}
|
||||
}
|
||||
|
||||
// Checks for ambient external modules.
|
||||
@@ -12246,6 +12311,10 @@ module ts {
|
||||
return grammarErrorOnNode(parameter.dotDotDotToken, Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
|
||||
}
|
||||
|
||||
if (isBindingPattern(parameter.name)) {
|
||||
return grammarErrorOnNode(parameter.name, Diagnostics.A_rest_element_cannot_contain_a_binding_pattern);
|
||||
}
|
||||
|
||||
if (parameter.questionToken) {
|
||||
return grammarErrorOnNode(parameter.questionToken, Diagnostics.A_rest_parameter_cannot_be_optional);
|
||||
}
|
||||
@@ -12732,6 +12801,11 @@ module ts {
|
||||
if (node !== elements[elements.length - 1]) {
|
||||
return grammarErrorOnNode(node, Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern);
|
||||
}
|
||||
|
||||
if (node.name.kind === SyntaxKind.ArrayBindingPattern || node.name.kind === SyntaxKind.ObjectBindingPattern) {
|
||||
return grammarErrorOnNode(node.name, Diagnostics.A_rest_element_cannot_contain_a_binding_pattern);
|
||||
}
|
||||
|
||||
if (node.initializer) {
|
||||
// Error on equals token which immediate precedes the initializer
|
||||
return grammarErrorAtPos(getSourceFileOfNode(node), node.initializer.pos - 1, 1, Diagnostics.A_rest_element_cannot_have_an_initializer);
|
||||
@@ -12929,6 +13003,11 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function isEvalOrArgumentsIdentifier(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.Identifier &&
|
||||
((<Identifier>node).text === "eval" || (<Identifier>node).text === "arguments");
|
||||
}
|
||||
|
||||
function checkGrammarConstructorTypeParameters(node: ConstructorDeclaration) {
|
||||
if (node.typeParameters) {
|
||||
return grammarErrorAtPos(getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -358,11 +358,12 @@ module ts {
|
||||
Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: DiagnosticCategory.Error, key: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." },
|
||||
Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: DiagnosticCategory.Error, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." },
|
||||
Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: DiagnosticCategory.Error, key: "Type '{0}' is not an array type or a string type." },
|
||||
The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression: { code: 2496, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression." },
|
||||
The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { code: 2496, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression." },
|
||||
External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: DiagnosticCategory.Error, key: "External module '{0}' resolves to a non-module entity and cannot be imported using this construct." },
|
||||
External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: DiagnosticCategory.Error, key: "External module '{0}' uses 'export =' and cannot be used with 'export *'." },
|
||||
An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." },
|
||||
A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." },
|
||||
A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." },
|
||||
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
|
||||
|
||||
@@ -1419,7 +1419,7 @@
|
||||
"category": "Error",
|
||||
"code": 2495
|
||||
},
|
||||
"The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression.": {
|
||||
"The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression.": {
|
||||
"category": "Error",
|
||||
"code": 2496
|
||||
},
|
||||
@@ -1439,6 +1439,10 @@
|
||||
"category": "Error",
|
||||
"code": 2500
|
||||
},
|
||||
"A rest element cannot contain a binding pattern.": {
|
||||
"category": "Error",
|
||||
"code": 2501
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
|
||||
+73
-61
@@ -1589,23 +1589,40 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
return result;
|
||||
}
|
||||
|
||||
function createPropertyAccessExpression(expression: LeftHandSideExpression, name: Identifier): PropertyAccessExpression {
|
||||
function createPropertyAccessExpression(expression: Expression, name: Identifier): PropertyAccessExpression {
|
||||
let result = <PropertyAccessExpression>createSynthesizedNode(SyntaxKind.PropertyAccessExpression);
|
||||
result.expression = expression;
|
||||
result.expression = parenthesizeForAccess(expression);
|
||||
result.dotToken = createSynthesizedNode(SyntaxKind.DotToken);
|
||||
result.name = name;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
function createElementAccessExpression(expression: LeftHandSideExpression, argumentExpression: Expression): ElementAccessExpression {
|
||||
function createElementAccessExpression(expression: Expression, argumentExpression: Expression): ElementAccessExpression {
|
||||
let result = <ElementAccessExpression>createSynthesizedNode(SyntaxKind.ElementAccessExpression);
|
||||
result.expression = expression;
|
||||
result.expression = parenthesizeForAccess(expression);
|
||||
result.argumentExpression = argumentExpression;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function parenthesizeForAccess(expr: Expression): LeftHandSideExpression {
|
||||
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
|
||||
// to parenthesize the expression before a dot. The known exceptions are:
|
||||
//
|
||||
// NewExpression:
|
||||
// new C.x -> not the same as (new C).x
|
||||
// NumberLiteral
|
||||
// 1.x -> not the same as (1).x
|
||||
//
|
||||
if (isLeftHandSideExpression(expr) && expr.kind !== SyntaxKind.NewExpression && expr.kind !== SyntaxKind.NumericLiteral) {
|
||||
return <LeftHandSideExpression>expr;
|
||||
}
|
||||
let node = <ParenthesizedExpression>createSynthesizedNode(SyntaxKind.ParenthesizedExpression);
|
||||
node.expression = expr;
|
||||
return node;
|
||||
}
|
||||
|
||||
function emitComputedPropertyName(node: ComputedPropertyName) {
|
||||
write("[");
|
||||
emitExpressionForPropertyName(node);
|
||||
@@ -2276,7 +2293,7 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
if (node.initializer.kind === SyntaxKind.ArrayLiteralExpression || node.initializer.kind === SyntaxKind.ObjectLiteralExpression) {
|
||||
// This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause
|
||||
// the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash.
|
||||
emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined, /*locationForCheckingExistingName*/ node);
|
||||
emitDestructuring(assignmentExpression, /*isAssignmentExpressionStatement*/ true, /*value*/ undefined);
|
||||
}
|
||||
else {
|
||||
emitNodeWithoutSourceMap(assignmentExpression);
|
||||
@@ -2480,16 +2497,7 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the root has a chance of being a synthesized node, callers should also pass a value for
|
||||
* lowestNonSynthesizedAncestor. This should be an ancestor of root, it should not be synthesized,
|
||||
* and there should not be a lower ancestor that introduces a scope. This node will be used as the
|
||||
* location for ensuring that temporary names are unique.
|
||||
*/
|
||||
function emitDestructuring(root: BinaryExpression | VariableDeclaration | ParameterDeclaration,
|
||||
isAssignmentExpressionStatement: boolean,
|
||||
value?: Expression,
|
||||
lowestNonSynthesizedAncestor?: Node) {
|
||||
function emitDestructuring(root: BinaryExpression | VariableDeclaration | ParameterDeclaration, isAssignmentExpressionStatement: boolean, value?: Expression) {
|
||||
let emitCount = 0;
|
||||
// An exported declaration is actually emitted as an assignment (to a property on the module object), so
|
||||
// temporary variables in an exported declaration need to have real declarations elsewhere
|
||||
@@ -2520,9 +2528,6 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
|
||||
function ensureIdentifier(expr: Expression): Expression {
|
||||
if (expr.kind !== SyntaxKind.Identifier) {
|
||||
// In case the root is a synthesized node, we need to pass lowestNonSynthesizedAncestor
|
||||
// as the location for determining uniqueness of the variable we are about to
|
||||
// generate.
|
||||
let identifier = createTempVariable(TempFlags.Auto);
|
||||
if (!isDeclaration) {
|
||||
recordTempDeclaration(identifier);
|
||||
@@ -2561,27 +2566,22 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
return node;
|
||||
}
|
||||
|
||||
function parenthesizeForAccess(expr: Expression): LeftHandSideExpression {
|
||||
if (expr.kind === SyntaxKind.Identifier || expr.kind === SyntaxKind.PropertyAccessExpression || expr.kind === SyntaxKind.ElementAccessExpression) {
|
||||
return <LeftHandSideExpression>expr;
|
||||
}
|
||||
let node = <ParenthesizedExpression>createSynthesizedNode(SyntaxKind.ParenthesizedExpression);
|
||||
node.expression = expr;
|
||||
return node;
|
||||
}
|
||||
|
||||
function createPropertyAccess(object: Expression, propName: Identifier): Expression {
|
||||
function createPropertyAccessForDestructuringProperty(object: Expression, propName: Identifier | LiteralExpression): Expression {
|
||||
if (propName.kind !== SyntaxKind.Identifier) {
|
||||
return createElementAccess(object, propName);
|
||||
return createElementAccessExpression(object, propName);
|
||||
}
|
||||
return createPropertyAccessExpression(parenthesizeForAccess(object), propName);
|
||||
|
||||
return createPropertyAccessExpression(object, propName);
|
||||
}
|
||||
|
||||
function createElementAccess(object: Expression, index: Expression): Expression {
|
||||
let node = <ElementAccessExpression>createSynthesizedNode(SyntaxKind.ElementAccessExpression);
|
||||
node.expression = parenthesizeForAccess(object);
|
||||
node.argumentExpression = index;
|
||||
return node;
|
||||
function createSliceCall(value: Expression, sliceIndex: number): CallExpression {
|
||||
let call = <CallExpression>createSynthesizedNode(SyntaxKind.CallExpression);
|
||||
let sliceIdentifier = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
|
||||
sliceIdentifier.text = "slice";
|
||||
call.expression = createPropertyAccessExpression(value, sliceIdentifier);
|
||||
call.arguments = <NodeArray<LiteralExpression>>createSynthesizedNodeArray();
|
||||
call.arguments[0] = createNumericLiteral(sliceIndex);
|
||||
return call;
|
||||
}
|
||||
|
||||
function emitObjectLiteralAssignment(target: ObjectLiteralExpression, value: Expression) {
|
||||
@@ -2594,8 +2594,8 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
for (let p of properties) {
|
||||
if (p.kind === SyntaxKind.PropertyAssignment || p.kind === SyntaxKind.ShorthandPropertyAssignment) {
|
||||
// TODO(andersh): Computed property support
|
||||
let propName = <Identifier>((<PropertyAssignment>p).name);
|
||||
emitDestructuringAssignment((<PropertyAssignment>p).initializer || propName, createPropertyAccess(value, propName));
|
||||
let propName = <Identifier | LiteralExpression>((<PropertyAssignment>p).name);
|
||||
emitDestructuringAssignment((<PropertyAssignment>p).initializer || propName, createPropertyAccessForDestructuringProperty(value, propName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2611,14 +2611,10 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
let e = elements[i];
|
||||
if (e.kind !== SyntaxKind.OmittedExpression) {
|
||||
if (e.kind !== SyntaxKind.SpreadElementExpression) {
|
||||
emitDestructuringAssignment(e, createElementAccess(value, createNumericLiteral(i)));
|
||||
emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i)));
|
||||
}
|
||||
else {
|
||||
if (i === elements.length - 1) {
|
||||
value = ensureIdentifier(value);
|
||||
emitAssignment(<Identifier>(<SpreadElementExpression>e).expression, value);
|
||||
write(".slice(" + i + ")");
|
||||
}
|
||||
else if (i === elements.length - 1) {
|
||||
emitDestructuringAssignment((<SpreadElementExpression>e).expression, createSliceCall(value, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2682,19 +2678,15 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
if (pattern.kind === SyntaxKind.ObjectBindingPattern) {
|
||||
// Rewrite element to a declaration with an initializer that fetches property
|
||||
let propName = element.propertyName || <Identifier>element.name;
|
||||
emitBindingElement(element, createPropertyAccess(value, propName));
|
||||
emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName));
|
||||
}
|
||||
else if (element.kind !== SyntaxKind.OmittedExpression) {
|
||||
if (!element.dotDotDotToken) {
|
||||
// Rewrite element to a declaration that accesses array element at index i
|
||||
emitBindingElement(element, createElementAccess(value, createNumericLiteral(i)));
|
||||
emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i)));
|
||||
}
|
||||
else {
|
||||
if (i === elements.length - 1) {
|
||||
value = ensureIdentifier(value);
|
||||
emitAssignment(<Identifier>element.name, value);
|
||||
write(".slice(" + i + ")");
|
||||
}
|
||||
else if (i === elements.length - 1) {
|
||||
emitBindingElement(element, createSliceCall(value, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2862,6 +2854,12 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
let tempIndex = 0;
|
||||
forEach(node.parameters, p => {
|
||||
// A rest parameter cannot have a binding pattern or an initializer,
|
||||
// so let's just ignore it.
|
||||
if (p.dotDotDotToken) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isBindingPattern(p.name)) {
|
||||
writeLine();
|
||||
write("var ");
|
||||
@@ -2892,6 +2890,12 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
if (languageVersion < ScriptTarget.ES6 && hasRestParameters(node)) {
|
||||
let restIndex = node.parameters.length - 1;
|
||||
let restParam = node.parameters[restIndex];
|
||||
|
||||
// A rest parameter cannot have a binding pattern, so let's just ignore it if it does.
|
||||
if (isBindingPattern(restParam.name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let tempName = createTempVariable(TempFlags._i).text;
|
||||
writeLine();
|
||||
emitLeadingComments(restParam);
|
||||
@@ -4207,6 +4211,10 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
return isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation);
|
||||
}
|
||||
|
||||
function isModuleMergedWithES6Class(node: ModuleDeclaration) {
|
||||
return languageVersion === ScriptTarget.ES6 && !!(resolver.getNodeCheckFlags(node) & NodeCheckFlags.LexicalModuleMergesWithClass);
|
||||
}
|
||||
|
||||
function emitModuleDeclaration(node: ModuleDeclaration) {
|
||||
// Emit only if this module is non-ambient.
|
||||
let shouldEmit = shouldEmitModuleDeclaration(node);
|
||||
@@ -4215,15 +4223,19 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
return emitOnlyPinnedOrTripleSlashComments(node);
|
||||
}
|
||||
|
||||
emitStart(node);
|
||||
if (isES6ExportedDeclaration(node)) {
|
||||
write("export ");
|
||||
if (!isModuleMergedWithES6Class(node)) {
|
||||
emitStart(node);
|
||||
if (isES6ExportedDeclaration(node)) {
|
||||
write("export ");
|
||||
}
|
||||
|
||||
write("var ");
|
||||
emit(node.name);
|
||||
write(";");
|
||||
emitEnd(node);
|
||||
writeLine();
|
||||
}
|
||||
write("var ");
|
||||
emit(node.name);
|
||||
write(";");
|
||||
emitEnd(node);
|
||||
writeLine();
|
||||
|
||||
emitStart(node);
|
||||
write("(function (");
|
||||
emitStart(node.name);
|
||||
|
||||
+745
-750
File diff suppressed because it is too large
Load Diff
@@ -54,6 +54,7 @@ module ts {
|
||||
}
|
||||
text = "";
|
||||
}
|
||||
|
||||
return text !== undefined ? createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined;
|
||||
}
|
||||
|
||||
|
||||
+41
-25
@@ -25,6 +25,8 @@ module ts {
|
||||
reScanTemplateToken(): SyntaxKind;
|
||||
scan(): SyntaxKind;
|
||||
setText(text: string): void;
|
||||
setOnError(onError: ErrorCallback): void;
|
||||
setScriptTarget(scriptTarget: ScriptTarget): void;
|
||||
setTextPos(textPos: number): void;
|
||||
// Invokes the provided callback then unconditionally restores the scanner to the state it
|
||||
// was in immediately prior to invoking the callback. The result of invoking the callback
|
||||
@@ -599,6 +601,7 @@ module ts {
|
||||
export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback): Scanner {
|
||||
let pos: number; // Current position (end position of text of current token)
|
||||
let len: number; // Length of text
|
||||
|
||||
let startPos: number; // Start position of whitespace before current token
|
||||
let tokenPos: number; // Start position of text of current token
|
||||
let token: SyntaxKind;
|
||||
@@ -607,6 +610,32 @@ module ts {
|
||||
let hasExtendedUnicodeEscape: boolean;
|
||||
let tokenIsUnterminated: boolean;
|
||||
|
||||
setText(text);
|
||||
|
||||
return {
|
||||
getStartPos: () => startPos,
|
||||
getTextPos: () => pos,
|
||||
getToken: () => token,
|
||||
getTokenPos: () => tokenPos,
|
||||
getTokenText: () => text.substring(tokenPos, pos),
|
||||
getTokenValue: () => tokenValue,
|
||||
hasExtendedUnicodeEscape: () => hasExtendedUnicodeEscape,
|
||||
hasPrecedingLineBreak: () => precedingLineBreak,
|
||||
isIdentifier: () => token === SyntaxKind.Identifier || token > SyntaxKind.LastReservedWord,
|
||||
isReservedWord: () => token >= SyntaxKind.FirstReservedWord && token <= SyntaxKind.LastReservedWord,
|
||||
isUnterminated: () => tokenIsUnterminated,
|
||||
reScanGreaterToken,
|
||||
reScanSlashToken,
|
||||
reScanTemplateToken,
|
||||
scan,
|
||||
setText,
|
||||
setScriptTarget,
|
||||
setOnError,
|
||||
setTextPos,
|
||||
tryScan,
|
||||
lookAhead,
|
||||
};
|
||||
|
||||
function error(message: DiagnosticMessage, length?: number): void {
|
||||
if (onError) {
|
||||
onError(message, length || 0);
|
||||
@@ -1450,37 +1479,24 @@ module ts {
|
||||
setTextPos(0);
|
||||
}
|
||||
|
||||
function setOnError(errorCallback: ErrorCallback) {
|
||||
onError = errorCallback;
|
||||
}
|
||||
|
||||
function setScriptTarget(scriptTarget: ScriptTarget) {
|
||||
languageVersion = scriptTarget;
|
||||
}
|
||||
|
||||
function setTextPos(textPos: number) {
|
||||
pos = textPos;
|
||||
startPos = textPos;
|
||||
tokenPos = textPos;
|
||||
token = SyntaxKind.Unknown;
|
||||
precedingLineBreak = false;
|
||||
|
||||
tokenValue = undefined;
|
||||
hasExtendedUnicodeEscape = false;
|
||||
tokenIsUnterminated = false;
|
||||
}
|
||||
|
||||
setText(text);
|
||||
|
||||
|
||||
return {
|
||||
getStartPos: () => startPos,
|
||||
getTextPos: () => pos,
|
||||
getToken: () => token,
|
||||
getTokenPos: () => tokenPos,
|
||||
getTokenText: () => text.substring(tokenPos, pos),
|
||||
getTokenValue: () => tokenValue,
|
||||
hasExtendedUnicodeEscape: () => hasExtendedUnicodeEscape,
|
||||
hasPrecedingLineBreak: () => precedingLineBreak,
|
||||
isIdentifier: () => token === SyntaxKind.Identifier || token > SyntaxKind.LastReservedWord,
|
||||
isReservedWord: () => token >= SyntaxKind.FirstReservedWord && token <= SyntaxKind.LastReservedWord,
|
||||
isUnterminated: () => tokenIsUnterminated,
|
||||
reScanGreaterToken,
|
||||
reScanSlashToken,
|
||||
reScanTemplateToken,
|
||||
scan,
|
||||
setText,
|
||||
setTextPos,
|
||||
tryScan,
|
||||
lookAhead,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,6 @@ module ts {
|
||||
WhileKeyword,
|
||||
WithKeyword,
|
||||
// Strict mode reserved words
|
||||
AsKeyword,
|
||||
ImplementsKeyword,
|
||||
InterfaceKeyword,
|
||||
LetKeyword,
|
||||
@@ -132,6 +131,7 @@ module ts {
|
||||
StaticKeyword,
|
||||
YieldKeyword,
|
||||
// Contextual keywords
|
||||
AsKeyword,
|
||||
AnyKeyword,
|
||||
BooleanKeyword,
|
||||
ConstructorKeyword,
|
||||
@@ -1405,6 +1405,7 @@ module ts {
|
||||
BlockScopedBindingInLoop = 0x00000100,
|
||||
EmitDecorate = 0x00000200, // Emit __decorate
|
||||
EmitParam = 0x00000400, // Emit __param helper for decorators
|
||||
LexicalModuleMergesWithClass = 0x00000800, // Instantiated lexical module declaration is merged with a previous class declaration.
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -1512,6 +1513,8 @@ module ts {
|
||||
export interface UnionType extends Type {
|
||||
types: Type[]; // Constituent types
|
||||
/* @internal */
|
||||
reducedType: Type; // Reduced union type (all subtypes removed)
|
||||
/* @internal */
|
||||
resolvedProperties: SymbolTable; // Cache of resolved properties
|
||||
}
|
||||
|
||||
|
||||
+277
-217
@@ -211,8 +211,10 @@ module ts {
|
||||
isCatchClauseVariableDeclaration(declaration);
|
||||
}
|
||||
|
||||
// Gets the nearest enclosing block scope container that has the provided node
|
||||
// as a descendant, that is not the provided node.
|
||||
export function getEnclosingBlockScopeContainer(node: Node): Node {
|
||||
let current = node;
|
||||
let current = node.parent;
|
||||
while (current) {
|
||||
if (isFunctionLike(current)) {
|
||||
return current;
|
||||
@@ -271,7 +273,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 +409,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 +439,6 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function isVariableLike(node: Node): boolean {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
@@ -1151,218 +1150,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 +1167,13 @@ module ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function createSynthesizedNodeArray(): NodeArray<any> {
|
||||
var array = <NodeArray<any>>[];
|
||||
array.pos = -1;
|
||||
array.end = -1;
|
||||
return array;
|
||||
}
|
||||
|
||||
export function createDiagnosticCollection(): DiagnosticCollection {
|
||||
let nonFileDiagnostics: Diagnostic[] = [];
|
||||
let fileDiagnostics: Map<Diagnostic[]> = {};
|
||||
@@ -1827,6 +1621,55 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function modifierToFlag(token: SyntaxKind): NodeFlags {
|
||||
switch (token) {
|
||||
case SyntaxKind.StaticKeyword: return NodeFlags.Static;
|
||||
case SyntaxKind.PublicKeyword: return NodeFlags.Public;
|
||||
case SyntaxKind.ProtectedKeyword: return NodeFlags.Protected;
|
||||
case SyntaxKind.PrivateKeyword: return NodeFlags.Private;
|
||||
case SyntaxKind.ExportKeyword: return NodeFlags.Export;
|
||||
case SyntaxKind.DeclareKeyword: return NodeFlags.Ambient;
|
||||
case SyntaxKind.ConstKeyword: return NodeFlags.Const;
|
||||
case SyntaxKind.DefaultKeyword: return NodeFlags.Default;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
export function isLeftHandSideExpression(expr: Expression): boolean {
|
||||
if (expr) {
|
||||
switch (expr.kind) {
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.RegularExpressionLiteral:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
case SyntaxKind.TemplateExpression:
|
||||
case SyntaxKind.FalseKeyword:
|
||||
case SyntaxKind.NullKeyword:
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.TrueKeyword:
|
||||
case SyntaxKind.SuperKeyword:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isAssignmentOperator(token: SyntaxKind): boolean {
|
||||
return token >= SyntaxKind.FirstAssignment && token <= SyntaxKind.LastAssignment;
|
||||
}
|
||||
|
||||
// Returns false if this heritage clause element's expression contains something unsupported
|
||||
// (i.e. not a name or dotted name).
|
||||
export function isSupportedHeritageClauseElement(node: HeritageClauseElement): boolean {
|
||||
@@ -1854,3 +1697,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,6 +253,10 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
});
|
||||
|
||||
it('Correct type baselines for ' + fileName, () => {
|
||||
if (fileName.indexOf("APISample") >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// NEWTODO: Type baselines
|
||||
if (result.errors.length === 0) {
|
||||
// The full walker simulates the types that you would get from doing a full
|
||||
@@ -270,29 +274,53 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
// These types are equivalent, but depend on what order the compiler observed
|
||||
// certain parts of the program.
|
||||
|
||||
var fullWalker = new TypeWriterWalker(program, /*fullTypeCheck:*/ true);
|
||||
var pullWalker = new TypeWriterWalker(program, /*fullTypeCheck:*/ false);
|
||||
let allFiles = toBeCompiled.concat(otherFiles).filter(file => !!program.getSourceFile(file.unitName));
|
||||
|
||||
var fullTypes = generateTypes(fullWalker);
|
||||
var pullTypes = generateTypes(pullWalker);
|
||||
let fullWalker = new TypeWriterWalker(program, /*fullTypeCheck:*/ true);
|
||||
let pullWalker = new TypeWriterWalker(program, /*fullTypeCheck:*/ false);
|
||||
|
||||
if (fullTypes !== pullTypes) {
|
||||
Harness.Baseline.runBaseline('Correct full expression types for ' + fileName, justName.replace(/\.ts/, '.types'), () => fullTypes);
|
||||
Harness.Baseline.runBaseline('Correct pull expression types for ' + fileName, justName.replace(/\.ts/, '.types.pull'), () => pullTypes);
|
||||
}
|
||||
else {
|
||||
Harness.Baseline.runBaseline('Correct expression types for ' + fileName, justName.replace(/\.ts/, '.types'), () => fullTypes);
|
||||
let fullResults: ts.Map<TypeWriterResult[]> = {};
|
||||
let pullResults: ts.Map<TypeWriterResult[]> = {};
|
||||
|
||||
for (let sourceFile of allFiles) {
|
||||
fullResults[sourceFile.unitName] = fullWalker.getTypeAndSymbols(sourceFile.unitName);
|
||||
pullResults[sourceFile.unitName] = fullWalker.getTypeAndSymbols(sourceFile.unitName);
|
||||
}
|
||||
|
||||
function generateTypes(walker: TypeWriterWalker): string {
|
||||
var allFiles = toBeCompiled.concat(otherFiles).filter(file => !!program.getSourceFile(file.unitName));
|
||||
var typeLines: string[] = [];
|
||||
var typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {};
|
||||
// Produce baselines. The first gives the types for all expressions.
|
||||
// The second gives symbols for all identifiers.
|
||||
checkBaseLines(/*isSymbolBaseLine:*/ false);
|
||||
checkBaseLines(/*isSymbolBaseLine:*/ true);
|
||||
|
||||
function checkBaseLines(isSymbolBaseLine: boolean) {
|
||||
let fullBaseLine = generateBaseLine(fullResults, isSymbolBaseLine);
|
||||
let pullBaseLine = generateBaseLine(pullResults, isSymbolBaseLine);
|
||||
|
||||
let fullExtension = isSymbolBaseLine ? '.symbols' : '.types';
|
||||
let pullExtension = isSymbolBaseLine ? '.symbols.pull' : '.types.pull';
|
||||
|
||||
if (fullBaseLine !== pullBaseLine) {
|
||||
Harness.Baseline.runBaseline('Correct full information for ' + fileName, justName.replace(/\.ts/, fullExtension), () => fullBaseLine);
|
||||
Harness.Baseline.runBaseline('Correct pull information for ' + fileName, justName.replace(/\.ts/, pullExtension), () => pullBaseLine);
|
||||
}
|
||||
else {
|
||||
Harness.Baseline.runBaseline('Correct information for ' + fileName, justName.replace(/\.ts/, fullExtension), () => fullBaseLine);
|
||||
}
|
||||
}
|
||||
|
||||
function generateBaseLine(typeWriterResults: ts.Map<TypeWriterResult[]>, isSymbolBaseline: boolean): string {
|
||||
let typeLines: string[] = [];
|
||||
let typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {};
|
||||
|
||||
allFiles.forEach(file => {
|
||||
var codeLines = file.content.split('\n');
|
||||
walker.getTypes(file.unitName).forEach(result => {
|
||||
var formattedLine = result.sourceText.replace(/\r?\n/g, "") + " : " + result.type;
|
||||
typeWriterResults[file.unitName].forEach(result => {
|
||||
if (isSymbolBaseline && !result.symbol) {
|
||||
return;
|
||||
}
|
||||
|
||||
var typeOrSymbolString = isSymbolBaseline ? result.symbol : result.type;
|
||||
var formattedLine = result.sourceText.replace(/\r?\n/g, "") + " : " + typeOrSymbolString;
|
||||
if (!typeMap[file.unitName]) {
|
||||
typeMap[file.unitName] = {};
|
||||
}
|
||||
@@ -316,11 +344,13 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
typeLines.push('>' + ty + '\r\n');
|
||||
});
|
||||
if (i + 1 < codeLines.length && (codeLines[i + 1].match(/^\s*[{|}]\s*$/) || codeLines[i + 1].trim() === '')) {
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
typeLines.push('\r\n');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
typeLines.push('No type information for this code.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ interface TypeWriterResult {
|
||||
syntaxKind: number;
|
||||
sourceText: string;
|
||||
type: string;
|
||||
symbol: string;
|
||||
}
|
||||
|
||||
class TypeWriterWalker {
|
||||
@@ -19,7 +20,7 @@ class TypeWriterWalker {
|
||||
: program.getTypeChecker();
|
||||
}
|
||||
|
||||
public getTypes(fileName: string): TypeWriterResult[] {
|
||||
public getTypeAndSymbols(fileName: string): TypeWriterResult[] {
|
||||
var sourceFile = this.program.getSourceFile(fileName);
|
||||
this.currentSourceFile = sourceFile;
|
||||
this.results = [];
|
||||
@@ -45,8 +46,9 @@ class TypeWriterWalker {
|
||||
var symbol = this.checker.getSymbolAtLocation(node);
|
||||
|
||||
var typeString = this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation);
|
||||
var symbolString: string;
|
||||
if (symbol) {
|
||||
var symbolString = "Symbol(" + this.checker.symbolToString(symbol, node.parent);
|
||||
symbolString = "Symbol(" + this.checker.symbolToString(symbol, node.parent);
|
||||
if (symbol.declarations) {
|
||||
for (let declaration of symbol.declarations) {
|
||||
symbolString += ", ";
|
||||
@@ -56,15 +58,14 @@ class TypeWriterWalker {
|
||||
}
|
||||
}
|
||||
symbolString += ")";
|
||||
|
||||
typeString += ", " + symbolString;
|
||||
}
|
||||
|
||||
this.results.push({
|
||||
line: lineAndCharacter.line,
|
||||
syntaxKind: node.kind,
|
||||
sourceText: sourceText,
|
||||
type: typeString
|
||||
type: typeString,
|
||||
symbol: symbolString
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+110
-4
@@ -21,13 +21,16 @@ interface TextStreamBase {
|
||||
* The column number of the current character position in an input stream.
|
||||
*/
|
||||
Column: number;
|
||||
|
||||
/**
|
||||
* The current line number in an input stream.
|
||||
*/
|
||||
Line: number;
|
||||
|
||||
/**
|
||||
* Closes a text stream.
|
||||
* It is not necessary to close standard streams; they close automatically when the process ends. If you close a standard stream, be aware that any other pointers to that standard stream become invalid.
|
||||
* It is not necessary to close standard streams; they close automatically when the process ends. If
|
||||
* you close a standard stream, be aware that any other pointers to that standard stream become invalid.
|
||||
*/
|
||||
Close(): void;
|
||||
}
|
||||
@@ -37,10 +40,12 @@ interface TextStreamWriter extends TextStreamBase {
|
||||
* Sends a string to an output stream.
|
||||
*/
|
||||
Write(s: string): void;
|
||||
|
||||
/**
|
||||
* Sends a specified number of blank lines (newline characters) to an output stream.
|
||||
*/
|
||||
WriteBlankLines(intLines: number): void;
|
||||
|
||||
/**
|
||||
* Sends a string followed by a newline character to an output stream.
|
||||
*/
|
||||
@@ -49,37 +54,43 @@ interface TextStreamWriter extends TextStreamBase {
|
||||
|
||||
interface TextStreamReader extends TextStreamBase {
|
||||
/**
|
||||
* Returns a specified number of characters from an input stream, beginning at the current pointer position.
|
||||
* Returns a specified number of characters from an input stream, starting at the current pointer position.
|
||||
* Does not return until the ENTER key is pressed.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
Read(characters: number): string;
|
||||
|
||||
/**
|
||||
* Returns all characters from an input stream.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
ReadAll(): string;
|
||||
|
||||
/**
|
||||
* Returns an entire line from an input stream.
|
||||
* Although this method extracts the newline character, it does not add it to the returned string.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
ReadLine(): string;
|
||||
|
||||
/**
|
||||
* Skips a specified number of characters when reading from an input text stream.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
* @param characters Positive number of characters to skip forward. (Backward skipping is not supported.)
|
||||
*/
|
||||
Skip(characters: number): void;
|
||||
|
||||
/**
|
||||
* Skips the next line when reading from an input text stream.
|
||||
* Can only be used on a stream in reading mode, not writing or appending mode.
|
||||
*/
|
||||
SkipLine(): void;
|
||||
|
||||
/**
|
||||
* Indicates whether the stream pointer position is at the end of a line.
|
||||
*/
|
||||
AtEndOfLine: boolean;
|
||||
|
||||
/**
|
||||
* Indicates whether the stream pointer position is at the end of a stream.
|
||||
*/
|
||||
@@ -88,85 +99,180 @@ interface TextStreamReader extends TextStreamBase {
|
||||
|
||||
declare var WScript: {
|
||||
/**
|
||||
* Outputs text to either a message box (under WScript.exe) or the command console window followed by a newline (under CScript.ext).
|
||||
* Outputs text to either a message box (under WScript.exe) or the command console window followed by
|
||||
* a newline (under CScript.exe).
|
||||
*/
|
||||
Echo(s: any): void;
|
||||
|
||||
/**
|
||||
* Exposes the write-only error output stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdErr: TextStreamWriter;
|
||||
|
||||
/**
|
||||
* Exposes the write-only output stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdOut: TextStreamWriter;
|
||||
Arguments: { length: number; Item(n: number): string; };
|
||||
|
||||
/**
|
||||
* The full path of the currently running script.
|
||||
*/
|
||||
ScriptFullName: string;
|
||||
|
||||
/**
|
||||
* Forces the script to stop immediately, with an optional exit code.
|
||||
*/
|
||||
Quit(exitCode?: number): number;
|
||||
|
||||
/**
|
||||
* The Windows Script Host build version number.
|
||||
*/
|
||||
BuildVersion: number;
|
||||
|
||||
/**
|
||||
* Fully qualified path of the host executable.
|
||||
*/
|
||||
FullName: string;
|
||||
|
||||
/**
|
||||
* Gets/sets the script mode - interactive(true) or batch(false).
|
||||
*/
|
||||
Interactive: boolean;
|
||||
|
||||
/**
|
||||
* The name of the host executable (WScript.exe or CScript.exe).
|
||||
*/
|
||||
Name: string;
|
||||
|
||||
/**
|
||||
* Path of the directory containing the host executable.
|
||||
*/
|
||||
Path: string;
|
||||
|
||||
/**
|
||||
* The filename of the currently running script.
|
||||
*/
|
||||
ScriptName: string;
|
||||
|
||||
/**
|
||||
* Exposes the read-only input stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdIn: TextStreamReader;
|
||||
|
||||
/**
|
||||
* Windows Script Host version
|
||||
*/
|
||||
Version: string;
|
||||
|
||||
/**
|
||||
* Connects a COM object's event sources to functions named with a given prefix, in the form prefix_event.
|
||||
*/
|
||||
ConnectObject(objEventSource: any, strPrefix: string): void;
|
||||
|
||||
/**
|
||||
* Creates a COM object.
|
||||
* @param strProgiID
|
||||
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
|
||||
*/
|
||||
CreateObject(strProgID: string, strPrefix?: string): any;
|
||||
|
||||
/**
|
||||
* Disconnects a COM object from its event sources.
|
||||
*/
|
||||
DisconnectObject(obj: any): void;
|
||||
|
||||
/**
|
||||
* Retrieves an existing object with the specified ProgID from memory, or creates a new one from a file.
|
||||
* @param strPathname Fully qualified path to the file containing the object persisted to disk. For objects in memory, pass a zero-length string.
|
||||
* @param strPathname Fully qualified path to the file containing the object persisted to disk.
|
||||
* For objects in memory, pass a zero-length string.
|
||||
* @param strProgID
|
||||
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
|
||||
*/
|
||||
GetObject(strPathname: string, strProgID?: string, strPrefix?: string): any;
|
||||
|
||||
/**
|
||||
* Suspends script execution for a specified length of time, then continues execution.
|
||||
* @param intTime Interval (in milliseconds) to suspend script execution.
|
||||
*/
|
||||
Sleep(intTime: number): void;
|
||||
};
|
||||
|
||||
/**
|
||||
* Allows enumerating over a COM collection, which may not have indexed item access.
|
||||
*/
|
||||
interface Enumerator<T> {
|
||||
/**
|
||||
* Returns true if the current item is the last one in the collection, or the collection is empty,
|
||||
* or the current item is undefined.
|
||||
*/
|
||||
atEnd(): boolean;
|
||||
|
||||
/**
|
||||
* Returns the current item in the collection
|
||||
*/
|
||||
item(): T;
|
||||
|
||||
/**
|
||||
* Resets the current item in the collection to the first item. If there are no items in the collection,
|
||||
* the current item is set to undefined.
|
||||
*/
|
||||
moveFirst(): void;
|
||||
|
||||
/**
|
||||
* Moves the current item to the next item in the collection. If the enumerator is at the end of
|
||||
* the collection or the collection is empty, the current item is set to undefined.
|
||||
*/
|
||||
moveNext(): void;
|
||||
}
|
||||
|
||||
interface EnumeratorConstructor {
|
||||
new <T>(collection: any): Enumerator<T>;
|
||||
new (collection: any): Enumerator<any>;
|
||||
}
|
||||
|
||||
declare var Enumerator: EnumeratorConstructor;
|
||||
|
||||
/**
|
||||
* Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions.
|
||||
*/
|
||||
interface VBArray<T> {
|
||||
/**
|
||||
* Returns the number of dimensions (1-based).
|
||||
*/
|
||||
dimensions(): number;
|
||||
|
||||
/**
|
||||
* Takes an index for each dimension in the array, and returns the item at the corresponding location.
|
||||
*/
|
||||
getItem(dimension1Index: number, ...dimensionNIndexes: number[]): T;
|
||||
|
||||
/**
|
||||
* Returns the smallest available index for a given dimension.
|
||||
* @param dimension 1-based dimension (defaults to 1)
|
||||
*/
|
||||
lbound(dimension?: number): number;
|
||||
|
||||
/**
|
||||
* Returns the largest available index for a given dimension.
|
||||
* @param dimension 1-based dimension (defaults to 1)
|
||||
*/
|
||||
ubound(dimension?: number): number;
|
||||
|
||||
/**
|
||||
* Returns a Javascript array with all the elements in the VBArray. If there are multiple dimensions,
|
||||
* each successive dimension is appended to the end of the array.
|
||||
* Example: [[1,2,3],[4,5,6]] becomes [1,2,3,4,5,6]
|
||||
*/
|
||||
toArray(): T[];
|
||||
}
|
||||
|
||||
interface VBArrayConstructor {
|
||||
new <T>(safeArray: any): VBArray<T>;
|
||||
new (safeArray: any): VBArray<any>;
|
||||
}
|
||||
|
||||
declare var VBArray: VBArrayConstructor;
|
||||
|
||||
+27
-42
@@ -10,11 +10,10 @@ module ts.NavigateTo {
|
||||
forEach(program.getSourceFiles(), sourceFile => {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
let declarations = sourceFile.getNamedDeclarations();
|
||||
for (let declaration of declarations) {
|
||||
var name = getDeclarationName(declaration);
|
||||
if (name !== undefined) {
|
||||
|
||||
let nameToDeclarations = sourceFile.getNamedDeclarations();
|
||||
for (let name in nameToDeclarations) {
|
||||
let declarations = getProperty(nameToDeclarations, name);
|
||||
if (declarations) {
|
||||
// First do a quick check to see if the name of the declaration matches the
|
||||
// last portion of the (possibly) dotted name they're searching for.
|
||||
let matches = patternMatcher.getMatchesForLastSegmentOfPattern(name);
|
||||
@@ -23,24 +22,26 @@ module ts.NavigateTo {
|
||||
continue;
|
||||
}
|
||||
|
||||
// It was a match! If the pattern has dots in it, then also see if the
|
||||
// declaration container matches as well.
|
||||
if (patternMatcher.patternContainsDots) {
|
||||
let containers = getContainers(declaration);
|
||||
if (!containers) {
|
||||
return undefined;
|
||||
for (let declaration of declarations) {
|
||||
// It was a match! If the pattern has dots in it, then also see if the
|
||||
// declaration container matches as well.
|
||||
if (patternMatcher.patternContainsDots) {
|
||||
let containers = getContainers(declaration);
|
||||
if (!containers) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
matches = patternMatcher.getMatches(containers, name);
|
||||
|
||||
if (!matches) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
matches = patternMatcher.getMatches(containers, name);
|
||||
|
||||
if (!matches) {
|
||||
continue;
|
||||
}
|
||||
let fileName = sourceFile.fileName;
|
||||
let matchKind = bestMatchKind(matches);
|
||||
rawItems.push({ name, fileName, matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration });
|
||||
}
|
||||
|
||||
let fileName = sourceFile.fileName;
|
||||
let matchKind = bestMatchKind(matches);
|
||||
rawItems.push({ name, fileName, matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration });
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -67,30 +68,14 @@ module ts.NavigateTo {
|
||||
return true;
|
||||
}
|
||||
|
||||
function getDeclarationName(declaration: Declaration): string {
|
||||
let result = getTextOfIdentifierOrLiteral(declaration.name);
|
||||
if (result !== undefined) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (declaration.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
let expr = (<ComputedPropertyName>declaration.name).expression;
|
||||
if (expr.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
return (<PropertyAccessExpression>expr).name.text;
|
||||
}
|
||||
|
||||
return getTextOfIdentifierOrLiteral(expr);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getTextOfIdentifierOrLiteral(node: Node) {
|
||||
if (node.kind === SyntaxKind.Identifier ||
|
||||
node.kind === SyntaxKind.StringLiteral ||
|
||||
node.kind === SyntaxKind.NumericLiteral) {
|
||||
if (node) {
|
||||
if (node.kind === SyntaxKind.Identifier ||
|
||||
node.kind === SyntaxKind.StringLiteral ||
|
||||
node.kind === SyntaxKind.NumericLiteral) {
|
||||
|
||||
return (<Identifier | LiteralExpression>node).text;
|
||||
return (<Identifier | LiteralExpression>node).text;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
||||
@@ -1,180 +1,180 @@
|
||||
/* @internal */
|
||||
module ts {
|
||||
export module OutliningElementsCollector {
|
||||
export function collectElements(sourceFile: SourceFile): OutliningSpan[] {
|
||||
let elements: OutliningSpan[] = [];
|
||||
let collapseText = "...";
|
||||
|
||||
function addOutliningSpan(hintSpanNode: Node, startElement: Node, endElement: Node, autoCollapse: boolean) {
|
||||
if (hintSpanNode && startElement && endElement) {
|
||||
let span: OutliningSpan = {
|
||||
textSpan: createTextSpanFromBounds(startElement.pos, endElement.end),
|
||||
hintSpan: createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end),
|
||||
bannerText: collapseText,
|
||||
autoCollapse: autoCollapse
|
||||
};
|
||||
elements.push(span);
|
||||
}
|
||||
}
|
||||
|
||||
function addOutliningSpanComments(commentSpan: CommentRange, autoCollapse: boolean) {
|
||||
if (commentSpan) {
|
||||
let span: OutliningSpan = {
|
||||
textSpan: createTextSpanFromBounds(commentSpan.pos, commentSpan.end),
|
||||
hintSpan: createTextSpanFromBounds(commentSpan.pos, commentSpan.end),
|
||||
bannerText: collapseText,
|
||||
autoCollapse: autoCollapse
|
||||
};
|
||||
elements.push(span);
|
||||
}
|
||||
}
|
||||
|
||||
function addOutliningForLeadingCommentsForNode(n: Node) {
|
||||
let comments = ts.getLeadingCommentRangesOfNode(n, sourceFile);
|
||||
|
||||
if (comments) {
|
||||
let firstSingleLineCommentStart = -1;
|
||||
let lastSingleLineCommentEnd = -1;
|
||||
let isFirstSingleLineComment = true;
|
||||
let singleLineCommentCount = 0;
|
||||
|
||||
for (let currentComment of comments) {
|
||||
|
||||
// For single line comments, combine consecutive ones (2 or more) into
|
||||
// a single span from the start of the first till the end of the last
|
||||
if (currentComment.kind === SyntaxKind.SingleLineCommentTrivia) {
|
||||
if (isFirstSingleLineComment) {
|
||||
firstSingleLineCommentStart = currentComment.pos;
|
||||
}
|
||||
isFirstSingleLineComment = false;
|
||||
lastSingleLineCommentEnd = currentComment.end;
|
||||
singleLineCommentCount++;
|
||||
}
|
||||
else if (currentComment.kind === SyntaxKind.MultiLineCommentTrivia) {
|
||||
combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd);
|
||||
addOutliningSpanComments(currentComment, /*autoCollapse*/ false);
|
||||
|
||||
singleLineCommentCount = 0;
|
||||
lastSingleLineCommentEnd = -1;
|
||||
isFirstSingleLineComment = true;
|
||||
}
|
||||
}
|
||||
|
||||
combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd);
|
||||
}
|
||||
}
|
||||
|
||||
function combineAndAddMultipleSingleLineComments(count: number, start: number, end: number) {
|
||||
// Only outline spans of two or more consecutive single line comments
|
||||
if (count > 1) {
|
||||
let multipleSingleLineComments = {
|
||||
pos: start,
|
||||
end: end,
|
||||
kind: SyntaxKind.SingleLineCommentTrivia
|
||||
}
|
||||
|
||||
addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false);
|
||||
}
|
||||
}
|
||||
|
||||
function autoCollapse(node: Node) {
|
||||
return isFunctionBlock(node) && node.parent.kind !== SyntaxKind.ArrowFunction;
|
||||
}
|
||||
|
||||
let depth = 0;
|
||||
let maxDepth = 20;
|
||||
function walk(n: Node): void {
|
||||
if (depth > maxDepth) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isDeclaration(n)) {
|
||||
addOutliningForLeadingCommentsForNode(n);
|
||||
}
|
||||
|
||||
switch (n.kind) {
|
||||
case SyntaxKind.Block:
|
||||
if (!isFunctionBlock(n)) {
|
||||
let parent = n.parent;
|
||||
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
|
||||
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
|
||||
|
||||
// Check if the block is standalone, or 'attached' to some parent statement.
|
||||
// If the latter, we want to collaps the block, but consider its hint span
|
||||
// to be the entire span of the parent.
|
||||
if (parent.kind === SyntaxKind.DoStatement ||
|
||||
parent.kind === SyntaxKind.ForInStatement ||
|
||||
parent.kind === SyntaxKind.ForOfStatement ||
|
||||
parent.kind === SyntaxKind.ForStatement ||
|
||||
parent.kind === SyntaxKind.IfStatement ||
|
||||
parent.kind === SyntaxKind.WhileStatement ||
|
||||
parent.kind === SyntaxKind.WithStatement ||
|
||||
parent.kind === SyntaxKind.CatchClause) {
|
||||
|
||||
addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n));
|
||||
break;
|
||||
}
|
||||
|
||||
if (parent.kind === SyntaxKind.TryStatement) {
|
||||
// Could be the try-block, or the finally-block.
|
||||
let tryStatement = <TryStatement>parent;
|
||||
if (tryStatement.tryBlock === n) {
|
||||
addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n));
|
||||
break;
|
||||
}
|
||||
else if (tryStatement.finallyBlock === n) {
|
||||
let finallyKeyword = findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile);
|
||||
if (finallyKeyword) {
|
||||
addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// fall through.
|
||||
}
|
||||
|
||||
// Block was a standalone block. In this case we want to only collapse
|
||||
// the span of the block, independent of any parent span.
|
||||
let span = createTextSpanFromBounds(n.getStart(), n.end);
|
||||
elements.push({
|
||||
textSpan: span,
|
||||
hintSpan: span,
|
||||
bannerText: collapseText,
|
||||
autoCollapse: autoCollapse(n)
|
||||
});
|
||||
break;
|
||||
}
|
||||
// Fallthrough.
|
||||
|
||||
case SyntaxKind.ModuleBlock: {
|
||||
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
|
||||
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
|
||||
addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n));
|
||||
break;
|
||||
}
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.CaseBlock: {
|
||||
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
|
||||
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
|
||||
addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n));
|
||||
break;
|
||||
}
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
let openBracket = findChildOfKind(n, SyntaxKind.OpenBracketToken, sourceFile);
|
||||
let closeBracket = findChildOfKind(n, SyntaxKind.CloseBracketToken, sourceFile);
|
||||
addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n));
|
||||
break;
|
||||
}
|
||||
depth++;
|
||||
forEachChild(n, walk);
|
||||
depth--;
|
||||
}
|
||||
|
||||
walk(sourceFile);
|
||||
return elements;
|
||||
}
|
||||
}
|
||||
/* @internal */
|
||||
module ts {
|
||||
export module OutliningElementsCollector {
|
||||
export function collectElements(sourceFile: SourceFile): OutliningSpan[] {
|
||||
let elements: OutliningSpan[] = [];
|
||||
let collapseText = "...";
|
||||
|
||||
function addOutliningSpan(hintSpanNode: Node, startElement: Node, endElement: Node, autoCollapse: boolean) {
|
||||
if (hintSpanNode && startElement && endElement) {
|
||||
let span: OutliningSpan = {
|
||||
textSpan: createTextSpanFromBounds(startElement.pos, endElement.end),
|
||||
hintSpan: createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end),
|
||||
bannerText: collapseText,
|
||||
autoCollapse: autoCollapse
|
||||
};
|
||||
elements.push(span);
|
||||
}
|
||||
}
|
||||
|
||||
function addOutliningSpanComments(commentSpan: CommentRange, autoCollapse: boolean) {
|
||||
if (commentSpan) {
|
||||
let span: OutliningSpan = {
|
||||
textSpan: createTextSpanFromBounds(commentSpan.pos, commentSpan.end),
|
||||
hintSpan: createTextSpanFromBounds(commentSpan.pos, commentSpan.end),
|
||||
bannerText: collapseText,
|
||||
autoCollapse: autoCollapse
|
||||
};
|
||||
elements.push(span);
|
||||
}
|
||||
}
|
||||
|
||||
function addOutliningForLeadingCommentsForNode(n: Node) {
|
||||
let comments = ts.getLeadingCommentRangesOfNode(n, sourceFile);
|
||||
|
||||
if (comments) {
|
||||
let firstSingleLineCommentStart = -1;
|
||||
let lastSingleLineCommentEnd = -1;
|
||||
let isFirstSingleLineComment = true;
|
||||
let singleLineCommentCount = 0;
|
||||
|
||||
for (let currentComment of comments) {
|
||||
|
||||
// For single line comments, combine consecutive ones (2 or more) into
|
||||
// a single span from the start of the first till the end of the last
|
||||
if (currentComment.kind === SyntaxKind.SingleLineCommentTrivia) {
|
||||
if (isFirstSingleLineComment) {
|
||||
firstSingleLineCommentStart = currentComment.pos;
|
||||
}
|
||||
isFirstSingleLineComment = false;
|
||||
lastSingleLineCommentEnd = currentComment.end;
|
||||
singleLineCommentCount++;
|
||||
}
|
||||
else if (currentComment.kind === SyntaxKind.MultiLineCommentTrivia) {
|
||||
combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd);
|
||||
addOutliningSpanComments(currentComment, /*autoCollapse*/ false);
|
||||
|
||||
singleLineCommentCount = 0;
|
||||
lastSingleLineCommentEnd = -1;
|
||||
isFirstSingleLineComment = true;
|
||||
}
|
||||
}
|
||||
|
||||
combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd);
|
||||
}
|
||||
}
|
||||
|
||||
function combineAndAddMultipleSingleLineComments(count: number, start: number, end: number) {
|
||||
// Only outline spans of two or more consecutive single line comments
|
||||
if (count > 1) {
|
||||
let multipleSingleLineComments = {
|
||||
pos: start,
|
||||
end: end,
|
||||
kind: SyntaxKind.SingleLineCommentTrivia
|
||||
}
|
||||
|
||||
addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false);
|
||||
}
|
||||
}
|
||||
|
||||
function autoCollapse(node: Node) {
|
||||
return isFunctionBlock(node) && node.parent.kind !== SyntaxKind.ArrowFunction;
|
||||
}
|
||||
|
||||
let depth = 0;
|
||||
let maxDepth = 20;
|
||||
function walk(n: Node): void {
|
||||
if (depth > maxDepth) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isDeclaration(n)) {
|
||||
addOutliningForLeadingCommentsForNode(n);
|
||||
}
|
||||
|
||||
switch (n.kind) {
|
||||
case SyntaxKind.Block:
|
||||
if (!isFunctionBlock(n)) {
|
||||
let parent = n.parent;
|
||||
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
|
||||
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
|
||||
|
||||
// Check if the block is standalone, or 'attached' to some parent statement.
|
||||
// If the latter, we want to collaps the block, but consider its hint span
|
||||
// to be the entire span of the parent.
|
||||
if (parent.kind === SyntaxKind.DoStatement ||
|
||||
parent.kind === SyntaxKind.ForInStatement ||
|
||||
parent.kind === SyntaxKind.ForOfStatement ||
|
||||
parent.kind === SyntaxKind.ForStatement ||
|
||||
parent.kind === SyntaxKind.IfStatement ||
|
||||
parent.kind === SyntaxKind.WhileStatement ||
|
||||
parent.kind === SyntaxKind.WithStatement ||
|
||||
parent.kind === SyntaxKind.CatchClause) {
|
||||
|
||||
addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n));
|
||||
break;
|
||||
}
|
||||
|
||||
if (parent.kind === SyntaxKind.TryStatement) {
|
||||
// Could be the try-block, or the finally-block.
|
||||
let tryStatement = <TryStatement>parent;
|
||||
if (tryStatement.tryBlock === n) {
|
||||
addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n));
|
||||
break;
|
||||
}
|
||||
else if (tryStatement.finallyBlock === n) {
|
||||
let finallyKeyword = findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile);
|
||||
if (finallyKeyword) {
|
||||
addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// fall through.
|
||||
}
|
||||
|
||||
// Block was a standalone block. In this case we want to only collapse
|
||||
// the span of the block, independent of any parent span.
|
||||
let span = createTextSpanFromBounds(n.getStart(), n.end);
|
||||
elements.push({
|
||||
textSpan: span,
|
||||
hintSpan: span,
|
||||
bannerText: collapseText,
|
||||
autoCollapse: autoCollapse(n)
|
||||
});
|
||||
break;
|
||||
}
|
||||
// Fallthrough.
|
||||
|
||||
case SyntaxKind.ModuleBlock: {
|
||||
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
|
||||
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
|
||||
addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n));
|
||||
break;
|
||||
}
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.CaseBlock: {
|
||||
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
|
||||
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
|
||||
addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n));
|
||||
break;
|
||||
}
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
let openBracket = findChildOfKind(n, SyntaxKind.OpenBracketToken, sourceFile);
|
||||
let closeBracket = findChildOfKind(n, SyntaxKind.CloseBracketToken, sourceFile);
|
||||
addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n));
|
||||
break;
|
||||
}
|
||||
depth++;
|
||||
forEachChild(n, walk);
|
||||
depth--;
|
||||
}
|
||||
|
||||
walk(sourceFile);
|
||||
return elements;
|
||||
}
|
||||
}
|
||||
}
|
||||
+178
-134
@@ -63,7 +63,8 @@ module ts {
|
||||
/* @internal */ scriptSnapshot: IScriptSnapshot;
|
||||
/* @internal */ nameTable: Map<string>;
|
||||
|
||||
getNamedDeclarations(): Declaration[];
|
||||
/* @internal */ getNamedDeclarations(): Map<Declaration[]>;
|
||||
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
@@ -749,7 +750,7 @@ module ts {
|
||||
public identifiers: Map<string>;
|
||||
public nameTable: Map<string>;
|
||||
|
||||
private namedDeclarations: Declaration[];
|
||||
private namedDeclarations: Map<Declaration[]>;
|
||||
|
||||
public update(newText: string, textChangeRange: TextChangeRange): SourceFile {
|
||||
return updateSourceFile(this, newText, textChangeRange);
|
||||
@@ -767,7 +768,7 @@ module ts {
|
||||
return ts.getPositionOfLineAndCharacter(this, line, character);
|
||||
}
|
||||
|
||||
public getNamedDeclarations() {
|
||||
public getNamedDeclarations(): Map<Declaration[]> {
|
||||
if (!this.namedDeclarations) {
|
||||
this.namedDeclarations = this.computeNamedDeclarations();
|
||||
}
|
||||
@@ -775,12 +776,57 @@ module ts {
|
||||
return this.namedDeclarations;
|
||||
}
|
||||
|
||||
private computeNamedDeclarations() {
|
||||
let namedDeclarations: Declaration[] = [];
|
||||
private computeNamedDeclarations(): Map<Declaration[]> {
|
||||
let result: Map<Declaration[]> = {};
|
||||
|
||||
forEachChild(this, visit);
|
||||
|
||||
return namedDeclarations;
|
||||
return result;
|
||||
|
||||
function addDeclaration(declaration: Declaration) {
|
||||
let name = getDeclarationName(declaration);
|
||||
if (name) {
|
||||
let declarations = getDeclarations(name);
|
||||
declarations.push(declaration);
|
||||
}
|
||||
}
|
||||
|
||||
function getDeclarations(name: string) {
|
||||
return getProperty(result, name) || (result[name] = []);
|
||||
}
|
||||
|
||||
function getDeclarationName(declaration: Declaration) {
|
||||
if (declaration.name) {
|
||||
let result = getTextOfIdentifierOrLiteral(declaration.name);
|
||||
if (result !== undefined) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (declaration.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
let expr = (<ComputedPropertyName>declaration.name).expression;
|
||||
if (expr.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
return (<PropertyAccessExpression>expr).name.text;
|
||||
}
|
||||
|
||||
return getTextOfIdentifierOrLiteral(expr);
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getTextOfIdentifierOrLiteral(node: Node) {
|
||||
if (node) {
|
||||
if (node.kind === SyntaxKind.Identifier ||
|
||||
node.kind === SyntaxKind.StringLiteral ||
|
||||
node.kind === SyntaxKind.NumericLiteral) {
|
||||
|
||||
return (<Identifier | LiteralExpression>node).text;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function visit(node: Node): void {
|
||||
switch (node.kind) {
|
||||
@@ -788,22 +834,22 @@ module ts {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
let functionDeclaration = <FunctionLikeDeclaration>node;
|
||||
let declarationName = getDeclarationName(functionDeclaration);
|
||||
|
||||
if (functionDeclaration.name && functionDeclaration.name.getFullWidth() > 0) {
|
||||
let lastDeclaration = namedDeclarations.length > 0 ?
|
||||
namedDeclarations[namedDeclarations.length - 1] :
|
||||
undefined;
|
||||
if (declarationName) {
|
||||
let declarations = getDeclarations(declarationName);
|
||||
let lastDeclaration = lastOrUndefined(declarations);
|
||||
|
||||
// Check whether this declaration belongs to an "overload group".
|
||||
if (lastDeclaration && functionDeclaration.symbol === lastDeclaration.symbol) {
|
||||
if (lastDeclaration && functionDeclaration.parent === lastDeclaration.parent && functionDeclaration.symbol === lastDeclaration.symbol) {
|
||||
// Overwrite the last declaration if it was an overload
|
||||
// and this one is an implementation.
|
||||
if (functionDeclaration.body && !(<FunctionLikeDeclaration>lastDeclaration).body) {
|
||||
namedDeclarations[namedDeclarations.length - 1] = functionDeclaration;
|
||||
declarations[declarations.length - 1] = functionDeclaration;
|
||||
}
|
||||
}
|
||||
else {
|
||||
namedDeclarations.push(functionDeclaration);
|
||||
declarations.push(functionDeclaration);
|
||||
}
|
||||
|
||||
forEachChild(node, visit);
|
||||
@@ -824,10 +870,8 @@ module ts {
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
if ((<Declaration>node).name) {
|
||||
namedDeclarations.push(<Declaration>node);
|
||||
}
|
||||
// fall through
|
||||
addDeclaration(<Declaration>node);
|
||||
// fall through
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.VariableStatement:
|
||||
case SyntaxKind.VariableDeclarationList:
|
||||
@@ -858,7 +902,7 @@ module ts {
|
||||
case SyntaxKind.EnumMember:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
namedDeclarations.push(<Declaration>node);
|
||||
addDeclaration(<Declaration>node);
|
||||
break;
|
||||
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
@@ -875,7 +919,7 @@ module ts {
|
||||
// Handle default import case e.g.:
|
||||
// import d from "mod";
|
||||
if (importClause.name) {
|
||||
namedDeclarations.push(importClause);
|
||||
addDeclaration(importClause);
|
||||
}
|
||||
|
||||
// Handle named bindings in imports e.g.:
|
||||
@@ -883,7 +927,7 @@ module ts {
|
||||
// import {a, b as B} from "mod";
|
||||
if (importClause.namedBindings) {
|
||||
if (importClause.namedBindings.kind === SyntaxKind.NamespaceImport) {
|
||||
namedDeclarations.push(<NamespaceImport>importClause.namedBindings);
|
||||
addDeclaration(<NamespaceImport>importClause.namedBindings);
|
||||
}
|
||||
else {
|
||||
forEach((<NamedImports>importClause.namedBindings).elements, visit);
|
||||
@@ -2260,8 +2304,6 @@ module ts {
|
||||
let ruleProvider: formatting.RulesProvider;
|
||||
let program: Program;
|
||||
|
||||
// this checker is used to answer all LS questions except errors
|
||||
let typeInfoResolver: TypeChecker;
|
||||
let useCaseSensitivefileNames = false;
|
||||
let cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken());
|
||||
|
||||
@@ -2343,8 +2385,10 @@ module ts {
|
||||
}
|
||||
|
||||
program = newProgram;
|
||||
typeInfoResolver = program.getTypeChecker();
|
||||
|
||||
// Make sure all the nodes in the program are both bound, and have their parent
|
||||
// pointers set property.
|
||||
program.getTypeChecker();
|
||||
return;
|
||||
|
||||
function getOrCreateSourceFile(fileName: string): SourceFile {
|
||||
@@ -2428,15 +2472,8 @@ module ts {
|
||||
return program;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up any semantic caches that are not needed.
|
||||
* The host can call this method if it wants to jettison unused memory.
|
||||
* We will just dump the typeChecker and recreate a new one. this should have the effect of destroying all the semantic caches.
|
||||
*/
|
||||
function cleanupSemanticCache(): void {
|
||||
if (program) {
|
||||
typeInfoResolver = program.getTypeChecker();
|
||||
}
|
||||
// TODO: Should we jettison the program (or it's type checker) here?
|
||||
}
|
||||
|
||||
function dispose(): void {
|
||||
@@ -2453,10 +2490,6 @@ module ts {
|
||||
return program.getSyntacticDiagnostics(getValidSourceFile(fileName));
|
||||
}
|
||||
|
||||
function isJavaScript(fileName: string) {
|
||||
return fileExtensionIs(fileName, ".js");
|
||||
}
|
||||
|
||||
/**
|
||||
* getSemanticDiagnostiscs return array of Diagnostics. If '-d' is not enabled, only report semantic errors
|
||||
* If '-d' enabled, report both semantic and emitter errors
|
||||
@@ -2704,32 +2737,8 @@ module ts {
|
||||
return unescapeIdentifier(displayName);
|
||||
}
|
||||
|
||||
function createCompletionEntry(symbol: Symbol, typeChecker: TypeChecker, location: Node): CompletionEntry {
|
||||
// Try to get a valid display name for this symbol, if we could not find one, then ignore it.
|
||||
// We would like to only show things that can be added after a dot, so for instance numeric properties can
|
||||
// not be accessed with a dot (a.1 <- invalid)
|
||||
let displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true);
|
||||
if (!displayName) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// TODO(drosen): Right now we just permit *all* semantic meanings when calling
|
||||
// 'getSymbolKind' which is permissible given that it is backwards compatible; but
|
||||
// really we should consider passing the meaning for the node so that we don't report
|
||||
// that a suggestion for a value is an interface. We COULD also just do what
|
||||
// 'getSymbolModifiers' does, which is to use the first declaration.
|
||||
|
||||
// Use a 'sortText' of 0' so that all symbol completion entries come before any other
|
||||
// entries (like JavaScript identifier entries).
|
||||
return {
|
||||
name: displayName,
|
||||
kind: getSymbolKind(symbol, typeChecker, location),
|
||||
kindModifiers: getSymbolModifiers(symbol),
|
||||
sortText: "0",
|
||||
};
|
||||
}
|
||||
|
||||
function getCompletionData(fileName: string, position: number) {
|
||||
let typeChecker = program.getTypeChecker();
|
||||
let syntacticStart = new Date().getTime();
|
||||
let sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
@@ -2813,29 +2822,29 @@ module ts {
|
||||
isNewIdentifierLocation = false;
|
||||
|
||||
if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
let symbol = typeInfoResolver.getSymbolAtLocation(node);
|
||||
let symbol = typeChecker.getSymbolAtLocation(node);
|
||||
|
||||
// This is an alias, follow what it aliases
|
||||
if (symbol && symbol.flags & SymbolFlags.Alias) {
|
||||
symbol = typeInfoResolver.getAliasedSymbol(symbol);
|
||||
symbol = typeChecker.getAliasedSymbol(symbol);
|
||||
}
|
||||
|
||||
if (symbol && symbol.flags & SymbolFlags.HasExports) {
|
||||
// Extract module or enum members
|
||||
let exportedSymbols = typeInfoResolver.getExportsOfModule(symbol);
|
||||
let exportedSymbols = typeChecker.getExportsOfModule(symbol);
|
||||
forEach(exportedSymbols, symbol => {
|
||||
if (typeInfoResolver.isValidPropertyAccess(<PropertyAccessExpression>(node.parent), symbol.name)) {
|
||||
if (typeChecker.isValidPropertyAccess(<PropertyAccessExpression>(node.parent), symbol.name)) {
|
||||
symbols.push(symbol);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let type = typeInfoResolver.getTypeAtLocation(node);
|
||||
let type = typeChecker.getTypeAtLocation(node);
|
||||
if (type) {
|
||||
// Filter private properties
|
||||
forEach(type.getApparentProperties(), symbol => {
|
||||
if (typeInfoResolver.isValidPropertyAccess(<PropertyAccessExpression>(node.parent), symbol.name)) {
|
||||
if (typeChecker.isValidPropertyAccess(<PropertyAccessExpression>(node.parent), symbol.name)) {
|
||||
symbols.push(symbol);
|
||||
}
|
||||
});
|
||||
@@ -2849,12 +2858,12 @@ module ts {
|
||||
isMemberCompletion = true;
|
||||
isNewIdentifierLocation = true;
|
||||
|
||||
let contextualType = typeInfoResolver.getContextualType(containingObjectLiteral);
|
||||
let contextualType = typeChecker.getContextualType(containingObjectLiteral);
|
||||
if (!contextualType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let contextualTypeMembers = typeInfoResolver.getPropertiesOfType(contextualType);
|
||||
let contextualTypeMembers = typeChecker.getPropertiesOfType(contextualType);
|
||||
if (contextualTypeMembers && contextualTypeMembers.length > 0) {
|
||||
// Add filtered items to the completion list
|
||||
symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties);
|
||||
@@ -2871,9 +2880,9 @@ module ts {
|
||||
|
||||
let exports: Symbol[];
|
||||
if (importDeclaration.moduleSpecifier) {
|
||||
let moduleSpecifierSymbol = typeInfoResolver.getSymbolAtLocation(importDeclaration.moduleSpecifier);
|
||||
let moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier);
|
||||
if (moduleSpecifierSymbol) {
|
||||
exports = typeInfoResolver.getExportsOfModule(moduleSpecifierSymbol);
|
||||
exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2922,7 +2931,7 @@ module ts {
|
||||
|
||||
/// TODO filter meaning based on the current context
|
||||
let symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias;
|
||||
symbols = typeInfoResolver.getSymbolsInScope(scopeNode, symbolMeanings);
|
||||
symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -3285,6 +3294,31 @@ module ts {
|
||||
return entries;
|
||||
}
|
||||
|
||||
function createCompletionEntry(symbol: Symbol, location: Node): CompletionEntry {
|
||||
// Try to get a valid display name for this symbol, if we could not find one, then ignore it.
|
||||
// We would like to only show things that can be added after a dot, so for instance numeric properties can
|
||||
// not be accessed with a dot (a.1 <- invalid)
|
||||
let displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true);
|
||||
if (!displayName) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// TODO(drosen): Right now we just permit *all* semantic meanings when calling
|
||||
// 'getSymbolKind' which is permissible given that it is backwards compatible; but
|
||||
// really we should consider passing the meaning for the node so that we don't report
|
||||
// that a suggestion for a value is an interface. We COULD also just do what
|
||||
// 'getSymbolModifiers' does, which is to use the first declaration.
|
||||
|
||||
// Use a 'sortText' of 0' so that all symbol completion entries come before any other
|
||||
// entries (like JavaScript identifier entries).
|
||||
return {
|
||||
name: displayName,
|
||||
kind: getSymbolKind(symbol, location),
|
||||
kindModifiers: getSymbolModifiers(symbol),
|
||||
sortText: "0",
|
||||
};
|
||||
}
|
||||
|
||||
function getCompletionEntriesFromSymbols(symbols: Symbol[]): CompletionEntry[] {
|
||||
let start = new Date().getTime();
|
||||
var entries: CompletionEntry[] = [];
|
||||
@@ -3292,7 +3326,7 @@ module ts {
|
||||
if (symbols) {
|
||||
var nameToSymbol: Map<Symbol> = {};
|
||||
for (let symbol of symbols) {
|
||||
let entry = createCompletionEntry(symbol, typeInfoResolver, location);
|
||||
let entry = createCompletionEntry(symbol, location);
|
||||
if (entry) {
|
||||
let id = escapeIdentifier(entry.name);
|
||||
if (!lookUp(nameToSymbol, id)) {
|
||||
@@ -3324,7 +3358,7 @@ module ts {
|
||||
let symbol = forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false) === entryName ? s : undefined);
|
||||
|
||||
if (symbol) {
|
||||
let displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location, typeInfoResolver, location, SemanticMeaning.All);
|
||||
let displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location, location, SemanticMeaning.All);
|
||||
return {
|
||||
name: entryName,
|
||||
kind: displayPartsDocumentationsAndSymbolKind.symbolKind,
|
||||
@@ -3351,7 +3385,7 @@ module ts {
|
||||
}
|
||||
|
||||
// TODO(drosen): use contextual SemanticMeaning.
|
||||
function getSymbolKind(symbol: Symbol, typeResolver: TypeChecker, location: Node): string {
|
||||
function getSymbolKind(symbol: Symbol, location: Node): string {
|
||||
let flags = symbol.getFlags();
|
||||
|
||||
if (flags & SymbolFlags.Class) return ScriptElementKind.classElement;
|
||||
@@ -3360,7 +3394,7 @@ module ts {
|
||||
if (flags & SymbolFlags.Interface) return ScriptElementKind.interfaceElement;
|
||||
if (flags & SymbolFlags.TypeParameter) return ScriptElementKind.typeParameterElement;
|
||||
|
||||
let result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, typeResolver, location);
|
||||
let result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, location);
|
||||
if (result === ScriptElementKind.unknown) {
|
||||
if (flags & SymbolFlags.TypeParameter) return ScriptElementKind.typeParameterElement;
|
||||
if (flags & SymbolFlags.EnumMember) return ScriptElementKind.variableElement;
|
||||
@@ -3371,11 +3405,13 @@ module ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol: Symbol, flags: SymbolFlags, typeResolver: TypeChecker, location: Node) {
|
||||
if (typeResolver.isUndefinedSymbol(symbol)) {
|
||||
function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol: Symbol, flags: SymbolFlags, location: Node) {
|
||||
let typeChecker = program.getTypeChecker();
|
||||
|
||||
if (typeChecker.isUndefinedSymbol(symbol)) {
|
||||
return ScriptElementKind.variableElement;
|
||||
}
|
||||
if (typeResolver.isArgumentsSymbol(symbol)) {
|
||||
if (typeChecker.isArgumentsSymbol(symbol)) {
|
||||
return ScriptElementKind.localVariableElement;
|
||||
}
|
||||
if (flags & SymbolFlags.Variable) {
|
||||
@@ -3399,7 +3435,7 @@ module ts {
|
||||
if (flags & SymbolFlags.Property) {
|
||||
if (flags & SymbolFlags.UnionProperty) {
|
||||
// If union property is result of union of non method (property/accessors/variables), it is labeled as property
|
||||
let unionPropertyKind = forEach(typeInfoResolver.getRootSymbols(symbol), rootSymbol => {
|
||||
let unionPropertyKind = forEach(typeChecker.getRootSymbols(symbol), rootSymbol => {
|
||||
let rootSymbolFlags = rootSymbol.getFlags();
|
||||
if (rootSymbolFlags & (SymbolFlags.PropertyOrAccessor | SymbolFlags.Variable)) {
|
||||
return ScriptElementKind.memberVariableElement;
|
||||
@@ -3409,7 +3445,7 @@ module ts {
|
||||
if (!unionPropertyKind) {
|
||||
// If this was union of all methods,
|
||||
//make sure it has call signatures before we can label it as method
|
||||
let typeOfUnionProperty = typeInfoResolver.getTypeOfSymbolAtLocation(symbol, location);
|
||||
let typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
||||
if (typeOfUnionProperty.getCallSignatures().length) {
|
||||
return ScriptElementKind.memberFunctionElement;
|
||||
}
|
||||
@@ -3442,15 +3478,16 @@ module ts {
|
||||
: ScriptElementKindModifier.none;
|
||||
}
|
||||
|
||||
// TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location
|
||||
function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol: Symbol, sourceFile: SourceFile, enclosingDeclaration: Node,
|
||||
typeResolver: TypeChecker, location: Node,
|
||||
// TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location
|
||||
semanticMeaning = getMeaningFromLocation(location)) {
|
||||
location: Node, semanticMeaning = getMeaningFromLocation(location)) {
|
||||
|
||||
let typeChecker = program.getTypeChecker();
|
||||
|
||||
let displayParts: SymbolDisplayPart[] = [];
|
||||
let documentation: SymbolDisplayPart[];
|
||||
let symbolFlags = symbol.flags;
|
||||
let symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, typeResolver, location);
|
||||
let symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, location);
|
||||
let hasAddedSymbolInfo: boolean;
|
||||
let type: Type;
|
||||
|
||||
@@ -3462,7 +3499,7 @@ module ts {
|
||||
}
|
||||
|
||||
let signature: Signature;
|
||||
type = typeResolver.getTypeOfSymbolAtLocation(symbol, location);
|
||||
type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
||||
if (type) {
|
||||
if (location.parent && location.parent.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
let right = (<PropertyAccessExpression>location.parent).name;
|
||||
@@ -3483,7 +3520,7 @@ module ts {
|
||||
|
||||
if (callExpression) {
|
||||
let candidateSignatures: Signature[] = [];
|
||||
signature = typeResolver.getResolvedSignature(callExpression, candidateSignatures);
|
||||
signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures);
|
||||
if (!signature && candidateSignatures.length) {
|
||||
// Use the first candidate:
|
||||
signature = candidateSignatures[0];
|
||||
@@ -3532,7 +3569,7 @@ module ts {
|
||||
displayParts.push(spacePart());
|
||||
}
|
||||
if (!(type.flags & TypeFlags.Anonymous)) {
|
||||
displayParts.push.apply(displayParts, symbolToDisplayParts(typeResolver, type.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments));
|
||||
displayParts.push.apply(displayParts, symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments));
|
||||
}
|
||||
addSignatureDisplayParts(signature, allSignatures, TypeFormatFlags.WriteArrowStyleSignature);
|
||||
break;
|
||||
@@ -3549,8 +3586,8 @@ module ts {
|
||||
// get the signature from the declaration and write it
|
||||
let functionDeclaration = <FunctionLikeDeclaration>location.parent;
|
||||
let allSignatures = functionDeclaration.kind === SyntaxKind.Constructor ? type.getConstructSignatures() : type.getCallSignatures();
|
||||
if (!typeResolver.isImplementationOfOverload(functionDeclaration)) {
|
||||
signature = typeResolver.getSignatureFromDeclaration(functionDeclaration);
|
||||
if (!typeChecker.isImplementationOfOverload(functionDeclaration)) {
|
||||
signature = typeChecker.getSignatureFromDeclaration(functionDeclaration);
|
||||
}
|
||||
else {
|
||||
signature = allSignatures[0];
|
||||
@@ -3593,7 +3630,7 @@ module ts {
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(operatorPart(SyntaxKind.EqualsToken));
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push.apply(displayParts, typeToDisplayParts(typeResolver, typeResolver.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration));
|
||||
displayParts.push.apply(displayParts, typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration));
|
||||
}
|
||||
if (symbolFlags & SymbolFlags.Enum) {
|
||||
addNewLineIfDisplayPartsExist();
|
||||
@@ -3629,7 +3666,7 @@ module ts {
|
||||
else {
|
||||
// Method/function type parameter
|
||||
let signatureDeclaration = <SignatureDeclaration>getDeclarationOfKind(symbol, SyntaxKind.TypeParameter).parent;
|
||||
let signature = typeResolver.getSignatureFromDeclaration(signatureDeclaration);
|
||||
let signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration);
|
||||
if (signatureDeclaration.kind === SyntaxKind.ConstructSignature) {
|
||||
displayParts.push(keywordPart(SyntaxKind.NewKeyword));
|
||||
displayParts.push(spacePart());
|
||||
@@ -3637,14 +3674,14 @@ module ts {
|
||||
else if (signatureDeclaration.kind !== SyntaxKind.CallSignature && signatureDeclaration.name) {
|
||||
addFullSymbolName(signatureDeclaration.symbol);
|
||||
}
|
||||
displayParts.push.apply(displayParts, signatureToDisplayParts(typeResolver, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature));
|
||||
displayParts.push.apply(displayParts, signatureToDisplayParts(typeChecker, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature));
|
||||
}
|
||||
}
|
||||
if (symbolFlags & SymbolFlags.EnumMember) {
|
||||
addPrefixForAnyFunctionOrVar(symbol, "enum member");
|
||||
let declaration = symbol.declarations[0];
|
||||
if (declaration.kind === SyntaxKind.EnumMember) {
|
||||
let constantValue = typeResolver.getConstantValue(<EnumMember>declaration);
|
||||
let constantValue = typeChecker.getConstantValue(<EnumMember>declaration);
|
||||
if (constantValue !== undefined) {
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(operatorPart(SyntaxKind.EqualsToken));
|
||||
@@ -3671,7 +3708,7 @@ module ts {
|
||||
displayParts.push(punctuationPart(SyntaxKind.CloseParenToken));
|
||||
}
|
||||
else {
|
||||
let internalAliasSymbol = typeResolver.getSymbolAtLocation(importEqualsDeclaration.moduleReference);
|
||||
let internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference);
|
||||
if (internalAliasSymbol) {
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(operatorPart(SyntaxKind.EqualsToken));
|
||||
@@ -3696,12 +3733,12 @@ module ts {
|
||||
// If the type is type parameter, format it specially
|
||||
if (type.symbol && type.symbol.flags & SymbolFlags.TypeParameter) {
|
||||
let typeParameterParts = mapToDisplayParts(writer => {
|
||||
typeResolver.getSymbolDisplayBuilder().buildTypeParameterDisplay(<TypeParameter>type, writer, enclosingDeclaration);
|
||||
typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(<TypeParameter>type, writer, enclosingDeclaration);
|
||||
});
|
||||
displayParts.push.apply(displayParts, typeParameterParts);
|
||||
}
|
||||
else {
|
||||
displayParts.push.apply(displayParts, typeToDisplayParts(typeResolver, type, enclosingDeclaration));
|
||||
displayParts.push.apply(displayParts, typeToDisplayParts(typeChecker, type, enclosingDeclaration));
|
||||
}
|
||||
}
|
||||
else if (symbolFlags & SymbolFlags.Function ||
|
||||
@@ -3716,7 +3753,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
symbolKind = getSymbolKind(symbol, typeResolver, location);
|
||||
symbolKind = getSymbolKind(symbol, location);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3733,7 +3770,7 @@ module ts {
|
||||
}
|
||||
|
||||
function addFullSymbolName(symbol: Symbol, enclosingDeclaration?: Node) {
|
||||
let fullSymbolDisplayParts = symbolToDisplayParts(typeResolver, symbol, enclosingDeclaration || sourceFile, /*meaning*/ undefined,
|
||||
let fullSymbolDisplayParts = symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, /*meaning*/ undefined,
|
||||
SymbolFormatFlags.WriteTypeParametersOrArguments | SymbolFormatFlags.UseOnlyExternalAliasing);
|
||||
displayParts.push.apply(displayParts, fullSymbolDisplayParts);
|
||||
}
|
||||
@@ -3765,7 +3802,7 @@ module ts {
|
||||
}
|
||||
|
||||
function addSignatureDisplayParts(signature: Signature, allSignatures: Signature[], flags?: TypeFormatFlags) {
|
||||
displayParts.push.apply(displayParts, signatureToDisplayParts(typeResolver, signature, enclosingDeclaration, flags | TypeFormatFlags.WriteTypeArgumentsOfSignature));
|
||||
displayParts.push.apply(displayParts, signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | TypeFormatFlags.WriteTypeArgumentsOfSignature));
|
||||
if (allSignatures.length > 1) {
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
|
||||
@@ -3780,7 +3817,7 @@ module ts {
|
||||
|
||||
function writeTypeParametersOfSymbol(symbol: Symbol, enclosingDeclaration: Node) {
|
||||
let typeParameterParts = mapToDisplayParts(writer => {
|
||||
typeResolver.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration);
|
||||
typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration);
|
||||
});
|
||||
displayParts.push.apply(displayParts, typeParameterParts);
|
||||
}
|
||||
@@ -3799,7 +3836,9 @@ module ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let symbol = typeInfoResolver.getSymbolAtLocation(node);
|
||||
let typeChecker = program.getTypeChecker();
|
||||
let symbol = typeChecker.getSymbolAtLocation(node);
|
||||
|
||||
if (!symbol) {
|
||||
// Try getting just type at this position and show
|
||||
switch (node.kind) {
|
||||
@@ -3809,13 +3848,13 @@ module ts {
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.SuperKeyword:
|
||||
// For the identifiers/this/super etc get the type at position
|
||||
let type = typeInfoResolver.getTypeAtLocation(node);
|
||||
let type = typeChecker.getTypeAtLocation(node);
|
||||
if (type) {
|
||||
return {
|
||||
kind: ScriptElementKind.unknown,
|
||||
kindModifiers: ScriptElementKindModifier.none,
|
||||
textSpan: createTextSpan(node.getStart(), node.getWidth()),
|
||||
displayParts: typeToDisplayParts(typeInfoResolver, type, getContainerNode(node)),
|
||||
displayParts: typeToDisplayParts(typeChecker, type, getContainerNode(node)),
|
||||
documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined
|
||||
};
|
||||
}
|
||||
@@ -3824,7 +3863,7 @@ module ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let displayPartsDocumentationsAndKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, getContainerNode(node), typeInfoResolver, node);
|
||||
let displayPartsDocumentationsAndKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, getContainerNode(node), node);
|
||||
return {
|
||||
kind: displayPartsDocumentationsAndKind.symbolKind,
|
||||
kindModifiers: getSymbolModifiers(symbol),
|
||||
@@ -3880,7 +3919,8 @@ module ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let symbol = typeInfoResolver.getSymbolAtLocation(node);
|
||||
let typeChecker = program.getTypeChecker();
|
||||
let symbol = typeChecker.getSymbolAtLocation(node);
|
||||
|
||||
// Could not find a symbol e.g. node is string or number keyword,
|
||||
// or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
|
||||
@@ -3895,7 +3935,7 @@ module ts {
|
||||
if (symbol.flags & SymbolFlags.Alias) {
|
||||
let declaration = symbol.declarations[0];
|
||||
if (node.kind === SyntaxKind.Identifier && node.parent === declaration) {
|
||||
symbol = typeInfoResolver.getAliasedSymbol(symbol);
|
||||
symbol = typeChecker.getAliasedSymbol(symbol);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3905,25 +3945,25 @@ module ts {
|
||||
// is performed at the location of property access, we would like to go to definition of the property in the short-hand
|
||||
// assignment. This case and others are handled by the following code.
|
||||
if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) {
|
||||
let shorthandSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
|
||||
let shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration);
|
||||
if (!shorthandSymbol) {
|
||||
return [];
|
||||
}
|
||||
|
||||
let shorthandDeclarations = shorthandSymbol.getDeclarations();
|
||||
let shorthandSymbolKind = getSymbolKind(shorthandSymbol, typeInfoResolver, node);
|
||||
let shorthandSymbolName = typeInfoResolver.symbolToString(shorthandSymbol);
|
||||
let shorthandContainerName = typeInfoResolver.symbolToString(symbol.parent, node);
|
||||
let shorthandSymbolKind = getSymbolKind(shorthandSymbol, node);
|
||||
let shorthandSymbolName = typeChecker.symbolToString(shorthandSymbol);
|
||||
let shorthandContainerName = typeChecker.symbolToString(symbol.parent, node);
|
||||
return map(shorthandDeclarations,
|
||||
declaration => createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName));
|
||||
}
|
||||
|
||||
let result: DefinitionInfo[] = [];
|
||||
let declarations = symbol.getDeclarations();
|
||||
let symbolName = typeInfoResolver.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
|
||||
let symbolKind = getSymbolKind(symbol, typeInfoResolver, node);
|
||||
let symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
|
||||
let symbolKind = getSymbolKind(symbol, node);
|
||||
let containerSymbol = symbol.parent;
|
||||
let containerName = containerSymbol ? typeInfoResolver.symbolToString(containerSymbol, node) : "";
|
||||
let containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : "";
|
||||
|
||||
if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) &&
|
||||
!tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) {
|
||||
@@ -4682,7 +4722,9 @@ module ts {
|
||||
return getReferencedSymbolsForNodes(node, program.getSourceFiles(), findInStrings, findInComments);
|
||||
}
|
||||
|
||||
function getReferencedSymbolsForNodes(node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean): ReferencedSymbol[]{
|
||||
function getReferencedSymbolsForNodes(node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean): ReferencedSymbol[] {
|
||||
let typeChecker = program.getTypeChecker();
|
||||
|
||||
// Labels
|
||||
if (isLabelName(node)) {
|
||||
if (isJumpStatementTarget(node)) {
|
||||
@@ -4705,7 +4747,7 @@ module ts {
|
||||
return getReferencesForSuperKeyword(node);
|
||||
}
|
||||
|
||||
let symbol = typeInfoResolver.getSymbolAtLocation(node);
|
||||
let symbol = typeChecker.getSymbolAtLocation(node);
|
||||
|
||||
// Could not find a symbol e.g. unknown identifier
|
||||
if (!symbol) {
|
||||
@@ -4756,7 +4798,7 @@ module ts {
|
||||
return result;
|
||||
|
||||
function getDefinition(symbol: Symbol): DefinitionInfo {
|
||||
let info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), typeInfoResolver, node);
|
||||
let info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), node);
|
||||
let name = map(info.displayParts, p => p.text).join("");
|
||||
let declarations = symbol.declarations;
|
||||
if (!declarations || declarations.length === 0) {
|
||||
@@ -4806,7 +4848,7 @@ module ts {
|
||||
return location.getText();
|
||||
}
|
||||
|
||||
name = typeInfoResolver.symbolToString(symbol);
|
||||
name = typeChecker.symbolToString(symbol);
|
||||
|
||||
return stripQuotes(name);
|
||||
}
|
||||
@@ -5042,10 +5084,10 @@ module ts {
|
||||
return;
|
||||
}
|
||||
|
||||
let referenceSymbol = typeInfoResolver.getSymbolAtLocation(referenceLocation);
|
||||
let referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation);
|
||||
if (referenceSymbol) {
|
||||
let referenceSymbolDeclaration = referenceSymbol.valueDeclaration;
|
||||
let shorthandValueSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration);
|
||||
let shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration);
|
||||
var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation);
|
||||
|
||||
if (relatedSymbol) {
|
||||
@@ -5270,7 +5312,7 @@ module ts {
|
||||
|
||||
// If the symbol is an alias, add what it alaises to the list
|
||||
if (isImportOrExportSpecifierImportSymbol(symbol)) {
|
||||
result.push(typeInfoResolver.getAliasedSymbol(symbol));
|
||||
result.push(typeChecker.getAliasedSymbol(symbol));
|
||||
}
|
||||
|
||||
// If the location is in a context sensitive location (i.e. in an object literal) try
|
||||
@@ -5278,7 +5320,7 @@ module ts {
|
||||
// type to the search set
|
||||
if (isNameOfPropertyAssignment(location)) {
|
||||
forEach(getPropertySymbolsFromContextualType(location), contextualSymbol => {
|
||||
result.push.apply(result, typeInfoResolver.getRootSymbols(contextualSymbol));
|
||||
result.push.apply(result, typeChecker.getRootSymbols(contextualSymbol));
|
||||
});
|
||||
|
||||
/* Because in short-hand property assignment, location has two meaning : property name and as value of the property
|
||||
@@ -5292,7 +5334,7 @@ module ts {
|
||||
* so that when matching with potential reference symbol, both symbols from property declaration and variable declaration
|
||||
* will be included correctly.
|
||||
*/
|
||||
let shorthandValueSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(location.parent);
|
||||
let shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent);
|
||||
if (shorthandValueSymbol) {
|
||||
result.push(shorthandValueSymbol);
|
||||
}
|
||||
@@ -5300,7 +5342,7 @@ module ts {
|
||||
|
||||
// If this is a union property, add all the symbols from all its source symbols in all unioned types.
|
||||
// If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list
|
||||
forEach(typeInfoResolver.getRootSymbols(symbol), rootSymbol => {
|
||||
forEach(typeChecker.getRootSymbols(symbol), rootSymbol => {
|
||||
if (rootSymbol !== symbol) {
|
||||
result.push(rootSymbol);
|
||||
}
|
||||
@@ -5330,9 +5372,9 @@ module ts {
|
||||
|
||||
function getPropertySymbolFromTypeReference(typeReference: HeritageClauseElement) {
|
||||
if (typeReference) {
|
||||
let type = typeInfoResolver.getTypeAtLocation(typeReference);
|
||||
let type = typeChecker.getTypeAtLocation(typeReference);
|
||||
if (type) {
|
||||
let propertySymbol = typeInfoResolver.getPropertyOfType(type, propertyName);
|
||||
let propertySymbol = typeChecker.getPropertyOfType(type, propertyName);
|
||||
if (propertySymbol) {
|
||||
result.push(propertySymbol);
|
||||
}
|
||||
@@ -5352,7 +5394,7 @@ module ts {
|
||||
// If the reference symbol is an alias, check if what it is aliasing is one of the search
|
||||
// symbols.
|
||||
if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) {
|
||||
var aliasedSymbol = typeInfoResolver.getAliasedSymbol(referenceSymbol);
|
||||
var aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol);
|
||||
if (searchSymbols.indexOf(aliasedSymbol) >= 0) {
|
||||
return aliasedSymbol;
|
||||
}
|
||||
@@ -5363,13 +5405,13 @@ module ts {
|
||||
// compare to our searchSymbol
|
||||
if (isNameOfPropertyAssignment(referenceLocation)) {
|
||||
return forEach(getPropertySymbolsFromContextualType(referenceLocation), contextualSymbol => {
|
||||
return forEach(typeInfoResolver.getRootSymbols(contextualSymbol), s => searchSymbols.indexOf(s) >= 0 ? s : undefined);
|
||||
return forEach(typeChecker.getRootSymbols(contextualSymbol), s => searchSymbols.indexOf(s) >= 0 ? s : undefined);
|
||||
});
|
||||
}
|
||||
|
||||
// Unwrap symbols to get to the root (e.g. transient symbols as a result of widening)
|
||||
// Or a union property, use its underlying unioned symbols
|
||||
return forEach(typeInfoResolver.getRootSymbols(referenceSymbol), rootSymbol => {
|
||||
return forEach(typeChecker.getRootSymbols(referenceSymbol), rootSymbol => {
|
||||
// if it is in the list, then we are done
|
||||
if (searchSymbols.indexOf(rootSymbol) >= 0) {
|
||||
return rootSymbol;
|
||||
@@ -5390,7 +5432,7 @@ module ts {
|
||||
function getPropertySymbolsFromContextualType(node: Node): Symbol[] {
|
||||
if (isNameOfPropertyAssignment(node)) {
|
||||
let objectLiteral = <ObjectLiteralExpression>node.parent.parent;
|
||||
let contextualType = typeInfoResolver.getContextualType(objectLiteral);
|
||||
let contextualType = typeChecker.getContextualType(objectLiteral);
|
||||
let name = (<Identifier>node).text;
|
||||
if (contextualType) {
|
||||
if (contextualType.flags & TypeFlags.Union) {
|
||||
@@ -5682,7 +5724,7 @@ module ts {
|
||||
|
||||
let sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
return SignatureHelp.getSignatureHelpItems(sourceFile, position, typeInfoResolver, cancellationToken);
|
||||
return SignatureHelp.getSignatureHelpItems(program, sourceFile, position, cancellationToken);
|
||||
}
|
||||
|
||||
/// Syntactic features
|
||||
@@ -5763,6 +5805,7 @@ module ts {
|
||||
synchronizeHostData();
|
||||
|
||||
let sourceFile = getValidSourceFile(fileName);
|
||||
let typeChecker = program.getTypeChecker();
|
||||
|
||||
let result: ClassifiedSpan[] = [];
|
||||
processNode(sourceFile);
|
||||
@@ -5815,7 +5858,7 @@ module ts {
|
||||
// Only walk into nodes that intersect the requested span.
|
||||
if (node && textSpanIntersectsWith(span, node.getStart(), node.getWidth())) {
|
||||
if (node.kind === SyntaxKind.Identifier && node.getWidth() > 0) {
|
||||
let symbol = typeInfoResolver.getSymbolAtLocation(node);
|
||||
let symbol = typeChecker.getSymbolAtLocation(node);
|
||||
if (symbol) {
|
||||
let type = classifySymbol(symbol, getMeaningFromLocation(node));
|
||||
if (type) {
|
||||
@@ -6297,12 +6340,13 @@ module ts {
|
||||
synchronizeHostData();
|
||||
|
||||
let sourceFile = getValidSourceFile(fileName);
|
||||
let typeChecker = program.getTypeChecker();
|
||||
|
||||
let node = getTouchingWord(sourceFile, position);
|
||||
|
||||
// Can only rename an identifier.
|
||||
if (node && node.kind === SyntaxKind.Identifier) {
|
||||
let symbol = typeInfoResolver.getSymbolAtLocation(node);
|
||||
let symbol = typeChecker.getSymbolAtLocation(node);
|
||||
|
||||
// Only allow a symbol to be renamed if it actually has at least one declaration.
|
||||
if (symbol) {
|
||||
@@ -6319,13 +6363,13 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
let kind = getSymbolKind(symbol, typeInfoResolver, node);
|
||||
let kind = getSymbolKind(symbol, node);
|
||||
if (kind) {
|
||||
return {
|
||||
canRename: true,
|
||||
localizedErrorMessage: undefined,
|
||||
displayName: symbol.name,
|
||||
fullDisplayName: typeInfoResolver.getFullyQualifiedName(symbol),
|
||||
fullDisplayName: typeChecker.getFullyQualifiedName(symbol),
|
||||
kind: kind,
|
||||
kindModifiers: getSymbolModifiers(symbol),
|
||||
triggerSpan: createTextSpan(node.getStart(), node.getWidth())
|
||||
|
||||
@@ -178,7 +178,9 @@ module ts.SignatureHelp {
|
||||
argumentCount: number;
|
||||
}
|
||||
|
||||
export function getSignatureHelpItems(sourceFile: SourceFile, position: number, typeInfoResolver: TypeChecker, cancellationToken: CancellationTokenObject): SignatureHelpItems {
|
||||
export function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, cancellationToken: CancellationTokenObject): SignatureHelpItems {
|
||||
let typeChecker = program.getTypeChecker();
|
||||
|
||||
// Decide whether to show signature help
|
||||
let startingToken = findTokenOnLeftOfPosition(sourceFile, position);
|
||||
if (!startingToken) {
|
||||
@@ -196,15 +198,61 @@ module ts.SignatureHelp {
|
||||
|
||||
let call = argumentInfo.invocation;
|
||||
let candidates = <Signature[]>[];
|
||||
let resolvedSignature = typeInfoResolver.getResolvedSignature(call, candidates);
|
||||
let resolvedSignature = typeChecker.getResolvedSignature(call, candidates);
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
if (!candidates.length) {
|
||||
// We didn't have any sig help items produced by the TS compiler. If this is a JS
|
||||
// file, then see if we can figure out anything better.
|
||||
if (isJavaScript(sourceFile.fileName)) {
|
||||
return createJavaScriptSignatureHelpItems(argumentInfo);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo);
|
||||
|
||||
function createJavaScriptSignatureHelpItems(argumentInfo: ArgumentListInfo): SignatureHelpItems {
|
||||
if (argumentInfo.invocation.kind !== SyntaxKind.CallExpression) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// See if we can find some symbol with the call expression name that has call signatures.
|
||||
let callExpression = <CallExpression>argumentInfo.invocation;
|
||||
let expression = callExpression.expression;
|
||||
let name = expression.kind === SyntaxKind.Identifier
|
||||
? <Identifier> expression
|
||||
: expression.kind === SyntaxKind.PropertyAccessExpression
|
||||
? (<PropertyAccessExpression>expression).name
|
||||
: undefined;
|
||||
|
||||
if (!name || !name.text) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let typeChecker = program.getTypeChecker();
|
||||
for (let sourceFile of program.getSourceFiles()) {
|
||||
let nameToDeclarations = sourceFile.getNamedDeclarations();
|
||||
let declarations = getProperty(nameToDeclarations, name.text);
|
||||
|
||||
if (declarations) {
|
||||
for (let declaration of declarations) {
|
||||
let symbol = declaration.symbol;
|
||||
if (symbol) {
|
||||
let type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration);
|
||||
if (type) {
|
||||
let callSignatures = type.getCallSignatures();
|
||||
if (callSignatures && callSignatures.length) {
|
||||
return createSignatureHelpItems(callSignatures, callSignatures[0], argumentInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns relevant information for the argument list and the current argument if we are
|
||||
* in the argument of an invocation; returns undefined otherwise.
|
||||
@@ -494,8 +542,8 @@ module ts.SignatureHelp {
|
||||
|
||||
let invocation = argumentListInfo.invocation;
|
||||
let callTarget = getInvokedExpression(invocation)
|
||||
let callTargetSymbol = typeInfoResolver.getSymbolAtLocation(callTarget);
|
||||
let callTargetDisplayParts = callTargetSymbol && symbolToDisplayParts(typeInfoResolver, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined);
|
||||
let callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget);
|
||||
let callTargetDisplayParts = callTargetSymbol && symbolToDisplayParts(typeChecker, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined);
|
||||
let items: SignatureHelpItem[] = map(candidates, candidateSignature => {
|
||||
let signatureHelpParameters: SignatureHelpParameter[];
|
||||
let prefixDisplayParts: SymbolDisplayPart[] = [];
|
||||
@@ -511,12 +559,12 @@ module ts.SignatureHelp {
|
||||
signatureHelpParameters = typeParameters && typeParameters.length > 0 ? map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray;
|
||||
suffixDisplayParts.push(punctuationPart(SyntaxKind.GreaterThanToken));
|
||||
let parameterParts = mapToDisplayParts(writer =>
|
||||
typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation));
|
||||
typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation));
|
||||
suffixDisplayParts.push.apply(suffixDisplayParts, parameterParts);
|
||||
}
|
||||
else {
|
||||
let typeParameterParts = mapToDisplayParts(writer =>
|
||||
typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation));
|
||||
typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation));
|
||||
prefixDisplayParts.push.apply(prefixDisplayParts, typeParameterParts);
|
||||
prefixDisplayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
|
||||
|
||||
@@ -526,7 +574,7 @@ module ts.SignatureHelp {
|
||||
}
|
||||
|
||||
let returnTypeParts = mapToDisplayParts(writer =>
|
||||
typeInfoResolver.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation));
|
||||
typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation));
|
||||
suffixDisplayParts.push.apply(suffixDisplayParts, returnTypeParts);
|
||||
|
||||
return {
|
||||
@@ -561,7 +609,7 @@ module ts.SignatureHelp {
|
||||
|
||||
function createSignatureHelpParameterForParameter(parameter: Symbol): SignatureHelpParameter {
|
||||
let displayParts = mapToDisplayParts(writer =>
|
||||
typeInfoResolver.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation));
|
||||
typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation));
|
||||
|
||||
let isOptional = hasQuestionToken(parameter.valueDeclaration);
|
||||
|
||||
@@ -575,7 +623,7 @@ module ts.SignatureHelp {
|
||||
|
||||
function createSignatureHelpParameterForTypeParameter(typeParameter: TypeParameter): SignatureHelpParameter {
|
||||
let displayParts = mapToDisplayParts(writer =>
|
||||
typeInfoResolver.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation));
|
||||
typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation));
|
||||
|
||||
return {
|
||||
name: typeParameter.symbol.name,
|
||||
|
||||
@@ -652,4 +652,8 @@ module ts {
|
||||
typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags);
|
||||
});
|
||||
}
|
||||
|
||||
export function isJavaScript(fileName: string) {
|
||||
return fileExtensionIs(fileName, ".js");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
=== tests/cases/compiler/2dArrays.ts ===
|
||||
class Cell {
|
||||
>Cell : Symbol(Cell, Decl(2dArrays.ts, 0, 0))
|
||||
}
|
||||
|
||||
class Ship {
|
||||
>Ship : Symbol(Ship, Decl(2dArrays.ts, 1, 1))
|
||||
|
||||
isSunk: boolean;
|
||||
>isSunk : Symbol(isSunk, Decl(2dArrays.ts, 3, 12))
|
||||
}
|
||||
|
||||
class Board {
|
||||
>Board : Symbol(Board, Decl(2dArrays.ts, 5, 1))
|
||||
|
||||
ships: Ship[];
|
||||
>ships : Symbol(ships, Decl(2dArrays.ts, 7, 13))
|
||||
>Ship : Symbol(Ship, Decl(2dArrays.ts, 1, 1))
|
||||
|
||||
cells: Cell[];
|
||||
>cells : Symbol(cells, Decl(2dArrays.ts, 8, 18))
|
||||
>Cell : Symbol(Cell, Decl(2dArrays.ts, 0, 0))
|
||||
|
||||
private allShipsSunk() {
|
||||
>allShipsSunk : Symbol(allShipsSunk, Decl(2dArrays.ts, 9, 18))
|
||||
|
||||
return this.ships.every(function (val) { return val.isSunk; });
|
||||
>this.ships.every : Symbol(Array.every, Decl(lib.d.ts, 1094, 62))
|
||||
>this.ships : Symbol(ships, Decl(2dArrays.ts, 7, 13))
|
||||
>this : Symbol(Board, Decl(2dArrays.ts, 5, 1))
|
||||
>ships : Symbol(ships, Decl(2dArrays.ts, 7, 13))
|
||||
>every : Symbol(Array.every, Decl(lib.d.ts, 1094, 62))
|
||||
>val : Symbol(val, Decl(2dArrays.ts, 12, 42))
|
||||
>val.isSunk : Symbol(Ship.isSunk, Decl(2dArrays.ts, 3, 12))
|
||||
>val : Symbol(val, Decl(2dArrays.ts, 12, 42))
|
||||
>isSunk : Symbol(Ship.isSunk, Decl(2dArrays.ts, 3, 12))
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,40 @@
|
||||
=== tests/cases/compiler/2dArrays.ts ===
|
||||
class Cell {
|
||||
>Cell : Cell, Symbol(Cell, Decl(2dArrays.ts, 0, 0))
|
||||
>Cell : Cell
|
||||
}
|
||||
|
||||
class Ship {
|
||||
>Ship : Ship, Symbol(Ship, Decl(2dArrays.ts, 1, 1))
|
||||
>Ship : Ship
|
||||
|
||||
isSunk: boolean;
|
||||
>isSunk : boolean, Symbol(isSunk, Decl(2dArrays.ts, 3, 12))
|
||||
>isSunk : boolean
|
||||
}
|
||||
|
||||
class Board {
|
||||
>Board : Board, Symbol(Board, Decl(2dArrays.ts, 5, 1))
|
||||
>Board : Board
|
||||
|
||||
ships: Ship[];
|
||||
>ships : Ship[], Symbol(ships, Decl(2dArrays.ts, 7, 13))
|
||||
>Ship : Ship, Symbol(Ship, Decl(2dArrays.ts, 1, 1))
|
||||
>ships : Ship[]
|
||||
>Ship : Ship
|
||||
|
||||
cells: Cell[];
|
||||
>cells : Cell[], Symbol(cells, Decl(2dArrays.ts, 8, 18))
|
||||
>Cell : Cell, Symbol(Cell, Decl(2dArrays.ts, 0, 0))
|
||||
>cells : Cell[]
|
||||
>Cell : Cell
|
||||
|
||||
private allShipsSunk() {
|
||||
>allShipsSunk : () => boolean, Symbol(allShipsSunk, Decl(2dArrays.ts, 9, 18))
|
||||
>allShipsSunk : () => boolean
|
||||
|
||||
return this.ships.every(function (val) { return val.isSunk; });
|
||||
>this.ships.every(function (val) { return val.isSunk; }) : boolean
|
||||
>this.ships.every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean, Symbol(Array.every, Decl(lib.d.ts, 1094, 62))
|
||||
>this.ships : Ship[], Symbol(ships, Decl(2dArrays.ts, 7, 13))
|
||||
>this : Board, Symbol(Board, Decl(2dArrays.ts, 5, 1))
|
||||
>ships : Ship[], Symbol(ships, Decl(2dArrays.ts, 7, 13))
|
||||
>every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean, Symbol(Array.every, Decl(lib.d.ts, 1094, 62))
|
||||
>this.ships.every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean
|
||||
>this.ships : Ship[]
|
||||
>this : Board
|
||||
>ships : Ship[]
|
||||
>every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean
|
||||
>function (val) { return val.isSunk; } : (val: Ship) => boolean
|
||||
>val : Ship, Symbol(val, Decl(2dArrays.ts, 12, 42))
|
||||
>val.isSunk : boolean, Symbol(Ship.isSunk, Decl(2dArrays.ts, 3, 12))
|
||||
>val : Ship, Symbol(val, Decl(2dArrays.ts, 12, 42))
|
||||
>isSunk : boolean, Symbol(Ship.isSunk, Decl(2dArrays.ts, 3, 12))
|
||||
>val : Ship
|
||||
>val.isSunk : boolean
|
||||
>val : Ship
|
||||
>isSunk : boolean
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,168 +0,0 @@
|
||||
=== tests/cases/compiler/APISample_compile.ts ===
|
||||
|
||||
/*
|
||||
* Note: This test is a public API sample. The sample sources can be found
|
||||
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler
|
||||
* Please log a "breaking change" issue for any API breaking change affecting this issue
|
||||
*/
|
||||
|
||||
declare var process: any;
|
||||
>process : any, Symbol(process, Decl(APISample_compile.ts, 7, 11))
|
||||
|
||||
declare var console: any;
|
||||
>console : any, Symbol(console, Decl(APISample_compile.ts, 8, 11))
|
||||
|
||||
declare var os: any;
|
||||
>os : any, Symbol(os, Decl(APISample_compile.ts, 9, 11))
|
||||
|
||||
import ts = require("typescript");
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_compile.ts, 9, 20))
|
||||
|
||||
export function compile(fileNames: string[], options: ts.CompilerOptions): void {
|
||||
>compile : (fileNames: string[], options: ts.CompilerOptions) => void, Symbol(compile, Decl(APISample_compile.ts, 11, 34))
|
||||
>fileNames : string[], Symbol(fileNames, Decl(APISample_compile.ts, 13, 24))
|
||||
>options : ts.CompilerOptions, Symbol(options, Decl(APISample_compile.ts, 13, 44))
|
||||
>ts : any, Symbol(ts, Decl(APISample_compile.ts, 9, 20))
|
||||
>CompilerOptions : ts.CompilerOptions, Symbol(ts.CompilerOptions, Decl(typescript.d.ts, 1074, 5))
|
||||
|
||||
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 : 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))
|
||||
>fileNames : string[], Symbol(fileNames, Decl(APISample_compile.ts, 13, 24))
|
||||
>options : ts.CompilerOptions, Symbol(options, Decl(APISample_compile.ts, 13, 44))
|
||||
|
||||
var emitResult = program.emit();
|
||||
>emitResult : ts.EmitResult, Symbol(emitResult, Decl(APISample_compile.ts, 15, 7))
|
||||
>program.emit() : ts.EmitResult
|
||||
>program.emit : (targetSourceFile?: ts.SourceFile, writeFile?: ts.WriteFileCallback) => ts.EmitResult, Symbol(ts.Program.emit, Decl(typescript.d.ts, 767, 39))
|
||||
>program : ts.Program, Symbol(program, Decl(APISample_compile.ts, 14, 7))
|
||||
>emit : (targetSourceFile?: ts.SourceFile, writeFile?: ts.WriteFileCallback) => ts.EmitResult, Symbol(ts.Program.emit, Decl(typescript.d.ts, 767, 39))
|
||||
|
||||
var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
>allDiagnostics : ts.Diagnostic[], Symbol(allDiagnostics, Decl(APISample_compile.ts, 17, 7))
|
||||
>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 : 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))
|
||||
>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))
|
||||
>emitResult : ts.EmitResult, Symbol(emitResult, Decl(APISample_compile.ts, 15, 7))
|
||||
>diagnostics : ts.Diagnostic[], Symbol(ts.EmitResult.diagnostics, Decl(typescript.d.ts, 820, 29))
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
>allDiagnostics.forEach(diagnostic => { var { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); }) : void
|
||||
>allDiagnostics.forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
|
||||
>allDiagnostics : ts.Diagnostic[], Symbol(allDiagnostics, Decl(APISample_compile.ts, 17, 7))
|
||||
>forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
|
||||
>diagnostic => { var { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); } : (diagnostic: ts.Diagnostic) => void
|
||||
>diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_compile.ts, 19, 27))
|
||||
|
||||
var { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
>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, 1263, 46))
|
||||
>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, 1263, 46))
|
||||
>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))
|
||||
|
||||
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 : 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))
|
||||
>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))
|
||||
>'\n' : string
|
||||
|
||||
console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
|
||||
>console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`) : any
|
||||
>console.log : any
|
||||
>console : any, Symbol(console, Decl(APISample_compile.ts, 8, 11))
|
||||
>log : any
|
||||
>`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}` : string
|
||||
>diagnostic.file.fileName : string, Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29))
|
||||
>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))
|
||||
>fileName : string, Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29))
|
||||
>line + 1 : number
|
||||
>line : number, Symbol(line, Decl(APISample_compile.ts, 20, 13))
|
||||
>1 : number
|
||||
>character + 1 : number
|
||||
>character : number, Symbol(character, Decl(APISample_compile.ts, 20, 19))
|
||||
>1 : number
|
||||
>message : string, Symbol(message, Decl(APISample_compile.ts, 21, 11))
|
||||
|
||||
});
|
||||
|
||||
var exitCode = emitResult.emitSkipped ? 1 : 0;
|
||||
>exitCode : number, Symbol(exitCode, Decl(APISample_compile.ts, 25, 7))
|
||||
>emitResult.emitSkipped ? 1 : 0 : number
|
||||
>emitResult.emitSkipped : boolean, Symbol(ts.EmitResult.emitSkipped, Decl(typescript.d.ts, 819, 26))
|
||||
>emitResult : ts.EmitResult, Symbol(emitResult, Decl(APISample_compile.ts, 15, 7))
|
||||
>emitSkipped : boolean, Symbol(ts.EmitResult.emitSkipped, Decl(typescript.d.ts, 819, 26))
|
||||
>1 : number
|
||||
>0 : number
|
||||
|
||||
console.log(`Process exiting with code '${exitCode}'.`);
|
||||
>console.log(`Process exiting with code '${exitCode}'.`) : any
|
||||
>console.log : any
|
||||
>console : any, Symbol(console, Decl(APISample_compile.ts, 8, 11))
|
||||
>log : any
|
||||
>`Process exiting with code '${exitCode}'.` : string
|
||||
>exitCode : number, Symbol(exitCode, Decl(APISample_compile.ts, 25, 7))
|
||||
|
||||
process.exit(exitCode);
|
||||
>process.exit(exitCode) : any
|
||||
>process.exit : any
|
||||
>process : any, Symbol(process, Decl(APISample_compile.ts, 7, 11))
|
||||
>exit : any
|
||||
>exitCode : number, Symbol(exitCode, Decl(APISample_compile.ts, 25, 7))
|
||||
}
|
||||
|
||||
compile(process.argv.slice(2), {
|
||||
>compile(process.argv.slice(2), { noEmitOnError: true, noImplicitAny: true, target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS}) : void
|
||||
>compile : (fileNames: string[], options: ts.CompilerOptions) => void, Symbol(compile, Decl(APISample_compile.ts, 11, 34))
|
||||
>process.argv.slice(2) : any
|
||||
>process.argv.slice : any
|
||||
>process.argv : any
|
||||
>process : any, Symbol(process, Decl(APISample_compile.ts, 7, 11))
|
||||
>argv : any
|
||||
>slice : any
|
||||
>2 : number
|
||||
>{ noEmitOnError: true, noImplicitAny: true, target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS} : { [x: string]: boolean | ts.ScriptTarget | ts.ModuleKind; noEmitOnError: boolean; noImplicitAny: boolean; target: ts.ScriptTarget; module: ts.ModuleKind; }
|
||||
|
||||
noEmitOnError: true, noImplicitAny: true,
|
||||
>noEmitOnError : boolean, Symbol(noEmitOnError, Decl(APISample_compile.ts, 30, 32))
|
||||
>true : boolean
|
||||
>noImplicitAny : boolean, Symbol(noImplicitAny, Decl(APISample_compile.ts, 31, 24))
|
||||
>true : boolean
|
||||
|
||||
target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS
|
||||
>target : ts.ScriptTarget, Symbol(target, Decl(APISample_compile.ts, 31, 45))
|
||||
>ts.ScriptTarget.ES5 : ts.ScriptTarget, Symbol(ts.ScriptTarget.ES5, Decl(typescript.d.ts, 1117, 16))
|
||||
>ts.ScriptTarget : typeof ts.ScriptTarget, Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1115, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_compile.ts, 9, 20))
|
||||
>ScriptTarget : typeof ts.ScriptTarget, Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1115, 5))
|
||||
>ES5 : ts.ScriptTarget, Symbol(ts.ScriptTarget.ES5, Decl(typescript.d.ts, 1117, 16))
|
||||
>module : ts.ModuleKind, Symbol(module, Decl(APISample_compile.ts, 32, 32))
|
||||
>ts.ModuleKind.CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17))
|
||||
>ts.ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_compile.ts, 9, 20))
|
||||
>ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5))
|
||||
>CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17))
|
||||
|
||||
});
|
||||
@@ -1,312 +0,0 @@
|
||||
=== tests/cases/compiler/APISample_linter.ts ===
|
||||
|
||||
/*
|
||||
* Note: This test is a public API sample. The sample sources can be found
|
||||
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter
|
||||
* Please log a "breaking change" issue for any API breaking change affecting this issue
|
||||
*/
|
||||
|
||||
declare var process: any;
|
||||
>process : any, Symbol(process, Decl(APISample_linter.ts, 7, 11))
|
||||
|
||||
declare var console: any;
|
||||
>console : any, Symbol(console, Decl(APISample_linter.ts, 8, 11))
|
||||
|
||||
declare var readFileSync: any;
|
||||
>readFileSync : any, Symbol(readFileSync, Decl(APISample_linter.ts, 9, 11))
|
||||
|
||||
import * as ts from "typescript";
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
|
||||
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))
|
||||
|
||||
delintNode(sourceFile);
|
||||
>delintNode(sourceFile) : void
|
||||
>delintNode : (node: ts.Node) => void, Symbol(delintNode, Decl(APISample_linter.ts, 14, 27))
|
||||
>sourceFile : ts.SourceFile, Symbol(sourceFile, Decl(APISample_linter.ts, 13, 23))
|
||||
|
||||
function delintNode(node: ts.Node) {
|
||||
>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))
|
||||
|
||||
switch (node.kind) {
|
||||
>node.kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
|
||||
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 16, 24))
|
||||
>kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
|
||||
|
||||
case ts.SyntaxKind.ForStatement:
|
||||
>ts.SyntaxKind.ForStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.ForStatement, Decl(typescript.d.ts, 209, 29))
|
||||
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>ForStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.ForStatement, Decl(typescript.d.ts, 209, 29))
|
||||
|
||||
case ts.SyntaxKind.ForInStatement:
|
||||
>ts.SyntaxKind.ForInStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.ForInStatement, Decl(typescript.d.ts, 210, 27))
|
||||
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>ForInStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.ForInStatement, Decl(typescript.d.ts, 210, 27))
|
||||
|
||||
case ts.SyntaxKind.WhileStatement:
|
||||
>ts.SyntaxKind.WhileStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.WhileStatement, Decl(typescript.d.ts, 208, 26))
|
||||
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>WhileStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.WhileStatement, Decl(typescript.d.ts, 208, 26))
|
||||
|
||||
case ts.SyntaxKind.DoStatement:
|
||||
>ts.SyntaxKind.DoStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.DoStatement, Decl(typescript.d.ts, 207, 26))
|
||||
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>DoStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.DoStatement, Decl(typescript.d.ts, 207, 26))
|
||||
|
||||
if ((<ts.IterationStatement>node).statement.kind !== ts.SyntaxKind.Block) {
|
||||
>(<ts.IterationStatement>node).statement.kind !== ts.SyntaxKind.Block : boolean
|
||||
>(<ts.IterationStatement>node).statement.kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
|
||||
>(<ts.IterationStatement>node).statement : ts.Statement, Symbol(ts.IterationStatement.statement, Decl(typescript.d.ts, 589, 52))
|
||||
>(<ts.IterationStatement>node) : ts.IterationStatement
|
||||
><ts.IterationStatement>node : ts.IterationStatement
|
||||
>ts : any, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>IterationStatement : ts.IterationStatement, Symbol(ts.IterationStatement, Decl(typescript.d.ts, 588, 5))
|
||||
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 16, 24))
|
||||
>statement : ts.Statement, Symbol(ts.IterationStatement.statement, Decl(typescript.d.ts, 589, 52))
|
||||
>kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
|
||||
>ts.SyntaxKind.Block : ts.SyntaxKind, Symbol(ts.SyntaxKind.Block, Decl(typescript.d.ts, 202, 36))
|
||||
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>Block : ts.SyntaxKind, Symbol(ts.SyntaxKind.Block, Decl(typescript.d.ts, 202, 36))
|
||||
|
||||
report(node, "A looping statement's contents should be wrapped in a block body.");
|
||||
>report(node, "A looping statement's contents should be wrapped in a block body.") : void
|
||||
>report : (node: ts.Node, message: string) => void, Symbol(report, Decl(APISample_linter.ts, 48, 5))
|
||||
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 16, 24))
|
||||
>"A looping statement's contents should be wrapped in a block body." : string
|
||||
}
|
||||
break;
|
||||
|
||||
case ts.SyntaxKind.IfStatement:
|
||||
>ts.SyntaxKind.IfStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.IfStatement, Decl(typescript.d.ts, 206, 34))
|
||||
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>IfStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.IfStatement, Decl(typescript.d.ts, 206, 34))
|
||||
|
||||
let ifStatement = (<ts.IfStatement>node);
|
||||
>ifStatement : ts.IfStatement, Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
|
||||
>(<ts.IfStatement>node) : ts.IfStatement
|
||||
><ts.IfStatement>node : ts.IfStatement
|
||||
>ts : any, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>IfStatement : ts.IfStatement, Symbol(ts.IfStatement, Decl(typescript.d.ts, 583, 5))
|
||||
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 16, 24))
|
||||
|
||||
if (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) {
|
||||
>ifStatement.thenStatement.kind !== ts.SyntaxKind.Block : boolean
|
||||
>ifStatement.thenStatement.kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
|
||||
>ifStatement.thenStatement : ts.Statement, Symbol(ts.IfStatement.thenStatement, Decl(typescript.d.ts, 585, 31))
|
||||
>ifStatement : ts.IfStatement, Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
|
||||
>thenStatement : ts.Statement, Symbol(ts.IfStatement.thenStatement, Decl(typescript.d.ts, 585, 31))
|
||||
>kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
|
||||
>ts.SyntaxKind.Block : ts.SyntaxKind, Symbol(ts.SyntaxKind.Block, Decl(typescript.d.ts, 202, 36))
|
||||
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>Block : ts.SyntaxKind, Symbol(ts.SyntaxKind.Block, Decl(typescript.d.ts, 202, 36))
|
||||
|
||||
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
|
||||
>report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.") : void
|
||||
>report : (node: ts.Node, message: string) => void, Symbol(report, Decl(APISample_linter.ts, 48, 5))
|
||||
>ifStatement.thenStatement : ts.Statement, Symbol(ts.IfStatement.thenStatement, Decl(typescript.d.ts, 585, 31))
|
||||
>ifStatement : ts.IfStatement, Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
|
||||
>thenStatement : ts.Statement, Symbol(ts.IfStatement.thenStatement, Decl(typescript.d.ts, 585, 31))
|
||||
>"An if statement's contents should be wrapped in a block body." : string
|
||||
}
|
||||
if (ifStatement.elseStatement &&
|
||||
>ifStatement.elseStatement && ifStatement.elseStatement.kind !== ts.SyntaxKind.Block && ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement : boolean
|
||||
>ifStatement.elseStatement && ifStatement.elseStatement.kind !== ts.SyntaxKind.Block : boolean
|
||||
>ifStatement.elseStatement : ts.Statement, Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
|
||||
>ifStatement : ts.IfStatement, Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
|
||||
>elseStatement : ts.Statement, Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
|
||||
|
||||
ifStatement.elseStatement.kind !== ts.SyntaxKind.Block &&
|
||||
>ifStatement.elseStatement.kind !== ts.SyntaxKind.Block : boolean
|
||||
>ifStatement.elseStatement.kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
|
||||
>ifStatement.elseStatement : ts.Statement, Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
|
||||
>ifStatement : ts.IfStatement, Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
|
||||
>elseStatement : ts.Statement, Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
|
||||
>kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
|
||||
>ts.SyntaxKind.Block : ts.SyntaxKind, Symbol(ts.SyntaxKind.Block, Decl(typescript.d.ts, 202, 36))
|
||||
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>Block : ts.SyntaxKind, Symbol(ts.SyntaxKind.Block, Decl(typescript.d.ts, 202, 36))
|
||||
|
||||
ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement) {
|
||||
>ifStatement.elseStatement.kind !== ts.SyntaxKind.IfStatement : boolean
|
||||
>ifStatement.elseStatement.kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
|
||||
>ifStatement.elseStatement : ts.Statement, Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
|
||||
>ifStatement : ts.IfStatement, Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
|
||||
>elseStatement : ts.Statement, Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
|
||||
>kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
|
||||
>ts.SyntaxKind.IfStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.IfStatement, Decl(typescript.d.ts, 206, 34))
|
||||
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>IfStatement : ts.SyntaxKind, Symbol(ts.SyntaxKind.IfStatement, Decl(typescript.d.ts, 206, 34))
|
||||
|
||||
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
|
||||
>report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.") : void
|
||||
>report : (node: ts.Node, message: string) => void, Symbol(report, Decl(APISample_linter.ts, 48, 5))
|
||||
>ifStatement.elseStatement : ts.Statement, Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
|
||||
>ifStatement : ts.IfStatement, Symbol(ifStatement, Decl(APISample_linter.ts, 28, 19))
|
||||
>elseStatement : ts.Statement, Symbol(ts.IfStatement.elseStatement, Decl(typescript.d.ts, 586, 33))
|
||||
>"An else statement's contents should be wrapped in a block body." : string
|
||||
}
|
||||
break;
|
||||
|
||||
case ts.SyntaxKind.BinaryExpression:
|
||||
>ts.SyntaxKind.BinaryExpression : ts.SyntaxKind, Symbol(ts.SyntaxKind.BinaryExpression, Decl(typescript.d.ts, 192, 37))
|
||||
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>BinaryExpression : ts.SyntaxKind, Symbol(ts.SyntaxKind.BinaryExpression, Decl(typescript.d.ts, 192, 37))
|
||||
|
||||
let op = (<ts.BinaryExpression>node).operatorToken.kind;
|
||||
>op : ts.SyntaxKind, Symbol(op, Decl(APISample_linter.ts, 40, 19))
|
||||
>(<ts.BinaryExpression>node).operatorToken.kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
|
||||
>(<ts.BinaryExpression>node).operatorToken : ts.Node, Symbol(ts.BinaryExpression.operatorToken, Decl(typescript.d.ts, 497, 25))
|
||||
>(<ts.BinaryExpression>node) : ts.BinaryExpression
|
||||
><ts.BinaryExpression>node : ts.BinaryExpression
|
||||
>ts : any, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>BinaryExpression : ts.BinaryExpression, Symbol(ts.BinaryExpression, Decl(typescript.d.ts, 495, 5))
|
||||
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 16, 24))
|
||||
>operatorToken : ts.Node, Symbol(ts.BinaryExpression.operatorToken, Decl(typescript.d.ts, 497, 25))
|
||||
>kind : ts.SyntaxKind, Symbol(ts.Node.kind, Decl(typescript.d.ts, 297, 38))
|
||||
|
||||
if (op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken) {
|
||||
>op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken : boolean
|
||||
>op === ts.SyntaxKind.EqualsEqualsToken : boolean
|
||||
>op : ts.SyntaxKind, Symbol(op, Decl(APISample_linter.ts, 40, 19))
|
||||
>ts.SyntaxKind.EqualsEqualsToken : ts.SyntaxKind, Symbol(ts.SyntaxKind.EqualsEqualsToken, Decl(typescript.d.ts, 51, 36))
|
||||
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>EqualsEqualsToken : ts.SyntaxKind, Symbol(ts.SyntaxKind.EqualsEqualsToken, Decl(typescript.d.ts, 51, 36))
|
||||
>op == ts.SyntaxKind.ExclamationEqualsToken : boolean
|
||||
>op : ts.SyntaxKind, Symbol(op, Decl(APISample_linter.ts, 40, 19))
|
||||
>ts.SyntaxKind.ExclamationEqualsToken : ts.SyntaxKind, Symbol(ts.SyntaxKind.ExclamationEqualsToken, Decl(typescript.d.ts, 52, 31))
|
||||
>ts.SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>SyntaxKind : typeof ts.SyntaxKind, Symbol(ts.SyntaxKind, Decl(typescript.d.ts, 22, 5))
|
||||
>ExclamationEqualsToken : ts.SyntaxKind, Symbol(ts.SyntaxKind.ExclamationEqualsToken, Decl(typescript.d.ts, 52, 31))
|
||||
|
||||
report(node, "Use '===' and '!=='.")
|
||||
>report(node, "Use '===' and '!=='.") : void
|
||||
>report : (node: ts.Node, message: string) => void, Symbol(report, Decl(APISample_linter.ts, 48, 5))
|
||||
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 16, 24))
|
||||
>"Use '===' and '!=='." : string
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
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 : 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))
|
||||
>node : ts.Node, Symbol(node, Decl(APISample_linter.ts, 16, 24))
|
||||
>delintNode : (node: ts.Node) => void, Symbol(delintNode, Decl(APISample_linter.ts, 14, 27))
|
||||
}
|
||||
|
||||
function report(node: ts.Node, message: string) {
|
||||
>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))
|
||||
>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, 1263, 46))
|
||||
>sourceFile : ts.SourceFile, Symbol(sourceFile, Decl(APISample_linter.ts, 13, 23))
|
||||
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter, Symbol(ts.SourceFile.getLineAndCharacterOfPosition, Decl(typescript.d.ts, 1263, 46))
|
||||
>node.getStart() : number
|
||||
>node.getStart : (sourceFile?: ts.SourceFile) => number, Symbol(ts.Node.getStart, Decl(typescript.d.ts, 1226, 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))
|
||||
|
||||
console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`);
|
||||
>console.log(`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}`) : any
|
||||
>console.log : any
|
||||
>console : any, Symbol(console, Decl(APISample_linter.ts, 8, 11))
|
||||
>log : any
|
||||
>`${sourceFile.fileName} (${line + 1},${character + 1}): ${message}` : string
|
||||
>sourceFile.fileName : string, Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29))
|
||||
>sourceFile : ts.SourceFile, Symbol(sourceFile, Decl(APISample_linter.ts, 13, 23))
|
||||
>fileName : string, Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29))
|
||||
>line + 1 : number
|
||||
>line : number, Symbol(line, Decl(APISample_linter.ts, 51, 13))
|
||||
>1 : number
|
||||
>character + 1 : number
|
||||
>character : number, Symbol(character, Decl(APISample_linter.ts, 51, 19))
|
||||
>1 : number
|
||||
>message : string, Symbol(message, Decl(APISample_linter.ts, 50, 34))
|
||||
}
|
||||
}
|
||||
|
||||
const fileNames = process.argv.slice(2);
|
||||
>fileNames : any, Symbol(fileNames, Decl(APISample_linter.ts, 56, 5))
|
||||
>process.argv.slice(2) : any
|
||||
>process.argv.slice : any
|
||||
>process.argv : any
|
||||
>process : any, Symbol(process, Decl(APISample_linter.ts, 7, 11))
|
||||
>argv : any
|
||||
>slice : any
|
||||
>2 : number
|
||||
|
||||
fileNames.forEach(fileName => {
|
||||
>fileNames.forEach(fileName => { // Parse a file let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); // delint it delint(sourceFile);}) : any
|
||||
>fileNames.forEach : any
|
||||
>fileNames : any, Symbol(fileNames, Decl(APISample_linter.ts, 56, 5))
|
||||
>forEach : any
|
||||
>fileName => { // Parse a file let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); // delint it delint(sourceFile);} : (fileName: any) => void
|
||||
>fileName : any, Symbol(fileName, Decl(APISample_linter.ts, 57, 18))
|
||||
|
||||
// Parse a file
|
||||
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 : 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))
|
||||
>fileName : any, Symbol(fileName, Decl(APISample_linter.ts, 57, 18))
|
||||
>readFileSync(fileName).toString() : any
|
||||
>readFileSync(fileName).toString : any
|
||||
>readFileSync(fileName) : any
|
||||
>readFileSync : any, Symbol(readFileSync, Decl(APISample_linter.ts, 9, 11))
|
||||
>fileName : any, Symbol(fileName, Decl(APISample_linter.ts, 57, 18))
|
||||
>toString : any
|
||||
>ts.ScriptTarget.ES6 : ts.ScriptTarget, Symbol(ts.ScriptTarget.ES6, Decl(typescript.d.ts, 1118, 16))
|
||||
>ts.ScriptTarget : typeof ts.ScriptTarget, Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1115, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_linter.ts, 11, 6))
|
||||
>ScriptTarget : typeof ts.ScriptTarget, Symbol(ts.ScriptTarget, Decl(typescript.d.ts, 1115, 5))
|
||||
>ES6 : ts.ScriptTarget, Symbol(ts.ScriptTarget.ES6, Decl(typescript.d.ts, 1118, 16))
|
||||
>true : boolean
|
||||
|
||||
// delint it
|
||||
delint(sourceFile);
|
||||
>delint(sourceFile) : void
|
||||
>delint : (sourceFile: ts.SourceFile) => void, Symbol(delint, Decl(APISample_linter.ts, 11, 33))
|
||||
>sourceFile : ts.SourceFile, Symbol(sourceFile, Decl(APISample_linter.ts, 59, 7))
|
||||
|
||||
});
|
||||
@@ -1,44 +0,0 @@
|
||||
=== tests/cases/compiler/APISample_transform.ts ===
|
||||
|
||||
/*
|
||||
* Note: This test is a public API sample. The sample sources can be found
|
||||
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-simple-transform-function
|
||||
* Please log a "breaking change" issue for any API breaking change affecting this issue
|
||||
*/
|
||||
|
||||
declare var console: any;
|
||||
>console : any, Symbol(console, Decl(APISample_transform.ts, 7, 11))
|
||||
|
||||
import * as ts from "typescript";
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_transform.ts, 9, 6))
|
||||
|
||||
const source = "let x: string = 'string'";
|
||||
>source : string, Symbol(source, Decl(APISample_transform.ts, 11, 5))
|
||||
>"let x: string = '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, 1729, 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, 1729, 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))
|
||||
>ts.ModuleKind.CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17))
|
||||
>ts.ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_transform.ts, 9, 6))
|
||||
>ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5))
|
||||
>CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17))
|
||||
|
||||
console.log(JSON.stringify(result));
|
||||
>console.log(JSON.stringify(result)) : any
|
||||
>console.log : any
|
||||
>console : any, Symbol(console, Decl(APISample_transform.ts, 7, 11))
|
||||
>log : any
|
||||
>JSON.stringify(result) : string
|
||||
>JSON.stringify : { (value: any): string; (value: any, replacer: (key: string, value: any) => any): string; (value: any, replacer: any[]): string; (value: any, replacer: (key: string, value: any) => any, space: any): string; (value: any, replacer: any[], space: any): string; }, Symbol(JSON.stringify, Decl(lib.d.ts, 964, 70), Decl(lib.d.ts, 969, 34), Decl(lib.d.ts, 975, 78), Decl(lib.d.ts, 981, 51), Decl(lib.d.ts, 988, 90))
|
||||
>JSON : JSON, Symbol(JSON, Decl(lib.d.ts, 955, 42), Decl(lib.d.ts, 1000, 11))
|
||||
>stringify : { (value: any): string; (value: any, replacer: (key: string, value: any) => any): string; (value: any, replacer: any[]): string; (value: any, replacer: (key: string, value: any) => any, space: any): string; (value: any, replacer: any[], space: any): string; }, Symbol(JSON.stringify, Decl(lib.d.ts, 964, 70), Decl(lib.d.ts, 969, 34), Decl(lib.d.ts, 975, 78), Decl(lib.d.ts, 981, 51), Decl(lib.d.ts, 988, 90))
|
||||
>result : string, Symbol(result, Decl(APISample_transform.ts, 13, 3))
|
||||
|
||||
@@ -1,443 +0,0 @@
|
||||
=== tests/cases/compiler/APISample_watcher.ts ===
|
||||
|
||||
/*
|
||||
* Note: This test is a public API sample. The sample sources can be found
|
||||
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#incremental-build-support-using-the-language-services
|
||||
* Please log a "breaking change" issue for any API breaking change affecting this issue
|
||||
*/
|
||||
|
||||
declare var process: any;
|
||||
>process : any, Symbol(process, Decl(APISample_watcher.ts, 7, 11))
|
||||
|
||||
declare var console: any;
|
||||
>console : any, Symbol(console, Decl(APISample_watcher.ts, 8, 11))
|
||||
|
||||
declare var fs: any;
|
||||
>fs : any, Symbol(fs, Decl(APISample_watcher.ts, 9, 11))
|
||||
|
||||
declare var path: any;
|
||||
>path : any, Symbol(path, Decl(APISample_watcher.ts, 10, 11))
|
||||
|
||||
import * as ts from "typescript";
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
|
||||
|
||||
function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
>watch : (rootFileNames: string[], options: ts.CompilerOptions) => void, Symbol(watch, Decl(APISample_watcher.ts, 12, 33))
|
||||
>rootFileNames : string[], Symbol(rootFileNames, Decl(APISample_watcher.ts, 14, 15))
|
||||
>options : ts.CompilerOptions, Symbol(options, Decl(APISample_watcher.ts, 14, 39))
|
||||
>ts : any, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
|
||||
>CompilerOptions : ts.CompilerOptions, Symbol(ts.CompilerOptions, Decl(typescript.d.ts, 1074, 5))
|
||||
|
||||
const files: ts.Map<{ version: number }> = {};
|
||||
>files : ts.Map<{ version: number; }>, Symbol(files, Decl(APISample_watcher.ts, 15, 9))
|
||||
>ts : any, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
|
||||
>Map : ts.Map<T>, Symbol(ts.Map, Decl(typescript.d.ts, 15, 29))
|
||||
>version : number, Symbol(version, Decl(APISample_watcher.ts, 15, 25))
|
||||
>{} : { [x: string]: undefined; }
|
||||
|
||||
// initialize the list of files
|
||||
rootFileNames.forEach(fileName => {
|
||||
>rootFileNames.forEach(fileName => { files[fileName] = { version: 0 }; }) : void
|
||||
>rootFileNames.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
|
||||
>rootFileNames : string[], Symbol(rootFileNames, Decl(APISample_watcher.ts, 14, 15))
|
||||
>forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
|
||||
>fileName => { files[fileName] = { version: 0 }; } : (fileName: string) => void
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 18, 26))
|
||||
|
||||
files[fileName] = { version: 0 };
|
||||
>files[fileName] = { version: 0 } : { version: number; }
|
||||
>files[fileName] : { version: number; }
|
||||
>files : ts.Map<{ version: number; }>, Symbol(files, Decl(APISample_watcher.ts, 15, 9))
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 18, 26))
|
||||
>{ version: 0 } : { version: number; }
|
||||
>version : number, Symbol(version, Decl(APISample_watcher.ts, 19, 27))
|
||||
>0 : number
|
||||
|
||||
});
|
||||
|
||||
// Create the language service host to allow the LS to communicate with the host
|
||||
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, 1295, 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,
|
||||
>getScriptFileNames : () => string[], Symbol(getScriptFileNames, Decl(APISample_watcher.ts, 23, 50))
|
||||
>() => rootFileNames : () => string[]
|
||||
>rootFileNames : string[], Symbol(rootFileNames, Decl(APISample_watcher.ts, 14, 15))
|
||||
|
||||
getScriptVersion: (fileName) => files[fileName] && files[fileName].version.toString(),
|
||||
>getScriptVersion : (fileName: string) => string, Symbol(getScriptVersion, Decl(APISample_watcher.ts, 24, 48))
|
||||
>(fileName) => files[fileName] && files[fileName].version.toString() : (fileName: string) => string
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 25, 27))
|
||||
>files[fileName] && files[fileName].version.toString() : string
|
||||
>files[fileName] : { version: number; }
|
||||
>files : ts.Map<{ version: number; }>, Symbol(files, Decl(APISample_watcher.ts, 15, 9))
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 25, 27))
|
||||
>files[fileName].version.toString() : string
|
||||
>files[fileName].version.toString : (radix?: number) => string, Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
|
||||
>files[fileName].version : number, Symbol(version, Decl(APISample_watcher.ts, 15, 25))
|
||||
>files[fileName] : { version: number; }
|
||||
>files : ts.Map<{ version: number; }>, Symbol(files, Decl(APISample_watcher.ts, 15, 9))
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 25, 27))
|
||||
>version : number, Symbol(version, Decl(APISample_watcher.ts, 15, 25))
|
||||
>toString : (radix?: number) => string, Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
|
||||
|
||||
getScriptSnapshot: (fileName) => {
|
||||
>getScriptSnapshot : (fileName: string) => ts.IScriptSnapshot, Symbol(getScriptSnapshot, Decl(APISample_watcher.ts, 25, 94))
|
||||
>(fileName) => { if (!fs.existsSync(fileName)) { return undefined; } return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString()); } : (fileName: string) => ts.IScriptSnapshot
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 26, 28))
|
||||
|
||||
if (!fs.existsSync(fileName)) {
|
||||
>!fs.existsSync(fileName) : boolean
|
||||
>fs.existsSync(fileName) : any
|
||||
>fs.existsSync : any
|
||||
>fs : any, Symbol(fs, Decl(APISample_watcher.ts, 9, 11))
|
||||
>existsSync : any
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 26, 28))
|
||||
|
||||
return undefined;
|
||||
>undefined : undefined, Symbol(undefined)
|
||||
}
|
||||
|
||||
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, 1288, 27))
|
||||
>ts.ScriptSnapshot : typeof ts.ScriptSnapshot, Symbol(ts.ScriptSnapshot, Decl(typescript.d.ts, 1287, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
|
||||
>ScriptSnapshot : typeof ts.ScriptSnapshot, Symbol(ts.ScriptSnapshot, Decl(typescript.d.ts, 1287, 5))
|
||||
>fromString : (text: string) => ts.IScriptSnapshot, Symbol(ts.ScriptSnapshot.fromString, Decl(typescript.d.ts, 1288, 27))
|
||||
>fs.readFileSync(fileName).toString() : any
|
||||
>fs.readFileSync(fileName).toString : any
|
||||
>fs.readFileSync(fileName) : any
|
||||
>fs.readFileSync : any
|
||||
>fs : any, Symbol(fs, Decl(APISample_watcher.ts, 9, 11))
|
||||
>readFileSync : any
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 26, 28))
|
||||
>toString : any
|
||||
|
||||
},
|
||||
getCurrentDirectory: () => process.cwd(),
|
||||
>getCurrentDirectory : () => any, Symbol(getCurrentDirectory, Decl(APISample_watcher.ts, 32, 10))
|
||||
>() => process.cwd() : () => any
|
||||
>process.cwd() : any
|
||||
>process.cwd : any
|
||||
>process : any, Symbol(process, Decl(APISample_watcher.ts, 7, 11))
|
||||
>cwd : any
|
||||
|
||||
getCompilationSettings: () => options,
|
||||
>getCompilationSettings : () => ts.CompilerOptions, Symbol(getCompilationSettings, Decl(APISample_watcher.ts, 33, 49))
|
||||
>() => options : () => ts.CompilerOptions
|
||||
>options : ts.CompilerOptions, Symbol(options, Decl(APISample_watcher.ts, 14, 39))
|
||||
|
||||
getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options),
|
||||
>getDefaultLibFileName : (options: ts.CompilerOptions) => string, Symbol(getDefaultLibFileName, Decl(APISample_watcher.ts, 34, 46))
|
||||
>(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, 1737, 44))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
|
||||
>getDefaultLibFilePath : (options: ts.CompilerOptions) => string, Symbol(ts.getDefaultLibFilePath, Decl(typescript.d.ts, 1737, 44))
|
||||
>options : ts.CompilerOptions, Symbol(options, Decl(APISample_watcher.ts, 35, 32))
|
||||
|
||||
};
|
||||
|
||||
// Create the language service files
|
||||
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, 1735, 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, 1735, 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, 1733, 193))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
|
||||
>createDocumentRegistry : () => ts.DocumentRegistry, Symbol(ts.createDocumentRegistry, Decl(typescript.d.ts, 1733, 193))
|
||||
|
||||
// Now let's watch the files
|
||||
rootFileNames.forEach(fileName => {
|
||||
>rootFileNames.forEach(fileName => { // First time around, emit all files emitFile(fileName); // Add a watch on the file to handle next change fs.watchFile(fileName, { persistent: true, interval: 250 }, (curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[fileName].version++; // write the changes to disk emitFile(fileName); }); }) : void
|
||||
>rootFileNames.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
|
||||
>rootFileNames : string[], Symbol(rootFileNames, Decl(APISample_watcher.ts, 14, 15))
|
||||
>forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
|
||||
>fileName => { // First time around, emit all files emitFile(fileName); // Add a watch on the file to handle next change fs.watchFile(fileName, { persistent: true, interval: 250 }, (curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[fileName].version++; // write the changes to disk emitFile(fileName); }); } : (fileName: string) => void
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 42, 26))
|
||||
|
||||
// First time around, emit all files
|
||||
emitFile(fileName);
|
||||
>emitFile(fileName) : void
|
||||
>emitFile : (fileName: string) => void, Symbol(emitFile, Decl(APISample_watcher.ts, 61, 7))
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 42, 26))
|
||||
|
||||
// Add a watch on the file to handle next change
|
||||
fs.watchFile(fileName,
|
||||
>fs.watchFile(fileName, { persistent: true, interval: 250 }, (curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[fileName].version++; // write the changes to disk emitFile(fileName); }) : any
|
||||
>fs.watchFile : any
|
||||
>fs : any, Symbol(fs, Decl(APISample_watcher.ts, 9, 11))
|
||||
>watchFile : any
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 42, 26))
|
||||
|
||||
{ persistent: true, interval: 250 },
|
||||
>{ persistent: true, interval: 250 } : { persistent: boolean; interval: number; }
|
||||
>persistent : boolean, Symbol(persistent, Decl(APISample_watcher.ts, 48, 13))
|
||||
>true : boolean
|
||||
>interval : number, Symbol(interval, Decl(APISample_watcher.ts, 48, 31))
|
||||
>250 : number
|
||||
|
||||
(curr, prev) => {
|
||||
>(curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[fileName].version++; // write the changes to disk emitFile(fileName); } : (curr: any, prev: any) => void
|
||||
>curr : any, Symbol(curr, Decl(APISample_watcher.ts, 49, 13))
|
||||
>prev : any, Symbol(prev, Decl(APISample_watcher.ts, 49, 18))
|
||||
|
||||
// Check timestamp
|
||||
if (+curr.mtime <= +prev.mtime) {
|
||||
>+curr.mtime <= +prev.mtime : boolean
|
||||
>+curr.mtime : number
|
||||
>curr.mtime : any
|
||||
>curr : any, Symbol(curr, Decl(APISample_watcher.ts, 49, 13))
|
||||
>mtime : any
|
||||
>+prev.mtime : number
|
||||
>prev.mtime : any
|
||||
>prev : any, Symbol(prev, Decl(APISample_watcher.ts, 49, 18))
|
||||
>mtime : any
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the version to signal a change in the file
|
||||
files[fileName].version++;
|
||||
>files[fileName].version++ : number
|
||||
>files[fileName].version : number, Symbol(version, Decl(APISample_watcher.ts, 15, 25))
|
||||
>files[fileName] : { version: number; }
|
||||
>files : ts.Map<{ version: number; }>, Symbol(files, Decl(APISample_watcher.ts, 15, 9))
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 42, 26))
|
||||
>version : number, Symbol(version, Decl(APISample_watcher.ts, 15, 25))
|
||||
|
||||
// write the changes to disk
|
||||
emitFile(fileName);
|
||||
>emitFile(fileName) : void
|
||||
>emitFile : (fileName: string) => void, Symbol(emitFile, Decl(APISample_watcher.ts, 61, 7))
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 42, 26))
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
function emitFile(fileName: string) {
|
||||
>emitFile : (fileName: string) => void, Symbol(emitFile, Decl(APISample_watcher.ts, 61, 7))
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 63, 22))
|
||||
|
||||
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, 1339, 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, 1339, 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, 1542, 34))
|
||||
>output : ts.EmitOutput, Symbol(output, Decl(APISample_watcher.ts, 64, 11))
|
||||
>emitSkipped : boolean, Symbol(ts.EmitOutput.emitSkipped, Decl(typescript.d.ts, 1542, 34))
|
||||
|
||||
console.log(`Emitting ${fileName}`);
|
||||
>console.log(`Emitting ${fileName}`) : any
|
||||
>console.log : any
|
||||
>console : any, Symbol(console, Decl(APISample_watcher.ts, 8, 11))
|
||||
>log : any
|
||||
>`Emitting ${fileName}` : string
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 63, 22))
|
||||
}
|
||||
else {
|
||||
console.log(`Emitting ${fileName} failed`);
|
||||
>console.log(`Emitting ${fileName} failed`) : any
|
||||
>console.log : any
|
||||
>console : any, Symbol(console, Decl(APISample_watcher.ts, 8, 11))
|
||||
>log : any
|
||||
>`Emitting ${fileName} failed` : string
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 63, 22))
|
||||
|
||||
logErrors(fileName);
|
||||
>logErrors(fileName) : void
|
||||
>logErrors : (fileName: string) => void, Symbol(logErrors, Decl(APISample_watcher.ts, 77, 5))
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 63, 22))
|
||||
}
|
||||
|
||||
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, 1541, 26))
|
||||
>output : ts.EmitOutput, Symbol(output, Decl(APISample_watcher.ts, 64, 11))
|
||||
>outputFiles : ts.OutputFile[], Symbol(ts.EmitOutput.outputFiles, Decl(typescript.d.ts, 1541, 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))
|
||||
|
||||
fs.writeFileSync(o.name, o.text, "utf8");
|
||||
>fs.writeFileSync(o.name, o.text, "utf8") : any
|
||||
>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, 1550, 26))
|
||||
>o : ts.OutputFile, Symbol(o, Decl(APISample_watcher.ts, 74, 35))
|
||||
>name : string, Symbol(ts.OutputFile.name, Decl(typescript.d.ts, 1550, 26))
|
||||
>o.text : string, Symbol(ts.OutputFile.text, Decl(typescript.d.ts, 1552, 36))
|
||||
>o : ts.OutputFile, Symbol(o, Decl(APISample_watcher.ts, 74, 35))
|
||||
>text : string, Symbol(ts.OutputFile.text, Decl(typescript.d.ts, 1552, 36))
|
||||
>"utf8" : string
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function logErrors(fileName: string) {
|
||||
>logErrors : (fileName: string) => void, Symbol(logErrors, Decl(APISample_watcher.ts, 77, 5))
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 79, 23))
|
||||
|
||||
let allDiagnostics = services.getCompilerOptionsDiagnostics()
|
||||
>allDiagnostics : ts.Diagnostic[], Symbol(allDiagnostics, Decl(APISample_watcher.ts, 80, 11))
|
||||
>services.getCompilerOptionsDiagnostics() .concat(services.getSyntacticDiagnostics(fileName)) .concat(services.getSemanticDiagnostics(fileName)) : ts.Diagnostic[]
|
||||
>services.getCompilerOptionsDiagnostics() .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.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, 1313, 63))
|
||||
>services : ts.LanguageService, Symbol(services, Decl(APISample_watcher.ts, 39, 9))
|
||||
>getCompilerOptionsDiagnostics : () => ts.Diagnostic[], Symbol(ts.LanguageService.getCompilerOptionsDiagnostics, Decl(typescript.d.ts, 1313, 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, 1311, 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, 1311, 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, 1312, 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, 1312, 64))
|
||||
>fileName : string, Symbol(fileName, Decl(APISample_watcher.ts, 79, 23))
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
>allDiagnostics.forEach(diagnostic => { let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"); if (diagnostic.file) { let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); } else { console.log(` Error: ${message}`); } }) : void
|
||||
>allDiagnostics.forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
|
||||
>allDiagnostics : ts.Diagnostic[], Symbol(allDiagnostics, Decl(APISample_watcher.ts, 80, 11))
|
||||
>forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void, Symbol(Array.forEach, Decl(lib.d.ts, 1108, 95))
|
||||
>diagnostic => { let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"); if (diagnostic.file) { let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); } else { console.log(` Error: ${message}`); } } : (diagnostic: ts.Diagnostic) => void
|
||||
>diagnostic : ts.Diagnostic, Symbol(diagnostic, Decl(APISample_watcher.ts, 84, 31))
|
||||
|
||||
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 : 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))
|
||||
>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))
|
||||
>"\n" : string
|
||||
|
||||
if (diagnostic.file) {
|
||||
>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))
|
||||
|
||||
let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
>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, 1263, 46))
|
||||
>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, 1263, 46))
|
||||
>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))
|
||||
|
||||
console.log(` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
|
||||
>console.log(` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`) : any
|
||||
>console.log : any
|
||||
>console : any, Symbol(console, Decl(APISample_watcher.ts, 8, 11))
|
||||
>log : any
|
||||
>` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}` : string
|
||||
>diagnostic.file.fileName : string, Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29))
|
||||
>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))
|
||||
>fileName : string, Symbol(ts.SourceFile.fileName, Decl(typescript.d.ts, 743, 29))
|
||||
>line + 1 : number
|
||||
>line : number, Symbol(line, Decl(APISample_watcher.ts, 87, 21))
|
||||
>1 : number
|
||||
>character + 1 : number
|
||||
>character : number, Symbol(character, Decl(APISample_watcher.ts, 87, 27))
|
||||
>1 : number
|
||||
>message : string, Symbol(message, Decl(APISample_watcher.ts, 85, 15))
|
||||
}
|
||||
else {
|
||||
console.log(` Error: ${message}`);
|
||||
>console.log(` Error: ${message}`) : any
|
||||
>console.log : any
|
||||
>console : any, Symbol(console, Decl(APISample_watcher.ts, 8, 11))
|
||||
>log : any
|
||||
>` Error: ${message}` : string
|
||||
>message : string, Symbol(message, Decl(APISample_watcher.ts, 85, 15))
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize files constituting the program as all .ts files in the current directory
|
||||
const currentDirectoryFiles = fs.readdirSync(process.cwd()).
|
||||
>currentDirectoryFiles : any, Symbol(currentDirectoryFiles, Decl(APISample_watcher.ts, 98, 5))
|
||||
>fs.readdirSync(process.cwd()). filter(fileName=> fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts") : any
|
||||
>fs.readdirSync(process.cwd()). filter : any
|
||||
>fs.readdirSync(process.cwd()) : any
|
||||
>fs.readdirSync : any
|
||||
>fs : any, Symbol(fs, Decl(APISample_watcher.ts, 9, 11))
|
||||
>readdirSync : any
|
||||
>process.cwd() : any
|
||||
>process.cwd : any
|
||||
>process : any, Symbol(process, Decl(APISample_watcher.ts, 7, 11))
|
||||
>cwd : any
|
||||
|
||||
filter(fileName=> fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts");
|
||||
>filter : any
|
||||
>fileName=> fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts" : (fileName: any) => boolean
|
||||
>fileName : any, Symbol(fileName, Decl(APISample_watcher.ts, 99, 11))
|
||||
>fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts" : boolean
|
||||
>fileName.length >= 3 : boolean
|
||||
>fileName.length : any
|
||||
>fileName : any, Symbol(fileName, Decl(APISample_watcher.ts, 99, 11))
|
||||
>length : any
|
||||
>3 : number
|
||||
>fileName.substr(fileName.length - 3, 3) === ".ts" : boolean
|
||||
>fileName.substr(fileName.length - 3, 3) : any
|
||||
>fileName.substr : any
|
||||
>fileName : any, Symbol(fileName, Decl(APISample_watcher.ts, 99, 11))
|
||||
>substr : any
|
||||
>fileName.length - 3 : number
|
||||
>fileName.length : any
|
||||
>fileName : any, Symbol(fileName, Decl(APISample_watcher.ts, 99, 11))
|
||||
>length : any
|
||||
>3 : number
|
||||
>3 : number
|
||||
>".ts" : string
|
||||
|
||||
// Start the watcher
|
||||
watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS });
|
||||
>watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS }) : void
|
||||
>watch : (rootFileNames: string[], options: ts.CompilerOptions) => void, Symbol(watch, Decl(APISample_watcher.ts, 12, 33))
|
||||
>currentDirectoryFiles : any, Symbol(currentDirectoryFiles, Decl(APISample_watcher.ts, 98, 5))
|
||||
>{ module: ts.ModuleKind.CommonJS } : { [x: string]: ts.ModuleKind; module: ts.ModuleKind; }
|
||||
>module : ts.ModuleKind, Symbol(module, Decl(APISample_watcher.ts, 102, 30))
|
||||
>ts.ModuleKind.CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17))
|
||||
>ts.ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5))
|
||||
>ts : typeof ts, Symbol(ts, Decl(APISample_watcher.ts, 12, 6))
|
||||
>ModuleKind : typeof ts.ModuleKind, Symbol(ts.ModuleKind, Decl(typescript.d.ts, 1106, 5))
|
||||
>CommonJS : ts.ModuleKind, Symbol(ts.ModuleKind.CommonJS, Decl(typescript.d.ts, 1108, 17))
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
|
||||
declare module Point {
|
||||
>Point : Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.d.ts, 0, 0))
|
||||
|
||||
export var Origin: { x: number; y: number; }
|
||||
>Origin : Symbol(Origin, Decl(module.d.ts, 1, 14))
|
||||
>x : Symbol(x, Decl(module.d.ts, 1, 24))
|
||||
>y : Symbol(y, Decl(module.d.ts, 1, 35))
|
||||
}
|
||||
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/function.d.ts ===
|
||||
declare function Point(): { x: number; y: number; }
|
||||
>Point : Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.d.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(function.d.ts, 0, 27))
|
||||
>y : Symbol(y, Decl(function.d.ts, 0, 38))
|
||||
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
|
||||
var cl: { x: number; y: number; }
|
||||
>cl : Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>x : Symbol(x, Decl(test.ts, 0, 9))
|
||||
>y : Symbol(y, Decl(test.ts, 0, 20))
|
||||
|
||||
var cl = Point();
|
||||
>cl : Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>Point : Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.d.ts, 0, 0))
|
||||
|
||||
var cl = Point.Origin;
|
||||
>cl : Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>Point.Origin : Symbol(Point.Origin, Decl(module.d.ts, 1, 14))
|
||||
>Point : Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.d.ts, 0, 0))
|
||||
>Origin : Symbol(Point.Origin, Decl(module.d.ts, 1, 14))
|
||||
|
||||
+16
-16
@@ -1,33 +1,33 @@
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
|
||||
declare module Point {
|
||||
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.d.ts, 0, 0))
|
||||
>Point : typeof Point
|
||||
|
||||
export var Origin: { x: number; y: number; }
|
||||
>Origin : { x: number; y: number; }, Symbol(Origin, Decl(module.d.ts, 1, 14))
|
||||
>x : number, Symbol(x, Decl(module.d.ts, 1, 24))
|
||||
>y : number, Symbol(y, Decl(module.d.ts, 1, 35))
|
||||
>Origin : { x: number; y: number; }
|
||||
>x : number
|
||||
>y : number
|
||||
}
|
||||
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/function.d.ts ===
|
||||
declare function Point(): { x: number; y: number; }
|
||||
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.d.ts, 0, 0))
|
||||
>x : number, Symbol(x, Decl(function.d.ts, 0, 27))
|
||||
>y : number, Symbol(y, Decl(function.d.ts, 0, 38))
|
||||
>Point : typeof Point
|
||||
>x : number
|
||||
>y : number
|
||||
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
|
||||
var cl: { x: number; y: number; }
|
||||
>cl : { x: number; y: number; }, Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>x : number, Symbol(x, Decl(test.ts, 0, 9))
|
||||
>y : number, Symbol(y, Decl(test.ts, 0, 20))
|
||||
>cl : { x: number; y: number; }
|
||||
>x : number
|
||||
>y : number
|
||||
|
||||
var cl = Point();
|
||||
>cl : { x: number; y: number; }, Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>cl : { x: number; y: number; }
|
||||
>Point() : { x: number; y: number; }
|
||||
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.d.ts, 0, 0))
|
||||
>Point : typeof Point
|
||||
|
||||
var cl = Point.Origin;
|
||||
>cl : { x: number; y: number; }, Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>Point.Origin : { x: number; y: number; }, Symbol(Point.Origin, Decl(module.d.ts, 1, 14))
|
||||
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.d.ts, 0, 0))
|
||||
>Origin : { x: number; y: number; }, Symbol(Point.Origin, Decl(module.d.ts, 1, 14))
|
||||
>cl : { x: number; y: number; }
|
||||
>Point.Origin : { x: number; y: number; }
|
||||
>Point : typeof Point
|
||||
>Origin : { x: number; y: number; }
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
|
||||
declare module A {
|
||||
>A : Symbol(A, Decl(module.d.ts, 0, 0), Decl(class.d.ts, 0, 0))
|
||||
|
||||
export module Point {
|
||||
>Point : Symbol(Point, Decl(module.d.ts, 0, 18), Decl(class.d.ts, 0, 18))
|
||||
|
||||
export var Origin: {
|
||||
>Origin : Symbol(Origin, Decl(module.d.ts, 2, 18))
|
||||
|
||||
x: number;
|
||||
>x : Symbol(x, Decl(module.d.ts, 2, 28))
|
||||
|
||||
y: number;
|
||||
>y : Symbol(y, Decl(module.d.ts, 3, 22))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/class.d.ts ===
|
||||
declare module A {
|
||||
>A : Symbol(A, Decl(module.d.ts, 0, 0), Decl(class.d.ts, 0, 0))
|
||||
|
||||
export class Point {
|
||||
>Point : Symbol(Point, Decl(module.d.ts, 0, 18), Decl(class.d.ts, 0, 18))
|
||||
|
||||
constructor(x: number, y: number);
|
||||
>x : Symbol(x, Decl(class.d.ts, 2, 20))
|
||||
>y : Symbol(y, Decl(class.d.ts, 2, 30))
|
||||
|
||||
x: number;
|
||||
>x : Symbol(x, Decl(class.d.ts, 2, 42))
|
||||
|
||||
y: number;
|
||||
>y : Symbol(y, Decl(class.d.ts, 3, 18))
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
|
||||
var p: { x: number; y: number; }
|
||||
>p : Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>x : Symbol(x, Decl(test.ts, 0, 8))
|
||||
>y : Symbol(y, Decl(test.ts, 0, 19))
|
||||
|
||||
var p = A.Point.Origin;
|
||||
>p : Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>A.Point.Origin : Symbol(A.Point.Origin, Decl(module.d.ts, 2, 18))
|
||||
>A.Point : Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(class.d.ts, 0, 18))
|
||||
>A : Symbol(A, Decl(module.d.ts, 0, 0), Decl(class.d.ts, 0, 0))
|
||||
>Point : Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(class.d.ts, 0, 18))
|
||||
>Origin : Symbol(A.Point.Origin, Decl(module.d.ts, 2, 18))
|
||||
|
||||
var p = new A.Point(0, 0); // unexpected error here, bug 840000
|
||||
>p : Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>A.Point : Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(class.d.ts, 0, 18))
|
||||
>A : Symbol(A, Decl(module.d.ts, 0, 0), Decl(class.d.ts, 0, 0))
|
||||
>Point : Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(class.d.ts, 0, 18))
|
||||
|
||||
@@ -1,61 +1,61 @@
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
|
||||
declare module A {
|
||||
>A : typeof A, Symbol(A, Decl(module.d.ts, 0, 0), Decl(class.d.ts, 0, 0))
|
||||
>A : typeof A
|
||||
|
||||
export module Point {
|
||||
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 18), Decl(class.d.ts, 0, 18))
|
||||
>Point : typeof Point
|
||||
|
||||
export var Origin: {
|
||||
>Origin : { x: number; y: number; }, Symbol(Origin, Decl(module.d.ts, 2, 18))
|
||||
>Origin : { x: number; y: number; }
|
||||
|
||||
x: number;
|
||||
>x : number, Symbol(x, Decl(module.d.ts, 2, 28))
|
||||
>x : number
|
||||
|
||||
y: number;
|
||||
>y : number, Symbol(y, Decl(module.d.ts, 3, 22))
|
||||
>y : number
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/class.d.ts ===
|
||||
declare module A {
|
||||
>A : typeof A, Symbol(A, Decl(module.d.ts, 0, 0), Decl(class.d.ts, 0, 0))
|
||||
>A : typeof A
|
||||
|
||||
export class Point {
|
||||
>Point : Point, Symbol(Point, Decl(module.d.ts, 0, 18), Decl(class.d.ts, 0, 18))
|
||||
>Point : Point
|
||||
|
||||
constructor(x: number, y: number);
|
||||
>x : number, Symbol(x, Decl(class.d.ts, 2, 20))
|
||||
>y : number, Symbol(y, Decl(class.d.ts, 2, 30))
|
||||
>x : number
|
||||
>y : number
|
||||
|
||||
x: number;
|
||||
>x : number, Symbol(x, Decl(class.d.ts, 2, 42))
|
||||
>x : number
|
||||
|
||||
y: number;
|
||||
>y : number, Symbol(y, Decl(class.d.ts, 3, 18))
|
||||
>y : number
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
|
||||
var p: { x: number; y: number; }
|
||||
>p : { x: number; y: number; }, Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>x : number, Symbol(x, Decl(test.ts, 0, 8))
|
||||
>y : number, Symbol(y, Decl(test.ts, 0, 19))
|
||||
>p : { x: number; y: number; }
|
||||
>x : number
|
||||
>y : number
|
||||
|
||||
var p = A.Point.Origin;
|
||||
>p : { x: number; y: number; }, Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>A.Point.Origin : { x: number; y: number; }, Symbol(A.Point.Origin, Decl(module.d.ts, 2, 18))
|
||||
>A.Point : typeof A.Point, Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(class.d.ts, 0, 18))
|
||||
>A : typeof A, Symbol(A, Decl(module.d.ts, 0, 0), Decl(class.d.ts, 0, 0))
|
||||
>Point : typeof A.Point, Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(class.d.ts, 0, 18))
|
||||
>Origin : { x: number; y: number; }, Symbol(A.Point.Origin, Decl(module.d.ts, 2, 18))
|
||||
>p : { x: number; y: number; }
|
||||
>A.Point.Origin : { x: number; y: number; }
|
||||
>A.Point : typeof A.Point
|
||||
>A : typeof A
|
||||
>Point : typeof A.Point
|
||||
>Origin : { x: number; y: number; }
|
||||
|
||||
var p = new A.Point(0, 0); // unexpected error here, bug 840000
|
||||
>p : { x: number; y: number; }, Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>p : { x: number; y: number; }
|
||||
>new A.Point(0, 0) : A.Point
|
||||
>A.Point : typeof A.Point, Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(class.d.ts, 0, 18))
|
||||
>A : typeof A, Symbol(A, Decl(module.d.ts, 0, 0), Decl(class.d.ts, 0, 0))
|
||||
>Point : typeof A.Point, Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(class.d.ts, 0, 18))
|
||||
>A.Point : typeof A.Point
|
||||
>A : typeof A
|
||||
>Point : typeof A.Point
|
||||
>0 : number
|
||||
>0 : number
|
||||
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
|
||||
declare module A {
|
||||
>A : Symbol(A, Decl(module.d.ts, 0, 0), Decl(classPoint.ts, 0, 0))
|
||||
|
||||
export module Point {
|
||||
>Point : Symbol(Point, Decl(module.d.ts, 0, 18), Decl(classPoint.ts, 0, 10))
|
||||
|
||||
export var Origin: {
|
||||
>Origin : Symbol(Origin, Decl(module.d.ts, 2, 18))
|
||||
|
||||
x: number;
|
||||
>x : Symbol(x, Decl(module.d.ts, 2, 28))
|
||||
|
||||
y: number;
|
||||
>y : Symbol(y, Decl(module.d.ts, 3, 22))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/classPoint.ts ===
|
||||
module A {
|
||||
>A : Symbol(A, Decl(module.d.ts, 0, 0), Decl(classPoint.ts, 0, 0))
|
||||
|
||||
export class Point {
|
||||
>Point : Symbol(Point, Decl(module.d.ts, 0, 18), Decl(classPoint.ts, 0, 10))
|
||||
|
||||
constructor(public x: number, public y: number) { }
|
||||
>x : Symbol(x, Decl(classPoint.ts, 2, 20))
|
||||
>y : Symbol(y, Decl(classPoint.ts, 2, 37))
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
|
||||
var p: { x: number; y: number; }
|
||||
>p : Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>x : Symbol(x, Decl(test.ts, 0, 8))
|
||||
>y : Symbol(y, Decl(test.ts, 0, 19))
|
||||
|
||||
var p = A.Point.Origin;
|
||||
>p : Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>A.Point.Origin : Symbol(A.Point.Origin, Decl(module.d.ts, 2, 18))
|
||||
>A.Point : Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(classPoint.ts, 0, 10))
|
||||
>A : Symbol(A, Decl(module.d.ts, 0, 0), Decl(classPoint.ts, 0, 0))
|
||||
>Point : Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(classPoint.ts, 0, 10))
|
||||
>Origin : Symbol(A.Point.Origin, Decl(module.d.ts, 2, 18))
|
||||
|
||||
var p = new A.Point(0, 0); // unexpected error here, bug 840000
|
||||
>p : Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>A.Point : Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(classPoint.ts, 0, 10))
|
||||
>A : Symbol(A, Decl(module.d.ts, 0, 0), Decl(classPoint.ts, 0, 0))
|
||||
>Point : Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(classPoint.ts, 0, 10))
|
||||
|
||||
+22
-22
@@ -1,55 +1,55 @@
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
|
||||
declare module A {
|
||||
>A : typeof A, Symbol(A, Decl(module.d.ts, 0, 0), Decl(classPoint.ts, 0, 0))
|
||||
>A : typeof A
|
||||
|
||||
export module Point {
|
||||
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 18), Decl(classPoint.ts, 0, 10))
|
||||
>Point : typeof Point
|
||||
|
||||
export var Origin: {
|
||||
>Origin : { x: number; y: number; }, Symbol(Origin, Decl(module.d.ts, 2, 18))
|
||||
>Origin : { x: number; y: number; }
|
||||
|
||||
x: number;
|
||||
>x : number, Symbol(x, Decl(module.d.ts, 2, 28))
|
||||
>x : number
|
||||
|
||||
y: number;
|
||||
>y : number, Symbol(y, Decl(module.d.ts, 3, 22))
|
||||
>y : number
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/classPoint.ts ===
|
||||
module A {
|
||||
>A : typeof A, Symbol(A, Decl(module.d.ts, 0, 0), Decl(classPoint.ts, 0, 0))
|
||||
>A : typeof A
|
||||
|
||||
export class Point {
|
||||
>Point : Point, Symbol(Point, Decl(module.d.ts, 0, 18), Decl(classPoint.ts, 0, 10))
|
||||
>Point : Point
|
||||
|
||||
constructor(public x: number, public y: number) { }
|
||||
>x : number, Symbol(x, Decl(classPoint.ts, 2, 20))
|
||||
>y : number, Symbol(y, Decl(classPoint.ts, 2, 37))
|
||||
>x : number
|
||||
>y : number
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
|
||||
var p: { x: number; y: number; }
|
||||
>p : { x: number; y: number; }, Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>x : number, Symbol(x, Decl(test.ts, 0, 8))
|
||||
>y : number, Symbol(y, Decl(test.ts, 0, 19))
|
||||
>p : { x: number; y: number; }
|
||||
>x : number
|
||||
>y : number
|
||||
|
||||
var p = A.Point.Origin;
|
||||
>p : { x: number; y: number; }, Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>A.Point.Origin : { x: number; y: number; }, Symbol(A.Point.Origin, Decl(module.d.ts, 2, 18))
|
||||
>A.Point : typeof A.Point, Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(classPoint.ts, 0, 10))
|
||||
>A : typeof A, Symbol(A, Decl(module.d.ts, 0, 0), Decl(classPoint.ts, 0, 0))
|
||||
>Point : typeof A.Point, Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(classPoint.ts, 0, 10))
|
||||
>Origin : { x: number; y: number; }, Symbol(A.Point.Origin, Decl(module.d.ts, 2, 18))
|
||||
>p : { x: number; y: number; }
|
||||
>A.Point.Origin : { x: number; y: number; }
|
||||
>A.Point : typeof A.Point
|
||||
>A : typeof A
|
||||
>Point : typeof A.Point
|
||||
>Origin : { x: number; y: number; }
|
||||
|
||||
var p = new A.Point(0, 0); // unexpected error here, bug 840000
|
||||
>p : { x: number; y: number; }, Symbol(p, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>p : { x: number; y: number; }
|
||||
>new A.Point(0, 0) : A.Point
|
||||
>A.Point : typeof A.Point, Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(classPoint.ts, 0, 10))
|
||||
>A : typeof A, Symbol(A, Decl(module.d.ts, 0, 0), Decl(classPoint.ts, 0, 0))
|
||||
>Point : typeof A.Point, Symbol(A.Point, Decl(module.d.ts, 0, 18), Decl(classPoint.ts, 0, 10))
|
||||
>A.Point : typeof A.Point
|
||||
>A : typeof A
|
||||
>Point : typeof A.Point
|
||||
>0 : number
|
||||
>0 : number
|
||||
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
|
||||
declare module Point {
|
||||
>Point : Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.ts, 0, 0))
|
||||
|
||||
export var Origin: { x: number; y: number; }
|
||||
>Origin : Symbol(Origin, Decl(module.d.ts, 1, 14))
|
||||
>x : Symbol(x, Decl(module.d.ts, 1, 24))
|
||||
>y : Symbol(y, Decl(module.d.ts, 1, 35))
|
||||
}
|
||||
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/function.ts ===
|
||||
function Point() {
|
||||
>Point : Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.ts, 0, 0))
|
||||
|
||||
return { x: 0, y: 0 };
|
||||
>x : Symbol(x, Decl(function.ts, 1, 12))
|
||||
>y : Symbol(y, Decl(function.ts, 1, 18))
|
||||
}
|
||||
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
|
||||
var cl: { x: number; y: number; }
|
||||
>cl : Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>x : Symbol(x, Decl(test.ts, 0, 9))
|
||||
>y : Symbol(y, Decl(test.ts, 0, 20))
|
||||
|
||||
var cl = Point();
|
||||
>cl : Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>Point : Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.ts, 0, 0))
|
||||
|
||||
var cl = Point.Origin;
|
||||
>cl : Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>Point.Origin : Symbol(Point.Origin, Decl(module.d.ts, 1, 14))
|
||||
>Point : Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.ts, 0, 0))
|
||||
>Origin : Symbol(Point.Origin, Decl(module.d.ts, 1, 14))
|
||||
|
||||
+16
-16
@@ -1,39 +1,39 @@
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/module.d.ts ===
|
||||
declare module Point {
|
||||
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.ts, 0, 0))
|
||||
>Point : typeof Point
|
||||
|
||||
export var Origin: { x: number; y: number; }
|
||||
>Origin : { x: number; y: number; }, Symbol(Origin, Decl(module.d.ts, 1, 14))
|
||||
>x : number, Symbol(x, Decl(module.d.ts, 1, 24))
|
||||
>y : number, Symbol(y, Decl(module.d.ts, 1, 35))
|
||||
>Origin : { x: number; y: number; }
|
||||
>x : number
|
||||
>y : number
|
||||
}
|
||||
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/function.ts ===
|
||||
function Point() {
|
||||
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.ts, 0, 0))
|
||||
>Point : typeof Point
|
||||
|
||||
return { x: 0, y: 0 };
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number, Symbol(x, Decl(function.ts, 1, 12))
|
||||
>x : number
|
||||
>0 : number
|
||||
>y : number, Symbol(y, Decl(function.ts, 1, 18))
|
||||
>y : number
|
||||
>0 : number
|
||||
}
|
||||
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
|
||||
var cl: { x: number; y: number; }
|
||||
>cl : { x: number; y: number; }, Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>x : number, Symbol(x, Decl(test.ts, 0, 9))
|
||||
>y : number, Symbol(y, Decl(test.ts, 0, 20))
|
||||
>cl : { x: number; y: number; }
|
||||
>x : number
|
||||
>y : number
|
||||
|
||||
var cl = Point();
|
||||
>cl : { x: number; y: number; }, Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>cl : { x: number; y: number; }
|
||||
>Point() : { x: number; y: number; }
|
||||
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.ts, 0, 0))
|
||||
>Point : typeof Point
|
||||
|
||||
var cl = Point.Origin;
|
||||
>cl : { x: number; y: number; }, Symbol(cl, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(test.ts, 2, 3))
|
||||
>Point.Origin : { x: number; y: number; }, Symbol(Point.Origin, Decl(module.d.ts, 1, 14))
|
||||
>Point : typeof Point, Symbol(Point, Decl(module.d.ts, 0, 0), Decl(function.ts, 0, 0))
|
||||
>Origin : { x: number; y: number; }, Symbol(Point.Origin, Decl(module.d.ts, 1, 14))
|
||||
>cl : { x: number; y: number; }
|
||||
>Point.Origin : { x: number; y: number; }
|
||||
>Point : typeof Point
|
||||
>Origin : { x: number; y: number; }
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction4.ts ===
|
||||
var v = (a, b) => {
|
||||
>v : Symbol(v, Decl(ArrowFunction4.ts, 0, 3))
|
||||
>a : Symbol(a, Decl(ArrowFunction4.ts, 0, 9))
|
||||
>b : Symbol(b, Decl(ArrowFunction4.ts, 0, 11))
|
||||
|
||||
};
|
||||
@@ -1,8 +1,8 @@
|
||||
=== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction4.ts ===
|
||||
var v = (a, b) => {
|
||||
>v : (a: any, b: any) => void, Symbol(v, Decl(ArrowFunction4.ts, 0, 3))
|
||||
>v : (a: any, b: any) => void
|
||||
>(a, b) => { } : (a: any, b: any) => void
|
||||
>a : any, Symbol(a, Decl(ArrowFunction4.ts, 0, 9))
|
||||
>b : any, Symbol(b, Decl(ArrowFunction4.ts, 0, 11))
|
||||
>a : any
|
||||
>b : any
|
||||
|
||||
};
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts ===
|
||||
class Point {
|
||||
>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 4, 1))
|
||||
|
||||
constructor(public x: number, public y: number) { }
|
||||
>x : Symbol(x, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 1, 16))
|
||||
>y : Symbol(y, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 1, 33))
|
||||
|
||||
static Origin(): Point { return { x: 0, y: 0 }; }
|
||||
>Origin : Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 1, 55))
|
||||
>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 4, 1))
|
||||
>x : Symbol(x, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 3, 37))
|
||||
>y : Symbol(y, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 3, 43))
|
||||
}
|
||||
|
||||
module Point {
|
||||
>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 4, 1))
|
||||
|
||||
function Origin() { return ""; }// not an error, since not exported
|
||||
>Origin : Symbol(Origin, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 6, 14))
|
||||
}
|
||||
|
||||
|
||||
module A {
|
||||
>A : Symbol(A, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 8, 1))
|
||||
|
||||
export class Point {
|
||||
>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 16, 5))
|
||||
|
||||
constructor(public x: number, public y: number) { }
|
||||
>x : Symbol(x, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 13, 20))
|
||||
>y : Symbol(y, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 13, 37))
|
||||
|
||||
static Origin(): Point { return { x: 0, y: 0 }; }
|
||||
>Origin : Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 13, 59))
|
||||
>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 16, 5))
|
||||
>x : Symbol(x, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 15, 41))
|
||||
>y : Symbol(y, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 15, 47))
|
||||
}
|
||||
|
||||
export module Point {
|
||||
>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 16, 5))
|
||||
|
||||
function Origin() { return ""; }// not an error since not exported
|
||||
>Origin : Symbol(Origin, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 18, 25))
|
||||
}
|
||||
}
|
||||
+19
-19
@@ -1,55 +1,55 @@
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts ===
|
||||
class Point {
|
||||
>Point : Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 4, 1))
|
||||
>Point : Point
|
||||
|
||||
constructor(public x: number, public y: number) { }
|
||||
>x : number, Symbol(x, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 1, 16))
|
||||
>y : number, Symbol(y, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 1, 33))
|
||||
>x : number
|
||||
>y : number
|
||||
|
||||
static Origin(): Point { return { x: 0, y: 0 }; }
|
||||
>Origin : () => Point, Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 1, 55))
|
||||
>Point : Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 4, 1))
|
||||
>Origin : () => Point
|
||||
>Point : Point
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number, Symbol(x, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 3, 37))
|
||||
>x : number
|
||||
>0 : number
|
||||
>y : number, Symbol(y, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 3, 43))
|
||||
>y : number
|
||||
>0 : number
|
||||
}
|
||||
|
||||
module Point {
|
||||
>Point : typeof Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 4, 1))
|
||||
>Point : typeof Point
|
||||
|
||||
function Origin() { return ""; }// not an error, since not exported
|
||||
>Origin : () => string, Symbol(Origin, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 6, 14))
|
||||
>Origin : () => string
|
||||
>"" : string
|
||||
}
|
||||
|
||||
|
||||
module A {
|
||||
>A : typeof A, Symbol(A, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 8, 1))
|
||||
>A : typeof A
|
||||
|
||||
export class Point {
|
||||
>Point : Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 16, 5))
|
||||
>Point : Point
|
||||
|
||||
constructor(public x: number, public y: number) { }
|
||||
>x : number, Symbol(x, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 13, 20))
|
||||
>y : number, Symbol(y, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 13, 37))
|
||||
>x : number
|
||||
>y : number
|
||||
|
||||
static Origin(): Point { return { x: 0, y: 0 }; }
|
||||
>Origin : () => Point, Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 13, 59))
|
||||
>Point : Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 16, 5))
|
||||
>Origin : () => Point
|
||||
>Point : Point
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number, Symbol(x, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 15, 41))
|
||||
>x : number
|
||||
>0 : number
|
||||
>y : number, Symbol(y, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 15, 47))
|
||||
>y : number
|
||||
>0 : number
|
||||
}
|
||||
|
||||
export module Point {
|
||||
>Point : typeof Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 16, 5))
|
||||
>Point : typeof Point
|
||||
|
||||
function Origin() { return ""; }// not an error since not exported
|
||||
>Origin : () => string, Symbol(Origin, Decl(ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts, 18, 25))
|
||||
>Origin : () => string
|
||||
>"" : string
|
||||
}
|
||||
}
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts ===
|
||||
class Point {
|
||||
>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 4, 1))
|
||||
|
||||
constructor(public x: number, public y: number) { }
|
||||
>x : Symbol(x, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 1, 16))
|
||||
>y : Symbol(y, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 1, 33))
|
||||
|
||||
static Origin: Point = { x: 0, y: 0 };
|
||||
>Origin : Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 1, 55))
|
||||
>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 4, 1))
|
||||
>x : Symbol(x, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 3, 28))
|
||||
>y : Symbol(y, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 3, 34))
|
||||
}
|
||||
|
||||
module Point {
|
||||
>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 4, 1))
|
||||
|
||||
var Origin = ""; // not an error, since not exported
|
||||
>Origin : Symbol(Origin, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 7, 7))
|
||||
}
|
||||
|
||||
|
||||
module A {
|
||||
>A : Symbol(A, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 8, 1))
|
||||
|
||||
export class Point {
|
||||
>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 16, 5))
|
||||
|
||||
constructor(public x: number, public y: number) { }
|
||||
>x : Symbol(x, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 13, 20))
|
||||
>y : Symbol(y, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 13, 37))
|
||||
|
||||
static Origin: Point = { x: 0, y: 0 };
|
||||
>Origin : Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 13, 59))
|
||||
>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 16, 5))
|
||||
>x : Symbol(x, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 15, 32))
|
||||
>y : Symbol(y, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 15, 38))
|
||||
}
|
||||
|
||||
export module Point {
|
||||
>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 16, 5))
|
||||
|
||||
var Origin = ""; // not an error since not exported
|
||||
>Origin : Symbol(Origin, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 19, 11))
|
||||
}
|
||||
}
|
||||
+19
-19
@@ -1,55 +1,55 @@
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts ===
|
||||
class Point {
|
||||
>Point : Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 4, 1))
|
||||
>Point : Point
|
||||
|
||||
constructor(public x: number, public y: number) { }
|
||||
>x : number, Symbol(x, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 1, 16))
|
||||
>y : number, Symbol(y, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 1, 33))
|
||||
>x : number
|
||||
>y : number
|
||||
|
||||
static Origin: Point = { x: 0, y: 0 };
|
||||
>Origin : Point, Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 1, 55))
|
||||
>Point : Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 4, 1))
|
||||
>Origin : Point
|
||||
>Point : Point
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number, Symbol(x, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 3, 28))
|
||||
>x : number
|
||||
>0 : number
|
||||
>y : number, Symbol(y, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 3, 34))
|
||||
>y : number
|
||||
>0 : number
|
||||
}
|
||||
|
||||
module Point {
|
||||
>Point : typeof Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 4, 1))
|
||||
>Point : typeof Point
|
||||
|
||||
var Origin = ""; // not an error, since not exported
|
||||
>Origin : string, Symbol(Origin, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 7, 7))
|
||||
>Origin : string
|
||||
>"" : string
|
||||
}
|
||||
|
||||
|
||||
module A {
|
||||
>A : typeof A, Symbol(A, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 8, 1))
|
||||
>A : typeof A
|
||||
|
||||
export class Point {
|
||||
>Point : Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 16, 5))
|
||||
>Point : Point
|
||||
|
||||
constructor(public x: number, public y: number) { }
|
||||
>x : number, Symbol(x, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 13, 20))
|
||||
>y : number, Symbol(y, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 13, 37))
|
||||
>x : number
|
||||
>y : number
|
||||
|
||||
static Origin: Point = { x: 0, y: 0 };
|
||||
>Origin : Point, Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 13, 59))
|
||||
>Point : Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 16, 5))
|
||||
>Origin : Point
|
||||
>Point : Point
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number, Symbol(x, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 15, 32))
|
||||
>x : number
|
||||
>0 : number
|
||||
>y : number, Symbol(y, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 15, 38))
|
||||
>y : number
|
||||
>0 : number
|
||||
}
|
||||
|
||||
export module Point {
|
||||
>Point : typeof Point, Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 16, 5))
|
||||
>Point : typeof Point
|
||||
|
||||
var Origin = ""; // not an error since not exported
|
||||
>Origin : string, Symbol(Origin, Decl(ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts, 19, 11))
|
||||
>Origin : string
|
||||
>"" : string
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStringIndexerAndExportedFunctionWithTypeIncompatibleWithIndexer.ts ===
|
||||
|
||||
No type information for this code.
|
||||
@@ -0,0 +1,44 @@
|
||||
tests/cases/conformance/internalModules/DeclarationMerging/module.ts(2,19): error TS2433: A module declaration cannot be in a different file from a class or function with which it is merged
|
||||
|
||||
|
||||
==== tests/cases/conformance/internalModules/DeclarationMerging/class.ts (0 errors) ====
|
||||
module X.Y {
|
||||
export class Point {
|
||||
constructor(x: number, y: number) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
}
|
||||
|
||||
==== tests/cases/conformance/internalModules/DeclarationMerging/module.ts (1 errors) ====
|
||||
module X.Y {
|
||||
export module Point {
|
||||
~~~~~
|
||||
!!! error TS2433: A module declaration cannot be in a different file from a class or function with which it is merged
|
||||
export var Origin = new Point(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
==== tests/cases/conformance/internalModules/DeclarationMerging/test.ts (0 errors) ====
|
||||
//var cl: { x: number; y: number; }
|
||||
var cl = new X.Y.Point(1,1);
|
||||
var cl = X.Y.Point.Origin; // error not expected here same as bug 83996 ?
|
||||
|
||||
|
||||
==== tests/cases/conformance/internalModules/DeclarationMerging/simple.ts (0 errors) ====
|
||||
class A {
|
||||
id: string;
|
||||
}
|
||||
|
||||
module A {
|
||||
export var Instance = new A();
|
||||
}
|
||||
|
||||
// ensure merging works as expected
|
||||
var a = A.Instance;
|
||||
var a = new A();
|
||||
var a: { id: string };
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
//// [tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleWithSameNameAndCommonRootES6.ts] ////
|
||||
|
||||
//// [class.ts]
|
||||
module X.Y {
|
||||
export class Point {
|
||||
constructor(x: number, y: number) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
}
|
||||
|
||||
//// [module.ts]
|
||||
module X.Y {
|
||||
export module Point {
|
||||
export var Origin = new Point(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//// [test.ts]
|
||||
//var cl: { x: number; y: number; }
|
||||
var cl = new X.Y.Point(1,1);
|
||||
var cl = X.Y.Point.Origin; // error not expected here same as bug 83996 ?
|
||||
|
||||
|
||||
//// [simple.ts]
|
||||
class A {
|
||||
id: string;
|
||||
}
|
||||
|
||||
module A {
|
||||
export var Instance = new A();
|
||||
}
|
||||
|
||||
// ensure merging works as expected
|
||||
var a = A.Instance;
|
||||
var a = new A();
|
||||
var a: { id: string };
|
||||
|
||||
|
||||
//// [class.js]
|
||||
var X;
|
||||
(function (X) {
|
||||
var Y;
|
||||
(function (Y) {
|
||||
class Point {
|
||||
constructor(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
Y.Point = Point;
|
||||
})(Y = X.Y || (X.Y = {}));
|
||||
})(X || (X = {}));
|
||||
//// [module.js]
|
||||
var X;
|
||||
(function (X) {
|
||||
var Y;
|
||||
(function (Y) {
|
||||
var Point;
|
||||
(function (Point) {
|
||||
Point.Origin = new Point(0, 0);
|
||||
})(Point = Y.Point || (Y.Point = {}));
|
||||
})(Y = X.Y || (X.Y = {}));
|
||||
})(X || (X = {}));
|
||||
//// [test.js]
|
||||
//var cl: { x: number; y: number; }
|
||||
var cl = new X.Y.Point(1, 1);
|
||||
var cl = X.Y.Point.Origin; // error not expected here same as bug 83996 ?
|
||||
//// [simple.js]
|
||||
class A {
|
||||
}
|
||||
(function (A) {
|
||||
A.Instance = new A();
|
||||
})(A || (A = {}));
|
||||
// ensure merging works as expected
|
||||
var a = A.Instance;
|
||||
var a = new A();
|
||||
var a;
|
||||
@@ -0,0 +1,4 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck2.ts ===
|
||||
for (var v of [true]) { }
|
||||
>v : Symbol(v, Decl(ES3For-ofTypeCheck2.ts, 0, 8))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck2.ts ===
|
||||
for (var v of [true]) { }
|
||||
>v : boolean, Symbol(v, Decl(ES3For-ofTypeCheck2.ts, 0, 8))
|
||||
>v : boolean
|
||||
>[true] : boolean[]
|
||||
>true : boolean
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck6.ts ===
|
||||
var union: string[] | number[];
|
||||
>union : Symbol(union, Decl(ES3For-ofTypeCheck6.ts, 0, 3))
|
||||
|
||||
for (var v of union) { }
|
||||
>v : Symbol(v, Decl(ES3For-ofTypeCheck6.ts, 1, 8))
|
||||
>union : Symbol(union, Decl(ES3For-ofTypeCheck6.ts, 0, 3))
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck6.ts ===
|
||||
var union: string[] | number[];
|
||||
>union : string[] | number[], Symbol(union, Decl(ES3For-ofTypeCheck6.ts, 0, 3))
|
||||
>union : string[] | number[]
|
||||
|
||||
for (var v of union) { }
|
||||
>v : string | number, Symbol(v, Decl(ES3For-ofTypeCheck6.ts, 1, 8))
|
||||
>union : string[] | number[], Symbol(union, Decl(ES3For-ofTypeCheck6.ts, 0, 3))
|
||||
>v : string | number
|
||||
>union : string[] | number[]
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of10.ts ===
|
||||
function foo() {
|
||||
>foo : Symbol(foo, Decl(ES5For-of10.ts, 0, 0))
|
||||
|
||||
return { x: 0 };
|
||||
>x : Symbol(x, Decl(ES5For-of10.ts, 1, 12))
|
||||
}
|
||||
for (foo().x of []) {
|
||||
>foo().x : Symbol(x, Decl(ES5For-of10.ts, 1, 12))
|
||||
>foo : Symbol(foo, Decl(ES5For-of10.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(ES5For-of10.ts, 1, 12))
|
||||
|
||||
for (foo().x of [])
|
||||
>foo().x : Symbol(x, Decl(ES5For-of10.ts, 1, 12))
|
||||
>foo : Symbol(foo, Decl(ES5For-of10.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(ES5For-of10.ts, 1, 12))
|
||||
|
||||
var p = foo().x;
|
||||
>p : Symbol(p, Decl(ES5For-of10.ts, 5, 11))
|
||||
>foo().x : Symbol(x, Decl(ES5For-of10.ts, 1, 12))
|
||||
>foo : Symbol(foo, Decl(ES5For-of10.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(ES5For-of10.ts, 1, 12))
|
||||
}
|
||||
@@ -1,30 +1,30 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of10.ts ===
|
||||
function foo() {
|
||||
>foo : () => { x: number; }, Symbol(foo, Decl(ES5For-of10.ts, 0, 0))
|
||||
>foo : () => { x: number; }
|
||||
|
||||
return { x: 0 };
|
||||
>{ x: 0 } : { x: number; }
|
||||
>x : number, Symbol(x, Decl(ES5For-of10.ts, 1, 12))
|
||||
>x : number
|
||||
>0 : number
|
||||
}
|
||||
for (foo().x of []) {
|
||||
>foo().x : number, Symbol(x, Decl(ES5For-of10.ts, 1, 12))
|
||||
>foo().x : number
|
||||
>foo() : { x: number; }
|
||||
>foo : () => { x: number; }, Symbol(foo, Decl(ES5For-of10.ts, 0, 0))
|
||||
>x : number, Symbol(x, Decl(ES5For-of10.ts, 1, 12))
|
||||
>foo : () => { x: number; }
|
||||
>x : number
|
||||
>[] : undefined[]
|
||||
|
||||
for (foo().x of [])
|
||||
>foo().x : number, Symbol(x, Decl(ES5For-of10.ts, 1, 12))
|
||||
>foo().x : number
|
||||
>foo() : { x: number; }
|
||||
>foo : () => { x: number; }, Symbol(foo, Decl(ES5For-of10.ts, 0, 0))
|
||||
>x : number, Symbol(x, Decl(ES5For-of10.ts, 1, 12))
|
||||
>foo : () => { x: number; }
|
||||
>x : number
|
||||
>[] : undefined[]
|
||||
|
||||
var p = foo().x;
|
||||
>p : number, Symbol(p, Decl(ES5For-of10.ts, 5, 11))
|
||||
>foo().x : number, Symbol(x, Decl(ES5For-of10.ts, 1, 12))
|
||||
>p : number
|
||||
>foo().x : number
|
||||
>foo() : { x: number; }
|
||||
>foo : () => { x: number; }, Symbol(foo, Decl(ES5For-of10.ts, 0, 0))
|
||||
>x : number, Symbol(x, Decl(ES5For-of10.ts, 1, 12))
|
||||
>foo : () => { x: number; }
|
||||
>x : number
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of11.ts ===
|
||||
var v;
|
||||
>v : Symbol(v, Decl(ES5For-of11.ts, 0, 3))
|
||||
|
||||
for (v of []) { }
|
||||
>v : Symbol(v, Decl(ES5For-of11.ts, 0, 3))
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of11.ts ===
|
||||
var v;
|
||||
>v : any, Symbol(v, Decl(ES5For-of11.ts, 0, 3))
|
||||
>v : any
|
||||
|
||||
for (v of []) { }
|
||||
>v : any, Symbol(v, Decl(ES5For-of11.ts, 0, 3))
|
||||
>v : any
|
||||
>[] : undefined[]
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of13.ts ===
|
||||
for (let v of ['a', 'b', 'c']) {
|
||||
>v : Symbol(v, Decl(ES5For-of13.ts, 0, 8))
|
||||
|
||||
var x = v;
|
||||
>x : Symbol(x, Decl(ES5For-of13.ts, 1, 7))
|
||||
>v : Symbol(v, Decl(ES5For-of13.ts, 0, 8))
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of13.ts ===
|
||||
for (let v of ['a', 'b', 'c']) {
|
||||
>v : string, Symbol(v, Decl(ES5For-of13.ts, 0, 8))
|
||||
>v : string
|
||||
>['a', 'b', 'c'] : string[]
|
||||
>'a' : string
|
||||
>'b' : string
|
||||
>'c' : string
|
||||
|
||||
var x = v;
|
||||
>x : string, Symbol(x, Decl(ES5For-of13.ts, 1, 7))
|
||||
>v : string, Symbol(v, Decl(ES5For-of13.ts, 0, 8))
|
||||
>x : string
|
||||
>v : string
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of14.ts ===
|
||||
for (const v of []) {
|
||||
>v : Symbol(v, Decl(ES5For-of14.ts, 0, 10))
|
||||
|
||||
var x = v;
|
||||
>x : Symbol(x, Decl(ES5For-of14.ts, 1, 7))
|
||||
>v : Symbol(v, Decl(ES5For-of14.ts, 0, 10))
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of14.ts ===
|
||||
for (const v of []) {
|
||||
>v : any, Symbol(v, Decl(ES5For-of14.ts, 0, 10))
|
||||
>v : any
|
||||
>[] : undefined[]
|
||||
|
||||
var x = v;
|
||||
>x : any, Symbol(x, Decl(ES5For-of14.ts, 1, 7))
|
||||
>v : any, Symbol(v, Decl(ES5For-of14.ts, 0, 10))
|
||||
>x : any
|
||||
>v : any
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of15.ts ===
|
||||
for (let v of []) {
|
||||
>v : Symbol(v, Decl(ES5For-of15.ts, 0, 8))
|
||||
|
||||
v;
|
||||
>v : Symbol(v, Decl(ES5For-of15.ts, 0, 8))
|
||||
|
||||
for (const v of []) {
|
||||
>v : Symbol(v, Decl(ES5For-of15.ts, 2, 14))
|
||||
|
||||
var x = v;
|
||||
>x : Symbol(x, Decl(ES5For-of15.ts, 3, 11))
|
||||
>v : Symbol(v, Decl(ES5For-of15.ts, 2, 14))
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of15.ts ===
|
||||
for (let v of []) {
|
||||
>v : any, Symbol(v, Decl(ES5For-of15.ts, 0, 8))
|
||||
>v : any
|
||||
>[] : undefined[]
|
||||
|
||||
v;
|
||||
>v : any, Symbol(v, Decl(ES5For-of15.ts, 0, 8))
|
||||
>v : any
|
||||
|
||||
for (const v of []) {
|
||||
>v : any, Symbol(v, Decl(ES5For-of15.ts, 2, 14))
|
||||
>v : any
|
||||
>[] : undefined[]
|
||||
|
||||
var x = v;
|
||||
>x : any, Symbol(x, Decl(ES5For-of15.ts, 3, 11))
|
||||
>v : any, Symbol(v, Decl(ES5For-of15.ts, 2, 14))
|
||||
>x : any
|
||||
>v : any
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of16.ts ===
|
||||
for (let v of []) {
|
||||
>v : Symbol(v, Decl(ES5For-of16.ts, 0, 8))
|
||||
|
||||
v;
|
||||
>v : Symbol(v, Decl(ES5For-of16.ts, 0, 8))
|
||||
|
||||
for (let v of []) {
|
||||
>v : Symbol(v, Decl(ES5For-of16.ts, 2, 12))
|
||||
|
||||
var x = v;
|
||||
>x : Symbol(x, Decl(ES5For-of16.ts, 3, 11))
|
||||
>v : Symbol(v, Decl(ES5For-of16.ts, 2, 12))
|
||||
|
||||
v++;
|
||||
>v : Symbol(v, Decl(ES5For-of16.ts, 2, 12))
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,21 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of16.ts ===
|
||||
for (let v of []) {
|
||||
>v : any, Symbol(v, Decl(ES5For-of16.ts, 0, 8))
|
||||
>v : any
|
||||
>[] : undefined[]
|
||||
|
||||
v;
|
||||
>v : any, Symbol(v, Decl(ES5For-of16.ts, 0, 8))
|
||||
>v : any
|
||||
|
||||
for (let v of []) {
|
||||
>v : any, Symbol(v, Decl(ES5For-of16.ts, 2, 12))
|
||||
>v : any
|
||||
>[] : undefined[]
|
||||
|
||||
var x = v;
|
||||
>x : any, Symbol(x, Decl(ES5For-of16.ts, 3, 11))
|
||||
>v : any, Symbol(v, Decl(ES5For-of16.ts, 2, 12))
|
||||
>x : any
|
||||
>v : any
|
||||
|
||||
v++;
|
||||
>v++ : number
|
||||
>v : any, Symbol(v, Decl(ES5For-of16.ts, 2, 12))
|
||||
>v : any
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of18.ts ===
|
||||
for (let v of []) {
|
||||
>v : Symbol(v, Decl(ES5For-of18.ts, 0, 8))
|
||||
|
||||
v;
|
||||
>v : Symbol(v, Decl(ES5For-of18.ts, 0, 8))
|
||||
}
|
||||
for (let v of []) {
|
||||
>v : Symbol(v, Decl(ES5For-of18.ts, 3, 8))
|
||||
|
||||
v;
|
||||
>v : Symbol(v, Decl(ES5For-of18.ts, 3, 8))
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of18.ts ===
|
||||
for (let v of []) {
|
||||
>v : any, Symbol(v, Decl(ES5For-of18.ts, 0, 8))
|
||||
>v : any
|
||||
>[] : undefined[]
|
||||
|
||||
v;
|
||||
>v : any, Symbol(v, Decl(ES5For-of18.ts, 0, 8))
|
||||
>v : any
|
||||
}
|
||||
for (let v of []) {
|
||||
>v : any, Symbol(v, Decl(ES5For-of18.ts, 3, 8))
|
||||
>v : any
|
||||
>[] : undefined[]
|
||||
|
||||
v;
|
||||
>v : any, Symbol(v, Decl(ES5For-of18.ts, 3, 8))
|
||||
>v : any
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of19.ts ===
|
||||
for (let v of []) {
|
||||
>v : Symbol(v, Decl(ES5For-of19.ts, 0, 8))
|
||||
|
||||
v;
|
||||
>v : Symbol(v, Decl(ES5For-of19.ts, 0, 8))
|
||||
|
||||
function foo() {
|
||||
>foo : Symbol(foo, Decl(ES5For-of19.ts, 1, 6))
|
||||
|
||||
for (const v of []) {
|
||||
>v : Symbol(v, Decl(ES5For-of19.ts, 3, 18))
|
||||
|
||||
v;
|
||||
>v : Symbol(v, Decl(ES5For-of19.ts, 3, 18))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of19.ts ===
|
||||
for (let v of []) {
|
||||
>v : any, Symbol(v, Decl(ES5For-of19.ts, 0, 8))
|
||||
>v : any
|
||||
>[] : undefined[]
|
||||
|
||||
v;
|
||||
>v : any, Symbol(v, Decl(ES5For-of19.ts, 0, 8))
|
||||
>v : any
|
||||
|
||||
function foo() {
|
||||
>foo : () => void, Symbol(foo, Decl(ES5For-of19.ts, 1, 6))
|
||||
>foo : () => void
|
||||
|
||||
for (const v of []) {
|
||||
>v : any, Symbol(v, Decl(ES5For-of19.ts, 3, 18))
|
||||
>v : any
|
||||
>[] : undefined[]
|
||||
|
||||
v;
|
||||
>v : any, Symbol(v, Decl(ES5For-of19.ts, 3, 18))
|
||||
>v : any
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of2.ts ===
|
||||
for (var v of []) {
|
||||
>v : Symbol(v, Decl(ES5For-of2.ts, 0, 8))
|
||||
|
||||
var x = v;
|
||||
>x : Symbol(x, Decl(ES5For-of2.ts, 1, 7))
|
||||
>v : Symbol(v, Decl(ES5For-of2.ts, 0, 8))
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of2.ts ===
|
||||
for (var v of []) {
|
||||
>v : any, Symbol(v, Decl(ES5For-of2.ts, 0, 8))
|
||||
>v : any
|
||||
>[] : undefined[]
|
||||
|
||||
var x = v;
|
||||
>x : any, Symbol(x, Decl(ES5For-of2.ts, 1, 7))
|
||||
>v : any, Symbol(v, Decl(ES5For-of2.ts, 0, 8))
|
||||
>x : any
|
||||
>v : any
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of21.ts ===
|
||||
for (let v of []) {
|
||||
>v : Symbol(v, Decl(ES5For-of21.ts, 0, 8))
|
||||
|
||||
for (let _i of []) { }
|
||||
>_i : Symbol(_i, Decl(ES5For-of21.ts, 1, 12))
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of21.ts ===
|
||||
for (let v of []) {
|
||||
>v : any, Symbol(v, Decl(ES5For-of21.ts, 0, 8))
|
||||
>v : any
|
||||
>[] : undefined[]
|
||||
|
||||
for (let _i of []) { }
|
||||
>_i : any, Symbol(_i, Decl(ES5For-of21.ts, 1, 12))
|
||||
>_i : any
|
||||
>[] : undefined[]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of24.ts ===
|
||||
var a = [1, 2, 3];
|
||||
>a : Symbol(a, Decl(ES5For-of24.ts, 0, 3))
|
||||
|
||||
for (var v of a) {
|
||||
>v : Symbol(v, Decl(ES5For-of24.ts, 1, 8))
|
||||
>a : Symbol(a, Decl(ES5For-of24.ts, 0, 3))
|
||||
|
||||
let a = 0;
|
||||
>a : Symbol(a, Decl(ES5For-of24.ts, 2, 7))
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of24.ts ===
|
||||
var a = [1, 2, 3];
|
||||
>a : number[], Symbol(a, Decl(ES5For-of24.ts, 0, 3))
|
||||
>a : number[]
|
||||
>[1, 2, 3] : number[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
|
||||
for (var v of a) {
|
||||
>v : number, Symbol(v, Decl(ES5For-of24.ts, 1, 8))
|
||||
>a : number[], Symbol(a, Decl(ES5For-of24.ts, 0, 3))
|
||||
>v : number
|
||||
>a : number[]
|
||||
|
||||
let a = 0;
|
||||
>a : number, Symbol(a, Decl(ES5For-of24.ts, 2, 7))
|
||||
>a : number
|
||||
>0 : number
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of25.ts ===
|
||||
var a = [1, 2, 3];
|
||||
>a : Symbol(a, Decl(ES5For-of25.ts, 0, 3))
|
||||
|
||||
for (var v of a) {
|
||||
>v : Symbol(v, Decl(ES5For-of25.ts, 1, 8))
|
||||
>a : Symbol(a, Decl(ES5For-of25.ts, 0, 3))
|
||||
|
||||
v;
|
||||
>v : Symbol(v, Decl(ES5For-of25.ts, 1, 8))
|
||||
|
||||
a;
|
||||
>a : Symbol(a, Decl(ES5For-of25.ts, 0, 3))
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of25.ts ===
|
||||
var a = [1, 2, 3];
|
||||
>a : number[], Symbol(a, Decl(ES5For-of25.ts, 0, 3))
|
||||
>a : number[]
|
||||
>[1, 2, 3] : number[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
|
||||
for (var v of a) {
|
||||
>v : number, Symbol(v, Decl(ES5For-of25.ts, 1, 8))
|
||||
>a : number[], Symbol(a, Decl(ES5For-of25.ts, 0, 3))
|
||||
>v : number
|
||||
>a : number[]
|
||||
|
||||
v;
|
||||
>v : number, Symbol(v, Decl(ES5For-of25.ts, 1, 8))
|
||||
>v : number
|
||||
|
||||
a;
|
||||
>a : number[], Symbol(a, Decl(ES5For-of25.ts, 0, 3))
|
||||
>a : number[]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of3.ts ===
|
||||
for (var v of ['a', 'b', 'c'])
|
||||
>v : Symbol(v, Decl(ES5For-of3.ts, 0, 8))
|
||||
|
||||
var x = v;
|
||||
>x : Symbol(x, Decl(ES5For-of3.ts, 1, 7))
|
||||
>v : Symbol(v, Decl(ES5For-of3.ts, 0, 8))
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of3.ts ===
|
||||
for (var v of ['a', 'b', 'c'])
|
||||
>v : string, Symbol(v, Decl(ES5For-of3.ts, 0, 8))
|
||||
>v : string
|
||||
>['a', 'b', 'c'] : string[]
|
||||
>'a' : string
|
||||
>'b' : string
|
||||
>'c' : string
|
||||
|
||||
var x = v;
|
||||
>x : string, Symbol(x, Decl(ES5For-of3.ts, 1, 7))
|
||||
>v : string, Symbol(v, Decl(ES5For-of3.ts, 0, 8))
|
||||
>x : string
|
||||
>v : string
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of4.ts ===
|
||||
for (var v of [])
|
||||
>v : Symbol(v, Decl(ES5For-of4.ts, 0, 8))
|
||||
|
||||
var x = v;
|
||||
>x : Symbol(x, Decl(ES5For-of4.ts, 1, 7))
|
||||
>v : Symbol(v, Decl(ES5For-of4.ts, 0, 8))
|
||||
|
||||
var y = v;
|
||||
>y : Symbol(y, Decl(ES5For-of4.ts, 2, 3))
|
||||
>v : Symbol(v, Decl(ES5For-of4.ts, 0, 8))
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of4.ts ===
|
||||
for (var v of [])
|
||||
>v : any, Symbol(v, Decl(ES5For-of4.ts, 0, 8))
|
||||
>v : any
|
||||
>[] : undefined[]
|
||||
|
||||
var x = v;
|
||||
>x : any, Symbol(x, Decl(ES5For-of4.ts, 1, 7))
|
||||
>v : any, Symbol(v, Decl(ES5For-of4.ts, 0, 8))
|
||||
>x : any
|
||||
>v : any
|
||||
|
||||
var y = v;
|
||||
>y : any, Symbol(y, Decl(ES5For-of4.ts, 2, 3))
|
||||
>v : any, Symbol(v, Decl(ES5For-of4.ts, 0, 8))
|
||||
>y : any
|
||||
>v : any
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of5.ts ===
|
||||
for (var _a of []) {
|
||||
>_a : Symbol(_a, Decl(ES5For-of5.ts, 0, 8))
|
||||
|
||||
var x = _a;
|
||||
>x : Symbol(x, Decl(ES5For-of5.ts, 1, 7))
|
||||
>_a : Symbol(_a, Decl(ES5For-of5.ts, 0, 8))
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of5.ts ===
|
||||
for (var _a of []) {
|
||||
>_a : any, Symbol(_a, Decl(ES5For-of5.ts, 0, 8))
|
||||
>_a : any
|
||||
>[] : undefined[]
|
||||
|
||||
var x = _a;
|
||||
>x : any, Symbol(x, Decl(ES5For-of5.ts, 1, 7))
|
||||
>_a : any, Symbol(_a, Decl(ES5For-of5.ts, 0, 8))
|
||||
>x : any
|
||||
>_a : any
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of6.ts ===
|
||||
for (var w of []) {
|
||||
>w : Symbol(w, Decl(ES5For-of6.ts, 0, 8))
|
||||
|
||||
for (var v of []) {
|
||||
>v : Symbol(v, Decl(ES5For-of6.ts, 1, 12))
|
||||
|
||||
var x = [w, v];
|
||||
>x : Symbol(x, Decl(ES5For-of6.ts, 2, 11))
|
||||
>w : Symbol(w, Decl(ES5For-of6.ts, 0, 8))
|
||||
>v : Symbol(v, Decl(ES5For-of6.ts, 1, 12))
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of6.ts ===
|
||||
for (var w of []) {
|
||||
>w : any, Symbol(w, Decl(ES5For-of6.ts, 0, 8))
|
||||
>w : any
|
||||
>[] : undefined[]
|
||||
|
||||
for (var v of []) {
|
||||
>v : any, Symbol(v, Decl(ES5For-of6.ts, 1, 12))
|
||||
>v : any
|
||||
>[] : undefined[]
|
||||
|
||||
var x = [w, v];
|
||||
>x : any[], Symbol(x, Decl(ES5For-of6.ts, 2, 11))
|
||||
>x : any[]
|
||||
>[w, v] : any[]
|
||||
>w : any, Symbol(w, Decl(ES5For-of6.ts, 0, 8))
|
||||
>v : any, Symbol(v, Decl(ES5For-of6.ts, 1, 12))
|
||||
>w : any
|
||||
>v : any
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of9.ts ===
|
||||
function foo() {
|
||||
>foo : Symbol(foo, Decl(ES5For-of9.ts, 0, 0))
|
||||
|
||||
return { x: 0 };
|
||||
>x : Symbol(x, Decl(ES5For-of9.ts, 1, 12))
|
||||
}
|
||||
for (foo().x of []) {
|
||||
>foo().x : Symbol(x, Decl(ES5For-of9.ts, 1, 12))
|
||||
>foo : Symbol(foo, Decl(ES5For-of9.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(ES5For-of9.ts, 1, 12))
|
||||
|
||||
for (foo().x of []) {
|
||||
>foo().x : Symbol(x, Decl(ES5For-of9.ts, 1, 12))
|
||||
>foo : Symbol(foo, Decl(ES5For-of9.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(ES5For-of9.ts, 1, 12))
|
||||
|
||||
var p = foo().x;
|
||||
>p : Symbol(p, Decl(ES5For-of9.ts, 5, 11))
|
||||
>foo().x : Symbol(x, Decl(ES5For-of9.ts, 1, 12))
|
||||
>foo : Symbol(foo, Decl(ES5For-of9.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(ES5For-of9.ts, 1, 12))
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,31 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of9.ts ===
|
||||
function foo() {
|
||||
>foo : () => { x: number; }, Symbol(foo, Decl(ES5For-of9.ts, 0, 0))
|
||||
>foo : () => { x: number; }
|
||||
|
||||
return { x: 0 };
|
||||
>{ x: 0 } : { x: number; }
|
||||
>x : number, Symbol(x, Decl(ES5For-of9.ts, 1, 12))
|
||||
>x : number
|
||||
>0 : number
|
||||
}
|
||||
for (foo().x of []) {
|
||||
>foo().x : number, Symbol(x, Decl(ES5For-of9.ts, 1, 12))
|
||||
>foo().x : number
|
||||
>foo() : { x: number; }
|
||||
>foo : () => { x: number; }, Symbol(foo, Decl(ES5For-of9.ts, 0, 0))
|
||||
>x : number, Symbol(x, Decl(ES5For-of9.ts, 1, 12))
|
||||
>foo : () => { x: number; }
|
||||
>x : number
|
||||
>[] : undefined[]
|
||||
|
||||
for (foo().x of []) {
|
||||
>foo().x : number, Symbol(x, Decl(ES5For-of9.ts, 1, 12))
|
||||
>foo().x : number
|
||||
>foo() : { x: number; }
|
||||
>foo : () => { x: number; }, Symbol(foo, Decl(ES5For-of9.ts, 0, 0))
|
||||
>x : number, Symbol(x, Decl(ES5For-of9.ts, 1, 12))
|
||||
>foo : () => { x: number; }
|
||||
>x : number
|
||||
>[] : undefined[]
|
||||
|
||||
var p = foo().x;
|
||||
>p : number, Symbol(p, Decl(ES5For-of9.ts, 5, 11))
|
||||
>foo().x : number, Symbol(x, Decl(ES5For-of9.ts, 1, 12))
|
||||
>p : number
|
||||
>foo().x : number
|
||||
>foo() : { x: number; }
|
||||
>foo : () => { x: number; }, Symbol(foo, Decl(ES5For-of9.ts, 0, 0))
|
||||
>x : number, Symbol(x, Decl(ES5For-of9.ts, 1, 12))
|
||||
>foo : () => { x: number; }
|
||||
>x : number
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck1.ts ===
|
||||
for (var v of "") { }
|
||||
>v : Symbol(v, Decl(ES5For-ofTypeCheck1.ts, 0, 8))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck1.ts ===
|
||||
for (var v of "") { }
|
||||
>v : string, Symbol(v, Decl(ES5For-ofTypeCheck1.ts, 0, 8))
|
||||
>v : string
|
||||
>"" : string
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck2.ts ===
|
||||
for (var v of [true]) { }
|
||||
>v : Symbol(v, Decl(ES5For-ofTypeCheck2.ts, 0, 8))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck2.ts ===
|
||||
for (var v of [true]) { }
|
||||
>v : boolean, Symbol(v, Decl(ES5For-ofTypeCheck2.ts, 0, 8))
|
||||
>v : boolean
|
||||
>[true] : boolean[]
|
||||
>true : boolean
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck3.ts ===
|
||||
var tuple: [string, number] = ["", 0];
|
||||
>tuple : Symbol(tuple, Decl(ES5For-ofTypeCheck3.ts, 0, 3))
|
||||
|
||||
for (var v of tuple) { }
|
||||
>v : Symbol(v, Decl(ES5For-ofTypeCheck3.ts, 1, 8))
|
||||
>tuple : Symbol(tuple, Decl(ES5For-ofTypeCheck3.ts, 0, 3))
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck3.ts ===
|
||||
var tuple: [string, number] = ["", 0];
|
||||
>tuple : [string, number], Symbol(tuple, Decl(ES5For-ofTypeCheck3.ts, 0, 3))
|
||||
>tuple : [string, number]
|
||||
>["", 0] : [string, number]
|
||||
>"" : string
|
||||
>0 : number
|
||||
|
||||
for (var v of tuple) { }
|
||||
>v : string | number, Symbol(v, Decl(ES5For-ofTypeCheck3.ts, 1, 8))
|
||||
>tuple : [string, number], Symbol(tuple, Decl(ES5For-ofTypeCheck3.ts, 0, 3))
|
||||
>v : string | number
|
||||
>tuple : [string, number]
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck4.ts ===
|
||||
var union: string | string[];
|
||||
>union : Symbol(union, Decl(ES5For-ofTypeCheck4.ts, 0, 3))
|
||||
|
||||
for (const v of union) { }
|
||||
>v : Symbol(v, Decl(ES5For-ofTypeCheck4.ts, 1, 10))
|
||||
>union : Symbol(union, Decl(ES5For-ofTypeCheck4.ts, 0, 3))
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck4.ts ===
|
||||
var union: string | string[];
|
||||
>union : string | string[], Symbol(union, Decl(ES5For-ofTypeCheck4.ts, 0, 3))
|
||||
>union : string | string[]
|
||||
|
||||
for (const v of union) { }
|
||||
>v : string, Symbol(v, Decl(ES5For-ofTypeCheck4.ts, 1, 10))
|
||||
>union : string | string[], Symbol(union, Decl(ES5For-ofTypeCheck4.ts, 0, 3))
|
||||
>v : string
|
||||
>union : string | string[]
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck5.ts ===
|
||||
var union: string | number[];
|
||||
>union : Symbol(union, Decl(ES5For-ofTypeCheck5.ts, 0, 3))
|
||||
|
||||
for (var v of union) { }
|
||||
>v : Symbol(v, Decl(ES5For-ofTypeCheck5.ts, 1, 8))
|
||||
>union : Symbol(union, Decl(ES5For-ofTypeCheck5.ts, 0, 3))
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck5.ts ===
|
||||
var union: string | number[];
|
||||
>union : string | number[], Symbol(union, Decl(ES5For-ofTypeCheck5.ts, 0, 3))
|
||||
>union : string | number[]
|
||||
|
||||
for (var v of union) { }
|
||||
>v : string | number, Symbol(v, Decl(ES5For-ofTypeCheck5.ts, 1, 8))
|
||||
>union : string | number[], Symbol(union, Decl(ES5For-ofTypeCheck5.ts, 0, 3))
|
||||
>v : string | number
|
||||
>union : string | number[]
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck6.ts ===
|
||||
var union: string[] | number[];
|
||||
>union : Symbol(union, Decl(ES5For-ofTypeCheck6.ts, 0, 3))
|
||||
|
||||
for (var v of union) { }
|
||||
>v : Symbol(v, Decl(ES5For-ofTypeCheck6.ts, 1, 8))
|
||||
>union : Symbol(union, Decl(ES5For-ofTypeCheck6.ts, 0, 3))
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck6.ts ===
|
||||
var union: string[] | number[];
|
||||
>union : string[] | number[], Symbol(union, Decl(ES5For-ofTypeCheck6.ts, 0, 3))
|
||||
>union : string[] | number[]
|
||||
|
||||
for (var v of union) { }
|
||||
>v : string | number, Symbol(v, Decl(ES5For-ofTypeCheck6.ts, 1, 8))
|
||||
>union : string[] | number[], Symbol(union, Decl(ES5For-ofTypeCheck6.ts, 0, 3))
|
||||
>v : string | number
|
||||
>union : string[] | number[]
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
=== tests/cases/conformance/Symbols/ES5SymbolType1.ts ===
|
||||
var s: symbol;
|
||||
>s : Symbol(s, Decl(ES5SymbolType1.ts, 0, 3))
|
||||
|
||||
s.toString();
|
||||
>s.toString : Symbol(Object.toString, Decl(lib.d.ts, 96, 26))
|
||||
>s : Symbol(s, Decl(ES5SymbolType1.ts, 0, 3))
|
||||
>toString : Symbol(Object.toString, Decl(lib.d.ts, 96, 26))
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
=== tests/cases/conformance/Symbols/ES5SymbolType1.ts ===
|
||||
var s: symbol;
|
||||
>s : symbol, Symbol(s, Decl(ES5SymbolType1.ts, 0, 3))
|
||||
>s : symbol
|
||||
|
||||
s.toString();
|
||||
>s.toString() : string
|
||||
>s.toString : () => string, Symbol(Object.toString, Decl(lib.d.ts, 96, 26))
|
||||
>s : symbol, Symbol(s, Decl(ES5SymbolType1.ts, 0, 3))
|
||||
>toString : () => string, Symbol(Object.toString, Decl(lib.d.ts, 96, 26))
|
||||
>s.toString : () => string
|
||||
>s : symbol
|
||||
>toString : () => string
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/EnumAndModuleWithSameNameAndCommonRoot.ts ===
|
||||
enum enumdule {
|
||||
>enumdule : Symbol(enumdule, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 0, 0), Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 2, 1))
|
||||
|
||||
Red, Blue
|
||||
>Red : Symbol(enumdule.Red, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 0, 15))
|
||||
>Blue : Symbol(enumdule.Blue, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 1, 8))
|
||||
}
|
||||
|
||||
module enumdule {
|
||||
>enumdule : Symbol(enumdule, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 0, 0), Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 2, 1))
|
||||
|
||||
export class Point {
|
||||
>Point : Symbol(Point, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 4, 17))
|
||||
|
||||
constructor(public x: number, public y: number) { }
|
||||
>x : Symbol(x, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 7, 20))
|
||||
>y : Symbol(y, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 7, 37))
|
||||
}
|
||||
}
|
||||
|
||||
var x: enumdule;
|
||||
>x : Symbol(x, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 11, 3), Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 12, 3))
|
||||
>enumdule : Symbol(enumdule, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 0, 0), Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 2, 1))
|
||||
|
||||
var x = enumdule.Red;
|
||||
>x : Symbol(x, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 11, 3), Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 12, 3))
|
||||
>enumdule.Red : Symbol(enumdule.Red, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 0, 15))
|
||||
>enumdule : Symbol(enumdule, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 0, 0), Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 2, 1))
|
||||
>Red : Symbol(enumdule.Red, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 0, 15))
|
||||
|
||||
var y: { x: number; y: number };
|
||||
>y : Symbol(y, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 14, 3), Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 15, 3))
|
||||
>x : Symbol(x, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 14, 8))
|
||||
>y : Symbol(y, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 14, 19))
|
||||
|
||||
var y = new enumdule.Point(0, 0);
|
||||
>y : Symbol(y, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 14, 3), Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 15, 3))
|
||||
>enumdule.Point : Symbol(enumdule.Point, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 4, 17))
|
||||
>enumdule : Symbol(enumdule, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 0, 0), Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 2, 1))
|
||||
>Point : Symbol(enumdule.Point, Decl(EnumAndModuleWithSameNameAndCommonRoot.ts, 4, 17))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user