mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into fixContextuallyTypedParameters
# Conflicts: # src/compiler/checker.ts
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../tsconfig-base",
|
||||
"extends": "../tsconfig-noncomposite-base",
|
||||
"compilerOptions": {
|
||||
"outDir": "../../built/local/",
|
||||
"rootDir": ".",
|
||||
|
||||
+68
-53
@@ -4855,7 +4855,7 @@ namespace ts {
|
||||
|
||||
function getLiteralPropertyNameText(name: PropertyName) {
|
||||
const type = getLiteralTypeFromPropertyName(name);
|
||||
return type.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral) ? "" + (<LiteralType>type).value : undefined;
|
||||
return type.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral) ? "" + (<StringLiteralType | NumberLiteralType>type).value : undefined;
|
||||
}
|
||||
|
||||
/** Return the inferred type for a binding element */
|
||||
@@ -5279,17 +5279,18 @@ namespace ts {
|
||||
let objectFlags = ObjectFlags.ObjectLiteral;
|
||||
forEach(pattern.elements, e => {
|
||||
const name = e.propertyName || <Identifier>e.name;
|
||||
if (isComputedNonLiteralName(name)) {
|
||||
// do not include computed properties in the implied type
|
||||
objectFlags |= ObjectFlags.ObjectLiteralPatternWithComputedProperties;
|
||||
return;
|
||||
}
|
||||
if (e.dotDotDotToken) {
|
||||
stringIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false);
|
||||
return;
|
||||
}
|
||||
|
||||
const text = getTextOfPropertyName(name);
|
||||
const exprType = getLiteralTypeFromPropertyName(name);
|
||||
if (!isTypeUsableAsPropertyName(exprType)) {
|
||||
// do not include computed properties in the implied type
|
||||
objectFlags |= ObjectFlags.ObjectLiteralPatternWithComputedProperties;
|
||||
return;
|
||||
}
|
||||
const text = getPropertyNameFromType(exprType);
|
||||
const flags = SymbolFlags.Property | (e.initializer ? SymbolFlags.Optional : 0);
|
||||
const symbol = createSymbol(flags, text);
|
||||
symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors);
|
||||
@@ -6402,9 +6403,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether a type can be used as a late-bound name.
|
||||
* Indicates whether a type can be used as a property name.
|
||||
*/
|
||||
function isTypeUsableAsLateBoundName(type: Type): type is LiteralType | UniqueESSymbolType {
|
||||
function isTypeUsableAsPropertyName(type: Type): type is StringLiteralType | NumberLiteralType | UniqueESSymbolType {
|
||||
return !!(type.flags & TypeFlags.StringOrNumberLiteralOrUnique);
|
||||
}
|
||||
|
||||
@@ -6419,7 +6420,7 @@ namespace ts {
|
||||
function isLateBindableName(node: DeclarationName): node is LateBoundName {
|
||||
return isComputedPropertyName(node)
|
||||
&& isEntityNameExpression(node.expression)
|
||||
&& isTypeUsableAsLateBoundName(checkComputedPropertyName(node));
|
||||
&& isTypeUsableAsPropertyName(checkComputedPropertyName(node));
|
||||
}
|
||||
|
||||
function isLateBoundName(name: __String): boolean {
|
||||
@@ -6451,14 +6452,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the symbolic name for a late-bound member from its type.
|
||||
* Gets the symbolic name for a member from its type.
|
||||
*/
|
||||
function getLateBoundNameFromType(type: LiteralType | UniqueESSymbolType): __String {
|
||||
function getPropertyNameFromType(type: StringLiteralType | NumberLiteralType | UniqueESSymbolType): __String {
|
||||
if (type.flags & TypeFlags.UniqueESSymbol) {
|
||||
return `__@${type.symbol.escapedName}@${getSymbolId(type.symbol)}` as __String;
|
||||
return (<UniqueESSymbolType>type).escapedName;
|
||||
}
|
||||
if (type.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral)) {
|
||||
return escapeLeadingUnderscores("" + (<LiteralType>type).value);
|
||||
return escapeLeadingUnderscores("" + (<StringLiteralType | NumberLiteralType>type).value);
|
||||
}
|
||||
return Debug.fail();
|
||||
}
|
||||
@@ -6521,8 +6522,8 @@ namespace ts {
|
||||
// fall back to the early-bound name of this member.
|
||||
links.resolvedSymbol = decl.symbol;
|
||||
const type = checkComputedPropertyName(decl.name);
|
||||
if (isTypeUsableAsLateBoundName(type)) {
|
||||
const memberName = getLateBoundNameFromType(type);
|
||||
if (isTypeUsableAsPropertyName(type)) {
|
||||
const memberName = getPropertyNameFromType(type);
|
||||
const symbolFlags = decl.symbol.flags;
|
||||
|
||||
// Get or add a late-bound symbol for the member. This allows us to merge late-bound accessor declarations.
|
||||
@@ -6537,9 +6538,9 @@ namespace ts {
|
||||
// If we have an existing early-bound member, combine its declarations so that we can
|
||||
// report an error at each declaration.
|
||||
const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
|
||||
const name = declarationNameToString(decl.name);
|
||||
forEach(declarations, declaration => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Duplicate_declaration_0, name));
|
||||
error(decl.name || decl, Diagnostics.Duplicate_declaration_0, name);
|
||||
const name = !(type.flags & TypeFlags.UniqueESSymbol) && unescapeLeadingUnderscores(memberName) || declarationNameToString(decl.name);
|
||||
forEach(declarations, declaration => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Property_0_was_also_declared_here, name));
|
||||
error(decl.name || decl, Diagnostics.Duplicate_property_0, name);
|
||||
lateSymbol = createSymbol(SymbolFlags.None, memberName, CheckFlags.Late);
|
||||
}
|
||||
lateSymbol.nameType = type;
|
||||
@@ -7171,8 +7172,8 @@ namespace ts {
|
||||
const propType = instantiateType(templateType, templateMapper);
|
||||
// If the current iteration type constituent is a string literal type, create a property.
|
||||
// Otherwise, for type string create a string index signature.
|
||||
if (t.flags & TypeFlags.StringOrNumberLiteralOrUnique) {
|
||||
const propName = getLateBoundNameFromType(t as LiteralType);
|
||||
if (isTypeUsableAsPropertyName(t)) {
|
||||
const propName = getPropertyNameFromType(t);
|
||||
const modifiersProp = getPropertyOfType(modifiersType, propName);
|
||||
const isOptional = !!(templateModifiers & MappedTypeModifiers.IncludeOptional ||
|
||||
!(templateModifiers & MappedTypeModifiers.ExcludeOptional) && modifiersProp && modifiersProp.flags & SymbolFlags.Optional);
|
||||
@@ -7357,7 +7358,8 @@ namespace ts {
|
||||
function isTypeInvalidDueToUnionDiscriminant(contextualType: Type, obj: ObjectLiteralExpression | JsxAttributes): boolean {
|
||||
const list = obj.properties as NodeArray<ObjectLiteralElementLike | JsxAttributeLike>;
|
||||
return list.some(property => {
|
||||
const name = property.name && getTextOfPropertyName(property.name);
|
||||
const nameType = property.name && getLiteralTypeFromPropertyName(property.name);
|
||||
const name = nameType && isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined;
|
||||
const expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name);
|
||||
return !!expected && isLiteralType(expected) && !isTypeIdenticalTo(getTypeOfNode(property), expected);
|
||||
});
|
||||
@@ -9725,8 +9727,8 @@ namespace ts {
|
||||
|
||||
function getPropertyTypeForIndexType(objectType: Type, indexType: Type, accessNode: ElementAccessExpression | IndexedAccessTypeNode | PropertyName | BindingName | SyntheticExpression | undefined, cacheSymbol: boolean, missingType: Type) {
|
||||
const accessExpression = accessNode && accessNode.kind === SyntaxKind.ElementAccessExpression ? accessNode : undefined;
|
||||
const propName = isTypeUsableAsLateBoundName(indexType) ?
|
||||
getLateBoundNameFromType(indexType) :
|
||||
const propName = isTypeUsableAsPropertyName(indexType) ?
|
||||
getPropertyNameFromType(indexType) :
|
||||
accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ?
|
||||
getPropertyNameForKnownSymbolName(idText((<PropertyAccessExpression>accessExpression.argumentExpression).name)) :
|
||||
accessNode && isPropertyName(accessNode) ?
|
||||
@@ -9817,7 +9819,7 @@ namespace ts {
|
||||
if (accessNode) {
|
||||
const indexNode = getIndexNodeForAccessExpression(accessNode);
|
||||
if (indexType.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral)) {
|
||||
error(indexNode, Diagnostics.Property_0_does_not_exist_on_type_1, "" + (<LiteralType>indexType).value, typeToString(objectType));
|
||||
error(indexNode, Diagnostics.Property_0_does_not_exist_on_type_1, "" + (<StringLiteralType | NumberLiteralType>indexType).value, typeToString(objectType));
|
||||
}
|
||||
else if (indexType.flags & (TypeFlags.String | TypeFlags.Number)) {
|
||||
error(indexNode, Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType));
|
||||
@@ -10416,6 +10418,7 @@ namespace ts {
|
||||
function createUniqueESSymbolType(symbol: Symbol) {
|
||||
const type = <UniqueESSymbolType>createType(TypeFlags.UniqueESSymbol);
|
||||
type.symbol = symbol;
|
||||
type.escapedName = `__@${type.symbol.escapedName}@${getSymbolId(type.symbol)}` as __String;
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -10636,7 +10639,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getRestrictiveTypeParameter(tp: TypeParameter) {
|
||||
return !tp.constraint ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol));
|
||||
return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (
|
||||
tp.restrictiveInstantiation = createTypeParameter(tp.symbol),
|
||||
(tp.restrictiveInstantiation as TypeParameter).constraint = unknownType,
|
||||
tp.restrictiveInstantiation
|
||||
);
|
||||
}
|
||||
|
||||
function restrictiveMapper(type: Type) {
|
||||
@@ -11303,7 +11310,7 @@ namespace ts {
|
||||
}
|
||||
if (resultObj.error) {
|
||||
const reportedDiag = resultObj.error;
|
||||
const propertyName = isTypeUsableAsLateBoundName(nameType) ? getLateBoundNameFromType(nameType) : undefined;
|
||||
const propertyName = isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined;
|
||||
const targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined;
|
||||
|
||||
let issuedElaboration = false;
|
||||
@@ -11762,11 +11769,11 @@ namespace ts {
|
||||
if (s & TypeFlags.StringLike && t & TypeFlags.String) return true;
|
||||
if (s & TypeFlags.StringLiteral && s & TypeFlags.EnumLiteral &&
|
||||
t & TypeFlags.StringLiteral && !(t & TypeFlags.EnumLiteral) &&
|
||||
(<LiteralType>source).value === (<LiteralType>target).value) return true;
|
||||
(<StringLiteralType>source).value === (<StringLiteralType>target).value) return true;
|
||||
if (s & TypeFlags.NumberLike && t & TypeFlags.Number) return true;
|
||||
if (s & TypeFlags.NumberLiteral && s & TypeFlags.EnumLiteral &&
|
||||
t & TypeFlags.NumberLiteral && !(t & TypeFlags.EnumLiteral) &&
|
||||
(<LiteralType>source).value === (<LiteralType>target).value) return true;
|
||||
(<NumberLiteralType>source).value === (<NumberLiteralType>target).value) return true;
|
||||
if (s & TypeFlags.BigIntLike && t & TypeFlags.BigInt) return true;
|
||||
if (s & TypeFlags.BooleanLike && t & TypeFlags.Boolean) return true;
|
||||
if (s & TypeFlags.ESSymbolLike && t & TypeFlags.ESSymbol) return true;
|
||||
@@ -13690,8 +13697,8 @@ namespace ts {
|
||||
// no flags for all other types (including non-falsy literal types).
|
||||
function getFalsyFlags(type: Type): TypeFlags {
|
||||
return type.flags & TypeFlags.Union ? getFalsyFlagsOfTypes((<UnionType>type).types) :
|
||||
type.flags & TypeFlags.StringLiteral ? (<LiteralType>type).value === "" ? TypeFlags.StringLiteral : 0 :
|
||||
type.flags & TypeFlags.NumberLiteral ? (<LiteralType>type).value === 0 ? TypeFlags.NumberLiteral : 0 :
|
||||
type.flags & TypeFlags.StringLiteral ? (<StringLiteralType>type).value === "" ? TypeFlags.StringLiteral : 0 :
|
||||
type.flags & TypeFlags.NumberLiteral ? (<NumberLiteralType>type).value === 0 ? TypeFlags.NumberLiteral : 0 :
|
||||
type.flags & TypeFlags.BigIntLiteral ? isZeroBigInt(<BigIntLiteralType>type) ? TypeFlags.BigIntLiteral : 0 :
|
||||
type.flags & TypeFlags.BooleanLiteral ? (type === falseType || type === regularFalseType) ? TypeFlags.BooleanLiteral : 0 :
|
||||
type.flags & TypeFlags.PossiblyFalsy;
|
||||
@@ -13714,8 +13721,8 @@ namespace ts {
|
||||
type === regularFalseType ||
|
||||
type === falseType ||
|
||||
type.flags & (TypeFlags.Void | TypeFlags.Undefined | TypeFlags.Null) ||
|
||||
type.flags & TypeFlags.StringLiteral && (<LiteralType>type).value === "" ||
|
||||
type.flags & TypeFlags.NumberLiteral && (<LiteralType>type).value === 0 ||
|
||||
type.flags & TypeFlags.StringLiteral && (<StringLiteralType>type).value === "" ||
|
||||
type.flags & TypeFlags.NumberLiteral && (<NumberLiteralType>type).value === 0 ||
|
||||
type.flags & TypeFlags.BigIntLiteral && isZeroBigInt(<BigIntLiteralType>type) ? type :
|
||||
neverType;
|
||||
}
|
||||
@@ -14570,7 +14577,12 @@ namespace ts {
|
||||
priority |= InferencePriority.MappedTypeConstraint;
|
||||
inferFromTypes(getIndexType(source), constraintType);
|
||||
priority = savePriority;
|
||||
inferFromTypes(getUnionType(map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(<MappedType>target));
|
||||
const valueTypes = compact([
|
||||
getIndexTypeOfType(source, IndexKind.String),
|
||||
getIndexTypeOfType(source, IndexKind.Number),
|
||||
...map(getPropertiesOfType(source), getTypeOfSymbol)
|
||||
]);
|
||||
inferFromTypes(getUnionType(valueTypes), getTemplateTypeFromMappedType(<MappedType>target));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -15103,7 +15115,7 @@ namespace ts {
|
||||
return strictNullChecks ? TypeFacts.StringStrictFacts : TypeFacts.StringFacts;
|
||||
}
|
||||
if (flags & TypeFlags.StringLiteral) {
|
||||
const isEmpty = (<LiteralType>type).value === "";
|
||||
const isEmpty = (<StringLiteralType>type).value === "";
|
||||
return strictNullChecks ?
|
||||
isEmpty ? TypeFacts.EmptyStringStrictFacts : TypeFacts.NonEmptyStringStrictFacts :
|
||||
isEmpty ? TypeFacts.EmptyStringFacts : TypeFacts.NonEmptyStringFacts;
|
||||
@@ -15112,7 +15124,7 @@ namespace ts {
|
||||
return strictNullChecks ? TypeFacts.NumberStrictFacts : TypeFacts.NumberFacts;
|
||||
}
|
||||
if (flags & TypeFlags.NumberLiteral) {
|
||||
const isZero = (<LiteralType>type).value === 0;
|
||||
const isZero = (<NumberLiteralType>type).value === 0;
|
||||
return strictNullChecks ?
|
||||
isZero ? TypeFacts.ZeroNumberStrictFacts : TypeFacts.NonZeroNumberStrictFacts :
|
||||
isZero ? TypeFacts.ZeroNumberFacts : TypeFacts.NonZeroNumberFacts;
|
||||
@@ -15175,7 +15187,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getTypeOfDestructuredProperty(type: Type, name: PropertyName) {
|
||||
const text = getTextOfPropertyName(name);
|
||||
const nameType = getLiteralTypeFromPropertyName(name);
|
||||
if (!isTypeUsableAsPropertyName(nameType)) return errorType;
|
||||
const text = getPropertyNameFromType(nameType);
|
||||
return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) ||
|
||||
isNumericLiteralName(text) && getIndexTypeOfType(type, IndexKind.Number) ||
|
||||
getIndexTypeOfType(type, IndexKind.String) ||
|
||||
@@ -15783,9 +15797,6 @@ namespace ts {
|
||||
|
||||
function getTypeAtSwitchClause(flow: FlowSwitchClause): FlowType {
|
||||
const expr = flow.switchStatement.expression;
|
||||
if (containsMatchingReferenceDiscriminant(reference, expr)) {
|
||||
return declaredType;
|
||||
}
|
||||
const flowType = getTypeAtFlowNode(flow.antecedent);
|
||||
let type = getTypeFromFlowType(flowType);
|
||||
if (isMatchingReference(reference, expr)) {
|
||||
@@ -15800,6 +15811,9 @@ namespace ts {
|
||||
else if (expr.kind === SyntaxKind.TypeOfExpression && isMatchingReference(reference, (expr as TypeOfExpression).expression)) {
|
||||
type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
|
||||
}
|
||||
else if (containsMatchingReferenceDiscriminant(reference, expr)) {
|
||||
type = declaredType;
|
||||
}
|
||||
return createFlowType(type, isIncomplete(flowType));
|
||||
}
|
||||
|
||||
@@ -17307,9 +17321,10 @@ namespace ts {
|
||||
const parentDeclaration = declaration.parent.parent;
|
||||
const name = declaration.propertyName || declaration.name;
|
||||
const parentType = getContextualTypeForVariableLikeDeclaration(parentDeclaration);
|
||||
if (parentType && !isBindingPattern(name)) {
|
||||
const text = getTextOfPropertyName(name);
|
||||
if (text !== undefined) {
|
||||
if (parentType && !isBindingPattern(name) && !isComputedNonLiteralName(name)) {
|
||||
const nameType = getLiteralTypeFromPropertyName(name);
|
||||
if (isTypeUsableAsPropertyName(nameType)) {
|
||||
const text = getPropertyNameFromType(nameType);
|
||||
return getTypeOfPropertyOfType(parentType, text);
|
||||
}
|
||||
}
|
||||
@@ -18266,10 +18281,9 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
typeFlags |= type.flags;
|
||||
const nameType = computedNameType && computedNameType.flags & TypeFlags.StringOrNumberLiteralOrUnique ?
|
||||
<LiteralType | UniqueESSymbolType>computedNameType : undefined;
|
||||
const nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined;
|
||||
const prop = nameType ?
|
||||
createSymbol(SymbolFlags.Property | member.flags, getLateBoundNameFromType(nameType), CheckFlags.Late) :
|
||||
createSymbol(SymbolFlags.Property | member.flags, getPropertyNameFromType(nameType), CheckFlags.Late) :
|
||||
createSymbol(SymbolFlags.Property | member.flags, member.escapedName);
|
||||
if (nameType) {
|
||||
prop.nameType = nameType;
|
||||
@@ -22297,7 +22311,7 @@ namespace ts {
|
||||
if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, TypeFlags.NumberLike | TypeFlags.ESSymbolLike))) {
|
||||
error(left, Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
|
||||
}
|
||||
if (!isTypeAssignableToKind(rightType, TypeFlags.NonPrimitive | TypeFlags.InstantiableNonPrimitive)) {
|
||||
if (!allTypesAssignableToKind(rightType, TypeFlags.NonPrimitive | TypeFlags.InstantiableNonPrimitive)) {
|
||||
error(right, Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
return booleanType;
|
||||
@@ -22318,15 +22332,15 @@ namespace ts {
|
||||
function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType: Type, property: ObjectLiteralElementLike, allProperties?: NodeArray<ObjectLiteralElementLike>, rightIsThis = false) {
|
||||
if (property.kind === SyntaxKind.PropertyAssignment || property.kind === SyntaxKind.ShorthandPropertyAssignment) {
|
||||
const name = property.name;
|
||||
const text = getTextOfPropertyName(name);
|
||||
if (text) {
|
||||
const exprType = getLiteralTypeFromPropertyName(name);
|
||||
if (isTypeUsableAsPropertyName(exprType)) {
|
||||
const text = getPropertyNameFromType(exprType);
|
||||
const prop = getPropertyOfType(objectLiteralType, text);
|
||||
if (prop) {
|
||||
markPropertyAsReferenced(prop, property, rightIsThis);
|
||||
checkPropertyAccessibility(property, /*isSuper*/ false, objectLiteralType, prop);
|
||||
}
|
||||
}
|
||||
const exprType = getLiteralTypeFromPropertyName(name);
|
||||
const elementType = getIndexedAccessType(objectLiteralType, exprType, name);
|
||||
const type = getFlowTypeOfDestructuring(property, elementType);
|
||||
return checkDestructuringAssignment(property.kind === SyntaxKind.ShorthandPropertyAssignment ? property : property.initializer, type);
|
||||
@@ -25642,8 +25656,9 @@ namespace ts {
|
||||
const parentType = getTypeForBindingElementParent(parent);
|
||||
const name = node.propertyName || node.name;
|
||||
if (parentType && !isBindingPattern(name)) {
|
||||
const nameText = getTextOfPropertyName(name);
|
||||
if (nameText) {
|
||||
const exprType = getLiteralTypeFromPropertyName(name);
|
||||
if (isTypeUsableAsPropertyName(exprType)) {
|
||||
const nameText = getPropertyNameFromType(exprType);
|
||||
const property = getPropertyOfType(parentType, nameText);
|
||||
if (property) {
|
||||
markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference.
|
||||
@@ -31181,7 +31196,7 @@ namespace ts {
|
||||
if (nodeArguments.length !== 1) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Dynamic_import_must_have_one_specifier_as_an_argument);
|
||||
}
|
||||
|
||||
checkGrammarForDisallowedTrailingComma(nodeArguments);
|
||||
// see: parseArgumentOrArrayLiteralElement...we use this function which parse arguments of callExpression to parse specifier for dynamic import.
|
||||
// parseArgumentOrArrayLiteralElement allows spread element to be in an argument list which is not allowed as specifier in dynamic import.
|
||||
if (isSpreadElement(nodeArguments[0])) {
|
||||
|
||||
@@ -884,8 +884,11 @@ namespace ts {
|
||||
/**
|
||||
* Compacts an array, removing any falsey elements.
|
||||
*/
|
||||
export function compact<T>(array: T[]): T[];
|
||||
export function compact<T>(array: ReadonlyArray<T>): ReadonlyArray<T>;
|
||||
export function compact<T>(array: (T | undefined | null | false | 0 | "")[]): T[];
|
||||
export function compact<T>(array: ReadonlyArray<T | undefined | null | false | 0 | "">): ReadonlyArray<T>;
|
||||
// TSLint thinks these can be combined with the above - they cannot; they'd produce higher-priority inferences and prevent the falsey types from being stripped
|
||||
export function compact<T>(array: T[]): T[]; // tslint:disable-line unified-signatures
|
||||
export function compact<T>(array: ReadonlyArray<T>): ReadonlyArray<T>; // tslint:disable-line unified-signatures
|
||||
export function compact<T>(array: T[]): T[] {
|
||||
let result: T[] | undefined;
|
||||
if (array) {
|
||||
|
||||
@@ -2433,7 +2433,7 @@
|
||||
"category": "Error",
|
||||
"code": 2717
|
||||
},
|
||||
"Duplicate declaration '{0}'.": {
|
||||
"Duplicate property '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2718
|
||||
},
|
||||
@@ -2493,6 +2493,10 @@
|
||||
"category": "Error",
|
||||
"code": 2732
|
||||
},
|
||||
"Property '{0}' was also declared here.": {
|
||||
"category": "Error",
|
||||
"code": 2733
|
||||
},
|
||||
"It is highly likely that you are missing a semicolon.": {
|
||||
"category": "Error",
|
||||
"code": 2734
|
||||
|
||||
+14
-9
@@ -38,17 +38,22 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export function getOutputPathsForBundle(options: CompilerOptions, forceDtsPaths: boolean): EmitFileNames {
|
||||
const outPath = options.outFile || options.out!;
|
||||
const jsFilePath = options.emitDeclarationOnly ? undefined : outPath;
|
||||
const sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options);
|
||||
const declarationFilePath = (forceDtsPaths || getEmitDeclarations(options)) ? removeFileExtension(outPath) + Extension.Dts : undefined;
|
||||
const declarationMapPath = declarationFilePath && getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
|
||||
const bundleInfoPath = options.references && jsFilePath ? (removeFileExtension(jsFilePath) + infoExtension) : undefined;
|
||||
return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, bundleInfoPath };
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
export function getOutputPathsFor(sourceFile: SourceFile | Bundle, host: EmitHost, forceDtsPaths: boolean): EmitFileNames {
|
||||
const options = host.getCompilerOptions();
|
||||
if (sourceFile.kind === SyntaxKind.Bundle) {
|
||||
const outPath = options.outFile || options.out!;
|
||||
const jsFilePath = options.emitDeclarationOnly ? undefined : outPath;
|
||||
const sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options);
|
||||
const declarationFilePath = (forceDtsPaths || getEmitDeclarations(options)) ? removeFileExtension(outPath) + Extension.Dts : undefined;
|
||||
const declarationMapPath = declarationFilePath && getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
|
||||
const bundleInfoPath = options.references && jsFilePath ? (removeFileExtension(jsFilePath) + infoExtension) : undefined;
|
||||
return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, bundleInfoPath };
|
||||
return getOutputPathsForBundle(options, forceDtsPaths);
|
||||
}
|
||||
else {
|
||||
const ownOutputFilePath = getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options));
|
||||
@@ -4372,10 +4377,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
/**
|
||||
* Skips trivia such as comments and white-space that can optionally overriden by the source map source
|
||||
* Skips trivia such as comments and white-space that can be optionally overridden by the source-map source
|
||||
*/
|
||||
function skipSourceTrivia(source: SourceMapSource, pos: number): number {
|
||||
return source.skipTrivia ? source.skipTrivia(pos) : skipTrivia(sourceMapSource.text, pos);
|
||||
return source.skipTrivia ? source.skipTrivia(pos) : skipTrivia(source.text, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+64
-17
@@ -2630,41 +2630,88 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function createUnparsedSourceFile(text: string): UnparsedSource;
|
||||
export function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts"): UnparsedSource;
|
||||
export function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource;
|
||||
export function createUnparsedSourceFile(text: string, mapPath?: string, map?: string): UnparsedSource {
|
||||
export function createUnparsedSourceFile(textOrInputFiles: string | InputFiles, mapPathOrType?: string, map?: string): UnparsedSource {
|
||||
const node = <UnparsedSource>createNode(SyntaxKind.UnparsedSource);
|
||||
node.text = text;
|
||||
node.sourceMapPath = mapPath;
|
||||
node.sourceMapText = map;
|
||||
if (!isString(textOrInputFiles)) {
|
||||
Debug.assert(mapPathOrType === "js" || mapPathOrType === "dts");
|
||||
node.fileName = mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath;
|
||||
node.sourceMapPath = mapPathOrType === "js" ? textOrInputFiles.javascriptMapPath : textOrInputFiles.declarationMapPath;
|
||||
Object.defineProperties(node, {
|
||||
text: { get() { return mapPathOrType === "js" ? textOrInputFiles.javascriptText : textOrInputFiles.declarationText; } },
|
||||
sourceMapText: { get() { return mapPathOrType === "js" ? textOrInputFiles.javascriptMapText : textOrInputFiles.declarationMapText; } },
|
||||
});
|
||||
}
|
||||
else {
|
||||
node.text = textOrInputFiles;
|
||||
node.sourceMapPath = mapPathOrType;
|
||||
node.sourceMapText = map;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
export function createInputFiles(
|
||||
javascript: string,
|
||||
declaration: string
|
||||
javascriptText: string,
|
||||
declarationText: string
|
||||
): InputFiles;
|
||||
export function createInputFiles(
|
||||
javascript: string,
|
||||
declaration: string,
|
||||
readFileText: (path: string) => string | undefined,
|
||||
javascriptPath: string,
|
||||
javascriptMapPath: string | undefined,
|
||||
declarationPath: string,
|
||||
declarationMapPath: string | undefined,
|
||||
): InputFiles;
|
||||
export function createInputFiles(
|
||||
javascriptText: string,
|
||||
declarationText: string,
|
||||
javascriptMapPath: string | undefined,
|
||||
javascriptMapText: string | undefined,
|
||||
declarationMapPath: string | undefined,
|
||||
declarationMapText: string | undefined
|
||||
): InputFiles;
|
||||
export function createInputFiles(
|
||||
javascript: string,
|
||||
declaration: string,
|
||||
javascriptTextOrReadFileText: string | ((path: string) => string | undefined),
|
||||
declarationTextOrJavascriptPath: string,
|
||||
javascriptMapPath?: string,
|
||||
javascriptMapText?: string,
|
||||
javascriptMapTextOrDeclarationPath?: string,
|
||||
declarationMapPath?: string,
|
||||
declarationMapText?: string
|
||||
): InputFiles {
|
||||
const node = <InputFiles>createNode(SyntaxKind.InputFiles);
|
||||
node.javascriptText = javascript;
|
||||
node.javascriptMapPath = javascriptMapPath;
|
||||
node.javascriptMapText = javascriptMapText;
|
||||
node.declarationText = declaration;
|
||||
node.declarationMapPath = declarationMapPath;
|
||||
node.declarationMapText = declarationMapText;
|
||||
if (!isString(javascriptTextOrReadFileText)) {
|
||||
const cache = createMap<string | false>();
|
||||
const textGetter = (path: string | undefined) => {
|
||||
if (path === undefined) return undefined;
|
||||
let value = cache.get(path);
|
||||
if (value === undefined) {
|
||||
value = javascriptTextOrReadFileText(path);
|
||||
cache.set(path, value !== undefined ? value : false);
|
||||
}
|
||||
return value !== false ? value as string : undefined;
|
||||
};
|
||||
const definedTextGetter = (path: string) => {
|
||||
const result = textGetter(path);
|
||||
return result !== undefined ? result : `/* Input file ${path} was missing */\r\n`;
|
||||
};
|
||||
node.javascriptPath = declarationTextOrJavascriptPath;
|
||||
node.javascriptMapPath = javascriptMapPath;
|
||||
node.declarationPath = Debug.assertDefined(javascriptMapTextOrDeclarationPath);
|
||||
node.declarationMapPath = declarationMapPath;
|
||||
Object.defineProperties(node, {
|
||||
javascriptText: { get() { return definedTextGetter(declarationTextOrJavascriptPath); } },
|
||||
javascriptMapText: { get() { return textGetter(javascriptMapPath); } }, // TODO:: if there is inline sourceMap in jsFile, use that
|
||||
declarationText: { get() { return definedTextGetter(Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } },
|
||||
declarationMapText: { get() { return textGetter(declarationMapPath); } } // TODO:: if there is inline sourceMap in dtsFile, use that
|
||||
});
|
||||
}
|
||||
else {
|
||||
node.javascriptText = javascriptTextOrReadFileText;
|
||||
node.javascriptMapPath = javascriptMapPath;
|
||||
node.javascriptMapText = javascriptMapTextOrDeclarationPath;
|
||||
node.declarationText = declarationTextOrJavascriptPath;
|
||||
node.declarationMapPath = declarationMapPath;
|
||||
node.declarationMapText = declarationMapText;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@@ -1093,6 +1093,10 @@ namespace ts {
|
||||
return currentToken = scanner.reScanTemplateToken();
|
||||
}
|
||||
|
||||
function reScanLessThanToken(): SyntaxKind {
|
||||
return currentToken = scanner.reScanLessThanToken();
|
||||
}
|
||||
|
||||
function scanJsxIdentifier(): SyntaxKind {
|
||||
return currentToken = scanner.scanJsxIdentifier();
|
||||
}
|
||||
@@ -2276,7 +2280,7 @@ namespace ts {
|
||||
function parseTypeReference(): TypeReferenceNode {
|
||||
const node = <TypeReferenceNode>createNode(SyntaxKind.TypeReference);
|
||||
node.typeName = parseEntityName(/*allowReservedWords*/ true, Diagnostics.Type_expected);
|
||||
if (!scanner.hasPrecedingLineBreak() && token() === SyntaxKind.LessThanToken) {
|
||||
if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === SyntaxKind.LessThanToken) {
|
||||
node.typeArguments = parseBracketedList(ParsingContext.TypeArguments, parseType, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken);
|
||||
}
|
||||
return finishNode(node);
|
||||
@@ -4523,7 +4527,8 @@ namespace ts {
|
||||
function parseCallExpressionRest(expression: LeftHandSideExpression): LeftHandSideExpression {
|
||||
while (true) {
|
||||
expression = parseMemberExpressionRest(expression);
|
||||
if (token() === SyntaxKind.LessThanToken) {
|
||||
// handle 'foo<<T>()'
|
||||
if (token() === SyntaxKind.LessThanToken || token() === SyntaxKind.LessThanLessThanToken) {
|
||||
// See if this is the start of a generic invocation. If so, consume it and
|
||||
// keep checking for postfix expressions. Otherwise, it's just a '<' that's
|
||||
// part of an arithmetic expression. Break out so we consume it higher in the
|
||||
@@ -4565,9 +4570,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseTypeArgumentsInExpression() {
|
||||
if (!parseOptional(SyntaxKind.LessThanToken)) {
|
||||
if (reScanLessThanToken() !== SyntaxKind.LessThanToken) {
|
||||
return undefined;
|
||||
}
|
||||
nextToken();
|
||||
|
||||
const typeArguments = parseDelimitedList(ParsingContext.TypeArguments, parseType);
|
||||
if (!parseExpected(SyntaxKind.GreaterThanToken)) {
|
||||
|
||||
@@ -1456,14 +1456,12 @@ namespace ts {
|
||||
// Upstream project didn't have outFile set -- skip (error will have been issued earlier)
|
||||
if (!out) continue;
|
||||
|
||||
const dtsFilename = changeExtension(out, ".d.ts");
|
||||
const js = host.readFile(out) || `/* Input file ${out} was missing */\r\n`;
|
||||
const jsMapPath = out + ".map"; // TODO: try to read sourceMappingUrl comment from the file
|
||||
const jsMap = host.readFile(jsMapPath);
|
||||
const dts = host.readFile(dtsFilename) || `/* Input file ${dtsFilename} was missing */\r\n`;
|
||||
const dtsMapPath = dtsFilename + ".map";
|
||||
const dtsMap = host.readFile(dtsMapPath);
|
||||
const node = createInputFiles(js, dts, jsMap && jsMapPath, jsMap, dtsMap && dtsMapPath, dtsMap);
|
||||
const { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath } = getOutputPathsForBundle(resolvedRefOpts.options, /*forceDtsPaths*/ true);
|
||||
const node = createInputFiles(fileName => {
|
||||
const path = toPath(fileName);
|
||||
const sourceFile = getSourceFileByPath(path);
|
||||
return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path);
|
||||
}, jsFilePath! , sourceMapFilePath, declarationFilePath! , declarationMapPath);
|
||||
nodes.push(node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace ts {
|
||||
scanJsxIdentifier(): SyntaxKind;
|
||||
scanJsxAttributeValue(): SyntaxKind;
|
||||
reScanJsxToken(): JsxTokenSyntaxKind;
|
||||
reScanLessThanToken(): SyntaxKind;
|
||||
scanJsxToken(): JsxTokenSyntaxKind;
|
||||
scanJSDocToken(): JsDocSyntaxKind;
|
||||
scan(): SyntaxKind;
|
||||
@@ -874,6 +875,7 @@ namespace ts {
|
||||
scanJsxIdentifier,
|
||||
scanJsxAttributeValue,
|
||||
reScanJsxToken,
|
||||
reScanLessThanToken,
|
||||
scanJsxToken,
|
||||
scanJSDocToken,
|
||||
scan,
|
||||
@@ -1939,6 +1941,14 @@ namespace ts {
|
||||
return token = scanJsxToken();
|
||||
}
|
||||
|
||||
function reScanLessThanToken(): SyntaxKind {
|
||||
if (token === SyntaxKind.LessThanLessThanToken) {
|
||||
pos = tokenPos + 1;
|
||||
return token = SyntaxKind.LessThanToken;
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
function scanJsxToken(): JsxTokenSyntaxKind {
|
||||
startPos = tokenPos = pos;
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace ts {
|
||||
}
|
||||
), mapDefined(node.prepends, prepend => {
|
||||
if (prepend.kind === SyntaxKind.InputFiles) {
|
||||
return createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapPath, prepend.declarationMapText);
|
||||
return createUnparsedSourceFile(prepend, "dts");
|
||||
}
|
||||
}));
|
||||
bundle.syntheticFileReferences = [];
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace ts {
|
||||
function transformBundle(node: Bundle) {
|
||||
return createBundle(node.sourceFiles.map(transformSourceFile), mapDefined(node.prepends, prepend => {
|
||||
if (prepend.kind === SyntaxKind.InputFiles) {
|
||||
return createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapPath, prepend.javascriptMapText);
|
||||
return createUnparsedSourceFile(prepend, "js");
|
||||
}
|
||||
return prepend;
|
||||
}));
|
||||
|
||||
@@ -2761,9 +2761,11 @@ namespace ts {
|
||||
|
||||
export interface InputFiles extends Node {
|
||||
kind: SyntaxKind.InputFiles;
|
||||
javascriptPath?: string;
|
||||
javascriptText: string;
|
||||
javascriptMapPath?: string;
|
||||
javascriptMapText?: string;
|
||||
declarationPath?: string;
|
||||
declarationText: string;
|
||||
declarationMapPath?: string;
|
||||
declarationMapText?: string;
|
||||
@@ -2771,6 +2773,7 @@ namespace ts {
|
||||
|
||||
export interface UnparsedSource extends Node {
|
||||
kind: SyntaxKind.UnparsedSource;
|
||||
fileName?: string;
|
||||
text: string;
|
||||
sourceMapPath?: string;
|
||||
sourceMapText?: string;
|
||||
@@ -3952,6 +3955,7 @@ namespace ts {
|
||||
// Unique symbol types (TypeFlags.UniqueESSymbol)
|
||||
export interface UniqueESSymbolType extends Type {
|
||||
symbol: Symbol;
|
||||
escapedName: __String;
|
||||
}
|
||||
|
||||
export interface StringLiteralType extends LiteralType {
|
||||
|
||||
@@ -778,7 +778,8 @@ namespace ts {
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
return escapeLeadingUnderscores(name.text);
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
return isStringOrNumericLiteralLike(name.expression) ? escapeLeadingUnderscores(name.expression.text) : undefined!; // TODO: GH#18217 Almost all uses of this assume the result to be defined!
|
||||
if (isStringOrNumericLiteralLike(name.expression)) return escapeLeadingUnderscores(name.expression.text);
|
||||
return Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames");
|
||||
default:
|
||||
return Debug.assertNever(name);
|
||||
}
|
||||
|
||||
@@ -939,8 +939,8 @@ namespace FourSlash {
|
||||
const startFile = this.activeFile.fileName;
|
||||
for (const fileName of files) {
|
||||
const searchFileNames = startFile === fileName ? [startFile] : [startFile, fileName];
|
||||
const highlights = this.getDocumentHighlightsAtCurrentPosition(searchFileNames)!;
|
||||
if (!highlights.every(dh => ts.contains(searchFileNames, dh.fileName))) {
|
||||
const highlights = this.getDocumentHighlightsAtCurrentPosition(searchFileNames);
|
||||
if (highlights && !highlights.every(dh => ts.contains(searchFileNames, dh.fileName))) {
|
||||
this.raiseError(`When asking for document highlights only in files ${searchFileNames}, got document highlights in ${unique(highlights, dh => dh.fileName)}`);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,5 +4,5 @@ The files within this directory are used to generate `lib.d.ts` and `lib.es6.d.t
|
||||
|
||||
## Generated files
|
||||
|
||||
Any files ending in `.generated.d.ts` aren't mean to be edited by hand.
|
||||
Any files ending in `.generated.d.ts` aren't meant to be edited by hand.
|
||||
If you need to make changes to such files, make a change to the input files for [**our library generator**](https://github.com/Microsoft/TSJS-lib-generator).
|
||||
|
||||
Vendored
+64
-10
@@ -587,7 +587,7 @@ interface TemplateStringsArray extends ReadonlyArray<string> {
|
||||
|
||||
/**
|
||||
* The type of `import.meta`.
|
||||
*
|
||||
*
|
||||
* If you need to declare that a given property exists on `import.meta`,
|
||||
* this type may be augmented via interface merging.
|
||||
*/
|
||||
@@ -1913,13 +1913,19 @@ interface Int8ArrayConstructor {
|
||||
*/
|
||||
of(...items: number[]): Int8Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<number>): Int8Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array;
|
||||
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array;
|
||||
|
||||
|
||||
}
|
||||
@@ -2183,13 +2189,19 @@ interface Uint8ArrayConstructor {
|
||||
*/
|
||||
of(...items: number[]): Uint8Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<number>): Uint8Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array;
|
||||
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array;
|
||||
|
||||
}
|
||||
declare const Uint8Array: Uint8ArrayConstructor;
|
||||
@@ -2452,13 +2464,19 @@ interface Uint8ClampedArrayConstructor {
|
||||
*/
|
||||
of(...items: number[]): Uint8ClampedArray;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<number>): Uint8ClampedArray;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray;
|
||||
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray;
|
||||
}
|
||||
declare const Uint8ClampedArray: Uint8ClampedArrayConstructor;
|
||||
|
||||
@@ -2719,13 +2737,19 @@ interface Int16ArrayConstructor {
|
||||
*/
|
||||
of(...items: number[]): Int16Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<number>): Int16Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array;
|
||||
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array;
|
||||
|
||||
|
||||
}
|
||||
@@ -2989,13 +3013,19 @@ interface Uint16ArrayConstructor {
|
||||
*/
|
||||
of(...items: number[]): Uint16Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<number>): Uint16Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array;
|
||||
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array;
|
||||
|
||||
|
||||
}
|
||||
@@ -3258,13 +3288,19 @@ interface Int32ArrayConstructor {
|
||||
*/
|
||||
of(...items: number[]): Int32Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<number>): Int32Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array;
|
||||
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array;
|
||||
|
||||
}
|
||||
declare const Int32Array: Int32ArrayConstructor;
|
||||
@@ -3526,13 +3562,19 @@ interface Uint32ArrayConstructor {
|
||||
*/
|
||||
of(...items: number[]): Uint32Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<number>): Uint32Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array;
|
||||
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array;
|
||||
|
||||
}
|
||||
declare const Uint32Array: Uint32ArrayConstructor;
|
||||
@@ -3795,13 +3837,19 @@ interface Float32ArrayConstructor {
|
||||
*/
|
||||
of(...items: number[]): Float32Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<number>): Float32Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array;
|
||||
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array;
|
||||
|
||||
|
||||
}
|
||||
@@ -4065,13 +4113,19 @@ interface Float64ArrayConstructor {
|
||||
*/
|
||||
of(...items: number[]): Float64Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<number>): Float64Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: ArrayLike<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array;
|
||||
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array;
|
||||
|
||||
}
|
||||
declare const Float64Array: Float64ArrayConstructor;
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace ts.FindAllReferences {
|
||||
return flattenEntries(Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options, sourceFilesSet));
|
||||
}
|
||||
|
||||
function flattenEntries(referenceSymbols: SymbolAndEntries[] | undefined): ReadonlyArray<Entry> | undefined {
|
||||
function flattenEntries(referenceSymbols: ReadonlyArray<SymbolAndEntries> | undefined): ReadonlyArray<Entry> | undefined {
|
||||
return referenceSymbols && flatMap(referenceSymbols, r => r.references);
|
||||
}
|
||||
|
||||
@@ -282,6 +282,11 @@ namespace ts.FindAllReferences {
|
||||
return createTextSpanFromBounds(start, end);
|
||||
}
|
||||
|
||||
export function getTextSpanOfEntry(entry: Entry) {
|
||||
return entry.kind === EntryKind.Span ? entry.textSpan :
|
||||
getTextSpan(entry.node, entry.node.getSourceFile());
|
||||
}
|
||||
|
||||
/** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */
|
||||
function isWriteAccessForReference(node: Node): boolean {
|
||||
const decl = getDeclarationFromName(node);
|
||||
@@ -353,7 +358,7 @@ namespace ts.FindAllReferences {
|
||||
/* @internal */
|
||||
namespace ts.FindAllReferences.Core {
|
||||
/** Core find-all-references algorithm. Handles special cases before delegating to `getReferencedSymbolsForSymbol`. */
|
||||
export function getReferencedSymbolsForNode(position: number, node: Node, program: Program, sourceFiles: ReadonlyArray<SourceFile>, cancellationToken: CancellationToken, options: Options = {}, sourceFilesSet: ReadonlyMap<true> = arrayToSet(sourceFiles, f => f.fileName)): SymbolAndEntries[] | undefined {
|
||||
export function getReferencedSymbolsForNode(position: number, node: Node, program: Program, sourceFiles: ReadonlyArray<SourceFile>, cancellationToken: CancellationToken, options: Options = {}, sourceFilesSet: ReadonlyMap<true> = arrayToSet(sourceFiles, f => f.fileName)): ReadonlyArray<SymbolAndEntries> | undefined {
|
||||
if (isSourceFile(node)) {
|
||||
const reference = GoToDefinition.getReferenceAtPosition(node, position, program);
|
||||
const moduleSymbol = reference && program.getTypeChecker().getMergedSymbol(reference.file.symbol);
|
||||
@@ -368,7 +373,7 @@ namespace ts.FindAllReferences.Core {
|
||||
}
|
||||
|
||||
const checker = program.getTypeChecker();
|
||||
let symbol = checker.getSymbolAtLocation(node);
|
||||
const symbol = checker.getSymbolAtLocation(node);
|
||||
|
||||
// Could not find a symbol e.g. unknown identifier
|
||||
if (!symbol) {
|
||||
@@ -380,23 +385,95 @@ namespace ts.FindAllReferences.Core {
|
||||
return getReferencedSymbolsForModule(program, symbol.parent!, /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet);
|
||||
}
|
||||
|
||||
let moduleReferences: SymbolAndEntries[] = emptyArray;
|
||||
const moduleSourceFile = isModuleSymbol(symbol);
|
||||
let referencedNode: Node | undefined = node;
|
||||
if (moduleSourceFile) {
|
||||
const exportEquals = symbol.exports!.get(InternalSymbolName.ExportEquals);
|
||||
// If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them.
|
||||
moduleReferences = getReferencedSymbolsForModule(program, symbol, !!exportEquals, sourceFiles, sourceFilesSet);
|
||||
if (!exportEquals || !sourceFilesSet.has(moduleSourceFile.fileName)) return moduleReferences;
|
||||
// Continue to get references to 'export ='.
|
||||
symbol = skipAlias(exportEquals, checker);
|
||||
referencedNode = undefined;
|
||||
const moduleReferences = getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet);
|
||||
if (moduleReferences && !(symbol.flags & SymbolFlags.Transient)) {
|
||||
return moduleReferences;
|
||||
}
|
||||
return concatenate(moduleReferences, getReferencedSymbolsForSymbol(symbol, referencedNode, sourceFiles, sourceFilesSet, checker, cancellationToken, options));
|
||||
|
||||
const aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(node, symbol, checker);
|
||||
const moduleReferencesOfExportTarget = aliasedSymbol &&
|
||||
getReferencedSymbolsForModuleIfDeclaredBySourceFile(aliasedSymbol, program, sourceFiles, cancellationToken, options, sourceFilesSet);
|
||||
|
||||
const references = getReferencedSymbolsForSymbol(symbol, node, sourceFiles, sourceFilesSet, checker, cancellationToken, options);
|
||||
return mergeReferences(program, moduleReferences, references, moduleReferencesOfExportTarget);
|
||||
}
|
||||
|
||||
function isModuleSymbol(symbol: Symbol): SourceFile | undefined {
|
||||
return symbol.flags & SymbolFlags.Module ? find(symbol.declarations, isSourceFile) : undefined;
|
||||
function getMergedAliasedSymbolOfNamespaceExportDeclaration(node: Node, symbol: Symbol, checker: TypeChecker) {
|
||||
if (node.parent && isNamespaceExportDeclaration(node.parent)) {
|
||||
const aliasedSymbol = checker.getAliasedSymbol(symbol);
|
||||
const targetSymbol = checker.getMergedSymbol(aliasedSymbol);
|
||||
if (aliasedSymbol !== targetSymbol) {
|
||||
return targetSymbol;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol: Symbol, program: Program, sourceFiles: ReadonlyArray<SourceFile>, cancellationToken: CancellationToken, options: Options, sourceFilesSet: ReadonlyMap<true>) {
|
||||
const moduleSourceFile = symbol.flags & SymbolFlags.Module ? find(symbol.declarations, isSourceFile) : undefined;
|
||||
if (!moduleSourceFile) return undefined;
|
||||
const exportEquals = symbol.exports!.get(InternalSymbolName.ExportEquals);
|
||||
// If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them.
|
||||
const moduleReferences = getReferencedSymbolsForModule(program, symbol, !!exportEquals, sourceFiles, sourceFilesSet);
|
||||
if (!exportEquals || !sourceFilesSet.has(moduleSourceFile.fileName)) return moduleReferences;
|
||||
// Continue to get references to 'export ='.
|
||||
const checker = program.getTypeChecker();
|
||||
symbol = skipAlias(exportEquals, checker);
|
||||
return mergeReferences(program, moduleReferences, getReferencedSymbolsForSymbol(symbol, /*node*/ undefined, sourceFiles, sourceFilesSet, checker, cancellationToken, options));
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges the references by sorting them (by file index in sourceFiles and their location in it) that point to same definition symbol
|
||||
*/
|
||||
function mergeReferences(program: Program, ...referencesToMerge: (SymbolAndEntries[] | undefined)[]): SymbolAndEntries[] | undefined {
|
||||
let result: SymbolAndEntries[] | undefined;
|
||||
for (const references of referencesToMerge) {
|
||||
if (!references || !references.length) continue;
|
||||
if (!result) {
|
||||
result = references;
|
||||
continue;
|
||||
}
|
||||
for (const entry of references) {
|
||||
if (!entry.definition || entry.definition.type !== DefinitionKind.Symbol) {
|
||||
result.push(entry);
|
||||
continue;
|
||||
}
|
||||
const symbol = entry.definition.symbol;
|
||||
const refIndex = findIndex(result, ref => !!ref.definition &&
|
||||
ref.definition.type === DefinitionKind.Symbol &&
|
||||
ref.definition.symbol === symbol);
|
||||
if (refIndex === -1) {
|
||||
result.push(entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
const reference = result[refIndex];
|
||||
result[refIndex] = {
|
||||
definition: reference.definition,
|
||||
references: reference.references.concat(entry.references).sort((entry1, entry2) => {
|
||||
const entry1File = getSourceFileIndexOfEntry(program, entry1);
|
||||
const entry2File = getSourceFileIndexOfEntry(program, entry2);
|
||||
if (entry1File !== entry2File) {
|
||||
return compareValues(entry1File, entry2File);
|
||||
}
|
||||
|
||||
const entry1Span = getTextSpanOfEntry(entry1);
|
||||
const entry2Span = getTextSpanOfEntry(entry2);
|
||||
return entry1Span.start !== entry2Span.start ?
|
||||
compareValues(entry1Span.start, entry2Span.start) :
|
||||
compareValues(entry1Span.length, entry2Span.length);
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function getSourceFileIndexOfEntry(program: Program, entry: Entry) {
|
||||
const sourceFile = entry.kind === EntryKind.Span ?
|
||||
program.getSourceFile(entry.fileName)! :
|
||||
entry.node.getSourceFile();
|
||||
return program.getSourceFiles().indexOf(sourceFile);
|
||||
}
|
||||
|
||||
function getReferencedSymbolsForModule(program: Program, symbol: Symbol, excludeImportTypeOfExportEquals: boolean, sourceFiles: ReadonlyArray<SourceFile>, sourceFilesSet: ReadonlyMap<true>): SymbolAndEntries[] {
|
||||
@@ -435,7 +512,7 @@ namespace ts.FindAllReferences.Core {
|
||||
break;
|
||||
default:
|
||||
// This may be merged with something.
|
||||
Debug.fail("Expected a module symbol to be declared by a SourceFile or ModuleDeclaration.");
|
||||
Debug.assert(!!(symbol.flags & SymbolFlags.Transient), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -551,6 +628,8 @@ namespace ts.FindAllReferences.Core {
|
||||
// If the symbol is declared as part of a declaration like `{ type: "a" } | { type: "b" }`, use the property on the union type to get more references.
|
||||
return firstDefined(symbol.declarations, decl => {
|
||||
if (!decl.parent) {
|
||||
// Ignore UMD module and global merge
|
||||
if (symbol.flags & SymbolFlags.Transient) return undefined;
|
||||
// Assertions for GH#21814. We should be handling SourceFile symbols in `getReferencedSymbolsForModule` instead of getting here.
|
||||
Debug.fail(`Unexpected symbol at ${Debug.showSyntaxKind(node)}: ${Debug.showSymbol(symbol)}`);
|
||||
}
|
||||
@@ -588,6 +667,12 @@ namespace ts.FindAllReferences.Core {
|
||||
Class,
|
||||
}
|
||||
|
||||
function getNonModuleSymbolOfMergedModuleSymbol(symbol: Symbol) {
|
||||
if (!(symbol.flags & (SymbolFlags.Module | SymbolFlags.Transient))) return undefined;
|
||||
const decl = symbol.declarations && find(symbol.declarations, d => !isSourceFile(d) && !isModuleDeclaration(d));
|
||||
return decl && decl.symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds all state needed for the finding references.
|
||||
* Unlike `Search`, there is only one `State`.
|
||||
@@ -648,7 +733,7 @@ namespace ts.FindAllReferences.Core {
|
||||
// The other two forms seem to be handled downstream (e.g. in `skipPastExportOrImportSpecifier`), so special-casing the first form
|
||||
// here appears to be intentional).
|
||||
const {
|
||||
text = stripQuotes(unescapeLeadingUnderscores((getLocalSymbolForExportDefault(symbol) || symbol).escapedName)),
|
||||
text = stripQuotes(unescapeLeadingUnderscores((getLocalSymbolForExportDefault(symbol) || getNonModuleSymbolOfMergedModuleSymbol(symbol) || symbol).escapedName)),
|
||||
allSearchSymbols = [symbol],
|
||||
} = searchOptions;
|
||||
const escapedText = escapeLeadingUnderscores(text);
|
||||
@@ -1573,6 +1658,13 @@ namespace ts.FindAllReferences.Core {
|
||||
if (res2) return res2;
|
||||
}
|
||||
|
||||
const aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(location, symbol, checker);
|
||||
if (aliasedSymbol) {
|
||||
// In case of UMD module and global merging, search for global as well
|
||||
const res = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, EntryKind.Node);
|
||||
if (res) return res;
|
||||
}
|
||||
|
||||
const res = fromRoot(symbol);
|
||||
if (res) return res;
|
||||
|
||||
|
||||
@@ -452,7 +452,7 @@ namespace ts.SignatureHelp {
|
||||
}
|
||||
|
||||
function getContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile, checker: TypeChecker, isManuallyInvoked: boolean): ArgumentListInfo | undefined {
|
||||
for (let n = node; isManuallyInvoked || (!isBlock(n) && !isSourceFile(n)); n = n.parent) {
|
||||
for (let n = node; !isSourceFile(n) && (isManuallyInvoked || !isBlock(n)); n = n.parent) {
|
||||
// If the node is not a subspan of its parent, this is a big problem.
|
||||
// There have been crashes that might be caused by this violation.
|
||||
Debug.assert(rangeContainsRange(n.parent, n), "Not a subspan", () => `Child: ${Debug.showSyntaxKind(n)}, parent: ${Debug.showSyntaxKind(n.parent)}`);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../tsconfig-base",
|
||||
"extends": "../tsconfig-noncomposite-base",
|
||||
"compilerOptions": {
|
||||
"outFile": "../../built/local/run.js",
|
||||
"composite": false,
|
||||
|
||||
@@ -129,5 +129,34 @@ namespace ts {
|
||||
},
|
||||
{ sourceMap: true }
|
||||
);
|
||||
|
||||
emitsCorrectly("skipTriviaExternalSourceFiles",
|
||||
[
|
||||
{
|
||||
file: "source.ts",
|
||||
// The source file contains preceding trivia (e.g. whitespace) to try to confuse the `skipSourceTrivia` function.
|
||||
text: " original;"
|
||||
},
|
||||
],
|
||||
{
|
||||
before: [
|
||||
context => node => visitNode(node, function visitor(node: Node): Node {
|
||||
if (isIdentifier(node) && node.text === "original") {
|
||||
const newNode = createIdentifier("changed");
|
||||
setSourceMapRange(newNode, {
|
||||
pos: 0,
|
||||
end: 7,
|
||||
// Do not provide a custom skipTrivia function for `source`.
|
||||
source: createSourceMapSource("another.html", "changed;")
|
||||
});
|
||||
return newNode;
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
})
|
||||
]
|
||||
},
|
||||
{ sourceMap: true }
|
||||
);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -469,11 +469,20 @@ export const b = new A();`);
|
||||
|
||||
describe("unittests:: tsbuild - baseline sectioned sourcemaps", () => {
|
||||
let fs: vfs.FileSystem | undefined;
|
||||
const actualReadFileMap = createMap<number>();
|
||||
before(() => {
|
||||
fs = outFileFs.shadow();
|
||||
const host = new fakes.SolutionBuilderHost(fs);
|
||||
const builder = createSolutionBuilder(host, ["/src/third"], { dry: false, force: false, verbose: false });
|
||||
host.clearDiagnostics();
|
||||
const originalReadFile = host.readFile;
|
||||
host.readFile = path => {
|
||||
// Dont record libs
|
||||
if (path.startsWith("/src/")) {
|
||||
actualReadFileMap.set(path, (actualReadFileMap.get(path) || 0) + 1);
|
||||
}
|
||||
return originalReadFile.call(host, path);
|
||||
};
|
||||
builder.buildAllProjects();
|
||||
host.assertDiagnosticMessages(/*none*/);
|
||||
});
|
||||
@@ -485,6 +494,38 @@ export const b = new A();`);
|
||||
// tslint:disable-next-line:no-null-keyword
|
||||
Harness.Baseline.runBaseline("outfile-concat.js", patch ? vfs.formatPatch(patch) : null);
|
||||
});
|
||||
it("verify readFile calls", () => {
|
||||
const expected = [
|
||||
// Configs
|
||||
"/src/third/tsconfig.json",
|
||||
"/src/second/tsconfig.json",
|
||||
"/src/first/tsconfig.json",
|
||||
|
||||
// Source files
|
||||
"/src/third/third_part1.ts",
|
||||
"/src/second/second_part1.ts",
|
||||
"/src/second/second_part2.ts",
|
||||
"/src/first/first_PART1.ts",
|
||||
"/src/first/first_part2.ts",
|
||||
"/src/first/first_part3.ts",
|
||||
|
||||
// outputs
|
||||
"/src/first/bin/first-output.js",
|
||||
"/src/first/bin/first-output.js.map",
|
||||
"/src/first/bin/first-output.d.ts",
|
||||
"/src/first/bin/first-output.d.ts.map",
|
||||
"/src/2/second-output.js",
|
||||
"/src/2/second-output.js.map",
|
||||
"/src/2/second-output.d.ts",
|
||||
"/src/2/second-output.d.ts.map"
|
||||
];
|
||||
|
||||
assert.equal(actualReadFileMap.size, expected.length, `Expected: ${JSON.stringify(expected)} \nActual: ${JSON.stringify(arrayFrom(actualReadFileMap.entries()))}`);
|
||||
expected.forEach(expectedValue => {
|
||||
const actual = actualReadFileMap.get(expectedValue);
|
||||
assert.equal(actual, 1, `Mismatch in read file call number for: ${expectedValue}\nExpected: ${JSON.stringify(expected)} \nActual: ${JSON.stringify(arrayFrom(actualReadFileMap.entries()))}`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("unittests:: tsbuild - downstream prepend projects always get rebuilt", () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../tsconfig-base",
|
||||
"extends": "../tsconfig-noncomposite-base",
|
||||
"compilerOptions": {
|
||||
"outFile": "../../built/local/tsc.js"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "./tsconfig-base",
|
||||
"compilerOptions": {
|
||||
"declaration": false,
|
||||
"declarationMap": false,
|
||||
"composite": false
|
||||
}
|
||||
}
|
||||
@@ -967,4 +967,12 @@ namespace ts.server {
|
||||
(process as any).noAsar = true;
|
||||
// Start listening
|
||||
ioSession.listen();
|
||||
|
||||
if (Debug.isDebugging) {
|
||||
Debug.enableDebugInfo();
|
||||
}
|
||||
|
||||
if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) {
|
||||
ts.sys.tryEnableSourceMapsForHost();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../tsconfig-base",
|
||||
"extends": "../tsconfig-noncomposite-base",
|
||||
|
||||
"compilerOptions": {
|
||||
"outFile": "../../built/local/tsserver.js",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../tsconfig-base",
|
||||
"extends": "../tsconfig-noncomposite-base",
|
||||
"compilerOptions": {
|
||||
"removeComments": true,
|
||||
"outFile": "../../built/local/typingsInstaller.js",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "../tsconfig-base",
|
||||
"extends": "../tsconfig-noncomposite-base",
|
||||
"compilerOptions": {
|
||||
"removeComments": true,
|
||||
"outFile": "../../built/local/watchGuard.js",
|
||||
@@ -13,4 +13,4 @@
|
||||
"files": [
|
||||
"watchGuard.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user