mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into disallowBadCommas
This commit is contained in:
+12
-8
@@ -126,6 +126,7 @@ var servicesSources = [
|
||||
"classifier.ts",
|
||||
"completions.ts",
|
||||
"documentHighlights.ts",
|
||||
"documentRegistry.ts",
|
||||
"findAllReferences.ts",
|
||||
"goToDefinition.ts",
|
||||
"jsDoc.ts",
|
||||
@@ -1003,15 +1004,18 @@ function acceptBaseline(containerFolder) {
|
||||
var deleteEnding = '.delete';
|
||||
for (var i in files) {
|
||||
var filename = files[i];
|
||||
if (filename.substr(filename.length - deleteEnding.length) === deleteEnding) {
|
||||
filename = filename.substr(0, filename.length - deleteEnding.length);
|
||||
fs.unlinkSync(path.join(targetFolder, filename));
|
||||
} else {
|
||||
var target = path.join(targetFolder, filename);
|
||||
if (fs.existsSync(target)) {
|
||||
fs.unlinkSync(target);
|
||||
var fullLocalPath = path.join(sourceFolder, filename);
|
||||
if (fs.statSync(fullLocalPath).isFile()) {
|
||||
if (filename.substr(filename.length - deleteEnding.length) === deleteEnding) {
|
||||
filename = filename.substr(0, filename.length - deleteEnding.length);
|
||||
fs.unlinkSync(path.join(targetFolder, filename));
|
||||
} else {
|
||||
var target = path.join(targetFolder, filename);
|
||||
if (fs.existsSync(target)) {
|
||||
fs.unlinkSync(target);
|
||||
}
|
||||
fs.renameSync(path.join(sourceFolder, filename), target);
|
||||
}
|
||||
fs.renameSync(path.join(sourceFolder, filename), target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -20,7 +20,7 @@ interface Map<K, V> {
|
||||
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
|
||||
get(key: K): V | undefined;
|
||||
has(key: K): boolean;
|
||||
set(key: K, value?: V): this;
|
||||
set(key: K, value: V): this;
|
||||
readonly size: number;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ interface WeakMap<K, V> {
|
||||
delete(key: K): boolean;
|
||||
get(key: K): V | undefined;
|
||||
has(key: K): boolean;
|
||||
set(key: K, value?: V): this;
|
||||
set(key: K, value: V): this;
|
||||
}
|
||||
|
||||
interface WeakMapConstructor {
|
||||
|
||||
@@ -591,6 +591,9 @@ namespace ts {
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
bindPrefixUnaryExpressionFlow(<PrefixUnaryExpression>node);
|
||||
break;
|
||||
case SyntaxKind.PostfixUnaryExpression:
|
||||
bindPostfixUnaryExpressionFlow(<PostfixUnaryExpression>node);
|
||||
break;
|
||||
case SyntaxKind.BinaryExpression:
|
||||
bindBinaryExpressionFlow(<BinaryExpression>node);
|
||||
break;
|
||||
@@ -1106,6 +1109,16 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
forEachChild(node, bind);
|
||||
if (node.operator === SyntaxKind.PlusEqualsToken || node.operator === SyntaxKind.MinusMinusToken) {
|
||||
bindAssignmentTargetFlow(node.operand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function bindPostfixUnaryExpressionFlow(node: PostfixUnaryExpression) {
|
||||
forEachChild(node, bind);
|
||||
if (node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) {
|
||||
bindAssignmentTargetFlow(node.operand);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+182
-172
@@ -334,6 +334,7 @@ namespace ts {
|
||||
const assignableRelation = createMap<RelationComparisonResult>();
|
||||
const comparableRelation = createMap<RelationComparisonResult>();
|
||||
const identityRelation = createMap<RelationComparisonResult>();
|
||||
const enumRelation = createMap<boolean>();
|
||||
|
||||
// This is for caching the result of getSymbolDisplayBuilder. Do not access directly.
|
||||
let _displayBuilder: SymbolDisplayBuilder;
|
||||
@@ -2068,7 +2069,7 @@ namespace ts {
|
||||
parentSymbol = symbol;
|
||||
}
|
||||
|
||||
// const the writer know we just wrote out a symbol. The declaration emitter writer uses
|
||||
// Let the writer know we just wrote out a symbol. The declaration emitter writer uses
|
||||
// this to determine if an import it has previously seen (and not written out) needs
|
||||
// to be written to the file once the walk of the tree is complete.
|
||||
//
|
||||
@@ -2076,37 +2077,34 @@ namespace ts {
|
||||
// up front (for example, during checking) could determine if we need to emit the imports
|
||||
// and we could then access that data during declaration emit.
|
||||
writer.trackSymbol(symbol, enclosingDeclaration, meaning);
|
||||
function walkSymbol(symbol: Symbol, meaning: SymbolFlags): void {
|
||||
if (symbol) {
|
||||
const accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & SymbolFormatFlags.UseOnlyExternalAliasing));
|
||||
/** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */
|
||||
function walkSymbol(symbol: Symbol, meaning: SymbolFlags, endOfChain: boolean): void {
|
||||
const accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & SymbolFormatFlags.UseOnlyExternalAliasing));
|
||||
|
||||
if (!accessibleSymbolChain ||
|
||||
needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
|
||||
if (!accessibleSymbolChain ||
|
||||
needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
|
||||
|
||||
// Go up and add our parent.
|
||||
walkSymbol(
|
||||
getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol),
|
||||
getQualifiedLeftMeaning(meaning));
|
||||
// Go up and add our parent.
|
||||
const parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol);
|
||||
if (parent) {
|
||||
walkSymbol(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false);
|
||||
}
|
||||
}
|
||||
|
||||
if (accessibleSymbolChain) {
|
||||
for (const accessibleSymbol of accessibleSymbolChain) {
|
||||
appendParentTypeArgumentsAndSymbolName(accessibleSymbol);
|
||||
}
|
||||
if (accessibleSymbolChain) {
|
||||
for (const accessibleSymbol of accessibleSymbolChain) {
|
||||
appendParentTypeArgumentsAndSymbolName(accessibleSymbol);
|
||||
}
|
||||
else {
|
||||
// If we didn't find accessible symbol chain for this symbol, break if this is external module
|
||||
if (!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (
|
||||
// If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols.
|
||||
endOfChain ||
|
||||
// If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.)
|
||||
!(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) &&
|
||||
// If a parent symbol is an anonymous type, don't write it.
|
||||
!(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral))) {
|
||||
|
||||
// if this is anonymous type break
|
||||
if (symbol.flags & SymbolFlags.TypeLiteral || symbol.flags & SymbolFlags.ObjectLiteral) {
|
||||
return;
|
||||
}
|
||||
|
||||
appendParentTypeArgumentsAndSymbolName(symbol);
|
||||
}
|
||||
appendParentTypeArgumentsAndSymbolName(symbol);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2116,11 +2114,11 @@ namespace ts {
|
||||
const isTypeParameter = symbol.flags & SymbolFlags.TypeParameter;
|
||||
const typeFormatFlag = TypeFormatFlags.UseFullyQualifiedType & typeFlags;
|
||||
if (!isTypeParameter && (enclosingDeclaration || typeFormatFlag)) {
|
||||
walkSymbol(symbol, meaning);
|
||||
return;
|
||||
walkSymbol(symbol, meaning, /*endOfChain*/ true);
|
||||
}
|
||||
else {
|
||||
appendParentTypeArgumentsAndSymbolName(symbol);
|
||||
}
|
||||
|
||||
return appendParentTypeArgumentsAndSymbolName(symbol);
|
||||
}
|
||||
|
||||
function buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]) {
|
||||
@@ -2922,7 +2920,7 @@ namespace ts {
|
||||
// undefined or any type of the parent.
|
||||
if (!parentType || isTypeAny(parentType)) {
|
||||
if (declaration.initializer) {
|
||||
return checkExpressionCached(declaration.initializer);
|
||||
return getBaseTypeOfLiteralType(checkExpressionCached(declaration.initializer));
|
||||
}
|
||||
return parentType;
|
||||
}
|
||||
@@ -2982,7 +2980,9 @@ namespace ts {
|
||||
if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & TypeFlags.Undefined)) {
|
||||
type = getTypeWithFacts(type, TypeFacts.NEUndefined);
|
||||
}
|
||||
return type;
|
||||
return declaration.initializer ?
|
||||
getUnionType([type, checkExpressionCached(declaration.initializer)], /*subtypeReduction*/ true) :
|
||||
type;
|
||||
}
|
||||
|
||||
function getTypeForVariableLikeDeclarationFromJSDocComment(declaration: VariableLikeDeclaration) {
|
||||
@@ -3091,7 +3091,9 @@ namespace ts {
|
||||
|
||||
// Use the type of the initializer expression if one is present
|
||||
if (declaration.initializer) {
|
||||
return addOptionality(checkExpressionCached(declaration.initializer), /*optional*/ declaration.questionToken && includeOptionality);
|
||||
const exprType = checkExpressionCached(declaration.initializer);
|
||||
const type = getCombinedNodeFlags(declaration) & NodeFlags.Const || getCombinedModifierFlags(declaration) & ModifierFlags.Readonly ? exprType : getBaseTypeOfLiteralType(exprType);
|
||||
return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality);
|
||||
}
|
||||
|
||||
// If it is a short-hand property assignment, use the type of the identifier
|
||||
@@ -3113,7 +3115,8 @@ namespace ts {
|
||||
// pattern. Otherwise, it is the type any.
|
||||
function getTypeFromBindingElement(element: BindingElement, includePatternInType?: boolean, reportErrors?: boolean): Type {
|
||||
if (element.initializer) {
|
||||
return checkExpressionCached(element.initializer);
|
||||
const exprType = checkExpressionCached(element.initializer);
|
||||
return getCombinedNodeFlags(element) & NodeFlags.Const ? exprType : getBaseTypeOfLiteralType(exprType);
|
||||
}
|
||||
if (isBindingPattern(element.name)) {
|
||||
return getTypeFromBindingPattern(<BindingPattern>element.name, includePatternInType, reportErrors);
|
||||
@@ -3397,7 +3400,7 @@ namespace ts {
|
||||
function getTypeOfEnumMember(symbol: Symbol): Type {
|
||||
const links = getSymbolLinks(symbol);
|
||||
if (!links.type) {
|
||||
links.type = getDeclaredTypeOfEnum(getParentOfSymbol(symbol));
|
||||
links.type = getDeclaredTypeOfEnumMember(symbol);
|
||||
}
|
||||
return links.type;
|
||||
}
|
||||
@@ -5712,7 +5715,7 @@ namespace ts {
|
||||
function getInferenceMapper(context: InferenceContext): TypeMapper {
|
||||
if (!context.mapper) {
|
||||
const mapper: TypeMapper = t => {
|
||||
const typeParameters = context.typeParameters;
|
||||
const typeParameters = context.signature.typeParameters;
|
||||
for (let i = 0; i < typeParameters.length; i++) {
|
||||
if (t === typeParameters[i]) {
|
||||
context.inferences[i].isFixed = true;
|
||||
@@ -5721,7 +5724,7 @@ namespace ts {
|
||||
}
|
||||
return t;
|
||||
};
|
||||
mapper.mappedTypes = context.typeParameters;
|
||||
mapper.mappedTypes = context.signature.typeParameters;
|
||||
mapper.context = context;
|
||||
context.mapper = mapper;
|
||||
}
|
||||
@@ -6204,8 +6207,14 @@ namespace ts {
|
||||
if (source === target) {
|
||||
return true;
|
||||
}
|
||||
if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & SymbolFlags.RegularEnum) || !(target.symbol.flags & SymbolFlags.RegularEnum)) {
|
||||
return false;
|
||||
const id = source.id + "," + target.id;
|
||||
if (enumRelation[id] !== undefined) {
|
||||
return enumRelation[id];
|
||||
}
|
||||
if (source.symbol.name !== target.symbol.name ||
|
||||
!(source.symbol.flags & SymbolFlags.RegularEnum) || !(target.symbol.flags & SymbolFlags.RegularEnum) ||
|
||||
(source.flags & TypeFlags.Union) !== (target.flags & TypeFlags.Union)) {
|
||||
return enumRelation[id] = false;
|
||||
}
|
||||
const targetEnumType = getTypeOfSymbol(target.symbol);
|
||||
for (const property of getPropertiesOfType(getTypeOfSymbol(source.symbol))) {
|
||||
@@ -6216,11 +6225,11 @@ namespace ts {
|
||||
errorReporter(Diagnostics.Property_0_is_missing_in_type_1, property.name,
|
||||
typeToString(target, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType));
|
||||
}
|
||||
return false;
|
||||
return enumRelation[id] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return enumRelation[id] = true;
|
||||
}
|
||||
|
||||
function isSimpleTypeRelatedTo(source: Type, target: Type, relation: Map<RelationComparisonResult>, errorReporter?: ErrorReporter) {
|
||||
@@ -6235,8 +6244,18 @@ namespace ts {
|
||||
if (source.flags & TypeFlags.Null && (!strictNullChecks || target.flags & TypeFlags.Null)) return true;
|
||||
if (relation === assignableRelation || relation === comparableRelation) {
|
||||
if (source.flags & TypeFlags.Any) return true;
|
||||
if (source.flags & (TypeFlags.Number | TypeFlags.NumberLiteral) && target.flags & TypeFlags.Enum) return true;
|
||||
if (source.flags & TypeFlags.NumberLiteral && target.flags & TypeFlags.EnumLiteral && (<LiteralType>source).text === (<LiteralType>target).text) return true;
|
||||
if ((source.flags & TypeFlags.Number | source.flags & TypeFlags.NumberLiteral) && target.flags & TypeFlags.EnumLike) return true;
|
||||
if (source.flags & TypeFlags.EnumLiteral &&
|
||||
target.flags & TypeFlags.EnumLiteral &&
|
||||
(<LiteralType>source).text === (<LiteralType>target).text &&
|
||||
isEnumTypeRelatedTo((<EnumLiteralType>source).baseType, (<EnumLiteralType>target).baseType, errorReporter)) {
|
||||
return true;
|
||||
}
|
||||
if (source.flags & TypeFlags.EnumLiteral &&
|
||||
target.flags & TypeFlags.Enum &&
|
||||
isEnumTypeRelatedTo(<EnumType>target, (<EnumLiteralType>source).baseType, errorReporter)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -7146,15 +7165,36 @@ namespace ts {
|
||||
return true;
|
||||
}
|
||||
|
||||
function literalTypesWithSameBaseType(types: Type[]): boolean {
|
||||
let commonBaseType: Type;
|
||||
for (const t of types) {
|
||||
const baseType = getBaseTypeOfLiteralType(t);
|
||||
if (!commonBaseType) {
|
||||
commonBaseType = baseType;
|
||||
}
|
||||
if (baseType === t || baseType !== commonBaseType) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// When the candidate types are all literal types with the same base type, the common
|
||||
// supertype is a union of those literal types. Otherwise, the common supertype is the
|
||||
// first type that is a supertype of each of the other types.
|
||||
function getSupertypeOrUnion(types: Type[]): Type {
|
||||
return literalTypesWithSameBaseType(types) ? getUnionType(types) : forEach(types, t => isSupertypeOfEach(t, types) ? t : undefined);
|
||||
}
|
||||
|
||||
function getCommonSupertype(types: Type[]): Type {
|
||||
if (!strictNullChecks) {
|
||||
return forEach(types, t => isSupertypeOfEach(t, types) ? t : undefined);
|
||||
return getSupertypeOrUnion(types);
|
||||
}
|
||||
const primaryTypes = filter(types, t => !(t.flags & TypeFlags.Nullable));
|
||||
if (!primaryTypes.length) {
|
||||
return getUnionType(types, /*subtypeReduction*/ true);
|
||||
}
|
||||
const supertype = forEach(primaryTypes, t => isSupertypeOfEach(t, primaryTypes) ? t : undefined);
|
||||
const supertype = getSupertypeOrUnion(primaryTypes);
|
||||
return supertype && includeFalsyTypes(supertype, getFalsyFlagsOfTypes(types) & TypeFlags.Nullable);
|
||||
}
|
||||
|
||||
@@ -7218,18 +7258,18 @@ namespace ts {
|
||||
return (type.flags & (TypeFlags.Literal | TypeFlags.Undefined | TypeFlags.Null)) !== 0;
|
||||
}
|
||||
|
||||
function isUnitUnionType(type: Type): boolean {
|
||||
function isLiteralType(type: Type): boolean {
|
||||
return type.flags & TypeFlags.Boolean ? true :
|
||||
type.flags & TypeFlags.Union ? type.flags & TypeFlags.Enum ? true : !forEach((<UnionType>type).types, t => !isUnitType(t)) :
|
||||
isUnitType(type);
|
||||
}
|
||||
|
||||
function getBaseTypeOfUnitType(type: Type): Type {
|
||||
function getBaseTypeOfLiteralType(type: Type): Type {
|
||||
return type.flags & TypeFlags.StringLiteral ? stringType :
|
||||
type.flags & TypeFlags.NumberLiteral ? numberType :
|
||||
type.flags & TypeFlags.BooleanLiteral ? booleanType :
|
||||
type.flags & TypeFlags.EnumLiteral ? (<EnumLiteralType>type).baseType :
|
||||
type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Enum) ? getUnionType(map((<UnionType>type).types, getBaseTypeOfUnitType)) :
|
||||
type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Enum) ? getUnionType(map((<UnionType>type).types, getBaseTypeOfLiteralType)) :
|
||||
type;
|
||||
}
|
||||
|
||||
@@ -7483,14 +7523,13 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function createInferenceContext(typeParameters: TypeParameter[], inferUnionTypes: boolean): InferenceContext {
|
||||
const inferences = map(typeParameters, createTypeInferencesObject);
|
||||
|
||||
function createInferenceContext(signature: Signature, inferUnionTypes: boolean): InferenceContext {
|
||||
const inferences = map(signature.typeParameters, createTypeInferencesObject);
|
||||
return {
|
||||
typeParameters,
|
||||
signature,
|
||||
inferUnionTypes,
|
||||
inferences,
|
||||
inferredTypes: new Array(typeParameters.length),
|
||||
inferredTypes: new Array(signature.typeParameters.length),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7498,6 +7537,7 @@ namespace ts {
|
||||
return {
|
||||
primary: undefined,
|
||||
secondary: undefined,
|
||||
topLevel: true,
|
||||
isFixed: false,
|
||||
};
|
||||
}
|
||||
@@ -7519,13 +7559,18 @@ namespace ts {
|
||||
return type.couldContainTypeParameters;
|
||||
}
|
||||
|
||||
function inferTypes(context: InferenceContext, source: Type, target: Type) {
|
||||
function isTypeParameterAtTopLevel(type: Type, typeParameter: TypeParameter): boolean {
|
||||
return type === typeParameter || type.flags & TypeFlags.UnionOrIntersection && forEach((<UnionOrIntersectionType>type).types, t => isTypeParameterAtTopLevel(t, typeParameter));
|
||||
}
|
||||
|
||||
function inferTypes(context: InferenceContext, originalSource: Type, originalTarget: Type) {
|
||||
const typeParameters = context.signature.typeParameters;
|
||||
let sourceStack: Type[];
|
||||
let targetStack: Type[];
|
||||
let depth = 0;
|
||||
let inferiority = 0;
|
||||
const visited = createMap<boolean>();
|
||||
inferFromTypes(source, target);
|
||||
inferFromTypes(originalSource, originalTarget);
|
||||
|
||||
function isInProcess(source: Type, target: Type) {
|
||||
for (let i = 0; i < depth; i++) {
|
||||
@@ -7579,7 +7624,6 @@ namespace ts {
|
||||
if (source.flags & TypeFlags.ContainsAnyFunctionType) {
|
||||
return;
|
||||
}
|
||||
const typeParameters = context.typeParameters;
|
||||
for (let i = 0; i < typeParameters.length; i++) {
|
||||
if (target === typeParameters[i]) {
|
||||
const inferences = context.inferences[i];
|
||||
@@ -7596,6 +7640,9 @@ namespace ts {
|
||||
if (!contains(candidates, source)) {
|
||||
candidates.push(source);
|
||||
}
|
||||
if (!isTypeParameterAtTopLevel(originalTarget, <TypeParameter>target)) {
|
||||
inferences.topLevel = false;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -7616,7 +7663,7 @@ namespace ts {
|
||||
let typeParameter: TypeParameter;
|
||||
// First infer to each type in union or intersection that isn't a type parameter
|
||||
for (const t of targetTypes) {
|
||||
if (t.flags & TypeFlags.TypeParameter && contains(context.typeParameters, t)) {
|
||||
if (t.flags & TypeFlags.TypeParameter && contains(typeParameters, t)) {
|
||||
typeParameter = <TypeParameter>t;
|
||||
typeParameterCount++;
|
||||
}
|
||||
@@ -7691,8 +7738,12 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function inferFromParameterTypes(source: Type, target: Type) {
|
||||
return inferFromTypes(source, target);
|
||||
}
|
||||
|
||||
function inferFromSignature(source: Signature, target: Signature) {
|
||||
forEachMatchingParameterType(source, target, inferFromTypes);
|
||||
forEachMatchingParameterType(source, target, inferFromParameterTypes);
|
||||
|
||||
if (source.typePredicate && target.typePredicate && source.typePredicate.kind === target.typePredicate.kind) {
|
||||
inferFromTypes(source.typePredicate.type, target.typePredicate.type);
|
||||
@@ -7751,14 +7802,28 @@ namespace ts {
|
||||
return inferences.primary || inferences.secondary || emptyArray;
|
||||
}
|
||||
|
||||
function hasPrimitiveConstraint(type: TypeParameter): boolean {
|
||||
const constraint = getConstraintOfTypeParameter(type);
|
||||
return constraint && maybeTypeOfKind(constraint, TypeFlags.Primitive);
|
||||
}
|
||||
|
||||
function getInferredType(context: InferenceContext, index: number): Type {
|
||||
let inferredType = context.inferredTypes[index];
|
||||
let inferenceSucceeded: boolean;
|
||||
if (!inferredType) {
|
||||
const inferences = getInferenceCandidates(context, index);
|
||||
if (inferences.length) {
|
||||
// We widen inferred literal types if
|
||||
// all inferences were made to top-level ocurrences of the type parameter, and
|
||||
// the type parameter has no constraint or its constraint includes no primitive or literal types, and
|
||||
// the type parameter was fixed during inference or does not occur at top-level in the return type.
|
||||
const signature = context.signature;
|
||||
const widenLiteralTypes = context.inferences[index].topLevel &&
|
||||
!hasPrimitiveConstraint(signature.typeParameters[index]) &&
|
||||
(context.inferences[index].isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), signature.typeParameters[index]));
|
||||
const baseInferences = widenLiteralTypes ? map(inferences, getBaseTypeOfLiteralType) : inferences;
|
||||
// Infer widened union or supertype, or the unknown type for no common supertype
|
||||
const unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences, /*subtypeReduction*/ true) : getCommonSupertype(inferences);
|
||||
const unionOrSuperType = context.inferUnionTypes ? getUnionType(baseInferences, /*subtypeReduction*/ true) : getCommonSupertype(baseInferences);
|
||||
inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType;
|
||||
inferenceSucceeded = !!unionOrSuperType;
|
||||
}
|
||||
@@ -7774,7 +7839,7 @@ namespace ts {
|
||||
|
||||
// Only do the constraint check if inference succeeded (to prevent cascading errors)
|
||||
if (inferenceSucceeded) {
|
||||
const constraint = getConstraintOfTypeParameter(context.typeParameters[index]);
|
||||
const constraint = getConstraintOfTypeParameter(context.signature.typeParameters[index]);
|
||||
if (constraint) {
|
||||
const instantiatedConstraint = instantiateType(constraint, getInferenceMapper(context));
|
||||
if (!isTypeAssignableTo(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
|
||||
@@ -7921,7 +7986,7 @@ namespace ts {
|
||||
if (prop && prop.flags & SymbolFlags.SyntheticProperty) {
|
||||
if ((<TransientSymbol>prop).isDiscriminantProperty === undefined) {
|
||||
(<TransientSymbol>prop).isDiscriminantProperty = !(<TransientSymbol>prop).hasCommonType &&
|
||||
isUnitUnionType(getTypeOfSymbol(prop));
|
||||
isLiteralType(getTypeOfSymbol(prop));
|
||||
}
|
||||
return (<TransientSymbol>prop).isDiscriminantProperty;
|
||||
}
|
||||
@@ -8324,7 +8389,8 @@ namespace ts {
|
||||
// Assignments only narrow the computed type if the declared type is a union type. Thus, we
|
||||
// only need to evaluate the assigned type if the declared type is a union type.
|
||||
if (isMatchingReference(reference, node)) {
|
||||
return declaredType.flags & TypeFlags.Union ?
|
||||
const isIncrementOrDecrement = node.parent.kind === SyntaxKind.PrefixUnaryExpression || node.parent.kind === SyntaxKind.PostfixUnaryExpression;
|
||||
return declaredType.flags & TypeFlags.Union && !isIncrementOrDecrement ?
|
||||
getAssignmentReducedType(<UnionType>declaredType, getInitialOrAssignedType(node)) :
|
||||
declaredType;
|
||||
}
|
||||
@@ -8537,6 +8603,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function narrowTypeByEquality(type: Type, operator: SyntaxKind, value: Expression, assumeTrue: boolean): Type {
|
||||
if (type.flags & TypeFlags.Any) {
|
||||
return type;
|
||||
}
|
||||
if (operator === SyntaxKind.ExclamationEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken) {
|
||||
assumeTrue = !assumeTrue;
|
||||
}
|
||||
@@ -8680,7 +8749,7 @@ namespace ts {
|
||||
// type. Otherwise, the types are completely unrelated, so narrow to an intersection of the
|
||||
// two types.
|
||||
const targetType = type.flags & TypeFlags.TypeParameter ? getApparentType(type) : type;
|
||||
return isTypeSubtypeOf(candidate, targetType) ? candidate :
|
||||
return isTypeSubtypeOf(candidate, type) ? candidate :
|
||||
isTypeAssignableTo(type, candidate) ? type :
|
||||
isTypeAssignableTo(candidate, targetType) ? candidate :
|
||||
getIntersectionType([type, candidate]);
|
||||
@@ -8920,6 +8989,7 @@ namespace ts {
|
||||
const isParameter = getRootDeclaration(declaration).kind === SyntaxKind.Parameter;
|
||||
const declarationContainer = getControlFlowContainer(declaration);
|
||||
let flowContainer = getControlFlowContainer(node);
|
||||
const isOuterVariable = flowContainer !== declarationContainer;
|
||||
// When the control flow originates in a function expression or arrow function and we are referencing
|
||||
// a const variable or parameter from an outer function, we extend the origin of the control flow
|
||||
// analysis to include the immediately enclosing function.
|
||||
@@ -8932,7 +9002,7 @@ namespace ts {
|
||||
// the entire control flow graph from the variable's declaration (i.e. when the flow container and
|
||||
// declaration container are the same).
|
||||
const assumeInitialized = !strictNullChecks || (type.flags & TypeFlags.Any) !== 0 || isParameter ||
|
||||
flowContainer !== declarationContainer || isInAmbientContext(declaration);
|
||||
isOuterVariable || isInAmbientContext(declaration);
|
||||
const flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer);
|
||||
// A variable is considered uninitialized when it is possible to analyze the entire control flow graph
|
||||
// from declaration to use, and when the variable's declared type doesn't include undefined but the
|
||||
@@ -9439,14 +9509,14 @@ namespace ts {
|
||||
if (parameter.dotDotDotToken) {
|
||||
const restTypes: Type[] = [];
|
||||
for (let i = indexOfParameter; i < iife.arguments.length; i++) {
|
||||
restTypes.push(getTypeOfExpression(iife.arguments[i]));
|
||||
restTypes.push(getBaseTypeOfLiteralType(checkExpression(iife.arguments[i])));
|
||||
}
|
||||
return createArrayType(getUnionType(restTypes));
|
||||
}
|
||||
const links = getNodeLinks(iife);
|
||||
const cached = links.resolvedSignature;
|
||||
links.resolvedSignature = anySignature;
|
||||
const type = checkExpression(iife.arguments[indexOfParameter]);
|
||||
const type = getBaseTypeOfLiteralType(checkExpression(iife.arguments[indexOfParameter]));
|
||||
links.resolvedSignature = cached;
|
||||
return type;
|
||||
}
|
||||
@@ -9797,6 +9867,7 @@ namespace ts {
|
||||
case SyntaxKind.BinaryExpression:
|
||||
return getContextualTypeForBinaryOperand(node);
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
return getContextualTypeForObjectLiteralElement(<ObjectLiteralElement>parent);
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
return getContextualTypeForElementExpression(node);
|
||||
@@ -9816,31 +9887,6 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function isLiteralTypeLocation(node: Node): boolean {
|
||||
const parent = node.parent;
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.BinaryExpression:
|
||||
switch ((<BinaryExpression>parent).operatorToken.kind) {
|
||||
case SyntaxKind.EqualsEqualsEqualsToken:
|
||||
case SyntaxKind.ExclamationEqualsEqualsToken:
|
||||
case SyntaxKind.EqualsEqualsToken:
|
||||
case SyntaxKind.ExclamationEqualsToken:
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
return (node === (<ConditionalExpression>parent).whenTrue ||
|
||||
node === (<ConditionalExpression>parent).whenFalse) &&
|
||||
isLiteralTypeLocation(parent);
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
return isLiteralTypeLocation(parent);
|
||||
case SyntaxKind.CaseClause:
|
||||
case SyntaxKind.LiteralType:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the given type is an object or union type, if that type has a single signature, and if
|
||||
// that signature is non-generic, return the signature. Otherwise return undefined.
|
||||
function getNonGenericSignature(type: Type): Signature {
|
||||
@@ -9977,7 +10023,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
const type = checkExpression(e, contextualMapper);
|
||||
const type = checkExpressionForMutableLocation(e, contextualMapper);
|
||||
elementTypes.push(type);
|
||||
}
|
||||
hasSpreadElement = hasSpreadElement || e.kind === SyntaxKind.SpreadElementExpression;
|
||||
@@ -10121,7 +10167,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
Debug.assert(memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment);
|
||||
type = checkExpression((<ShorthandPropertyAssignment>memberDecl).name, contextualMapper);
|
||||
type = checkExpressionForMutableLocation((<ShorthandPropertyAssignment>memberDecl).name, contextualMapper);
|
||||
}
|
||||
typeFlags |= type.flags;
|
||||
const prop = <TransientSymbol>createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.name);
|
||||
@@ -10846,10 +10892,7 @@ namespace ts {
|
||||
checkClassPropertyAccess(node, left, apparentType, prop);
|
||||
}
|
||||
|
||||
let propType = getTypeOfSymbol(prop);
|
||||
if (prop.flags & SymbolFlags.EnumMember && isLiteralContextForType(<Expression>node, propType)) {
|
||||
propType = getDeclaredTypeOfSymbol(prop);
|
||||
}
|
||||
const propType = getTypeOfSymbol(prop);
|
||||
|
||||
// Only compute control flow type if this is a property access expression that isn't an
|
||||
// assignment target, and the referenced property was declared as a variable, property,
|
||||
@@ -11267,7 +11310,7 @@ namespace ts {
|
||||
|
||||
// Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec)
|
||||
function instantiateSignatureInContextOf(signature: Signature, contextualSignature: Signature, contextualMapper: TypeMapper): Signature {
|
||||
const context = createInferenceContext(signature.typeParameters, /*inferUnionTypes*/ true);
|
||||
const context = createInferenceContext(signature, /*inferUnionTypes*/ true);
|
||||
forEachMatchingParameterType(contextualSignature, signature, (source, target) => {
|
||||
// Type parameters from outer context referenced by source type are fixed by instantiation of the source type
|
||||
inferTypes(context, instantiateType(source, contextualMapper), target);
|
||||
@@ -11923,7 +11966,7 @@ namespace ts {
|
||||
let candidate: Signature;
|
||||
let typeArgumentsAreValid: boolean;
|
||||
const inferenceContext = originalCandidate.typeParameters
|
||||
? createInferenceContext(originalCandidate.typeParameters, /*inferUnionTypes*/ false)
|
||||
? createInferenceContext(originalCandidate, /*inferUnionTypes*/ false)
|
||||
: undefined;
|
||||
|
||||
while (true) {
|
||||
@@ -12354,7 +12397,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function checkAssertion(node: AssertionExpression) {
|
||||
const exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression));
|
||||
const exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(checkExpression(node.expression)));
|
||||
|
||||
checkSourceElement(node.type);
|
||||
const targetType = getTypeFromTypeNode(node.type);
|
||||
@@ -12544,20 +12587,8 @@ namespace ts {
|
||||
return isAsync ? createPromiseReturnType(func, voidType) : voidType;
|
||||
}
|
||||
}
|
||||
// When yield/return statements are contextually typed we allow the return type to be a union type.
|
||||
// Otherwise we require the yield/return expressions to have a best common supertype.
|
||||
type = contextualSignature ? getUnionType(types, /*subtypeReduction*/ true) : getCommonSupertype(types);
|
||||
if (!type) {
|
||||
if (funcIsGenerator) {
|
||||
error(func, Diagnostics.No_best_common_type_exists_among_yield_expressions);
|
||||
return createIterableIteratorType(unknownType);
|
||||
}
|
||||
else {
|
||||
error(func, Diagnostics.No_best_common_type_exists_among_return_expressions);
|
||||
// Defer to unioning the return types so we get a) downstream errors earlier and b) better Salsa experience
|
||||
return isAsync ? createPromiseReturnType(func, getUnionType(types, /*subtypeReduction*/ true)) : getUnionType(types, /*subtypeReduction*/ true);
|
||||
}
|
||||
}
|
||||
// Return a union of the return expression types.
|
||||
type = getUnionType(types, /*subtypeReduction*/ true);
|
||||
|
||||
if (funcIsGenerator) {
|
||||
type = createIterableIteratorType(type);
|
||||
@@ -12566,6 +12597,9 @@ namespace ts {
|
||||
if (!contextualSignature) {
|
||||
reportErrorsFromWidening(func, type);
|
||||
}
|
||||
if (isUnitType(type) && !(contextualSignature && isLiteralContextualType(getReturnTypeOfSignature(contextualSignature)))) {
|
||||
type = getBaseTypeOfLiteralType(type);
|
||||
}
|
||||
|
||||
const widenedType = getWidenedType(type);
|
||||
// From within an async function you can return either a non-promise value or a promise. Any
|
||||
@@ -12601,7 +12635,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
const type = checkExpression(node.expression);
|
||||
if (!isUnitUnionType(type)) {
|
||||
if (!isLiteralType(type)) {
|
||||
return false;
|
||||
}
|
||||
const switchTypes = getSwitchClauseTypes(node);
|
||||
@@ -12944,7 +12978,7 @@ namespace ts {
|
||||
|
||||
function checkPrefixUnaryExpression(node: PrefixUnaryExpression): Type {
|
||||
const operandType = checkExpression(node.operand);
|
||||
if (node.operator === SyntaxKind.MinusToken && node.operand.kind === SyntaxKind.NumericLiteral && isLiteralContextForType(node, numberType)) {
|
||||
if (node.operator === SyntaxKind.MinusToken && node.operand.kind === SyntaxKind.NumericLiteral) {
|
||||
return getLiteralTypeForText(TypeFlags.NumberLiteral, "" + -(<LiteralExpression>node.operand).text);
|
||||
}
|
||||
switch (node.operator) {
|
||||
@@ -13405,11 +13439,11 @@ namespace ts {
|
||||
case SyntaxKind.ExclamationEqualsToken:
|
||||
case SyntaxKind.EqualsEqualsEqualsToken:
|
||||
case SyntaxKind.ExclamationEqualsEqualsToken:
|
||||
const leftIsUnit = isUnitUnionType(leftType);
|
||||
const rightIsUnit = isUnitUnionType(rightType);
|
||||
if (!leftIsUnit || !rightIsUnit) {
|
||||
leftType = leftIsUnit ? getBaseTypeOfUnitType(leftType) : leftType;
|
||||
rightType = rightIsUnit ? getBaseTypeOfUnitType(rightType) : rightType;
|
||||
const leftIsLiteral = isLiteralType(leftType);
|
||||
const rightIsLiteral = isLiteralType(rightType);
|
||||
if (!leftIsLiteral || !rightIsLiteral) {
|
||||
leftType = leftIsLiteral ? getBaseTypeOfLiteralType(leftType) : leftType;
|
||||
rightType = rightIsLiteral ? getBaseTypeOfLiteralType(rightType) : rightType;
|
||||
}
|
||||
if (!isTypeEqualityComparableTo(leftType, rightType) && !isTypeEqualityComparableTo(rightType, leftType)) {
|
||||
reportOperatorError();
|
||||
@@ -13421,7 +13455,7 @@ namespace ts {
|
||||
return checkInExpression(left, right, leftType, rightType);
|
||||
case SyntaxKind.AmpersandAmpersandToken:
|
||||
return getTypeFacts(leftType) & TypeFacts.Truthy ?
|
||||
includeFalsyTypes(rightType, getFalsyFlags(strictNullChecks ? leftType : getBaseTypeOfUnitType(rightType))) :
|
||||
includeFalsyTypes(rightType, getFalsyFlags(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType))) :
|
||||
leftType;
|
||||
case SyntaxKind.BarBarToken:
|
||||
return getTypeFacts(leftType) & TypeFacts.Falsy ?
|
||||
@@ -13558,64 +13592,18 @@ namespace ts {
|
||||
return getBestChoiceType(type1, type2);
|
||||
}
|
||||
|
||||
function typeContainsLiteralFromEnum(type: Type, enumType: EnumType) {
|
||||
if (type.flags & TypeFlags.Union) {
|
||||
for (const t of (<UnionType>type).types) {
|
||||
if (t.flags & TypeFlags.EnumLiteral && (<EnumLiteralType>t).baseType === enumType) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (type.flags & TypeFlags.EnumLiteral) {
|
||||
return (<EnumLiteralType>type).baseType === enumType;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isLiteralContextForType(node: Expression, type: Type) {
|
||||
if (isLiteralTypeLocation(node)) {
|
||||
return true;
|
||||
}
|
||||
let contextualType = getContextualType(node);
|
||||
if (contextualType) {
|
||||
if (contextualType.flags & TypeFlags.TypeParameter) {
|
||||
const apparentType = getApparentTypeOfTypeParameter(<TypeParameter>contextualType);
|
||||
// If the type parameter is constrained to the base primitive type we're checking for,
|
||||
// consider this a literal context. For example, given a type parameter 'T extends string',
|
||||
// this causes us to infer string literal types for T.
|
||||
if (type === apparentType) {
|
||||
return true;
|
||||
}
|
||||
contextualType = apparentType;
|
||||
}
|
||||
if (type.flags & TypeFlags.String) {
|
||||
return maybeTypeOfKind(contextualType, TypeFlags.StringLiteral);
|
||||
}
|
||||
if (type.flags & TypeFlags.Number) {
|
||||
return maybeTypeOfKind(contextualType, (TypeFlags.NumberLiteral | TypeFlags.EnumLiteral));
|
||||
}
|
||||
if (type.flags & TypeFlags.Boolean) {
|
||||
return maybeTypeOfKind(contextualType, TypeFlags.BooleanLiteral) && !isTypeAssignableTo(booleanType, contextualType);
|
||||
}
|
||||
if (type.flags & TypeFlags.Enum) {
|
||||
return typeContainsLiteralFromEnum(contextualType, <EnumType>type);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkLiteralExpression(node: Expression): Type {
|
||||
if (node.kind === SyntaxKind.NumericLiteral) {
|
||||
checkGrammarNumericLiteral(<NumericLiteral>node);
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.StringLiteral:
|
||||
return isLiteralContextForType(node, stringType) ? getLiteralTypeForText(TypeFlags.StringLiteral, (<LiteralExpression>node).text) : stringType;
|
||||
return getLiteralTypeForText(TypeFlags.StringLiteral, (<LiteralExpression>node).text);
|
||||
case SyntaxKind.NumericLiteral:
|
||||
return isLiteralContextForType(node, numberType) ? getLiteralTypeForText(TypeFlags.NumberLiteral, (<LiteralExpression>node).text) : numberType;
|
||||
return getLiteralTypeForText(TypeFlags.NumberLiteral, (<LiteralExpression>node).text);
|
||||
case SyntaxKind.TrueKeyword:
|
||||
case SyntaxKind.FalseKeyword:
|
||||
return isLiteralContextForType(node, booleanType) ? node.kind === SyntaxKind.TrueKeyword ? trueType : falseType : booleanType;
|
||||
return node.kind === SyntaxKind.TrueKeyword ? trueType : falseType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13654,6 +13642,28 @@ namespace ts {
|
||||
return links.resolvedType;
|
||||
}
|
||||
|
||||
function isLiteralContextualType(contextualType: Type) {
|
||||
if (contextualType) {
|
||||
if (contextualType.flags & TypeFlags.TypeParameter) {
|
||||
const apparentType = getApparentTypeOfTypeParameter(<TypeParameter>contextualType);
|
||||
// If the type parameter is constrained to the base primitive type we're checking for,
|
||||
// consider this a literal context. For example, given a type parameter 'T extends string',
|
||||
// this causes us to infer string literal types for T.
|
||||
if (apparentType.flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Enum)) {
|
||||
return true;
|
||||
}
|
||||
contextualType = apparentType;
|
||||
}
|
||||
return maybeTypeOfKind(contextualType, TypeFlags.Literal);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkExpressionForMutableLocation(node: Expression, contextualMapper?: TypeMapper): Type {
|
||||
const type = checkExpression(node, contextualMapper);
|
||||
return isLiteralContextualType(getContextualType(node)) ? type : getBaseTypeOfLiteralType(type);
|
||||
}
|
||||
|
||||
function checkPropertyAssignment(node: PropertyAssignment, contextualMapper?: TypeMapper): Type {
|
||||
// Do not use hasDynamicName here, because that returns false for well known symbols.
|
||||
// We want to perform checkComputedPropertyName for all computed properties, including
|
||||
@@ -13662,7 +13672,7 @@ namespace ts {
|
||||
checkComputedPropertyName(<ComputedPropertyName>node.name);
|
||||
}
|
||||
|
||||
return checkExpression((<PropertyAssignment>node).initializer, contextualMapper);
|
||||
return checkExpressionForMutableLocation((<PropertyAssignment>node).initializer, contextualMapper);
|
||||
}
|
||||
|
||||
function checkObjectLiteralMethod(node: MethodDeclaration, contextualMapper?: TypeMapper): Type {
|
||||
|
||||
@@ -294,6 +294,7 @@ namespace ts {
|
||||
"classic": ModuleResolutionKind.Classic,
|
||||
}),
|
||||
description: Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
|
||||
paramType: Diagnostics.STRATEGY,
|
||||
},
|
||||
{
|
||||
name: "allowUnusedLabels",
|
||||
|
||||
@@ -1063,10 +1063,6 @@
|
||||
"category": "Error",
|
||||
"code": 2353
|
||||
},
|
||||
"No best common type exists among return expressions.": {
|
||||
"category": "Error",
|
||||
"code": 2354
|
||||
},
|
||||
"A function whose declared type is neither 'void' nor 'any' must return a value.": {
|
||||
"category": "Error",
|
||||
"code": 2355
|
||||
@@ -1631,10 +1627,6 @@
|
||||
"category": "Error",
|
||||
"code": 2503
|
||||
},
|
||||
"No best common type exists among yield expressions.": {
|
||||
"category": "Error",
|
||||
"code": 2504
|
||||
},
|
||||
"A generator cannot have a 'void' type annotation.": {
|
||||
"category": "Error",
|
||||
"code": 2505
|
||||
@@ -2476,6 +2468,10 @@
|
||||
"category": "Message",
|
||||
"code": 6038
|
||||
},
|
||||
"STRATEGY": {
|
||||
"category": "Message",
|
||||
"code": 6039
|
||||
},
|
||||
"Compilation complete. Watching for file changes.": {
|
||||
"category": "Message",
|
||||
"code": 6042
|
||||
@@ -2875,7 +2871,7 @@
|
||||
"Element implicitly has an 'any' type because index expression is not of type 'number'.": {
|
||||
"category": "Error",
|
||||
"code": 7015
|
||||
},
|
||||
},
|
||||
"Index signature of object type implicitly has an 'any' type.": {
|
||||
"category": "Error",
|
||||
"code": 7017
|
||||
|
||||
@@ -252,7 +252,9 @@ const _super = (function (geti, seti) {
|
||||
|
||||
// Emit helpers from all the files
|
||||
if (isBundledEmit && moduleKind) {
|
||||
forEach(sourceFiles, emitEmitHelpers);
|
||||
for (const sourceFile of sourceFiles) {
|
||||
emitEmitHelpers(sourceFile);
|
||||
}
|
||||
}
|
||||
|
||||
// Print each transformed source file.
|
||||
|
||||
@@ -541,7 +541,7 @@ namespace ts {
|
||||
*
|
||||
* @param node A ClassDeclaration node.
|
||||
*/
|
||||
function visitClassDeclaration(node: ClassDeclaration): Statement {
|
||||
function visitClassDeclaration(node: ClassDeclaration): VisitResult<Statement> {
|
||||
// [source]
|
||||
// class C { }
|
||||
//
|
||||
@@ -552,8 +552,17 @@ namespace ts {
|
||||
// return C;
|
||||
// }());
|
||||
|
||||
const modifierFlags = getModifierFlags(node);
|
||||
const isExported = modifierFlags & ModifierFlags.Export;
|
||||
const isDefault = modifierFlags & ModifierFlags.Default;
|
||||
|
||||
// Add an `export` modifier to the statement if needed (for `--target es5 --module es6`)
|
||||
const modifiers = isExported && !isDefault
|
||||
? filter(node.modifiers, isExportModifier)
|
||||
: undefined;
|
||||
|
||||
const statement = createVariableStatement(
|
||||
/*modifiers*/ undefined,
|
||||
modifiers,
|
||||
createVariableDeclarationList([
|
||||
createVariableDeclaration(
|
||||
getDeclarationName(node, /*allowComments*/ true),
|
||||
@@ -566,9 +575,26 @@ namespace ts {
|
||||
|
||||
setOriginalNode(statement, node);
|
||||
startOnNewLine(statement);
|
||||
|
||||
// Add an `export default` statement for default exports (for `--target es5 --module es6`)
|
||||
if (isExported && isDefault) {
|
||||
const statements: Statement[] = [statement];
|
||||
statements.push(createExportAssignment(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*isExportEquals*/ false,
|
||||
getDeclarationName(node, /*allowComments*/ false)
|
||||
));
|
||||
return statements;
|
||||
}
|
||||
|
||||
return statement;
|
||||
}
|
||||
|
||||
function isExportModifier(node: Modifier) {
|
||||
return node.kind === SyntaxKind.ExportKeyword;
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a ClassExpression and transforms it into an expression.
|
||||
*
|
||||
|
||||
@@ -2629,7 +2629,7 @@ namespace ts {
|
||||
* Flush the final label of the generator function body.
|
||||
*/
|
||||
function flushFinalLabel(operationIndex: number): void {
|
||||
if (!lastOperationWasCompletion) {
|
||||
if (isFinalLabelReachable(operationIndex)) {
|
||||
tryEnterLabel(operationIndex);
|
||||
withBlockStack = undefined;
|
||||
writeReturn(/*expression*/ undefined, /*operationLocation*/ undefined);
|
||||
@@ -2642,6 +2642,34 @@ namespace ts {
|
||||
updateLabelExpressions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the final label of the generator function body
|
||||
* is reachable by user code.
|
||||
*/
|
||||
function isFinalLabelReachable(operationIndex: number) {
|
||||
// if the last operation was *not* a completion (return/throw) then
|
||||
// the final label is reachable.
|
||||
if (!lastOperationWasCompletion) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// if there are no labels defined or referenced, then the final label is
|
||||
// not reachable.
|
||||
if (!labelOffsets || !labelExpressions) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// if the label for this offset is referenced, then the final label
|
||||
// is reachable.
|
||||
for (let label = 0; label < labelOffsets.length; label++) {
|
||||
if (labelOffsets[label] === operationIndex && labelExpressions[label]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a case clause for the last label and sets the new label.
|
||||
*
|
||||
|
||||
@@ -705,7 +705,7 @@ namespace ts {
|
||||
createFunctionDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
/*asteriskToken*/ undefined,
|
||||
node.asteriskToken,
|
||||
name,
|
||||
/*typeParameters*/ undefined,
|
||||
node.parameters,
|
||||
|
||||
@@ -2593,13 +2593,14 @@ namespace ts {
|
||||
export interface TypeInferences {
|
||||
primary: Type[]; // Inferences made directly to a type parameter
|
||||
secondary: Type[]; // Inferences made to a type parameter in a union type
|
||||
topLevel: boolean; // True if all inferences were made from top-level (not nested in object type) locations
|
||||
isFixed: boolean; // Whether the type parameter is fixed, as defined in section 4.12.2 of the TypeScript spec
|
||||
// If a type parameter is fixed, no more inferences can be made for the type parameter
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export interface InferenceContext {
|
||||
typeParameters: TypeParameter[]; // Type parameters for which inferences are made
|
||||
signature: Signature; // Generic signature for which inferences are made
|
||||
inferUnionTypes: boolean; // Infer union types for disjoint candidates (otherwise undefinedType)
|
||||
inferences: TypeInferences[]; // Inferences made for each type parameter
|
||||
inferredTypes: Type[]; // Inferred type for each type parameter
|
||||
|
||||
@@ -954,26 +954,20 @@ namespace FourSlash {
|
||||
assert.equal(actual, expected);
|
||||
}
|
||||
|
||||
public verifyQuickInfoString(negative: boolean, expectedText?: string, expectedDocumentation?: string) {
|
||||
public verifyQuickInfoString(negative: boolean, expectedText: string, expectedDocumentation?: string) {
|
||||
const actualQuickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
const actualQuickInfoText = actualQuickInfo ? ts.displayPartsToString(actualQuickInfo.displayParts) : "";
|
||||
const actualQuickInfoDocumentation = actualQuickInfo ? ts.displayPartsToString(actualQuickInfo.documentation) : "";
|
||||
|
||||
if (negative) {
|
||||
if (expectedText !== undefined) {
|
||||
assert.notEqual(actualQuickInfoText, expectedText, this.messageAtLastKnownMarker("quick info text"));
|
||||
}
|
||||
// TODO: should be '==='?
|
||||
if (expectedDocumentation != undefined) {
|
||||
assert.notEqual(actualQuickInfoText, expectedText, this.messageAtLastKnownMarker("quick info text"));
|
||||
if (expectedDocumentation !== undefined) {
|
||||
assert.notEqual(actualQuickInfoDocumentation, expectedDocumentation, this.messageAtLastKnownMarker("quick info doc comment"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (expectedText !== undefined) {
|
||||
assert.equal(actualQuickInfoText, expectedText, this.messageAtLastKnownMarker("quick info text"));
|
||||
}
|
||||
// TODO: should be '==='?
|
||||
if (expectedDocumentation != undefined) {
|
||||
assert.equal(actualQuickInfoText, expectedText, this.messageAtLastKnownMarker("quick info text"));
|
||||
if (expectedDocumentation !== undefined) {
|
||||
assert.equal(actualQuickInfoDocumentation, expectedDocumentation, this.assertionMessageAtLastKnownMarker("quick info doc"));
|
||||
}
|
||||
}
|
||||
@@ -2969,7 +2963,7 @@ namespace FourSlashInterface {
|
||||
this.state.verifyErrorExistsAfterMarker(markerName, !this.negative, /*after*/ false);
|
||||
}
|
||||
|
||||
public quickInfoIs(expectedText?: string, expectedDocumentation?: string) {
|
||||
public quickInfoIs(expectedText: string, expectedDocumentation?: string) {
|
||||
this.state.verifyQuickInfoString(this.negative, expectedText, expectedDocumentation);
|
||||
}
|
||||
|
||||
|
||||
@@ -408,6 +408,9 @@ namespace Harness.LanguageService {
|
||||
getCompletionEntryDetails(fileName: string, position: number, entryName: string): ts.CompletionEntryDetails {
|
||||
return unwrapJSONCallResult(this.shim.getCompletionEntryDetails(fileName, position, entryName));
|
||||
}
|
||||
getCompletionEntrySymbol(fileName: string, position: number, entryName: string): ts.Symbol {
|
||||
throw new Error("getCompletionEntrySymbol not implemented across the shim layer.");
|
||||
}
|
||||
getQuickInfoAtPosition(fileName: string, position: number): ts.QuickInfo {
|
||||
return unwrapJSONCallResult(this.shim.getQuickInfoAtPosition(fileName, position));
|
||||
}
|
||||
|
||||
@@ -246,6 +246,10 @@ namespace ts.server {
|
||||
return response.body[0];
|
||||
}
|
||||
|
||||
getCompletionEntrySymbol(fileName: string, position: number, entryName: string): Symbol {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
getNavigateToItems(searchValue: string): NavigateToItem[] {
|
||||
const args: protocol.NavtoRequestArgs = {
|
||||
searchValue,
|
||||
|
||||
+100
-36
@@ -335,10 +335,11 @@ namespace ts.Completions {
|
||||
const baseDirectory = getDirectoryPath(absolutePath);
|
||||
const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
|
||||
|
||||
if (directoryProbablyExists(baseDirectory, host)) {
|
||||
if (host.readDirectory) {
|
||||
// Enumerate the available files if possible
|
||||
const files = host.readDirectory(baseDirectory, extensions, /*exclude*/undefined, /*include*/["./*"]);
|
||||
if (tryDirectoryExists(host, baseDirectory)) {
|
||||
// Enumerate the available files if possible
|
||||
const files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/undefined, /*include*/["./*"]);
|
||||
|
||||
if (files) {
|
||||
const foundFiles = createMap<boolean>();
|
||||
for (let filePath of files) {
|
||||
filePath = normalizePath(filePath);
|
||||
@@ -359,8 +360,9 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
// If possible, get folder completion as well
|
||||
if (host.getDirectories) {
|
||||
const directories = host.getDirectories(baseDirectory);
|
||||
const directories = tryGetDirectories(host, baseDirectory);
|
||||
|
||||
if (directories) {
|
||||
for (const directory of directories) {
|
||||
const directoryName = getBaseFileName(normalizePath(directory));
|
||||
|
||||
@@ -449,22 +451,24 @@ namespace ts.Completions {
|
||||
// doesn't support. For now, this is safer but slower
|
||||
const includeGlob = normalizedSuffix ? "**/*" : "./*";
|
||||
|
||||
const matches = host.readDirectory(baseDirectory, fileExtensions, undefined, [includeGlob]);
|
||||
const result: string[] = [];
|
||||
const matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]);
|
||||
if (matches) {
|
||||
const result: string[] = [];
|
||||
|
||||
// Trim away prefix and suffix
|
||||
for (const match of matches) {
|
||||
const normalizedMatch = normalizePath(match);
|
||||
if (!endsWith(normalizedMatch, normalizedSuffix) || !startsWith(normalizedMatch, completePrefix)) {
|
||||
continue;
|
||||
// Trim away prefix and suffix
|
||||
for (const match of matches) {
|
||||
const normalizedMatch = normalizePath(match);
|
||||
if (!endsWith(normalizedMatch, normalizedSuffix) || !startsWith(normalizedMatch, completePrefix)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const start = completePrefix.length;
|
||||
const length = normalizedMatch.length - start - normalizedSuffix.length;
|
||||
|
||||
result.push(removeFileExtension(normalizedMatch.substr(start, length)));
|
||||
}
|
||||
|
||||
const start = completePrefix.length;
|
||||
const length = normalizedMatch.length - start - normalizedSuffix.length;
|
||||
|
||||
result.push(removeFileExtension(normalizedMatch.substr(start, length)));
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -499,13 +503,14 @@ namespace ts.Completions {
|
||||
if (!isNestedModule) {
|
||||
nonRelativeModules.push(visibleModule.moduleName);
|
||||
}
|
||||
else if (host.readDirectory && startsWith(visibleModule.moduleName, moduleNameFragment)) {
|
||||
const nestedFiles = host.readDirectory(visibleModule.moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]);
|
||||
|
||||
for (let f of nestedFiles) {
|
||||
f = normalizePath(f);
|
||||
const nestedModule = removeFileExtension(getBaseFileName(f));
|
||||
nonRelativeModules.push(nestedModule);
|
||||
else if (startsWith(visibleModule.moduleName, moduleNameFragment)) {
|
||||
const nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]);
|
||||
if (nestedFiles) {
|
||||
for (let f of nestedFiles) {
|
||||
f = normalizePath(f);
|
||||
const nestedModule = removeFileExtension(getBaseFileName(f));
|
||||
nonRelativeModules.push(nestedModule);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -570,9 +575,17 @@ namespace ts.Completions {
|
||||
}
|
||||
}
|
||||
else if (host.getDirectories) {
|
||||
const typeRoots = getEffectiveTypeRoots(options, host);
|
||||
for (const root of typeRoots) {
|
||||
getCompletionEntriesFromDirectories(host, options, root, span, result);
|
||||
let typeRoots: string[];
|
||||
try {
|
||||
// Wrap in try catch because getEffectiveTypeRoots touches the filesystem
|
||||
typeRoots = getEffectiveTypeRoots(options, host);
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
if (typeRoots) {
|
||||
for (const root of typeRoots) {
|
||||
getCompletionEntriesFromDirectories(host, options, root, span, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -588,10 +601,13 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
function getCompletionEntriesFromDirectories(host: LanguageServiceHost, options: CompilerOptions, directory: string, span: TextSpan, result: CompletionEntry[]) {
|
||||
if (host.getDirectories && directoryProbablyExists(directory, host)) {
|
||||
for (let typeDirectory of host.getDirectories(directory)) {
|
||||
typeDirectory = normalizePath(typeDirectory);
|
||||
result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName, span));
|
||||
if (host.getDirectories && tryDirectoryExists(host, directory)) {
|
||||
const directories = tryGetDirectories(host, directory);
|
||||
if (directories) {
|
||||
for (let typeDirectory of directories) {
|
||||
typeDirectory = normalizePath(typeDirectory);
|
||||
result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName, span));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -600,7 +616,7 @@ namespace ts.Completions {
|
||||
const paths: string[] = [];
|
||||
let currentConfigPath: string;
|
||||
while (true) {
|
||||
currentConfigPath = findConfigFile(currentDir, (f) => host.fileExists(f), "package.json");
|
||||
currentConfigPath = findConfigFile(currentDir, (f) => tryFileExists(host, f), "package.json");
|
||||
if (currentConfigPath) {
|
||||
paths.push(currentConfigPath);
|
||||
|
||||
@@ -652,8 +668,8 @@ namespace ts.Completions {
|
||||
|
||||
function tryReadingPackageJson(filePath: string) {
|
||||
try {
|
||||
const fileText = host.readFile(filePath);
|
||||
return JSON.parse(fileText);
|
||||
const fileText = tryReadFile(host, filePath);
|
||||
return fileText ? JSON.parse(fileText) : undefined;
|
||||
}
|
||||
catch (e) {
|
||||
return undefined;
|
||||
@@ -736,6 +752,22 @@ namespace ts.Completions {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getCompletionEntrySymbol(typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number, entryName: string): Symbol {
|
||||
// Compute all the completion symbols again.
|
||||
const completionData = getCompletionData(typeChecker, log, sourceFile, position);
|
||||
if (completionData) {
|
||||
const { symbols, location } = completionData;
|
||||
|
||||
// Find the symbol with the matching entry name.
|
||||
// We don't need to perform character checks here because we're only comparing the
|
||||
// name against 'entryName' (which is known to be good), not building a new
|
||||
// completion entry.
|
||||
return forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location) === entryName ? s : undefined);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getCompletionData(typeChecker: TypeChecker, log: (message: string) => void, sourceFile: SourceFile, position: number) {
|
||||
const isJavaScriptFile = isSourceFileJavaScript(sourceFile);
|
||||
|
||||
@@ -1644,4 +1676,36 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
const nodeModulesDependencyKeys = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
|
||||
|
||||
function tryGetDirectories(host: LanguageServiceHost, directoryName: string): string[] {
|
||||
return tryIOAndConsumeErrors(host, host.getDirectories, directoryName);
|
||||
}
|
||||
|
||||
function tryReadDirectory(host: LanguageServiceHost, path: string, extensions?: string[], exclude?: string[], include?: string[]): string[] {
|
||||
return tryIOAndConsumeErrors(host, host.readDirectory, path, extensions, exclude, include);
|
||||
}
|
||||
|
||||
function tryReadFile(host: LanguageServiceHost, path: string): string {
|
||||
return tryIOAndConsumeErrors(host, host.readFile, path);
|
||||
}
|
||||
|
||||
function tryFileExists(host: LanguageServiceHost, path: string): boolean {
|
||||
return tryIOAndConsumeErrors(host, host.fileExists, path);
|
||||
}
|
||||
|
||||
function tryDirectoryExists(host: LanguageServiceHost, path: string): boolean {
|
||||
try {
|
||||
return directoryProbablyExists(path, host);
|
||||
}
|
||||
catch (e) {}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function tryIOAndConsumeErrors<T>(host: LanguageServiceHost, toApply: (...a: any[]) => T, ...args: any[]) {
|
||||
try {
|
||||
return toApply && toApply.apply(host, args);
|
||||
}
|
||||
catch (e) {}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,240 @@
|
||||
namespace ts {
|
||||
/**
|
||||
* The document registry represents a store of SourceFile objects that can be shared between
|
||||
* multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST)
|
||||
* of files in the context.
|
||||
* SourceFile objects account for most of the memory usage by the language service. Sharing
|
||||
* the same DocumentRegistry instance between different instances of LanguageService allow
|
||||
* for more efficient memory utilization since all projects will share at least the library
|
||||
* file (lib.d.ts).
|
||||
*
|
||||
* A more advanced use of the document registry is to serialize sourceFile objects to disk
|
||||
* and re-hydrate them when needed.
|
||||
*
|
||||
* To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it
|
||||
* to all subsequent createLanguageService calls.
|
||||
*/
|
||||
export interface DocumentRegistry {
|
||||
/**
|
||||
* Request a stored SourceFile with a given fileName and compilationSettings.
|
||||
* The first call to acquire will call createLanguageServiceSourceFile to generate
|
||||
* the SourceFile if was not found in the registry.
|
||||
*
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
* @parm scriptSnapshot Text of the file. Only used if the file was not found
|
||||
* in the registry and a new one was created.
|
||||
* @parm version Current version of the file. Only used if the file was not found
|
||||
* in the registry and a new one was created.
|
||||
*/
|
||||
acquireDocument(
|
||||
fileName: string,
|
||||
compilationSettings: CompilerOptions,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
scriptKind?: ScriptKind): SourceFile;
|
||||
|
||||
acquireDocumentWithKey(
|
||||
fileName: string,
|
||||
path: Path,
|
||||
compilationSettings: CompilerOptions,
|
||||
key: DocumentRegistryBucketKey,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
scriptKind?: ScriptKind): SourceFile;
|
||||
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
* and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile
|
||||
* to get an updated SourceFile.
|
||||
*
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
* @param scriptSnapshot Text of the file.
|
||||
* @param version Current version of the file.
|
||||
*/
|
||||
updateDocument(
|
||||
fileName: string,
|
||||
compilationSettings: CompilerOptions,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
scriptKind?: ScriptKind): SourceFile;
|
||||
|
||||
updateDocumentWithKey(
|
||||
fileName: string,
|
||||
path: Path,
|
||||
compilationSettings: CompilerOptions,
|
||||
key: DocumentRegistryBucketKey,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
scriptKind?: ScriptKind): SourceFile;
|
||||
|
||||
getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey;
|
||||
/**
|
||||
* Informs the DocumentRegistry that a file is not needed any longer.
|
||||
*
|
||||
* Note: It is not allowed to call release on a SourceFile that was not acquired from
|
||||
* this registry originally.
|
||||
*
|
||||
* @param fileName The name of the file to be released
|
||||
* @param compilationSettings The compilation settings used to acquire the file
|
||||
*/
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
|
||||
|
||||
releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void;
|
||||
|
||||
reportStats(): string;
|
||||
}
|
||||
|
||||
export type DocumentRegistryBucketKey = string & { __bucketKey: any };
|
||||
|
||||
interface DocumentRegistryEntry {
|
||||
sourceFile: SourceFile;
|
||||
|
||||
// The number of language services that this source file is referenced in. When no more
|
||||
// language services are referencing the file, then the file can be removed from the
|
||||
// registry.
|
||||
languageServiceRefCount: number;
|
||||
owners: string[];
|
||||
}
|
||||
|
||||
export function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory = ""): DocumentRegistry {
|
||||
// Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have
|
||||
// for those settings.
|
||||
const buckets = createMap<FileMap<DocumentRegistryEntry>>();
|
||||
const getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames);
|
||||
|
||||
function getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey {
|
||||
return <DocumentRegistryBucketKey>`_${settings.target}|${settings.module}|${settings.noResolve}|${settings.jsx}|${settings.allowJs}|${settings.baseUrl}|${JSON.stringify(settings.typeRoots)}|${JSON.stringify(settings.rootDirs)}|${JSON.stringify(settings.paths)}`;
|
||||
}
|
||||
|
||||
function getBucketForCompilationSettings(key: DocumentRegistryBucketKey, createIfMissing: boolean): FileMap<DocumentRegistryEntry> {
|
||||
let bucket = buckets[key];
|
||||
if (!bucket && createIfMissing) {
|
||||
buckets[key] = bucket = createFileMap<DocumentRegistryEntry>();
|
||||
}
|
||||
return bucket;
|
||||
}
|
||||
|
||||
function reportStats() {
|
||||
const bucketInfoArray = Object.keys(buckets).filter(name => name && name.charAt(0) === "_").map(name => {
|
||||
const entries = buckets[name];
|
||||
const sourceFiles: { name: string; refCount: number; references: string[]; }[] = [];
|
||||
entries.forEachValue((key, entry) => {
|
||||
sourceFiles.push({
|
||||
name: key,
|
||||
refCount: entry.languageServiceRefCount,
|
||||
references: entry.owners.slice(0)
|
||||
});
|
||||
});
|
||||
sourceFiles.sort((x, y) => y.refCount - x.refCount);
|
||||
return {
|
||||
bucket: name,
|
||||
sourceFiles
|
||||
};
|
||||
});
|
||||
return JSON.stringify(bucketInfoArray, undefined, 2);
|
||||
}
|
||||
|
||||
function acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile {
|
||||
const path = toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
const key = getKeyForCompilationSettings(compilationSettings);
|
||||
return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
|
||||
}
|
||||
|
||||
function acquireDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile {
|
||||
return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind);
|
||||
}
|
||||
|
||||
function updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile {
|
||||
const path = toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
const key = getKeyForCompilationSettings(compilationSettings);
|
||||
return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
|
||||
}
|
||||
|
||||
function updateDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile {
|
||||
return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
|
||||
}
|
||||
|
||||
function acquireOrUpdateDocument(
|
||||
fileName: string,
|
||||
path: Path,
|
||||
compilationSettings: CompilerOptions,
|
||||
key: DocumentRegistryBucketKey,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
acquiring: boolean,
|
||||
scriptKind?: ScriptKind): SourceFile {
|
||||
|
||||
const bucket = getBucketForCompilationSettings(key, /*createIfMissing*/ true);
|
||||
let entry = bucket.get(path);
|
||||
if (!entry) {
|
||||
Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?");
|
||||
|
||||
// Have never seen this file with these settings. Create a new source file for it.
|
||||
const sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents*/ false, scriptKind);
|
||||
|
||||
entry = {
|
||||
sourceFile: sourceFile,
|
||||
languageServiceRefCount: 0,
|
||||
owners: []
|
||||
};
|
||||
bucket.set(path, entry);
|
||||
}
|
||||
else {
|
||||
// We have an entry for this file. However, it may be for a different version of
|
||||
// the script snapshot. If so, update it appropriately. Otherwise, we can just
|
||||
// return it as is.
|
||||
if (entry.sourceFile.version !== version) {
|
||||
entry.sourceFile = updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version,
|
||||
scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot));
|
||||
}
|
||||
}
|
||||
|
||||
// If we're acquiring, then this is the first time this LS is asking for this document.
|
||||
// Increase our ref count so we know there's another LS using the document. If we're
|
||||
// not acquiring, then that means the LS is 'updating' the file instead, and that means
|
||||
// it has already acquired the document previously. As such, we do not need to increase
|
||||
// the ref count.
|
||||
if (acquiring) {
|
||||
entry.languageServiceRefCount++;
|
||||
}
|
||||
|
||||
return entry.sourceFile;
|
||||
}
|
||||
|
||||
function releaseDocument(fileName: string, compilationSettings: CompilerOptions): void {
|
||||
const path = toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
const key = getKeyForCompilationSettings(compilationSettings);
|
||||
return releaseDocumentWithKey(path, key);
|
||||
}
|
||||
|
||||
function releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void {
|
||||
const bucket = getBucketForCompilationSettings(key, /*createIfMissing*/false);
|
||||
Debug.assert(bucket !== undefined);
|
||||
|
||||
const entry = bucket.get(path);
|
||||
entry.languageServiceRefCount--;
|
||||
|
||||
Debug.assert(entry.languageServiceRefCount >= 0);
|
||||
if (entry.languageServiceRefCount === 0) {
|
||||
bucket.remove(path);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
acquireDocument,
|
||||
acquireDocumentWithKey,
|
||||
updateDocument,
|
||||
updateDocumentWithKey,
|
||||
releaseDocument,
|
||||
releaseDocumentWithKey,
|
||||
reportStats,
|
||||
getKeyForCompilationSettings
|
||||
};
|
||||
}
|
||||
}
|
||||
+7
-146
@@ -7,6 +7,7 @@
|
||||
/// <reference path='classifier.ts' />
|
||||
/// <reference path='completions.ts' />
|
||||
/// <reference path='documentHighlights.ts' />
|
||||
/// <reference path='documentRegistry.ts' />
|
||||
/// <reference path='findAllReferences.ts' />
|
||||
/// <reference path='goToDefinition.ts' />
|
||||
/// <reference path='jsDoc.ts' />
|
||||
@@ -668,16 +669,6 @@ namespace ts {
|
||||
scriptKind: ScriptKind;
|
||||
}
|
||||
|
||||
interface DocumentRegistryEntry {
|
||||
sourceFile: SourceFile;
|
||||
|
||||
// The number of language services that this source file is referenced in. When no more
|
||||
// language services are referencing the file, then the file can be removed from the
|
||||
// registry.
|
||||
languageServiceRefCount: number;
|
||||
owners: string[];
|
||||
}
|
||||
|
||||
export interface DisplayPartsSymbolWriter extends SymbolWriter {
|
||||
displayParts(): SymbolDisplayPart[];
|
||||
}
|
||||
@@ -899,142 +890,6 @@ namespace ts {
|
||||
return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true, sourceFile.scriptKind);
|
||||
}
|
||||
|
||||
export function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory = ""): DocumentRegistry {
|
||||
// Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have
|
||||
// for those settings.
|
||||
const buckets = createMap<FileMap<DocumentRegistryEntry>>();
|
||||
const getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames);
|
||||
|
||||
function getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey {
|
||||
return <DocumentRegistryBucketKey>`_${settings.target}|${settings.module}|${settings.noResolve}|${settings.jsx}|${settings.allowJs}|${settings.baseUrl}|${JSON.stringify(settings.typeRoots)}|${JSON.stringify(settings.rootDirs)}|${JSON.stringify(settings.paths)}`;
|
||||
}
|
||||
|
||||
function getBucketForCompilationSettings(key: DocumentRegistryBucketKey, createIfMissing: boolean): FileMap<DocumentRegistryEntry> {
|
||||
let bucket = buckets[key];
|
||||
if (!bucket && createIfMissing) {
|
||||
buckets[key] = bucket = createFileMap<DocumentRegistryEntry>();
|
||||
}
|
||||
return bucket;
|
||||
}
|
||||
|
||||
function reportStats() {
|
||||
const bucketInfoArray = Object.keys(buckets).filter(name => name && name.charAt(0) === "_").map(name => {
|
||||
const entries = buckets[name];
|
||||
const sourceFiles: { name: string; refCount: number; references: string[]; }[] = [];
|
||||
entries.forEachValue((key, entry) => {
|
||||
sourceFiles.push({
|
||||
name: key,
|
||||
refCount: entry.languageServiceRefCount,
|
||||
references: entry.owners.slice(0)
|
||||
});
|
||||
});
|
||||
sourceFiles.sort((x, y) => y.refCount - x.refCount);
|
||||
return {
|
||||
bucket: name,
|
||||
sourceFiles
|
||||
};
|
||||
});
|
||||
return JSON.stringify(bucketInfoArray, undefined, 2);
|
||||
}
|
||||
|
||||
function acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile {
|
||||
const path = toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
const key = getKeyForCompilationSettings(compilationSettings);
|
||||
return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
|
||||
}
|
||||
|
||||
function acquireDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile {
|
||||
return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind);
|
||||
}
|
||||
|
||||
function updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile {
|
||||
const path = toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
const key = getKeyForCompilationSettings(compilationSettings);
|
||||
return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
|
||||
}
|
||||
|
||||
function updateDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile {
|
||||
return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
|
||||
}
|
||||
|
||||
function acquireOrUpdateDocument(
|
||||
fileName: string,
|
||||
path: Path,
|
||||
compilationSettings: CompilerOptions,
|
||||
key: DocumentRegistryBucketKey,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
acquiring: boolean,
|
||||
scriptKind?: ScriptKind): SourceFile {
|
||||
|
||||
const bucket = getBucketForCompilationSettings(key, /*createIfMissing*/ true);
|
||||
let entry = bucket.get(path);
|
||||
if (!entry) {
|
||||
Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?");
|
||||
|
||||
// Have never seen this file with these settings. Create a new source file for it.
|
||||
const sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents*/ false, scriptKind);
|
||||
|
||||
entry = {
|
||||
sourceFile: sourceFile,
|
||||
languageServiceRefCount: 0,
|
||||
owners: []
|
||||
};
|
||||
bucket.set(path, entry);
|
||||
}
|
||||
else {
|
||||
// We have an entry for this file. However, it may be for a different version of
|
||||
// the script snapshot. If so, update it appropriately. Otherwise, we can just
|
||||
// return it as is.
|
||||
if (entry.sourceFile.version !== version) {
|
||||
entry.sourceFile = updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version,
|
||||
scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot));
|
||||
}
|
||||
}
|
||||
|
||||
// If we're acquiring, then this is the first time this LS is asking for this document.
|
||||
// Increase our ref count so we know there's another LS using the document. If we're
|
||||
// not acquiring, then that means the LS is 'updating' the file instead, and that means
|
||||
// it has already acquired the document previously. As such, we do not need to increase
|
||||
// the ref count.
|
||||
if (acquiring) {
|
||||
entry.languageServiceRefCount++;
|
||||
}
|
||||
|
||||
return entry.sourceFile;
|
||||
}
|
||||
|
||||
function releaseDocument(fileName: string, compilationSettings: CompilerOptions): void {
|
||||
const path = toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
const key = getKeyForCompilationSettings(compilationSettings);
|
||||
return releaseDocumentWithKey(path, key);
|
||||
}
|
||||
|
||||
function releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void {
|
||||
const bucket = getBucketForCompilationSettings(key, /*createIfMissing*/false);
|
||||
Debug.assert(bucket !== undefined);
|
||||
|
||||
const entry = bucket.get(path);
|
||||
entry.languageServiceRefCount--;
|
||||
|
||||
Debug.assert(entry.languageServiceRefCount >= 0);
|
||||
if (entry.languageServiceRefCount === 0) {
|
||||
bucket.remove(path);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
acquireDocument,
|
||||
acquireDocumentWithKey,
|
||||
updateDocument,
|
||||
updateDocumentWithKey,
|
||||
releaseDocument,
|
||||
releaseDocumentWithKey,
|
||||
reportStats,
|
||||
getKeyForCompilationSettings
|
||||
};
|
||||
}
|
||||
|
||||
class CancellationTokenObject implements CancellationToken {
|
||||
constructor(private cancellationToken: HostCancellationToken) {
|
||||
}
|
||||
@@ -1351,6 +1206,11 @@ namespace ts {
|
||||
return Completions.getCompletionEntryDetails(program.getTypeChecker(), log, program.getCompilerOptions(), getValidSourceFile(fileName), position, entryName);
|
||||
}
|
||||
|
||||
function getCompletionEntrySymbol(fileName: string, position: number, entryName: string): Symbol {
|
||||
synchronizeHostData();
|
||||
return Completions.getCompletionEntrySymbol(program.getTypeChecker(), log, program.getCompilerOptions(), getValidSourceFile(fileName), position, entryName);
|
||||
}
|
||||
|
||||
function getQuickInfoAtPosition(fileName: string, position: number): QuickInfo {
|
||||
synchronizeHostData();
|
||||
|
||||
@@ -1913,6 +1773,7 @@ namespace ts {
|
||||
getEncodedSemanticClassifications,
|
||||
getCompletionsAtPosition,
|
||||
getCompletionEntryDetails,
|
||||
getCompletionEntrySymbol,
|
||||
getSignatureHelpItems,
|
||||
getQuickInfoAtPosition,
|
||||
getDefinitionAtPosition,
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
"classifier.ts",
|
||||
"completions.ts",
|
||||
"documentHighlights.ts",
|
||||
"documentRegistry.ts",
|
||||
"findAllReferences.ts",
|
||||
"goToDefinition.ts",
|
||||
"jsDoc.ts",
|
||||
|
||||
+1
-93
@@ -194,6 +194,7 @@ namespace ts {
|
||||
|
||||
getCompletionsAtPosition(fileName: string, position: number): CompletionInfo;
|
||||
getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails;
|
||||
getCompletionEntrySymbol(fileName: string, position: number, entryName: string): Symbol;
|
||||
|
||||
getQuickInfoAtPosition(fileName: string, position: number): QuickInfo;
|
||||
|
||||
@@ -575,99 +576,6 @@ namespace ts {
|
||||
getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications;
|
||||
}
|
||||
|
||||
/**
|
||||
* The document registry represents a store of SourceFile objects that can be shared between
|
||||
* multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST)
|
||||
* of files in the context.
|
||||
* SourceFile objects account for most of the memory usage by the language service. Sharing
|
||||
* the same DocumentRegistry instance between different instances of LanguageService allow
|
||||
* for more efficient memory utilization since all projects will share at least the library
|
||||
* file (lib.d.ts).
|
||||
*
|
||||
* A more advanced use of the document registry is to serialize sourceFile objects to disk
|
||||
* and re-hydrate them when needed.
|
||||
*
|
||||
* To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it
|
||||
* to all subsequent createLanguageService calls.
|
||||
*/
|
||||
export interface DocumentRegistry {
|
||||
/**
|
||||
* Request a stored SourceFile with a given fileName and compilationSettings.
|
||||
* The first call to acquire will call createLanguageServiceSourceFile to generate
|
||||
* the SourceFile if was not found in the registry.
|
||||
*
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
* @parm scriptSnapshot Text of the file. Only used if the file was not found
|
||||
* in the registry and a new one was created.
|
||||
* @parm version Current version of the file. Only used if the file was not found
|
||||
* in the registry and a new one was created.
|
||||
*/
|
||||
acquireDocument(
|
||||
fileName: string,
|
||||
compilationSettings: CompilerOptions,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
scriptKind?: ScriptKind): SourceFile;
|
||||
|
||||
acquireDocumentWithKey(
|
||||
fileName: string,
|
||||
path: Path,
|
||||
compilationSettings: CompilerOptions,
|
||||
key: DocumentRegistryBucketKey,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
scriptKind?: ScriptKind): SourceFile;
|
||||
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
* and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile
|
||||
* to get an updated SourceFile.
|
||||
*
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
* @param scriptSnapshot Text of the file.
|
||||
* @param version Current version of the file.
|
||||
*/
|
||||
updateDocument(
|
||||
fileName: string,
|
||||
compilationSettings: CompilerOptions,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
scriptKind?: ScriptKind): SourceFile;
|
||||
|
||||
updateDocumentWithKey(
|
||||
fileName: string,
|
||||
path: Path,
|
||||
compilationSettings: CompilerOptions,
|
||||
key: DocumentRegistryBucketKey,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
scriptKind?: ScriptKind): SourceFile;
|
||||
|
||||
getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey;
|
||||
/**
|
||||
* Informs the DocumentRegistry that a file is not needed any longer.
|
||||
*
|
||||
* Note: It is not allowed to call release on a SourceFile that was not acquired from
|
||||
* this registry originally.
|
||||
*
|
||||
* @param fileName The name of the file to be released
|
||||
* @param compilationSettings The compilation settings used to acquire the file
|
||||
*/
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
|
||||
|
||||
releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void;
|
||||
|
||||
reportStats(): string;
|
||||
}
|
||||
|
||||
export type DocumentRegistryBucketKey = string & { __bucketKey: any };
|
||||
|
||||
// TODO: move these to enums
|
||||
export namespace ScriptElementKind {
|
||||
export const unknown = "";
|
||||
|
||||
@@ -56,6 +56,6 @@ var p = new A.Point(0, 0); // unexpected error here, bug 840000
|
||||
>A.Point : typeof A.Point
|
||||
>A : typeof A
|
||||
>Point : typeof A.Point
|
||||
>0 : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>0 : 0
|
||||
|
||||
|
||||
+2
-2
@@ -50,6 +50,6 @@ var p = new A.Point(0, 0); // unexpected error here, bug 840000
|
||||
>A.Point : typeof A.Point
|
||||
>A : typeof A
|
||||
>Point : typeof A.Point
|
||||
>0 : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>0 : 0
|
||||
|
||||
|
||||
+2
-2
@@ -15,9 +15,9 @@ function Point() {
|
||||
return { x: 0, y: 0 };
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts ===
|
||||
|
||||
+6
-6
@@ -11,9 +11,9 @@ class Point {
|
||||
>Point : Point
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
module Point {
|
||||
@@ -21,7 +21,7 @@ module Point {
|
||||
|
||||
function Origin() { return ""; }// not an error, since not exported
|
||||
>Origin : () => string
|
||||
>"" : string
|
||||
>"" : ""
|
||||
}
|
||||
|
||||
|
||||
@@ -40,9 +40,9 @@ module A {
|
||||
>Point : Point
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
export module Point {
|
||||
@@ -50,6 +50,6 @@ module A {
|
||||
|
||||
function Origin() { return ""; }// not an error since not exported
|
||||
>Origin : () => string
|
||||
>"" : string
|
||||
>"" : ""
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -11,9 +11,9 @@ class Point {
|
||||
>Point : Point
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
module Point {
|
||||
@@ -21,7 +21,7 @@ module Point {
|
||||
|
||||
var Origin = ""; // not an error, since not exported
|
||||
>Origin : string
|
||||
>"" : string
|
||||
>"" : ""
|
||||
}
|
||||
|
||||
|
||||
@@ -40,9 +40,9 @@ module A {
|
||||
>Point : Point
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
export module Point {
|
||||
@@ -50,6 +50,6 @@ module A {
|
||||
|
||||
var Origin = ""; // not an error since not exported
|
||||
>Origin : string
|
||||
>"" : string
|
||||
>"" : ""
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,5 +7,5 @@ class C {
|
||||
|
||||
x = 10;
|
||||
>x : number
|
||||
>10 : number
|
||||
>10 : 10
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
for (var v of [true]) { }
|
||||
>v : boolean
|
||||
>[true] : boolean[]
|
||||
>true : boolean
|
||||
>true : true
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ function foo() {
|
||||
return { x: 0 };
|
||||
>{ x: 0 } : { x: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
}
|
||||
for (foo().x of []) {
|
||||
>foo().x : number
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
for (let v of ['a', 'b', 'c']) {
|
||||
>v : string
|
||||
>['a', 'b', 'c'] : string[]
|
||||
>'a' : string
|
||||
>'b' : string
|
||||
>'c' : string
|
||||
>'a' : "a"
|
||||
>'b' : "b"
|
||||
>'c' : "c"
|
||||
|
||||
var x = v;
|
||||
>x : string
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
var a = [1, 2, 3];
|
||||
>a : number[]
|
||||
>[1, 2, 3] : number[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
for (var v of a) {
|
||||
>v : number
|
||||
@@ -12,5 +12,5 @@ for (var v of a) {
|
||||
|
||||
let a = 0;
|
||||
>a : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
var a = [1, 2, 3];
|
||||
>a : number[]
|
||||
>[1, 2, 3] : number[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
for (var v of a) {
|
||||
>v : number
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
for (var v of ['a', 'b', 'c'])
|
||||
>v : string
|
||||
>['a', 'b', 'c'] : string[]
|
||||
>'a' : string
|
||||
>'b' : string
|
||||
>'c' : string
|
||||
>'a' : "a"
|
||||
>'b' : "b"
|
||||
>'c' : "c"
|
||||
|
||||
var x = v;
|
||||
>x : string
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,6): error TS2461: Type 'string | number' is not an array type.
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,7): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,14): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,7): error TS2322: Type '1' is not assignable to type 'string'.
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,14): error TS2322: Type '""' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts (3 errors) ====
|
||||
@@ -10,9 +10,9 @@ tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,14): error
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2461: Type 'string | number' is not an array type.
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type '1' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type '""' is not assignable to type 'number'.
|
||||
a;
|
||||
b;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ function foo() {
|
||||
return { x: 0 };
|
||||
>{ x: 0 } : { x: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
}
|
||||
for (foo().x of []) {
|
||||
>foo().x : number
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck1.ts ===
|
||||
for (var v of "") { }
|
||||
>v : string
|
||||
>"" : string
|
||||
>"" : ""
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck12.ts(1,17): error TS2495: Type 'number' is not an array type or a string type.
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck12.ts(1,17): error TS2495: Type '0' is not an array type or a string type.
|
||||
|
||||
|
||||
==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck12.ts (1 errors) ====
|
||||
for (const v of 0) { }
|
||||
~
|
||||
!!! error TS2495: Type 'number' is not an array type or a string type.
|
||||
!!! error TS2495: Type '0' is not an array type or a string type.
|
||||
@@ -2,5 +2,5 @@
|
||||
for (var v of [true]) { }
|
||||
>v : boolean
|
||||
>[true] : boolean[]
|
||||
>true : boolean
|
||||
>true : true
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
var tuple: [string, number] = ["", 0];
|
||||
>tuple : [string, number]
|
||||
>["", 0] : [string, number]
|
||||
>"" : string
|
||||
>0 : number
|
||||
>"" : ""
|
||||
>0 : 0
|
||||
|
||||
for (var v of tuple) { }
|
||||
>v : string | number
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
var array = [1,2,3];
|
||||
>array : number[]
|
||||
>[1,2,3] : number[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
var sum = 0;
|
||||
>sum : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
|
||||
for (let num of array) {
|
||||
>num : number
|
||||
@@ -24,9 +24,9 @@ for (let num of array) {
|
||||
>array = [4,5,6] : number[]
|
||||
>array : number[]
|
||||
>[4,5,6] : number[]
|
||||
>4 : number
|
||||
>5 : number
|
||||
>6 : number
|
||||
>4 : 4
|
||||
>5 : 5
|
||||
>6 : 6
|
||||
}
|
||||
|
||||
sum += num;
|
||||
|
||||
@@ -3,8 +3,8 @@ enum enumdule {
|
||||
>enumdule : enumdule
|
||||
|
||||
Red, Blue
|
||||
>Red : enumdule
|
||||
>Blue : enumdule
|
||||
>Red : enumdule.Red
|
||||
>Blue : enumdule.Blue
|
||||
}
|
||||
|
||||
module enumdule {
|
||||
@@ -25,9 +25,9 @@ var x: enumdule;
|
||||
|
||||
var x = enumdule.Red;
|
||||
>x : enumdule
|
||||
>enumdule.Red : enumdule
|
||||
>enumdule.Red : enumdule.Red
|
||||
>enumdule : typeof enumdule
|
||||
>Red : enumdule
|
||||
>Red : enumdule.Red
|
||||
|
||||
var y: { x: number; y: number };
|
||||
>y : { x: number; y: number; }
|
||||
@@ -40,6 +40,6 @@ var y = new enumdule.Point(0, 0);
|
||||
>enumdule.Point : typeof enumdule.Point
|
||||
>enumdule : typeof enumdule
|
||||
>Point : typeof enumdule.Point
|
||||
>0 : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>0 : 0
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ module A {
|
||||
>Point : Point
|
||||
|
||||
return 1;
|
||||
>1 : number
|
||||
>1 : 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -17,9 +17,9 @@ module A {
|
||||
>Point : Point
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
|
||||
export class Point3d extends Point {
|
||||
>Point3d : Point3d
|
||||
@@ -34,11 +34,11 @@ module A {
|
||||
>Point3d : Point3d
|
||||
>{ x: 0, y: 0, z: 0 } : { x: number; y: number; z: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>z : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
|
||||
export class Line<TPoint extends Point>{
|
||||
>Line : Line<TPoint>
|
||||
|
||||
+5
-5
@@ -17,9 +17,9 @@ module A {
|
||||
>Point : Point
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
|
||||
export class Point3d extends Point {
|
||||
>Point3d : Point3d
|
||||
@@ -34,11 +34,11 @@ module A {
|
||||
>Point3d : Point3d
|
||||
>{ x: 0, y: 0, z: 0 } : { x: number; y: number; z: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>z : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
|
||||
export class Line<TPoint extends Point>{
|
||||
>Line : Line<TPoint>
|
||||
|
||||
+2
-2
@@ -33,9 +33,9 @@ module A {
|
||||
>Line : typeof Line
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>p : Point
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -33,9 +33,9 @@ module A {
|
||||
>Line : typeof Line
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>p : Point
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -33,9 +33,9 @@ module A {
|
||||
>Line : typeof Line
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>p : Point
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -17,9 +17,9 @@ module A {
|
||||
>Point : Point
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
|
||||
export interface Point3d extends Point {
|
||||
>Point3d : Point3d
|
||||
@@ -34,11 +34,11 @@ module A {
|
||||
>Point3d : Point3d
|
||||
>{ x: 0, y: 0, z: 0 } : { x: number; y: number; z: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>z : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
|
||||
export interface Line<TPoint extends Point>{
|
||||
>Line : Line<TPoint>
|
||||
|
||||
+5
-5
@@ -17,9 +17,9 @@ module A {
|
||||
>Point : Point
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
|
||||
export interface Point3d extends Point {
|
||||
>Point3d : Point3d
|
||||
@@ -34,11 +34,11 @@ module A {
|
||||
>Point3d : Point3d
|
||||
>{ x: 0, y: 0, z: 0 } : { x: number; y: number; z: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>z : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
|
||||
export interface Line<TPoint extends Point>{
|
||||
>Line : Line<TPoint>
|
||||
|
||||
@@ -18,8 +18,8 @@ module A {
|
||||
>Point : Point
|
||||
>new Point(0, 0) : Point
|
||||
>Point : typeof Point
|
||||
>0 : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>0 : 0
|
||||
|
||||
export class Line {
|
||||
>Line : Line
|
||||
@@ -42,9 +42,9 @@ module A {
|
||||
>Line : typeof Line
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>p : Point
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -15,9 +15,9 @@ module A {
|
||||
>Point : Point
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
|
||||
export var Unity = { start: new Point(0, 0), end: new Point(1, 0) };
|
||||
>Unity : { start: Point; end: Point; }
|
||||
@@ -25,12 +25,12 @@ module A {
|
||||
>start : Point
|
||||
>new Point(0, 0) : Point
|
||||
>Point : typeof Point
|
||||
>0 : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>0 : 0
|
||||
>end : Point
|
||||
>new Point(1, 0) : Point
|
||||
>Point : typeof Point
|
||||
>1 : number
|
||||
>0 : number
|
||||
>1 : 1
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ module A {
|
||||
>Point : Point
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ module A {
|
||||
>Point : Point
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
|
||||
interface Point3d extends Point {
|
||||
>Point3d : Point3d
|
||||
@@ -36,10 +36,10 @@ module A {
|
||||
>Point3d : Point3d
|
||||
>{ x: 0, y: 0, z: 0 } : { x: number; y: number; z: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>z : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ module A {
|
||||
return { x: 0, y: 0 };
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ module B {
|
||||
>Origin : { x: number; y: number; }
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ enum enumdule {
|
||||
>enumdule : enumdule
|
||||
|
||||
Red, Blue
|
||||
>Red : enumdule
|
||||
>Blue : enumdule
|
||||
>Red : enumdule.Red
|
||||
>Blue : enumdule.Blue
|
||||
}
|
||||
|
||||
var x: enumdule;
|
||||
@@ -25,9 +25,9 @@ var x: enumdule;
|
||||
|
||||
var x = enumdule.Red;
|
||||
>x : enumdule
|
||||
>enumdule.Red : enumdule
|
||||
>enumdule.Red : enumdule.Red
|
||||
>enumdule : typeof enumdule
|
||||
>Red : enumdule
|
||||
>Red : enumdule.Red
|
||||
|
||||
var y: { x: number; y: number };
|
||||
>y : { x: number; y: number; }
|
||||
@@ -40,6 +40,6 @@ var y = new enumdule.Point(0, 0);
|
||||
>enumdule.Point : typeof enumdule.Point
|
||||
>enumdule : typeof enumdule
|
||||
>Point : typeof enumdule.Point
|
||||
>0 : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>0 : 0
|
||||
|
||||
|
||||
+5
-5
@@ -39,9 +39,9 @@ module A {
|
||||
>Point : Point
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
=== tests/cases/conformance/internalModules/DeclarationMerging/part2.ts ===
|
||||
@@ -51,7 +51,7 @@ module A {
|
||||
// not a collision, since we don't export
|
||||
var Origin: string = "0,0";
|
||||
>Origin : string
|
||||
>"0,0" : string
|
||||
>"0,0" : "0,0"
|
||||
|
||||
export module Utils {
|
||||
>Utils : typeof Utils
|
||||
@@ -123,8 +123,8 @@ var p = new A.Utils.Plane(o, { x: 1, y: 1 });
|
||||
>o : { x: number; y: number; }
|
||||
>{ x: 1, y: 1 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>1 : number
|
||||
>1 : 1
|
||||
>y : number
|
||||
>1 : number
|
||||
>1 : 1
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -55,9 +55,9 @@ module otherRoot {
|
||||
>Point : Root.A.Point
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
|
||||
export module Utils {
|
||||
>Utils : typeof Utils
|
||||
|
||||
@@ -45,9 +45,9 @@ module A {
|
||||
>Point : Point
|
||||
>{ x: 0, y: 0 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>y : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
|
||||
export module Utils {
|
||||
>Utils : typeof Utils
|
||||
@@ -119,8 +119,8 @@ var p = new A.Utils.Plane(o, { x: 1, y: 1 });
|
||||
>o : { x: number; y: number; }
|
||||
>{ x: 1, y: 1 } : { x: number; y: number; }
|
||||
>x : number
|
||||
>1 : number
|
||||
>1 : 1
|
||||
>y : number
|
||||
>1 : number
|
||||
>1 : 1
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
=== tests/cases/conformance/expressions/typeGuards/TypeGuardWithEnumUnion.ts ===
|
||||
enum Color { R, G, B }
|
||||
>Color : Color
|
||||
>R : Color
|
||||
>G : Color
|
||||
>B : Color
|
||||
>R : Color.R
|
||||
>G : Color.G
|
||||
>B : Color.B
|
||||
|
||||
function f1(x: Color | string) {
|
||||
>f1 : (x: string | Color) => void
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts ===
|
||||
let a: number = 1
|
||||
>a : number
|
||||
>1 : number
|
||||
>1 : 1
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts ===
|
||||
const a = 1
|
||||
>a : number
|
||||
>1 : number
|
||||
>a : 1
|
||||
>1 : 1
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts ===
|
||||
const a: number = 1
|
||||
>a : number
|
||||
>1 : number
|
||||
>1 : 1
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts ===
|
||||
let a = 1
|
||||
>a : number
|
||||
>1 : number
|
||||
>1 : 1
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
=== tests/cases/compiler/abstractIdentifierNameStrict.ts ===
|
||||
var abstract = true;
|
||||
>abstract : boolean
|
||||
>true : boolean
|
||||
>true : true
|
||||
|
||||
function foo() {
|
||||
>foo : () => void
|
||||
|
||||
"use strict";
|
||||
>"use strict" : string
|
||||
>"use strict" : "use strict"
|
||||
|
||||
var abstract = true;
|
||||
>abstract : boolean
|
||||
>true : boolean
|
||||
>true : true
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class C extends B {
|
||||
|
||||
get prop() { return "foo"; }
|
||||
>prop : string
|
||||
>"foo" : string
|
||||
>"foo" : "foo"
|
||||
|
||||
set prop(v) { }
|
||||
>prop : string
|
||||
@@ -48,11 +48,11 @@ class C extends B {
|
||||
|
||||
raw = "edge";
|
||||
>raw : string
|
||||
>"edge" : string
|
||||
>"edge" : "edge"
|
||||
|
||||
readonly ro = "readonly please";
|
||||
>ro : string
|
||||
>"readonly please" : string
|
||||
>ro : "readonly please"
|
||||
>"readonly please" : "readonly please"
|
||||
|
||||
readonlyProp: string; // don't have to give a value, in fact
|
||||
>readonlyProp : string
|
||||
|
||||
@@ -13,11 +13,11 @@ class Point {
|
||||
>"x=" + this.x + " y=" + this.y : string
|
||||
>"x=" + this.x + " y=" : string
|
||||
>"x=" + this.x : string
|
||||
>"x=" : string
|
||||
>"x=" : "x="
|
||||
>this.x : number
|
||||
>this : this
|
||||
>x : number
|
||||
>" y=" : string
|
||||
>" y=" : " y="
|
||||
>this.y : number
|
||||
>this : this
|
||||
>y : number
|
||||
@@ -48,7 +48,7 @@ class ColoredPoint extends Point {
|
||||
>super.toString : () => string
|
||||
>super : Point
|
||||
>toString : () => string
|
||||
>" color=" : string
|
||||
>" color=" : " color="
|
||||
>this.color : string
|
||||
>this : this
|
||||
>color : string
|
||||
|
||||
@@ -7,7 +7,7 @@ class C {
|
||||
>x : number
|
||||
|
||||
return 1;
|
||||
>1 : number
|
||||
>1 : 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ var x = {
|
||||
|
||||
get a() { return 1 }
|
||||
>a : number
|
||||
>1 : number
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
var y = {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,55): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,55): error TS2322: Type '""' is not assignable to type 'number'.
|
||||
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,54): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,54): error TS2322: Type '""' is not assignable to type 'number'.
|
||||
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(6,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(8,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(9,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(9,52): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(9,52): error TS2322: Type '0' is not assignable to type 'string'.
|
||||
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(11,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(11,51): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(11,51): error TS2322: Type '0' is not assignable to type 'string'.
|
||||
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(12,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
|
||||
|
||||
@@ -21,13 +21,13 @@ tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(12,16): error TS1
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type '""' is not assignable to type 'number'.
|
||||
|
||||
public get AnnotatedSetter_SetterLast() { return ""; }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type '""' is not assignable to type 'number'.
|
||||
public set AnnotatedSetter_SetterLast(a: number) { }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
@@ -39,13 +39,13 @@ tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(12,16): error TS1
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
~~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type '0' is not assignable to type 'string'.
|
||||
|
||||
public set AnnotatedGetter_GetterLast(aStr) { aStr = 0; }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
~~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type '0' is not assignable to type 'string'.
|
||||
public get AnnotatedGetter_GetterLast(): string { return ""; }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
|
||||
@@ -22,5 +22,5 @@ var kitty = a(1);
|
||||
>kitty : string
|
||||
>a(1) : string
|
||||
>a : Bar
|
||||
>1 : number
|
||||
>1 : 1
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ class C {
|
||||
}
|
||||
enum E { a, b, c }
|
||||
>E : E
|
||||
>a : E
|
||||
>b : E
|
||||
>c : E
|
||||
>a : E.a
|
||||
>b : E.b
|
||||
>c : E.c
|
||||
|
||||
module M { export var a }
|
||||
>M : typeof M
|
||||
@@ -130,9 +130,9 @@ var r15 = a + E.a;
|
||||
>r15 : any
|
||||
>a + E.a : any
|
||||
>a : any
|
||||
>E.a : E
|
||||
>E.a : E.a
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>a : E.a
|
||||
|
||||
var r16 = a + M;
|
||||
>r16 : any
|
||||
@@ -144,13 +144,13 @@ var r17 = a + '';
|
||||
>r17 : string
|
||||
>a + '' : string
|
||||
>a : any
|
||||
>'' : string
|
||||
>'' : ""
|
||||
|
||||
var r18 = a + 123;
|
||||
>r18 : any
|
||||
>a + 123 : any
|
||||
>a : any
|
||||
>123 : number
|
||||
>123 : 123
|
||||
|
||||
var r19 = a + { a: '' };
|
||||
>r19 : any
|
||||
@@ -158,7 +158,7 @@ var r19 = a + { a: '' };
|
||||
>a : any
|
||||
>{ a: '' } : { a: string; }
|
||||
>a : string
|
||||
>'' : string
|
||||
>'' : ""
|
||||
|
||||
var r20 = a + ((a: string) => { return a });
|
||||
>r20 : any
|
||||
|
||||
@@ -6,17 +6,17 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(25,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'boolean'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(26,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'number'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(27,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(30,11): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(31,11): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(32,11): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'number'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(30,11): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'true'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(31,11): error TS2365: Operator '+' cannot be applied to types 'true' and 'false'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(32,11): error TS2365: Operator '+' cannot be applied to types 'true' and '123'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(33,11): error TS2365: Operator '+' cannot be applied to types '{}' and '{}'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(34,11): error TS2365: Operator '+' cannot be applied to types 'number' and 'Number'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(35,11): error TS2365: Operator '+' cannot be applied to types 'number' and '() => void'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(36,11): error TS2365: Operator '+' cannot be applied to types 'number' and 'void'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(37,11): error TS2365: Operator '+' cannot be applied to types 'number' and 'typeof C'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(38,11): error TS2365: Operator '+' cannot be applied to types 'E' and 'C'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(39,11): error TS2365: Operator '+' cannot be applied to types 'E' and 'void'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(40,11): error TS2365: Operator '+' cannot be applied to types 'E' and 'typeof M'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(38,11): error TS2365: Operator '+' cannot be applied to types 'E.a' and 'C'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(39,11): error TS2365: Operator '+' cannot be applied to types 'E.a' and 'void'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(40,11): error TS2365: Operator '+' cannot be applied to types 'E.a' and 'typeof M'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts (19 errors) ====
|
||||
@@ -67,13 +67,13 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe
|
||||
// other cases
|
||||
var r10 = a + true;
|
||||
~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'true'.
|
||||
var r11 = true + false;
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'true' and 'false'.
|
||||
var r12 = true + 123;
|
||||
~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'number'.
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'true' and '123'.
|
||||
var r13 = {} + {};
|
||||
~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types '{}' and '{}'.
|
||||
@@ -91,10 +91,10 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'number' and 'typeof C'.
|
||||
var r18 = E.a + new C();
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'E' and 'C'.
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'E.a' and 'C'.
|
||||
var r19 = E.a + C.foo();
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'E' and 'void'.
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'E.a' and 'void'.
|
||||
var r20 = E.a + M;
|
||||
~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'E' and 'typeof M'.
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'E.a' and 'typeof M'.
|
||||
+2
-2
@@ -5,7 +5,7 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(15,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(16,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(19,10): error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'true' and 'true'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(21,10): error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(22,11): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(23,11): error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'.
|
||||
@@ -47,7 +47,7 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'.
|
||||
var r8 = null + true;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'true' and 'true'.
|
||||
var r9 = null + { a: '' };
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'.
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
enum E { a, b, c }
|
||||
>E : E
|
||||
>a : E
|
||||
>b : E
|
||||
>c : E
|
||||
>a : E.a
|
||||
>b : E.b
|
||||
>c : E.c
|
||||
|
||||
var a: any;
|
||||
>a : any
|
||||
@@ -44,7 +44,7 @@ var r4 = null + 1;
|
||||
>r4 : number
|
||||
>null + 1 : number
|
||||
>null : null
|
||||
>1 : number
|
||||
>1 : 1
|
||||
|
||||
var r5 = null + c;
|
||||
>r5 : number
|
||||
@@ -56,17 +56,17 @@ var r6 = null + E.a;
|
||||
>r6 : number
|
||||
>null + E.a : number
|
||||
>null : null
|
||||
>E.a : E
|
||||
>E.a : E.a
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>a : E.a
|
||||
|
||||
var r7 = null + E['a'];
|
||||
>r7 : number
|
||||
>null + E['a'] : number
|
||||
>null : null
|
||||
>E['a'] : E
|
||||
>E['a'] : E.a
|
||||
>E : typeof E
|
||||
>'a' : string
|
||||
>'a' : "a"
|
||||
|
||||
var r8 = b + null;
|
||||
>r8 : number
|
||||
@@ -77,7 +77,7 @@ var r8 = b + null;
|
||||
var r9 = 1 + null;
|
||||
>r9 : number
|
||||
>1 + null : number
|
||||
>1 : number
|
||||
>1 : 1
|
||||
>null : null
|
||||
|
||||
var r10 = c + null
|
||||
@@ -89,17 +89,17 @@ var r10 = c + null
|
||||
var r11 = E.a + null;
|
||||
>r11 : number
|
||||
>E.a + null : number
|
||||
>E.a : E
|
||||
>E.a : E.a
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>a : E.a
|
||||
>null : null
|
||||
|
||||
var r12 = E['a'] + null;
|
||||
>r12 : number
|
||||
>E['a'] + null : number
|
||||
>E['a'] : E
|
||||
>E['a'] : E.a
|
||||
>E : typeof E
|
||||
>'a' : string
|
||||
>'a' : "a"
|
||||
>null : null
|
||||
|
||||
// null + string
|
||||
@@ -113,7 +113,7 @@ var r14 = null + '';
|
||||
>r14 : string
|
||||
>null + '' : string
|
||||
>null : null
|
||||
>'' : string
|
||||
>'' : ""
|
||||
|
||||
var r15 = d + null;
|
||||
>r15 : string
|
||||
@@ -124,6 +124,6 @@ var r15 = d + null;
|
||||
var r16 = '' + null;
|
||||
>r16 : string
|
||||
>'' + null : string
|
||||
>'' : string
|
||||
>'' : ""
|
||||
>null : null
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
=== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNumberAndEnum.ts ===
|
||||
enum E { a, b }
|
||||
>E : E
|
||||
>a : E
|
||||
>b : E
|
||||
>a : E.a
|
||||
>b : E.b
|
||||
|
||||
enum F { c, d }
|
||||
>F : F
|
||||
>c : F
|
||||
>d : F
|
||||
>c : F.c
|
||||
>d : F.d
|
||||
|
||||
var a: number;
|
||||
>a : number
|
||||
@@ -48,46 +48,46 @@ var r4 = b + b;
|
||||
var r5 = 0 + a;
|
||||
>r5 : number
|
||||
>0 + a : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>a : number
|
||||
|
||||
var r6 = E.a + 0;
|
||||
>r6 : number
|
||||
>E.a + 0 : number
|
||||
>E.a : E
|
||||
>E.a : E.a
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>0 : number
|
||||
>a : E.a
|
||||
>0 : 0
|
||||
|
||||
var r7 = E.a + E.b;
|
||||
>r7 : number
|
||||
>E.a + E.b : number
|
||||
>E.a : E
|
||||
>E.a : E.a
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>E.b : E
|
||||
>a : E.a
|
||||
>E.b : E.b
|
||||
>E : typeof E
|
||||
>b : E
|
||||
>b : E.b
|
||||
|
||||
var r8 = E['a'] + E['b'];
|
||||
>r8 : number
|
||||
>E['a'] + E['b'] : number
|
||||
>E['a'] : E
|
||||
>E['a'] : E.a
|
||||
>E : typeof E
|
||||
>'a' : string
|
||||
>E['b'] : E
|
||||
>'a' : "a"
|
||||
>E['b'] : E.b
|
||||
>E : typeof E
|
||||
>'b' : string
|
||||
>'b' : "b"
|
||||
|
||||
var r9 = E['a'] + F['c'];
|
||||
>r9 : number
|
||||
>E['a'] + F['c'] : number
|
||||
>E['a'] : E
|
||||
>E['a'] : E.a
|
||||
>E : typeof E
|
||||
>'a' : string
|
||||
>F['c'] : F
|
||||
>'a' : "a"
|
||||
>F['c'] : F.c
|
||||
>F : typeof F
|
||||
>'c' : string
|
||||
>'c' : "c"
|
||||
|
||||
var r10 = a + c;
|
||||
>r10 : number
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
=== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithStringAndEveryType.ts ===
|
||||
enum E { a, b, c }
|
||||
>E : E
|
||||
>a : E
|
||||
>b : E
|
||||
>c : E
|
||||
>a : E.a
|
||||
>b : E.b
|
||||
>c : E.c
|
||||
|
||||
var a: any;
|
||||
>a : any
|
||||
@@ -129,21 +129,21 @@ var r16 = x + E.a;
|
||||
>r16 : string
|
||||
>x + E.a : string
|
||||
>x : string
|
||||
>E.a : E
|
||||
>E.a : E.a
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>a : E.a
|
||||
|
||||
var r17 = x + '';
|
||||
>r17 : string
|
||||
>x + '' : string
|
||||
>x : string
|
||||
>'' : string
|
||||
>'' : ""
|
||||
|
||||
var r18 = x + 0;
|
||||
>r18 : string
|
||||
>x + 0 : string
|
||||
>x : string
|
||||
>0 : number
|
||||
>0 : 0
|
||||
|
||||
var r19 = x + { a: '' };
|
||||
>r19 : string
|
||||
@@ -151,7 +151,7 @@ var r19 = x + { a: '' };
|
||||
>x : string
|
||||
>{ a: '' } : { a: string; }
|
||||
>a : string
|
||||
>'' : string
|
||||
>'' : ""
|
||||
|
||||
var r20 = x + [];
|
||||
>r20 : string
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(15,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(16,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(19,10): error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'true' and 'true'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(21,10): error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(22,11): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'.
|
||||
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(23,11): error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'.
|
||||
@@ -47,7 +47,7 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'.
|
||||
var r8 = undefined + true;
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||
!!! error TS2365: Operator '+' cannot be applied to types 'true' and 'true'.
|
||||
var r9 = undefined + { a: '' };
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'.
|
||||
|
||||
+15
-15
@@ -3,9 +3,9 @@
|
||||
|
||||
enum E { a, b, c }
|
||||
>E : E
|
||||
>a : E
|
||||
>b : E
|
||||
>c : E
|
||||
>a : E.a
|
||||
>b : E.b
|
||||
>c : E.c
|
||||
|
||||
var a: any;
|
||||
>a : any
|
||||
@@ -44,7 +44,7 @@ var r4 = undefined + 1;
|
||||
>r4 : number
|
||||
>undefined + 1 : number
|
||||
>undefined : undefined
|
||||
>1 : number
|
||||
>1 : 1
|
||||
|
||||
var r5 = undefined + c;
|
||||
>r5 : number
|
||||
@@ -56,17 +56,17 @@ var r6 = undefined + E.a;
|
||||
>r6 : number
|
||||
>undefined + E.a : number
|
||||
>undefined : undefined
|
||||
>E.a : E
|
||||
>E.a : E.a
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>a : E.a
|
||||
|
||||
var r7 = undefined + E['a'];
|
||||
>r7 : number
|
||||
>undefined + E['a'] : number
|
||||
>undefined : undefined
|
||||
>E['a'] : E
|
||||
>E['a'] : E.a
|
||||
>E : typeof E
|
||||
>'a' : string
|
||||
>'a' : "a"
|
||||
|
||||
var r8 = b + undefined;
|
||||
>r8 : number
|
||||
@@ -77,7 +77,7 @@ var r8 = b + undefined;
|
||||
var r9 = 1 + undefined;
|
||||
>r9 : number
|
||||
>1 + undefined : number
|
||||
>1 : number
|
||||
>1 : 1
|
||||
>undefined : undefined
|
||||
|
||||
var r10 = c + undefined
|
||||
@@ -89,17 +89,17 @@ var r10 = c + undefined
|
||||
var r11 = E.a + undefined;
|
||||
>r11 : number
|
||||
>E.a + undefined : number
|
||||
>E.a : E
|
||||
>E.a : E.a
|
||||
>E : typeof E
|
||||
>a : E
|
||||
>a : E.a
|
||||
>undefined : undefined
|
||||
|
||||
var r12 = E['a'] + undefined;
|
||||
>r12 : number
|
||||
>E['a'] + undefined : number
|
||||
>E['a'] : E
|
||||
>E['a'] : E.a
|
||||
>E : typeof E
|
||||
>'a' : string
|
||||
>'a' : "a"
|
||||
>undefined : undefined
|
||||
|
||||
// undefined + string
|
||||
@@ -113,7 +113,7 @@ var r14 = undefined + '';
|
||||
>r14 : string
|
||||
>undefined + '' : string
|
||||
>undefined : undefined
|
||||
>'' : string
|
||||
>'' : ""
|
||||
|
||||
var r15 = d + undefined;
|
||||
>r15 : string
|
||||
@@ -124,6 +124,6 @@ var r15 = d + undefined;
|
||||
var r16 = '' + undefined;
|
||||
>r16 : string
|
||||
>'' + undefined : string
|
||||
>'' : string
|
||||
>'' : ""
|
||||
>undefined : undefined
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/aliasAssignments_1.ts(3,1): error TS2322: Type 'number' is not assignable to type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"'.
|
||||
tests/cases/compiler/aliasAssignments_1.ts(3,1): error TS2322: Type '1' is not assignable to type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"'.
|
||||
tests/cases/compiler/aliasAssignments_1.ts(5,1): error TS2322: Type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"' is not assignable to type 'number'.
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ tests/cases/compiler/aliasAssignments_1.ts(5,1): error TS2322: Type 'typeof "tes
|
||||
var x = moduleA;
|
||||
x = 1; // Should be error
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"'.
|
||||
!!! error TS2322: Type '1' is not assignable to type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"'.
|
||||
var y = 1;
|
||||
y = moduleA; // should be error
|
||||
~
|
||||
|
||||
@@ -103,14 +103,14 @@ declare enum E2 {
|
||||
|
||||
a = 1,
|
||||
>a : E2
|
||||
>1 : number
|
||||
>1 : 1
|
||||
|
||||
b,
|
||||
>b : E2
|
||||
|
||||
c = 2,
|
||||
>c : E2
|
||||
>2 : number
|
||||
>2 : 2
|
||||
|
||||
d
|
||||
>d : E2
|
||||
|
||||
@@ -6,13 +6,13 @@ declare enum E {
|
||||
|
||||
a = 10,
|
||||
>a : E
|
||||
>10 : number
|
||||
>10 : 10
|
||||
|
||||
b = 10 + 1,
|
||||
>b : E
|
||||
>10 + 1 : number
|
||||
>10 : number
|
||||
>1 : number
|
||||
>10 : 10
|
||||
>1 : 1
|
||||
|
||||
c = b,
|
||||
>c : E
|
||||
@@ -23,13 +23,13 @@ declare enum E {
|
||||
>(c) + 1 : number
|
||||
>(c) : E
|
||||
>c : E
|
||||
>1 : number
|
||||
>1 : 1
|
||||
|
||||
e = 10 << 2 * 8,
|
||||
>e : E
|
||||
>10 << 2 * 8 : number
|
||||
>10 : number
|
||||
>10 : 10
|
||||
>2 * 8 : number
|
||||
>2 : number
|
||||
>8 : number
|
||||
>2 : 2
|
||||
>8 : 8
|
||||
}
|
||||
|
||||
@@ -4,5 +4,5 @@ declare enum E {
|
||||
|
||||
e = 3
|
||||
>e : E
|
||||
>3 : number
|
||||
>3 : 3
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ declare enum E {
|
||||
|
||||
e = -3 // Negative
|
||||
>e : E
|
||||
>-3 : number
|
||||
>3 : number
|
||||
>-3 : -3
|
||||
>3 : 3
|
||||
}
|
||||
|
||||
@@ -4,5 +4,5 @@ declare enum E {
|
||||
|
||||
e = 3.3 // Decimal
|
||||
>e : E
|
||||
>3.3 : number
|
||||
>3.3 : 3.3
|
||||
}
|
||||
|
||||
@@ -4,5 +4,5 @@ declare enum E {
|
||||
|
||||
e = 0xA
|
||||
>e : E
|
||||
>0xA : number
|
||||
>0xA : 10
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ declare enum E {
|
||||
|
||||
e = -0xA
|
||||
>e : E
|
||||
>-0xA : number
|
||||
>0xA : number
|
||||
>-0xA : -10
|
||||
>0xA : 10
|
||||
}
|
||||
|
||||
@@ -7,6 +7,6 @@ declare module M {
|
||||
|
||||
e = 3
|
||||
>e : E
|
||||
>3 : number
|
||||
>3 : 3
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ declare module Foo.Bar { export var foo; };
|
||||
>foo : any
|
||||
|
||||
Foo.Bar.foo = 5;
|
||||
>Foo.Bar.foo = 5 : number
|
||||
>Foo.Bar.foo = 5 : 5
|
||||
>Foo.Bar.foo : any
|
||||
>Foo.Bar : typeof Foo.Bar
|
||||
>Foo : typeof Foo
|
||||
>Bar : typeof Foo.Bar
|
||||
>foo : any
|
||||
>5 : number
|
||||
>5 : 5
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class TestClass2 {
|
||||
>x : any
|
||||
|
||||
return 0;
|
||||
>0 : number
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
public foo(x: string): number;
|
||||
|
||||
@@ -19,8 +19,8 @@ export enum E1 {
|
||||
>E1 : E1
|
||||
|
||||
A,B,C
|
||||
>A : E1
|
||||
>B : E1
|
||||
>C : E1
|
||||
>A : E1.A
|
||||
>B : E1.B
|
||||
>C : E1.C
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ var y: typeof foo.C1.s1 = false;
|
||||
>foo : typeof foo
|
||||
>C1 : typeof foo.C1
|
||||
>s1 : boolean
|
||||
>false : boolean
|
||||
>false : false
|
||||
|
||||
var z: foo.M1.I2;
|
||||
>z : f.I2
|
||||
@@ -49,11 +49,11 @@ export class C1 {
|
||||
|
||||
m1 = 42;
|
||||
>m1 : number
|
||||
>42 : number
|
||||
>42 : 42
|
||||
|
||||
static s1 = true;
|
||||
>s1 : boolean
|
||||
>true : boolean
|
||||
>true : true
|
||||
}
|
||||
|
||||
export interface I1 {
|
||||
@@ -81,8 +81,8 @@ export enum E1 {
|
||||
>E1 : E1
|
||||
|
||||
A,B,C
|
||||
>A : E1
|
||||
>B : E1
|
||||
>C : E1
|
||||
>A : E1.A
|
||||
>B : E1.B
|
||||
>C : E1.C
|
||||
}
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@ class Foo {
|
||||
|
||||
constructor() {
|
||||
this.x = 5;
|
||||
>this.x = 5 : number
|
||||
>this.x = 5 : 5
|
||||
>this.x : number
|
||||
>this : this
|
||||
>x : number
|
||||
>5 : number
|
||||
>5 : 5
|
||||
}
|
||||
}
|
||||
export = Foo;
|
||||
|
||||
@@ -34,9 +34,9 @@ c.m(function(n) { return "hello: "+n; },18);
|
||||
>function(n) { return "hello: "+n; } : (n: number) => string
|
||||
>n : number
|
||||
>"hello: "+n : string
|
||||
>"hello: " : string
|
||||
>"hello: " : "hello: "
|
||||
>n : number
|
||||
>18 : number
|
||||
>18 : 18
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ var b = x('hello');
|
||||
>b : any
|
||||
>x('hello') : any
|
||||
>x : any
|
||||
>'hello' : string
|
||||
>'hello' : "hello"
|
||||
|
||||
var c = x(x);
|
||||
>c : any
|
||||
|
||||
@@ -24,8 +24,8 @@ var o = new Point(3, 4);
|
||||
>o : any
|
||||
>new Point(3, 4) : any
|
||||
>Point : (x: any, y: any) => void
|
||||
>3 : number
|
||||
>4 : number
|
||||
>3 : 3
|
||||
>4 : 4
|
||||
|
||||
var xx = o.x;
|
||||
>xx : any
|
||||
|
||||
@@ -246,7 +246,7 @@ module f {
|
||||
|
||||
export var bar = 1;
|
||||
>bar : number
|
||||
>1 : number
|
||||
>1 : 1
|
||||
}
|
||||
declare function foo15(x: typeof f): typeof f;
|
||||
>foo15 : { (x: typeof f): typeof f; (x: any): any; }
|
||||
@@ -273,7 +273,7 @@ module CC {
|
||||
|
||||
export var bar = 1;
|
||||
>bar : number
|
||||
>1 : number
|
||||
>1 : 1
|
||||
}
|
||||
declare function foo16(x: CC): CC;
|
||||
>foo16 : { (x: CC): CC; (x: any): any; }
|
||||
|
||||
@@ -187,7 +187,7 @@ module f {
|
||||
|
||||
export var bar = 1;
|
||||
>bar : number
|
||||
>1 : number
|
||||
>1 : 1
|
||||
}
|
||||
interface I15 {
|
||||
>I15 : I15
|
||||
@@ -210,7 +210,7 @@ module c {
|
||||
|
||||
export var bar = 1;
|
||||
>bar : number
|
||||
>1 : number
|
||||
>1 : 1
|
||||
}
|
||||
interface I16 {
|
||||
>I16 : I16
|
||||
|
||||
@@ -3,11 +3,11 @@ var x;
|
||||
>x : any
|
||||
|
||||
x.name = "hello";
|
||||
>x.name = "hello" : string
|
||||
>x.name = "hello" : "hello"
|
||||
>x.name : any
|
||||
>x : any
|
||||
>name : any
|
||||
>"hello" : string
|
||||
>"hello" : "hello"
|
||||
|
||||
var z = x + x;
|
||||
>z : any
|
||||
|
||||
@@ -12,14 +12,14 @@ var b = x['foo'];
|
||||
>b : any
|
||||
>x['foo'] : any
|
||||
>x : any
|
||||
>'foo' : string
|
||||
>'foo' : "foo"
|
||||
|
||||
var c = x['fn']();
|
||||
>c : any
|
||||
>x['fn']() : any
|
||||
>x['fn'] : any
|
||||
>x : any
|
||||
>'fn' : string
|
||||
>'fn' : "fn"
|
||||
|
||||
var d = x.bar.baz;
|
||||
>d : any
|
||||
@@ -34,7 +34,7 @@ var e = x[0].foo;
|
||||
>x[0].foo : any
|
||||
>x[0] : any
|
||||
>x : any
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>foo : any
|
||||
|
||||
var f = x['0'].bar;
|
||||
@@ -42,6 +42,6 @@ var f = x['0'].bar;
|
||||
>x['0'].bar : any
|
||||
>x['0'] : any
|
||||
>x : any
|
||||
>'0' : string
|
||||
>'0' : "0"
|
||||
>bar : any
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class C {
|
||||
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
>i : number
|
||||
>0 : number
|
||||
>0 : 0
|
||||
>i < arguments.length : boolean
|
||||
>i : number
|
||||
>arguments.length : number
|
||||
@@ -34,7 +34,7 @@ c.P(1,2,3);
|
||||
>c.P : (ii: number, j: number, k: number) => void
|
||||
>c : C
|
||||
>P : (ii: number, j: number, k: number) => void
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>3 : 3
|
||||
|
||||
|
||||
@@ -6,5 +6,5 @@ function f() {
|
||||
>x : any
|
||||
>arguments[12] : any
|
||||
>arguments : IArguments
|
||||
>12 : number
|
||||
>12 : 12
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts(3,5): error TS2322: Type 'number' is not assignable to type 'IArguments'.
|
||||
tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts(3,5): error TS2322: Type '10' is not assignable to type 'IArguments'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts (1 errors) ====
|
||||
@@ -6,5 +6,5 @@ tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts(3,5): error TS
|
||||
function foo(a) {
|
||||
arguments = 10; /// This shouldnt be of type number and result in error.
|
||||
~~~~~~~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'IArguments'.
|
||||
!!! error TS2322: Type '10' is not assignable to type 'IArguments'.
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/compiler/arithAssignTyping.ts(3,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/compiler/arithAssignTyping.ts(4,1): error TS2365: Operator '+=' cannot be applied to types 'typeof f' and 'number'.
|
||||
tests/cases/compiler/arithAssignTyping.ts(4,1): error TS2365: Operator '+=' cannot be applied to types 'typeof f' and '1'.
|
||||
tests/cases/compiler/arithAssignTyping.ts(5,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/arithAssignTyping.ts(6,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/arithAssignTyping.ts(7,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -20,7 +20,7 @@ tests/cases/compiler/arithAssignTyping.ts(14,1): error TS2362: The left-hand sid
|
||||
!!! error TS2364: Invalid left-hand side of assignment expression.
|
||||
f += 1; // error
|
||||
~~~~~~
|
||||
!!! error TS2365: Operator '+=' cannot be applied to types 'typeof f' and 'number'.
|
||||
!!! error TS2365: Operator '+=' cannot be applied to types 'typeof f' and '1'.
|
||||
f -= 1; // error
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user