mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into createTypeNode
This commit is contained in:
+106
-74
@@ -288,6 +288,8 @@ namespace ts {
|
||||
let deferredGlobalAsyncIterableIteratorType: GenericType;
|
||||
let deferredGlobalTemplateStringsArrayType: ObjectType;
|
||||
let deferredJsxElementClassType: Type;
|
||||
let deferredJsxElementType: Type;
|
||||
let deferredJsxStatelessElementType: Type;
|
||||
|
||||
let deferredNodes: Node[];
|
||||
let deferredUnusedIdentifierNodes: Node[];
|
||||
@@ -408,7 +410,6 @@ namespace ts {
|
||||
});
|
||||
const typeofType = createTypeofType();
|
||||
|
||||
let jsxElementType: Type;
|
||||
let _jsxNamespace: string;
|
||||
let _jsxFactoryEntity: EntityName;
|
||||
|
||||
@@ -1072,9 +1073,10 @@ namespace ts {
|
||||
// block-scoped variable and namespace module. However, only when we
|
||||
// try to resolve name in /*1*/ which is used in variable position,
|
||||
// we want to check for block-scoped
|
||||
if (meaning & SymbolFlags.BlockScopedVariable) {
|
||||
if (meaning & SymbolFlags.BlockScopedVariable ||
|
||||
((meaning & SymbolFlags.Class || meaning & SymbolFlags.Enum) && (meaning & SymbolFlags.Value) === SymbolFlags.Value)) {
|
||||
const exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
|
||||
if (exportOrLocalSymbol.flags & SymbolFlags.BlockScopedVariable) {
|
||||
if (exportOrLocalSymbol.flags & SymbolFlags.BlockScopedVariable || exportOrLocalSymbol.flags & SymbolFlags.Class || exportOrLocalSymbol.flags & SymbolFlags.Enum) {
|
||||
checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
|
||||
}
|
||||
}
|
||||
@@ -1187,14 +1189,22 @@ namespace ts {
|
||||
}
|
||||
|
||||
function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void {
|
||||
Debug.assert((result.flags & SymbolFlags.BlockScopedVariable) !== 0);
|
||||
Debug.assert(!!(result.flags & SymbolFlags.BlockScopedVariable || result.flags & SymbolFlags.Class || result.flags & SymbolFlags.Enum));
|
||||
// Block-scoped variables cannot be used before their definition
|
||||
const declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) ? d : undefined);
|
||||
const declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) || isClassLike(d) || (d.kind === SyntaxKind.EnumDeclaration) ? d : undefined);
|
||||
|
||||
Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined");
|
||||
Debug.assert(declaration !== undefined, "Declaration to checkResolvedBlockScopedVariable is undefined");
|
||||
|
||||
if (!isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
|
||||
error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name));
|
||||
if (result.flags & SymbolFlags.BlockScopedVariable) {
|
||||
error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name));
|
||||
}
|
||||
else if (result.flags & SymbolFlags.Class) {
|
||||
error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationNameToString(declaration.name));
|
||||
}
|
||||
else if (result.flags & SymbolFlags.Enum) {
|
||||
error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationNameToString(declaration.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2203,7 +2213,7 @@ namespace ts {
|
||||
typeToTypeNode,
|
||||
indexInfoToIndexSignatureDeclaration,
|
||||
signatureToSignatureDeclaration
|
||||
}
|
||||
};
|
||||
|
||||
return nodeBuilderCache;
|
||||
|
||||
@@ -2359,7 +2369,7 @@ namespace ts {
|
||||
const typeParameter = getTypeParameterFromMappedType(<MappedType>type);
|
||||
const typeParameterNode = typeParameterToDeclaration(typeParameter, enclosingDeclaration, flags);
|
||||
|
||||
const templateType = getTemplateTypeFromMappedType(<MappedType>type)
|
||||
const templateType = getTemplateTypeFromMappedType(<MappedType>type);
|
||||
const templateTypeNode = templateType && typeToTypeNodeWorker(templateType);
|
||||
const readonlyToken = (<MappedType>type).declaration && (<MappedType>type).declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined;
|
||||
const questionToken = (<MappedType>type).declaration && (<MappedType>type).declaration.questionToken ? createToken(SyntaxKind.QuestionToken) : undefined;
|
||||
@@ -2395,7 +2405,7 @@ namespace ts {
|
||||
symbolStack = [];
|
||||
}
|
||||
symbolStack.push(symbol);
|
||||
let result = createTypeNodeFromObjectType(type);
|
||||
const result = createTypeNodeFromObjectType(type);
|
||||
symbolStack.pop();
|
||||
return result;
|
||||
}
|
||||
@@ -2537,7 +2547,7 @@ namespace ts {
|
||||
return;
|
||||
}
|
||||
const propertyName = oldDeclaration.name;
|
||||
const optionalToken = propertySymbol.flags & SymbolFlags.Optional ? createToken(SyntaxKind.QuestionToken) : undefined;;
|
||||
const optionalToken = propertySymbol.flags & SymbolFlags.Optional ? createToken(SyntaxKind.QuestionToken) : undefined;
|
||||
if (propertySymbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(propertyType).length) {
|
||||
const signatures = getSignaturesOfType(propertyType, SignatureKind.Call);
|
||||
for (const signature of signatures) {
|
||||
@@ -2632,13 +2642,12 @@ namespace ts {
|
||||
function symbolToName(symbol: Symbol, enclosingDeclaration: Node | undefined, expectsIdentifier: false, flags: NodeBuilderFlags): EntityName;
|
||||
function symbolToName(symbol: Symbol, enclosingDeclaration: Node | undefined, expectsIdentifier: boolean, flags: NodeBuilderFlags): EntityName {
|
||||
let parentSymbol: Symbol;
|
||||
let meaning: SymbolFlags;
|
||||
|
||||
// Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration.
|
||||
let chain: Symbol[];
|
||||
const isTypeParameter = symbol.flags & SymbolFlags.TypeParameter;
|
||||
if (!isTypeParameter && enclosingDeclaration) {
|
||||
chain = getSymbolChain(symbol, meaning, /*endOfChain*/ true);
|
||||
chain = getSymbolChain(symbol, SymbolFlags.None, /*endOfChain*/ true);
|
||||
Debug.assert(chain && chain.length > 0);
|
||||
}
|
||||
else {
|
||||
@@ -2671,7 +2680,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
if (typeParameters && typeParameters.length > 0) {
|
||||
encounteredError = encounteredError || !(flags & NodeBuilderFlags.allowTypeParameterInQualifiedName);;
|
||||
encounteredError = encounteredError || !(flags & NodeBuilderFlags.allowTypeParameterInQualifiedName);
|
||||
|
||||
const writer = getSingleLineStringWriter();
|
||||
const displayBuilder = getSymbolDisplayBuilder();
|
||||
@@ -2683,7 +2692,7 @@ namespace ts {
|
||||
}
|
||||
const symbolName = getNameOfSymbol(symbol);
|
||||
const symbolNameWithTypeParameters = typeParameterString.length > 0 ? `${symbolName}<${typeParameterString}>` : symbolName;
|
||||
let identifier = createIdentifier(symbolNameWithTypeParameters);
|
||||
const identifier = createIdentifier(symbolNameWithTypeParameters);
|
||||
|
||||
return index > 0 ? createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier;
|
||||
}
|
||||
@@ -5686,7 +5695,8 @@ namespace ts {
|
||||
const excludeModifiers = isUnion ? ModifierFlags.NonPublicAccessibilityModifier : 0;
|
||||
// Flags we want to propagate to the result if they exist in all source symbols
|
||||
let commonFlags = isUnion ? SymbolFlags.None : SymbolFlags.Optional;
|
||||
let checkFlags = CheckFlags.SyntheticProperty;
|
||||
let syntheticFlag = CheckFlags.SyntheticMethod;
|
||||
let checkFlags = 0;
|
||||
for (const current of types) {
|
||||
const type = getApparentType(current);
|
||||
if (type !== unknownType) {
|
||||
@@ -5705,6 +5715,9 @@ namespace ts {
|
||||
(modifiers & ModifierFlags.Protected ? CheckFlags.ContainsProtected : 0) |
|
||||
(modifiers & ModifierFlags.Private ? CheckFlags.ContainsPrivate : 0) |
|
||||
(modifiers & ModifierFlags.Static ? CheckFlags.ContainsStatic : 0);
|
||||
if (!isMethodLike(prop)) {
|
||||
syntheticFlag = CheckFlags.SyntheticProperty;
|
||||
}
|
||||
}
|
||||
else if (isUnion) {
|
||||
checkFlags |= CheckFlags.Partial;
|
||||
@@ -5734,7 +5747,7 @@ namespace ts {
|
||||
propTypes.push(type);
|
||||
}
|
||||
const result = createSymbol(SymbolFlags.Property | commonFlags, name);
|
||||
result.checkFlags = checkFlags;
|
||||
result.checkFlags = syntheticFlag | checkFlags;
|
||||
result.containingType = containingType;
|
||||
result.declarations = declarations;
|
||||
result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes);
|
||||
@@ -8820,8 +8833,8 @@ namespace ts {
|
||||
maybeStack[depth].set(id, RelationComparisonResult.Succeeded);
|
||||
depth++;
|
||||
const saveExpandingFlags = expandingFlags;
|
||||
if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) expandingFlags |= 1;
|
||||
if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) expandingFlags |= 2;
|
||||
if (!(expandingFlags & 1) && isDeeplyNestedType(source, sourceStack, depth)) expandingFlags |= 1;
|
||||
if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2;
|
||||
let result: Ternary;
|
||||
if (expandingFlags === 3) {
|
||||
result = Ternary.Maybe;
|
||||
@@ -9187,7 +9200,7 @@ namespace ts {
|
||||
// Invoke the callback for each underlying property symbol of the given symbol and return the first
|
||||
// value that isn't undefined.
|
||||
function forEachProperty<T>(prop: Symbol, callback: (p: Symbol) => T): T {
|
||||
if (getCheckFlags(prop) & CheckFlags.SyntheticProperty) {
|
||||
if (getCheckFlags(prop) & CheckFlags.Synthetic) {
|
||||
for (const t of (<TransientSymbol>prop).containingType.types) {
|
||||
const p = getPropertyOfType(t, prop.name);
|
||||
const result = p && forEachProperty(p, callback);
|
||||
@@ -9241,21 +9254,23 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return true if the given type is part of a deeply nested chain of generic instantiations. We consider this to be the case
|
||||
// when structural type comparisons have been started for 10 or more instantiations of the same generic type. It is possible,
|
||||
// though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely expanding.
|
||||
// Effectively, we will generate a false positive when two types are structurally equal to at least 10 levels, but unequal at
|
||||
// some level beyond that.
|
||||
function isDeeplyNestedGeneric(type: Type, stack: Type[], depth: number): boolean {
|
||||
// We track type references (created by createTypeReference) and instantiated types (created by instantiateType)
|
||||
if (getObjectFlags(type) & (ObjectFlags.Reference | ObjectFlags.Instantiated) && depth >= 5) {
|
||||
// Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons
|
||||
// for 5 or more occurrences or instantiations of the type have been recorded on the given stack. It is possible,
|
||||
// though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely
|
||||
// expanding. Effectively, we will generate a false positive when two types are structurally equal to at least 5
|
||||
// levels, but unequal at some level beyond that.
|
||||
function isDeeplyNestedType(type: Type, stack: Type[], depth: number): boolean {
|
||||
// We track all object types that have an associated symbol (representing the origin of the type)
|
||||
if (depth >= 5 && type.flags & TypeFlags.Object) {
|
||||
const symbol = type.symbol;
|
||||
let count = 0;
|
||||
for (let i = 0; i < depth; i++) {
|
||||
const t = stack[i];
|
||||
if (getObjectFlags(t) & (ObjectFlags.Reference | ObjectFlags.Instantiated) && t.symbol === symbol) {
|
||||
count++;
|
||||
if (count >= 5) return true;
|
||||
if (symbol) {
|
||||
let count = 0;
|
||||
for (let i = 0; i < depth; i++) {
|
||||
const t = stack[i];
|
||||
if (t.flags & TypeFlags.Object && t.symbol === symbol) {
|
||||
count++;
|
||||
if (count >= 5) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9998,7 +10013,7 @@ namespace ts {
|
||||
if (isInProcess(source, target)) {
|
||||
return;
|
||||
}
|
||||
if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) {
|
||||
if (isDeeplyNestedType(source, sourceStack, depth) && isDeeplyNestedType(target, targetStack, depth)) {
|
||||
return;
|
||||
}
|
||||
const key = source.id + "," + target.id;
|
||||
@@ -13006,12 +13021,12 @@ namespace ts {
|
||||
type.flags & TypeFlags.UnionOrIntersection && !forEach((<UnionOrIntersectionType>type).types, t => !isValidSpreadType(t)));
|
||||
}
|
||||
|
||||
function checkJsxSelfClosingElement(node: JsxSelfClosingElement) {
|
||||
function checkJsxSelfClosingElement(node: JsxSelfClosingElement): Type {
|
||||
checkJsxOpeningLikeElement(node);
|
||||
return jsxElementType || anyType;
|
||||
return getJsxGlobalElementType() || anyType;
|
||||
}
|
||||
|
||||
function checkJsxElement(node: JsxElement) {
|
||||
function checkJsxElement(node: JsxElement): Type {
|
||||
// Check attributes
|
||||
checkJsxOpeningLikeElement(node.openingElement);
|
||||
|
||||
@@ -13038,7 +13053,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
return jsxElementType || anyType;
|
||||
return getJsxGlobalElementType() || anyType;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -13279,13 +13294,14 @@ namespace ts {
|
||||
function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement: JsxOpeningLikeElement, elementType: Type, elemInstanceType: Type, elementClassType?: Type): Type {
|
||||
Debug.assert(!(elementType.flags & TypeFlags.Union));
|
||||
if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) {
|
||||
if (jsxElementType) {
|
||||
const jsxStatelessElementType = getJsxGlobalStatelessElementType();
|
||||
if (jsxStatelessElementType) {
|
||||
// We don't call getResolvedSignature here because we have already resolve the type of JSX Element.
|
||||
const callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, /*candidatesOutArray*/ undefined);
|
||||
if (callSignature !== unknownSignature) {
|
||||
const callReturnType = callSignature && getReturnTypeOfSignature(callSignature);
|
||||
let paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0]));
|
||||
if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) {
|
||||
if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) {
|
||||
// Intersect in JSX.IntrinsicAttributes if it exists
|
||||
const intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes);
|
||||
if (intrinsicAttributes !== unknownType) {
|
||||
@@ -13313,7 +13329,8 @@ namespace ts {
|
||||
Debug.assert(!(elementType.flags & TypeFlags.Union));
|
||||
if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) {
|
||||
// Is this is a stateless function component? See if its single signature's return type is assignable to the JSX Element Type
|
||||
if (jsxElementType) {
|
||||
const jsxStatelessElementType = getJsxGlobalStatelessElementType();
|
||||
if (jsxStatelessElementType) {
|
||||
// We don't call getResolvedSignature because here we have already resolve the type of JSX Element.
|
||||
const candidatesOutArray: Signature[] = [];
|
||||
getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray);
|
||||
@@ -13322,7 +13339,7 @@ namespace ts {
|
||||
for (const candidate of candidatesOutArray) {
|
||||
const callReturnType = getReturnTypeOfSignature(candidate);
|
||||
const paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0]));
|
||||
if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) {
|
||||
if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) {
|
||||
let shouldBeCandidate = true;
|
||||
for (const attribute of openingLikeElement.attributes.properties) {
|
||||
if (isJsxAttribute(attribute) &&
|
||||
@@ -13566,6 +13583,23 @@ namespace ts {
|
||||
return deferredJsxElementClassType;
|
||||
}
|
||||
|
||||
function getJsxGlobalElementType(): Type {
|
||||
if (!deferredJsxElementType) {
|
||||
deferredJsxElementType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.Element);
|
||||
}
|
||||
return deferredJsxElementType;
|
||||
}
|
||||
|
||||
function getJsxGlobalStatelessElementType(): Type {
|
||||
if (!deferredJsxStatelessElementType) {
|
||||
const jsxElementType = getJsxGlobalElementType();
|
||||
if (jsxElementType) {
|
||||
deferredJsxStatelessElementType = getUnionType([jsxElementType, nullType]);
|
||||
}
|
||||
}
|
||||
return deferredJsxStatelessElementType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the properties of the Jsx.IntrinsicElements interface
|
||||
*/
|
||||
@@ -13580,7 +13614,7 @@ namespace ts {
|
||||
error(errorNode, Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided);
|
||||
}
|
||||
|
||||
if (jsxElementType === undefined) {
|
||||
if (getJsxGlobalElementType() === undefined) {
|
||||
if (noImplicitAny) {
|
||||
error(errorNode, Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist);
|
||||
}
|
||||
@@ -13669,7 +13703,7 @@ namespace ts {
|
||||
const flags = getCombinedModifierFlags(s.valueDeclaration);
|
||||
return s.parent && s.parent.flags & SymbolFlags.Class ? flags : flags & ~ModifierFlags.AccessibilityModifier;
|
||||
}
|
||||
if (getCheckFlags(s) & CheckFlags.SyntheticProperty) {
|
||||
if (getCheckFlags(s) & CheckFlags.Synthetic) {
|
||||
const checkFlags = (<TransientSymbol>s).checkFlags;
|
||||
const accessModifier = checkFlags & CheckFlags.ContainsPrivate ? ModifierFlags.Private :
|
||||
checkFlags & CheckFlags.ContainsPublic ? ModifierFlags.Public :
|
||||
@@ -13687,6 +13721,10 @@ namespace ts {
|
||||
return s.valueDeclaration ? getCombinedNodeFlags(s.valueDeclaration) : 0;
|
||||
}
|
||||
|
||||
function isMethodLike(symbol: Symbol) {
|
||||
return !!(symbol.flags & SymbolFlags.Method || getCheckFlags(symbol) & CheckFlags.SyntheticMethod);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the requested property access is valid.
|
||||
* Returns true if node is a valid property access, and false otherwise.
|
||||
@@ -13716,11 +13754,11 @@ namespace ts {
|
||||
// where this references the constructor function object of a derived class,
|
||||
// a super property access is permitted and must specify a public static member function of the base class.
|
||||
if (languageVersion < ScriptTarget.ES2015) {
|
||||
const propKind = getDeclarationKindFromSymbol(prop);
|
||||
if (propKind !== SyntaxKind.MethodDeclaration && propKind !== SyntaxKind.MethodSignature) {
|
||||
// `prop` refers to a *property* declared in the super class
|
||||
// rather than a *method*, so it does not satisfy the above criteria.
|
||||
|
||||
const hasNonMethodDeclaration = forEachProperty(prop, p => {
|
||||
const propKind = getDeclarationKindFromSymbol(p);
|
||||
return propKind !== SyntaxKind.MethodDeclaration && propKind !== SyntaxKind.MethodSignature;
|
||||
});
|
||||
if (hasNonMethodDeclaration) {
|
||||
error(errorNode, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword);
|
||||
return false;
|
||||
}
|
||||
@@ -13871,10 +13909,17 @@ namespace ts {
|
||||
}
|
||||
return unknownType;
|
||||
}
|
||||
if (prop.valueDeclaration &&
|
||||
isInPropertyInitializer(node) &&
|
||||
!isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) {
|
||||
error(right, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text);
|
||||
if (prop.valueDeclaration) {
|
||||
if (isInPropertyInitializer(node) &&
|
||||
!isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) {
|
||||
error(right, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text);
|
||||
}
|
||||
if (prop.valueDeclaration.kind === SyntaxKind.ClassDeclaration &&
|
||||
node.parent && node.parent.kind !== SyntaxKind.TypeReference &&
|
||||
!isInAmbientContext(prop.valueDeclaration) &&
|
||||
!isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) {
|
||||
error(right, Diagnostics.Class_0_used_before_its_declaration, right.text);
|
||||
}
|
||||
}
|
||||
|
||||
markPropertyAsReferenced(prop);
|
||||
@@ -15659,8 +15704,8 @@ namespace ts {
|
||||
else {
|
||||
let types: Type[];
|
||||
if (functionFlags & FunctionFlags.Generator) { // Generator or AsyncGenerator function
|
||||
types = checkAndAggregateYieldOperandTypes(func, checkMode);
|
||||
if (types.length === 0) {
|
||||
types = concatenate(checkAndAggregateYieldOperandTypes(func, checkMode), checkAndAggregateReturnExpressionTypes(func, checkMode));
|
||||
if (!types || types.length === 0) {
|
||||
const iterableIteratorAny = functionFlags & FunctionFlags.Async
|
||||
? createAsyncIterableIteratorType(anyType) // AsyncGenerator function
|
||||
: createIterableIteratorType(anyType); // Generator function
|
||||
@@ -19301,7 +19346,7 @@ namespace ts {
|
||||
|
||||
// unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved
|
||||
// in this case error about missing name is already reported - do not report extra one
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.Object | TypeFlags.TypeVariable)) {
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.Object | TypeFlags.TypeVariable | TypeFlags.NonPrimitive)) {
|
||||
error(node.expression, Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
|
||||
@@ -20121,14 +20166,6 @@ namespace ts {
|
||||
error(node.name || node, Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
|
||||
}
|
||||
|
||||
if (baseType.symbol && baseType.symbol.valueDeclaration &&
|
||||
!isInAmbientContext(baseType.symbol.valueDeclaration) &&
|
||||
baseType.symbol.valueDeclaration.kind === SyntaxKind.ClassDeclaration) {
|
||||
if (!isBlockScopedNameDeclaredBeforeUse(baseType.symbol.valueDeclaration, node)) {
|
||||
error(baseTypeNode, Diagnostics.A_class_must_be_declared_after_its_base_class);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class) && !(baseConstructorType.flags & TypeFlags.TypeVariable)) {
|
||||
// When the static base type is a "class-like" constructor function (but not actually a class), we verify
|
||||
// that all instantiated base constructor signatures return the same type. We can simply compare the type
|
||||
@@ -20254,7 +20291,7 @@ namespace ts {
|
||||
else {
|
||||
// derived overrides base.
|
||||
const derivedDeclarationFlags = getDeclarationModifierFlagsFromSymbol(derived);
|
||||
if ((baseDeclarationFlags & ModifierFlags.Private) || (derivedDeclarationFlags & ModifierFlags.Private)) {
|
||||
if (baseDeclarationFlags & ModifierFlags.Private || derivedDeclarationFlags & ModifierFlags.Private) {
|
||||
// either base or derived property is private - not override, skip it
|
||||
continue;
|
||||
}
|
||||
@@ -20264,28 +20301,24 @@ namespace ts {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((base.flags & derived.flags & SymbolFlags.Method) || ((base.flags & SymbolFlags.PropertyOrAccessor) && (derived.flags & SymbolFlags.PropertyOrAccessor))) {
|
||||
if (isMethodLike(base) && isMethodLike(derived) || base.flags & SymbolFlags.PropertyOrAccessor && derived.flags & SymbolFlags.PropertyOrAccessor) {
|
||||
// method is overridden with method or property/accessor is overridden with property/accessor - correct case
|
||||
continue;
|
||||
}
|
||||
|
||||
let errorMessage: DiagnosticMessage;
|
||||
if (base.flags & SymbolFlags.Method) {
|
||||
if (isMethodLike(base)) {
|
||||
if (derived.flags & SymbolFlags.Accessor) {
|
||||
errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor;
|
||||
}
|
||||
else {
|
||||
Debug.assert((derived.flags & SymbolFlags.Property) !== 0);
|
||||
errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property;
|
||||
}
|
||||
}
|
||||
else if (base.flags & SymbolFlags.Property) {
|
||||
Debug.assert((derived.flags & SymbolFlags.Method) !== 0);
|
||||
errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function;
|
||||
}
|
||||
else {
|
||||
Debug.assert((base.flags & SymbolFlags.Accessor) !== 0);
|
||||
Debug.assert((derived.flags & SymbolFlags.Method) !== 0);
|
||||
errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function;
|
||||
}
|
||||
|
||||
@@ -21944,7 +21977,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getRootSymbols(symbol: Symbol): Symbol[] {
|
||||
if (getCheckFlags(symbol) & CheckFlags.SyntheticProperty) {
|
||||
if (getCheckFlags(symbol) & CheckFlags.Synthetic) {
|
||||
const symbols: Symbol[] = [];
|
||||
const name = symbol.name;
|
||||
forEach(getSymbolLinks(symbol).containingType.types, t => {
|
||||
@@ -22625,7 +22658,6 @@ namespace ts {
|
||||
globalNumberType = getGlobalType("Number", /*arity*/ 0, /*reportErrors*/ true);
|
||||
globalBooleanType = getGlobalType("Boolean", /*arity*/ 0, /*reportErrors*/ true);
|
||||
globalRegExpType = getGlobalType("RegExp", /*arity*/ 0, /*reportErrors*/ true);
|
||||
jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element);
|
||||
anyArrayType = createArrayType(anyType);
|
||||
autoArrayType = createArrayType(autoType);
|
||||
|
||||
|
||||
+631
-410
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
"Unterminated string literal.": {
|
||||
"category": "Error",
|
||||
"code": 1002
|
||||
@@ -1435,6 +1435,14 @@
|
||||
"category": "Error",
|
||||
"code": 2448
|
||||
},
|
||||
"Class '{0}' used before its declaration.": {
|
||||
"category": "Error",
|
||||
"code": 2449
|
||||
},
|
||||
"Enum '{0}' used before its declaration.": {
|
||||
"category": "Error",
|
||||
"code": 2450
|
||||
},
|
||||
"Cannot redeclare block-scoped variable '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2451
|
||||
@@ -2019,10 +2027,6 @@
|
||||
"category": "Error",
|
||||
"code": 2689
|
||||
},
|
||||
"A class must be declared after its base class.": {
|
||||
"category": "Error",
|
||||
"code": 2690
|
||||
},
|
||||
"An import path cannot end with a '{0}' extension. Consider importing '{1}' instead.": {
|
||||
"category": "Error",
|
||||
"code": 2691
|
||||
@@ -2781,7 +2785,7 @@
|
||||
"category": "Message",
|
||||
"code": 6083
|
||||
},
|
||||
"Specify the object invoked for createElement and __spread when targeting 'react' JSX emit.": {
|
||||
"[Deprecated] Use '--jsxFactory' instead. Specify the object invoked for createElement when targeting 'react' JSX emit": {
|
||||
"category": "Message",
|
||||
"code": 6084
|
||||
},
|
||||
@@ -3037,14 +3041,139 @@
|
||||
"category": "Message",
|
||||
"code": 6148
|
||||
},
|
||||
"Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3.": {
|
||||
"Show diagnostic information.": {
|
||||
"category": "Message",
|
||||
"code": 6149
|
||||
},
|
||||
"Enable all strict type checks.": {
|
||||
"Show verbose diagnostic information.": {
|
||||
"category": "Message",
|
||||
"code": 6150
|
||||
},
|
||||
"Emit a single file with source maps instead of having a separate file.": {
|
||||
"category": "Message",
|
||||
"code": 6151
|
||||
},
|
||||
"Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set.": {
|
||||
"category": "Message",
|
||||
"code": 6152
|
||||
},
|
||||
"Transpile each file as a separate module (similar to 'ts.transpileModule').": {
|
||||
"category": "Message",
|
||||
"code": 6153
|
||||
},
|
||||
"Print names of generated files part of the compilation.": {
|
||||
"category": "Message",
|
||||
"code": 6154
|
||||
},
|
||||
"Print names of files part of the compilation.": {
|
||||
"category": "Message",
|
||||
"code": 6155
|
||||
},
|
||||
"The locale used when displaying messages to the user (e.g. 'en-us')": {
|
||||
"category": "Message",
|
||||
"code": 6156
|
||||
},
|
||||
"Do not generate custom helper functions like '__extends' in compiled output.": {
|
||||
"category": "Message",
|
||||
"code": 6157
|
||||
},
|
||||
"Do not include the default library file (lib.d.ts).": {
|
||||
"category": "Message",
|
||||
"code": 6158
|
||||
},
|
||||
"Do not add triple-slash references or imported modules to the list of compiled files.": {
|
||||
"category": "Message",
|
||||
"code": 6159
|
||||
},
|
||||
"[Deprecated] Use '--skipLibCheck' instead. Skip type checking of default library declaration files.": {
|
||||
"category": "Message",
|
||||
"code": 6160
|
||||
},
|
||||
"List of folders to include type definitions from.": {
|
||||
"category": "Message",
|
||||
"code": 6161
|
||||
},
|
||||
"Disable size limitations on JavaScript projects.": {
|
||||
"category": "Message",
|
||||
"code": 6162
|
||||
},
|
||||
"The character set of the input files.": {
|
||||
"category": "Message",
|
||||
"code": 6163
|
||||
},
|
||||
"Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.": {
|
||||
"category": "Message",
|
||||
"code": 6164
|
||||
},
|
||||
"Do not truncate error messages.": {
|
||||
"category": "Message",
|
||||
"code": 6165
|
||||
},
|
||||
"Output directory for generated declaration files.": {
|
||||
"category": "Message",
|
||||
"code": 6166
|
||||
},
|
||||
"A series of entries which re-map imports to lookup locations relative to the 'baseUrl'.": {
|
||||
"category": "Message",
|
||||
"code": 6167
|
||||
},
|
||||
"List of root folders whose combined content represents the structure of the project at runtime.": {
|
||||
"category": "Message",
|
||||
"code": 6168
|
||||
},
|
||||
"Show all compiler options.": {
|
||||
"category": "Message",
|
||||
"code": 6169
|
||||
},
|
||||
"[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file": {
|
||||
"category": "Message",
|
||||
"code": 6170
|
||||
},
|
||||
"Command-line Options": {
|
||||
"category": "Message",
|
||||
"code": 6171
|
||||
},
|
||||
"Basic Options": {
|
||||
"category": "Message",
|
||||
"code": 6172
|
||||
},
|
||||
"Strict Type-Checking Options": {
|
||||
"category": "Message",
|
||||
"code": 6173
|
||||
},
|
||||
"Module Resolution Options": {
|
||||
"category": "Message",
|
||||
"code": 6174
|
||||
},
|
||||
"Source Map Options": {
|
||||
"category": "Message",
|
||||
"code": 6175
|
||||
},
|
||||
"Additional Checks": {
|
||||
"category": "Message",
|
||||
"code": 6176
|
||||
},
|
||||
"Experimental Options": {
|
||||
"category": "Message",
|
||||
"code": 6177
|
||||
},
|
||||
"Advanced Options": {
|
||||
"category": "Message",
|
||||
"code": 6178
|
||||
},
|
||||
"Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'.": {
|
||||
"category": "Message",
|
||||
"code": 6179
|
||||
},
|
||||
"Enable all strict type-checking options.": {
|
||||
"category": "Message",
|
||||
"code": 6180
|
||||
},
|
||||
"List of language service plugins.": {
|
||||
"category": "Message",
|
||||
"code": 6181
|
||||
},
|
||||
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
"code": 7005
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace ts {
|
||||
*/
|
||||
/* @internal */
|
||||
export function getSynthesizedClone<T extends Node>(node: T | undefined): T {
|
||||
if(node === undefined) {
|
||||
if (node === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
// We don't use "clone" from core.ts here, as we need to preserve the prototype chain of
|
||||
@@ -334,7 +334,7 @@ namespace ts {
|
||||
export function createTypeOperatorNode(type: TypeNode) {
|
||||
const typeOperatorNode = createSynthesizedNode(SyntaxKind.TypeOperator) as TypeOperatorNode;
|
||||
typeOperatorNode.operator = SyntaxKind.KeyOfKeyword;
|
||||
typeOperatorNode.type = type
|
||||
typeOperatorNode.type = type;
|
||||
return typeOperatorNode;
|
||||
}
|
||||
|
||||
@@ -423,7 +423,7 @@ namespace ts {
|
||||
return <ConstructSignatureDeclaration>updateSignatureDeclaration(node, typeParameters, parameters, type);
|
||||
}
|
||||
|
||||
export function createMethodSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature{
|
||||
export function createMethodSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature {
|
||||
const methodSignature = createSignatureDeclaration(SyntaxKind.MethodSignature, typeParameters, parameters, type) as MethodSignature;
|
||||
methodSignature.name = asName(name);
|
||||
methodSignature.questionToken = questionToken;
|
||||
@@ -1749,7 +1749,7 @@ namespace ts {
|
||||
|
||||
// Clauses
|
||||
|
||||
export function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[]) {
|
||||
export function createHeritageClause(token: HeritageClause["token"], types: ExpressionWithTypeArguments[]) {
|
||||
const node = <HeritageClause>createSynthesizedNode(SyntaxKind.HeritageClause);
|
||||
node.token = token;
|
||||
node.types = createNodeArray(types);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="core.ts" />
|
||||
/// <reference path="core.ts" />
|
||||
/// <reference path="diagnosticInformationMap.generated.ts" />
|
||||
|
||||
namespace ts {
|
||||
|
||||
@@ -5437,9 +5437,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseHeritageClause(): HeritageClause | undefined {
|
||||
if (token() === SyntaxKind.ExtendsKeyword || token() === SyntaxKind.ImplementsKeyword) {
|
||||
const tok = token();
|
||||
if (tok === SyntaxKind.ExtendsKeyword || tok === SyntaxKind.ImplementsKeyword) {
|
||||
const node = <HeritageClause>createNode(SyntaxKind.HeritageClause);
|
||||
node.token = token();
|
||||
node.token = tok;
|
||||
nextToken();
|
||||
node.types = parseDelimitedList(ParsingContext.HeritageClauseElement, parseExpressionWithTypeArguments);
|
||||
return finishNode(node);
|
||||
|
||||
@@ -298,8 +298,8 @@ namespace ts {
|
||||
let noDiagnosticsTypeChecker: TypeChecker;
|
||||
let classifiableNames: Map<string>;
|
||||
|
||||
let cachedSemanticDiagnosticsForFile: DiagnosticCache = {};
|
||||
let cachedDeclarationDiagnosticsForFile: DiagnosticCache = {};
|
||||
const cachedSemanticDiagnosticsForFile: DiagnosticCache = {};
|
||||
const cachedDeclarationDiagnosticsForFile: DiagnosticCache = {};
|
||||
|
||||
let resolvedTypeReferenceDirectives = createMap<ResolvedTypeReferenceDirective>();
|
||||
let fileProcessingDiagnostics = createDiagnosticCollection();
|
||||
@@ -1105,7 +1105,7 @@ namespace ts {
|
||||
return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache);
|
||||
}
|
||||
|
||||
function getDeclarationDiagnosticsForFileNoCache(sourceFile: SourceFile| undefined, cancellationToken: CancellationToken) {
|
||||
function getDeclarationDiagnosticsForFileNoCache(sourceFile: SourceFile | undefined, cancellationToken: CancellationToken) {
|
||||
return runWithCancellationToken(() => {
|
||||
const resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
|
||||
// Don't actually write any files since we're just getting diagnostics.
|
||||
|
||||
+8
-7
@@ -225,9 +225,9 @@ namespace ts {
|
||||
return sys.exit(ExitStatus.Success);
|
||||
}
|
||||
|
||||
if (commandLine.options.help) {
|
||||
if (commandLine.options.help || commandLine.options.all) {
|
||||
printVersion();
|
||||
printHelp();
|
||||
printHelp(commandLine.options.all);
|
||||
return sys.exit(ExitStatus.Success);
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ namespace ts {
|
||||
|
||||
if (commandLine.fileNames.length === 0 && !configFileName) {
|
||||
printVersion();
|
||||
printHelp();
|
||||
printHelp(commandLine.options.all);
|
||||
return sys.exit(ExitStatus.Success);
|
||||
}
|
||||
|
||||
@@ -618,7 +618,7 @@ namespace ts {
|
||||
sys.write(getDiagnosticText(Diagnostics.Version_0, ts.version) + sys.newLine);
|
||||
}
|
||||
|
||||
function printHelp() {
|
||||
function printHelp(showAllOptions: boolean) {
|
||||
const output: string[] = [];
|
||||
|
||||
// We want to align our "syntax" and "examples" commands to a certain margin.
|
||||
@@ -643,8 +643,9 @@ namespace ts {
|
||||
output.push(getDiagnosticText(Diagnostics.Options_Colon) + sys.newLine);
|
||||
|
||||
// Sort our options by their names, (e.g. "--noImplicitAny" comes before "--watch")
|
||||
const optsList = filter(optionDeclarations.slice(), v => !v.experimental);
|
||||
optsList.sort((a, b) => compareValues<string>(a.name.toLowerCase(), b.name.toLowerCase()));
|
||||
const optsList = showAllOptions ?
|
||||
optionDeclarations.slice().sort((a, b) => compareValues<string>(a.name.toLowerCase(), b.name.toLowerCase())) :
|
||||
filter(optionDeclarations.slice(), v => v.showInSimplifiedHelpView);
|
||||
|
||||
// We want our descriptions to align at the same column in our output,
|
||||
// so we keep track of the longest option usage string.
|
||||
@@ -738,7 +739,7 @@ namespace ts {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file), /* host */ undefined);
|
||||
}
|
||||
else {
|
||||
sys.writeFile(file, JSON.stringify(generateTSConfig(options, fileNames), undefined, 4));
|
||||
sys.writeFile(file, generateTSConfig(options, fileNames));
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file), /* host */ undefined);
|
||||
}
|
||||
|
||||
|
||||
+35
-27
@@ -815,18 +815,21 @@ namespace ts {
|
||||
|
||||
export interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement {
|
||||
kind: SyntaxKind.Constructor;
|
||||
parent?: ClassDeclaration | ClassExpression;
|
||||
body?: FunctionBody;
|
||||
}
|
||||
|
||||
/** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements.*/
|
||||
export interface SemicolonClassElement extends ClassElement {
|
||||
kind: SyntaxKind.SemicolonClassElement;
|
||||
parent?: ClassDeclaration | ClassExpression;
|
||||
}
|
||||
|
||||
// See the comment on MethodDeclaration for the intuition behind GetAccessorDeclaration being a
|
||||
// ClassElement and an ObjectLiteralElement.
|
||||
export interface GetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement {
|
||||
kind: SyntaxKind.GetAccessor;
|
||||
parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression;
|
||||
name: PropertyName;
|
||||
body: FunctionBody;
|
||||
}
|
||||
@@ -835,6 +838,7 @@ namespace ts {
|
||||
// ClassElement and an ObjectLiteralElement.
|
||||
export interface SetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement {
|
||||
kind: SyntaxKind.SetAccessor;
|
||||
parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression;
|
||||
name: PropertyName;
|
||||
body: FunctionBody;
|
||||
}
|
||||
@@ -843,6 +847,7 @@ namespace ts {
|
||||
|
||||
export interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement {
|
||||
kind: SyntaxKind.IndexSignature;
|
||||
parent?: ClassDeclaration | ClassExpression | InterfaceDeclaration | TypeLiteralNode;
|
||||
}
|
||||
|
||||
export interface TypeNode extends Node {
|
||||
@@ -867,15 +872,13 @@ namespace ts {
|
||||
kind: SyntaxKind.ThisType;
|
||||
}
|
||||
|
||||
export interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration {
|
||||
kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType;
|
||||
}
|
||||
export type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode;
|
||||
|
||||
export interface FunctionTypeNode extends FunctionOrConstructorTypeNode {
|
||||
export interface FunctionTypeNode extends TypeNode, SignatureDeclaration {
|
||||
kind: SyntaxKind.FunctionType;
|
||||
}
|
||||
|
||||
export interface ConstructorTypeNode extends FunctionOrConstructorTypeNode {
|
||||
export interface ConstructorTypeNode extends TypeNode, SignatureDeclaration {
|
||||
kind: SyntaxKind.ConstructorType;
|
||||
}
|
||||
|
||||
@@ -912,17 +915,16 @@ namespace ts {
|
||||
elementTypes: NodeArray<TypeNode>;
|
||||
}
|
||||
|
||||
export interface UnionOrIntersectionTypeNode extends TypeNode {
|
||||
kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType;
|
||||
export type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode;
|
||||
|
||||
export interface UnionTypeNode extends TypeNode {
|
||||
kind: SyntaxKind.UnionType;
|
||||
types: NodeArray<TypeNode>;
|
||||
}
|
||||
|
||||
export interface UnionTypeNode extends UnionOrIntersectionTypeNode {
|
||||
kind: SyntaxKind.UnionType;
|
||||
}
|
||||
|
||||
export interface IntersectionTypeNode extends UnionOrIntersectionTypeNode {
|
||||
export interface IntersectionTypeNode extends TypeNode {
|
||||
kind: SyntaxKind.IntersectionType;
|
||||
types: NodeArray<TypeNode>;
|
||||
}
|
||||
|
||||
export interface ParenthesizedTypeNode extends TypeNode {
|
||||
@@ -944,6 +946,7 @@ namespace ts {
|
||||
|
||||
export interface MappedTypeNode extends TypeNode, Declaration {
|
||||
kind: SyntaxKind.MappedType;
|
||||
parent?: TypeAliasDeclaration;
|
||||
readonlyToken?: ReadonlyToken;
|
||||
typeParameter: TypeParameterDeclaration;
|
||||
questionToken?: QuestionToken;
|
||||
@@ -1457,7 +1460,7 @@ namespace ts {
|
||||
kind: SyntaxKind.NewExpression;
|
||||
expression: LeftHandSideExpression;
|
||||
typeArguments?: NodeArray<TypeNode>;
|
||||
arguments: NodeArray<Expression>;
|
||||
arguments?: NodeArray<Expression>;
|
||||
}
|
||||
|
||||
export interface TaggedTemplateExpression extends MemberExpression {
|
||||
@@ -1511,6 +1514,7 @@ namespace ts {
|
||||
export type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression;
|
||||
|
||||
export interface JsxAttributes extends ObjectLiteralExpressionBase<JsxAttributeLike> {
|
||||
parent?: JsxOpeningLikeElement;
|
||||
}
|
||||
|
||||
/// The opening element of a <Tag>...</Tag> JsxElement
|
||||
@@ -1530,7 +1534,7 @@ namespace ts {
|
||||
|
||||
export interface JsxAttribute extends ObjectLiteralElement {
|
||||
kind: SyntaxKind.JsxAttribute;
|
||||
parent?: JsxOpeningLikeElement;
|
||||
parent?: JsxAttributes;
|
||||
name: Identifier;
|
||||
/// JSX attribute initializers are optional; <X y /> is sugar for <X y={true} />
|
||||
initializer?: StringLiteral | JsxExpression;
|
||||
@@ -1538,7 +1542,7 @@ namespace ts {
|
||||
|
||||
export interface JsxSpreadAttribute extends ObjectLiteralElement {
|
||||
kind: SyntaxKind.JsxSpreadAttribute;
|
||||
parent?: JsxOpeningLikeElement;
|
||||
parent?: JsxAttributes;
|
||||
expression: Expression;
|
||||
}
|
||||
|
||||
@@ -1783,8 +1787,8 @@ namespace ts {
|
||||
export interface HeritageClause extends Node {
|
||||
kind: SyntaxKind.HeritageClause;
|
||||
parent?: InterfaceDeclaration | ClassDeclaration | ClassExpression;
|
||||
token: SyntaxKind;
|
||||
types?: NodeArray<ExpressionWithTypeArguments>;
|
||||
token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword;
|
||||
types: NodeArray<ExpressionWithTypeArguments>;
|
||||
}
|
||||
|
||||
export interface TypeAliasDeclaration extends DeclarationStatement {
|
||||
@@ -2230,7 +2234,7 @@ namespace ts {
|
||||
endOfFileToken: Token<SyntaxKind.EndOfFileToken>;
|
||||
|
||||
fileName: string;
|
||||
/* internal */ path: Path;
|
||||
/* @internal */ path: Path;
|
||||
text: string;
|
||||
|
||||
amdDependencies: AmdDependency[];
|
||||
@@ -2853,13 +2857,15 @@ namespace ts {
|
||||
export const enum CheckFlags {
|
||||
Instantiated = 1 << 0, // Instantiated symbol
|
||||
SyntheticProperty = 1 << 1, // Property in union or intersection type
|
||||
Readonly = 1 << 2, // Readonly transient symbol
|
||||
Partial = 1 << 3, // Synthetic property present in some but not all constituents
|
||||
HasNonUniformType = 1 << 4, // Synthetic property with non-uniform type in constituents
|
||||
ContainsPublic = 1 << 5, // Synthetic property with public constituent(s)
|
||||
ContainsProtected = 1 << 6, // Synthetic property with protected constituent(s)
|
||||
ContainsPrivate = 1 << 7, // Synthetic property with private constituent(s)
|
||||
ContainsStatic = 1 << 8, // Synthetic property with static constituent(s)
|
||||
SyntheticMethod = 1 << 2, // Method in union or intersection type
|
||||
Readonly = 1 << 3, // Readonly transient symbol
|
||||
Partial = 1 << 4, // Synthetic property present in some but not all constituents
|
||||
HasNonUniformType = 1 << 5, // Synthetic property with non-uniform type in constituents
|
||||
ContainsPublic = 1 << 6, // Synthetic property with public constituent(s)
|
||||
ContainsProtected = 1 << 7, // Synthetic property with protected constituent(s)
|
||||
ContainsPrivate = 1 << 8, // Synthetic property with private constituent(s)
|
||||
ContainsStatic = 1 << 9, // Synthetic property with static constituent(s)
|
||||
Synthetic = SyntheticProperty | SyntheticMethod
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -3036,7 +3042,6 @@ namespace ts {
|
||||
ObjectLiteral = 1 << 7, // Originates in an object literal
|
||||
EvolvingArray = 1 << 8, // Evolving array type
|
||||
ObjectLiteralPatternWithComputedProperties = 1 << 9, // Object literal pattern with computed properties
|
||||
NonPrimitive = 1 << 10, // NonPrimitive object type
|
||||
ClassOrInterface = Class | Interface
|
||||
}
|
||||
|
||||
@@ -3353,6 +3358,7 @@ namespace ts {
|
||||
export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike<string[]> | PluginImport[];
|
||||
|
||||
export interface CompilerOptions {
|
||||
/*@internal*/ all?: boolean;
|
||||
allowJs?: boolean;
|
||||
/*@internal*/ allowNonTsExtensions?: boolean;
|
||||
allowSyntheticDefaultImports?: boolean;
|
||||
@@ -3545,8 +3551,10 @@ namespace ts {
|
||||
shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help'
|
||||
description?: DiagnosticMessage; // The message describing what the command line switch does
|
||||
paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter
|
||||
experimental?: boolean;
|
||||
isTSConfigOnly?: boolean; // True if option can only be specified via tsconfig.json file
|
||||
isCommandLineOnly?: boolean;
|
||||
showInSimplifiedHelpView?: boolean;
|
||||
category?: DiagnosticMessage;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
|
||||
@@ -524,7 +524,7 @@ namespace ts {
|
||||
export function declarationNameToString(name: DeclarationName) {
|
||||
return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
|
||||
}
|
||||
|
||||
|
||||
export function getNameFromIndexInfo(info: IndexInfo) {
|
||||
return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined;
|
||||
}
|
||||
@@ -2679,7 +2679,7 @@ namespace ts {
|
||||
if (sourceFiles.length) {
|
||||
const jsFilePath = options.outFile || options.out;
|
||||
const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options);
|
||||
const declarationFilePath = options.declaration ? removeFileExtension(jsFilePath) + ".d.ts" : undefined;
|
||||
const declarationFilePath = options.declaration ? removeFileExtension(jsFilePath) + ".d.ts" : "";
|
||||
action({ jsFilePath, sourceMapFilePath, declarationFilePath }, createBundle(sourceFiles), emitOnlyDtsFiles);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/// <reference path="factory.ts" />
|
||||
/// <reference path="utilities.ts" />
|
||||
|
||||
namespace ts {
|
||||
namespace ts {
|
||||
export const nullTransformationContext: TransformationContext = {
|
||||
enableEmitNotification: noop,
|
||||
enableSubstitution: noop,
|
||||
|
||||
Reference in New Issue
Block a user