mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'main' into server-vfs-support
This commit is contained in:
Generated
+7
-7
@@ -234,7 +234,7 @@
|
||||
"normalize-path": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz",
|
||||
"integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=",
|
||||
"integrity": "sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"remove-trailing-separator": "^1.0.1"
|
||||
@@ -638,9 +638,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "17.0.36",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.36.tgz",
|
||||
"integrity": "sha512-V3orv+ggDsWVHP99K3JlwtH20R7J4IhI1Kksgc+64q5VxgfRkQG8Ws3MFm/FZOKDYGy9feGFlZ70/HpCNe9QaA==",
|
||||
"version": "17.0.38",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.38.tgz",
|
||||
"integrity": "sha512-5jY9RhV7c0Z4Jy09G+NIDTsCZ5G0L5n+Z+p+Y7t5VJHM30bgwzSjVtlcBxqAj+6L/swIlvtOSzr8rBk/aNyV2g==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/node-fetch": {
|
||||
@@ -4834,7 +4834,7 @@
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
|
||||
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
|
||||
"dev": true
|
||||
},
|
||||
"object-copy": {
|
||||
@@ -5157,7 +5157,7 @@
|
||||
"plugin-error": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-0.1.2.tgz",
|
||||
"integrity": "sha1-O5uzM1zPAPQl4HQ34ZJ2ln2kes4=",
|
||||
"integrity": "sha512-WzZHcm4+GO34sjFMxQMqZbsz3xiNEgonCskQ9v+IroMmYgk/tas8dG+Hr2D6IbRPybZ12oWpzE/w3cGJ6FJzOw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-cyan": "^0.1.1",
|
||||
@@ -5291,7 +5291,7 @@
|
||||
"q": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz",
|
||||
"integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=",
|
||||
"integrity": "sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==",
|
||||
"dev": true
|
||||
},
|
||||
"qs": {
|
||||
|
||||
+113
-101
@@ -74,7 +74,7 @@ namespace ts {
|
||||
TypeofNEString = 1 << 8, // typeof x !== "string"
|
||||
TypeofNENumber = 1 << 9, // typeof x !== "number"
|
||||
TypeofNEBigInt = 1 << 10, // typeof x !== "bigint"
|
||||
TypeofNEBoolean = 1 << 11, // typeof x !== "boolean"
|
||||
TypeofNEBoolean = 1 << 11, // typeof x !== "boolean"
|
||||
TypeofNESymbol = 1 << 12, // typeof x !== "symbol"
|
||||
TypeofNEObject = 1 << 13, // typeof x !== "object"
|
||||
TypeofNEFunction = 1 << 14, // typeof x !== "function"
|
||||
@@ -87,7 +87,10 @@ namespace ts {
|
||||
NEUndefinedOrNull = 1 << 21, // x != undefined / x != null
|
||||
Truthy = 1 << 22, // x
|
||||
Falsy = 1 << 23, // !x
|
||||
All = (1 << 24) - 1,
|
||||
IsUndefined = 1 << 24, // Exactly undefined
|
||||
IsNull = 1 << 25, // Exactly null
|
||||
IsUndefinedOrNull = IsUndefined | IsNull,
|
||||
All = (1 << 27) - 1,
|
||||
// The following members encode facts about particular kinds of types for use in the getTypeFacts function.
|
||||
// The presence of a particular fact means that the given test is true for some (and possibly all) values
|
||||
// of that kind of type.
|
||||
@@ -129,11 +132,13 @@ namespace ts {
|
||||
ObjectFacts = ObjectStrictFacts | EQUndefined | EQNull | EQUndefinedOrNull | Falsy,
|
||||
FunctionStrictFacts = TypeofEQFunction | TypeofEQHostObject | TypeofNEString | TypeofNENumber | TypeofNEBigInt | TypeofNEBoolean | TypeofNESymbol | TypeofNEObject | NEUndefined | NENull | NEUndefinedOrNull | Truthy,
|
||||
FunctionFacts = FunctionStrictFacts | EQUndefined | EQNull | EQUndefinedOrNull | Falsy,
|
||||
UndefinedFacts = TypeofNEString | TypeofNENumber | TypeofNEBigInt | TypeofNEBoolean | TypeofNESymbol | TypeofNEObject | TypeofNEFunction | TypeofNEHostObject | EQUndefined | EQUndefinedOrNull | NENull | Falsy,
|
||||
NullFacts = TypeofEQObject | TypeofNEString | TypeofNENumber | TypeofNEBigInt | TypeofNEBoolean | TypeofNESymbol | TypeofNEFunction | TypeofNEHostObject | EQNull | EQUndefinedOrNull | NEUndefined | Falsy,
|
||||
EmptyObjectStrictFacts = All & ~(EQUndefined | EQNull | EQUndefinedOrNull),
|
||||
VoidFacts = TypeofNEString | TypeofNENumber | TypeofNEBigInt | TypeofNEBoolean | TypeofNESymbol | TypeofNEObject | TypeofNEFunction | TypeofNEHostObject | EQUndefined | EQUndefinedOrNull | NENull | Falsy,
|
||||
UndefinedFacts = TypeofNEString | TypeofNENumber | TypeofNEBigInt | TypeofNEBoolean | TypeofNESymbol | TypeofNEObject | TypeofNEFunction | TypeofNEHostObject | EQUndefined | EQUndefinedOrNull | NENull | Falsy | IsUndefined,
|
||||
NullFacts = TypeofEQObject | TypeofNEString | TypeofNENumber | TypeofNEBigInt | TypeofNEBoolean | TypeofNESymbol | TypeofNEFunction | TypeofNEHostObject | EQNull | EQUndefinedOrNull | NEUndefined | Falsy | IsNull,
|
||||
EmptyObjectStrictFacts = All & ~(EQUndefined | EQNull | EQUndefinedOrNull | IsUndefinedOrNull),
|
||||
EmptyObjectFacts = All & ~IsUndefinedOrNull,
|
||||
UnknownFacts = All & ~IsUndefinedOrNull,
|
||||
AllTypeofNE = TypeofNEString | TypeofNENumber | TypeofNEBigInt | TypeofNEBoolean | TypeofNESymbol | TypeofNEObject | TypeofNEFunction | NEUndefined,
|
||||
EmptyObjectFacts = All,
|
||||
// Masks
|
||||
OrFactsMask = TypeofEQFunction | TypeofNEObject,
|
||||
AndFactsMask = All & ~OrFactsMask,
|
||||
@@ -2478,7 +2483,12 @@ namespace ts {
|
||||
function checkAndReportErrorForUsingTypeAsValue(errorLocation: Node, name: __String, meaning: SymbolFlags): boolean {
|
||||
if (meaning & (SymbolFlags.Value & ~SymbolFlags.NamespaceModule)) {
|
||||
if (isPrimitiveTypeName(name)) {
|
||||
error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, unescapeLeadingUnderscores(name));
|
||||
if (isExtendedByInterface(errorLocation)) {
|
||||
error(errorLocation, Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes, unescapeLeadingUnderscores(name));
|
||||
}
|
||||
else {
|
||||
error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, unescapeLeadingUnderscores(name));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
||||
@@ -2499,6 +2509,17 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function isExtendedByInterface(node: Node): boolean {
|
||||
const grandparent = node.parent.parent;
|
||||
const parentOfGrandparent = grandparent.parent;
|
||||
if(grandparent && parentOfGrandparent){
|
||||
const isExtending = isHeritageClause(grandparent) && grandparent.token === SyntaxKind.ExtendsKeyword;
|
||||
const isInterface = isInterfaceDeclaration(parentOfGrandparent);
|
||||
return isExtending && isInterface;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function maybeMappedType(node: Node, symbol: Symbol) {
|
||||
const container = findAncestor(node.parent, n =>
|
||||
isComputedPropertyName(n) || isPropertySignature(n) ? false : isTypeLiteralNode(n) || "quit") as TypeLiteralNode | undefined;
|
||||
@@ -5622,7 +5643,7 @@ namespace ts {
|
||||
anyType : getNonMissingTypeOfSymbol(propertySymbol);
|
||||
const saveEnclosingDeclaration = context.enclosingDeclaration;
|
||||
context.enclosingDeclaration = undefined;
|
||||
if (context.tracker.trackSymbol && getCheckFlags(propertySymbol) & CheckFlags.Late && isLateBoundName(propertySymbol.escapedName)) {
|
||||
if (context.tracker.trackSymbol && isLateBoundName(propertySymbol.escapedName)) {
|
||||
if (propertySymbol.declarations) {
|
||||
const decl = first(propertySymbol.declarations);
|
||||
if (hasLateBindableName(decl)) {
|
||||
@@ -6203,6 +6224,7 @@ namespace ts {
|
||||
factory.createStringLiteral("import")
|
||||
)
|
||||
])));
|
||||
context.tracker.reportImportTypeNodeResolutionModeOverride?.();
|
||||
}
|
||||
}
|
||||
if (!specifier) {
|
||||
@@ -6226,6 +6248,7 @@ namespace ts {
|
||||
factory.createStringLiteral(swappedMode === ModuleKind.ESNext ? "import" : "require")
|
||||
)
|
||||
])));
|
||||
context.tracker.reportImportTypeNodeResolutionModeOverride?.();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7558,7 +7581,7 @@ namespace ts {
|
||||
...!length(baseTypes) ? [] : [factory.createHeritageClause(SyntaxKind.ExtendsKeyword, map(baseTypes, b => serializeBaseType(b, staticBaseType, localName)))],
|
||||
...!length(implementsExpressions) ? [] : [factory.createHeritageClause(SyntaxKind.ImplementsKeyword, implementsExpressions)]
|
||||
];
|
||||
const symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType));
|
||||
const symbolProps = getNonInheritedProperties(classType, baseTypes, getPropertiesOfType(classType));
|
||||
const publicSymbolProps = filter(symbolProps, s => {
|
||||
// `valueDeclaration` could be undefined if inherited from
|
||||
// a union/intersection base type, but inherited properties
|
||||
@@ -8887,7 +8910,7 @@ namespace ts {
|
||||
if (getEffectiveTypeAnnotationNode(walkUpBindingElementsAndPatterns(declaration))) {
|
||||
// In strict null checking mode, if a default value of a non-undefined type is specified, remove
|
||||
// undefined from the final type.
|
||||
return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, CheckMode.Normal)) & TypeFlags.Undefined) ? getNonUndefinedType(type) : type;
|
||||
return strictNullChecks && !(getTypeFacts(checkDeclarationInitializer(declaration, CheckMode.Normal)) & TypeFacts.IsUndefined) ? getNonUndefinedType(type) : type;
|
||||
}
|
||||
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, CheckMode.Normal)], UnionReduction.Subtype));
|
||||
}
|
||||
@@ -12287,7 +12310,7 @@ namespace ts {
|
||||
let objectType;
|
||||
return !!(type.flags & TypeFlags.IndexedAccess && getObjectFlags(objectType = (type as IndexedAccessType).objectType) & ObjectFlags.Mapped &&
|
||||
!isGenericMappedType(objectType) && isGenericIndexType((type as IndexedAccessType).indexType) &&
|
||||
!(objectType as MappedType).declaration.questionToken && !(objectType as MappedType).declaration.nameType);
|
||||
!(getMappedTypeModifiers(objectType as MappedType) & MappedTypeModifiers.ExcludeOptional) && !(objectType as MappedType).declaration.nameType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -17996,7 +18019,7 @@ namespace ts {
|
||||
const sourceSig = checkMode & SignatureCheckMode.Callback ? undefined : getSingleCallSignature(getNonNullableType(sourceType));
|
||||
const targetSig = checkMode & SignatureCheckMode.Callback ? undefined : getSingleCallSignature(getNonNullableType(targetType));
|
||||
const callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) &&
|
||||
(getFalsyFlags(sourceType) & TypeFlags.Nullable) === (getFalsyFlags(targetType) & TypeFlags.Nullable);
|
||||
(getTypeFacts(sourceType) & TypeFacts.IsUndefinedOrNull) === (getTypeFacts(targetType) & TypeFacts.IsUndefinedOrNull);
|
||||
let related = callbacks ?
|
||||
compareSignaturesRelated(targetSig, sourceSig, (checkMode & SignatureCheckMode.StrictArity) | (strictVariance ? SignatureCheckMode.StrictCallback : SignatureCheckMode.BivariantCallback), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) :
|
||||
!(checkMode & SignatureCheckMode.Callback) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors);
|
||||
@@ -21364,31 +21387,8 @@ namespace ts {
|
||||
return value.base10Value === "0";
|
||||
}
|
||||
|
||||
function getFalsyFlagsOfTypes(types: Type[]): TypeFlags {
|
||||
let result: TypeFlags = 0;
|
||||
for (const t of types) {
|
||||
result |= getFalsyFlags(t);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Returns the String, Number, Boolean, StringLiteral, NumberLiteral, BooleanLiteral, Void, Undefined, or Null
|
||||
// flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns
|
||||
// no flags for all other types (including non-falsy literal types).
|
||||
function getFalsyFlags(type: Type): TypeFlags {
|
||||
const t = type.flags & TypeFlags.Intersection ? getBaseConstraintOrType(type) : type;
|
||||
return t.flags & TypeFlags.Union ? getFalsyFlagsOfTypes((t as UnionType).types) :
|
||||
t.flags & TypeFlags.StringLiteral ? (t as StringLiteralType).value === "" ? TypeFlags.StringLiteral : 0 :
|
||||
t.flags & TypeFlags.NumberLiteral ? (t as NumberLiteralType).value === 0 ? TypeFlags.NumberLiteral : 0 :
|
||||
t.flags & TypeFlags.BigIntLiteral ? isZeroBigInt(t as BigIntLiteralType) ? TypeFlags.BigIntLiteral : 0 :
|
||||
t.flags & TypeFlags.BooleanLiteral ? (t === falseType || t === regularFalseType) ? TypeFlags.BooleanLiteral : 0 :
|
||||
t.flags & TypeFlags.PossiblyFalsy;
|
||||
}
|
||||
|
||||
function removeDefinitelyFalsyTypes(type: Type): Type {
|
||||
return getFalsyFlags(type) & TypeFlags.DefinitelyFalsy ?
|
||||
filterType(type, t => !(getFalsyFlags(t) & TypeFlags.DefinitelyFalsy)) :
|
||||
type;
|
||||
return filterType(type, t => !!(getTypeFacts(t) & TypeFacts.Truthy));
|
||||
}
|
||||
|
||||
function extractDefinitelyFalsyTypes(type: Type): Type {
|
||||
@@ -21436,14 +21436,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getNonNullableType(type: Type): Type {
|
||||
if (strictNullChecks) {
|
||||
// First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
|
||||
// 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
|
||||
// that isn't eliminated by a NonNullable<T> instantiation.
|
||||
const reducedType = getTypeWithFacts(type, TypeFacts.NEUndefinedOrNull);
|
||||
return maybeTypeOfKind(reducedType, TypeFlags.Instantiable) ? getGlobalNonNullableTypeInstantiation(reducedType) : reducedType;
|
||||
}
|
||||
return type;
|
||||
return strictNullChecks ? getAdjustedTypeWithFacts(type, TypeFacts.NEUndefinedOrNull) : type;
|
||||
}
|
||||
|
||||
function addOptionalTypeMarker(type: Type) {
|
||||
@@ -23533,13 +23526,16 @@ namespace ts {
|
||||
resolved.members.get("bind" as __String) && isTypeSubtypeOf(type, globalFunctionType));
|
||||
}
|
||||
|
||||
function getTypeFacts(type: Type, ignoreObjects = false): TypeFacts {
|
||||
function getTypeFacts(type: Type): TypeFacts {
|
||||
if (type.flags & (TypeFlags.Intersection | TypeFlags.Instantiable)) {
|
||||
type = getBaseConstraintOfType(type) || unknownType;
|
||||
}
|
||||
const flags = type.flags;
|
||||
if (flags & TypeFlags.String) {
|
||||
if (flags & (TypeFlags.String | TypeFlags.StringMapping)) {
|
||||
return strictNullChecks ? TypeFacts.StringStrictFacts : TypeFacts.StringFacts;
|
||||
}
|
||||
if (flags & TypeFlags.StringLiteral) {
|
||||
const isEmpty = (type as StringLiteralType).value === "";
|
||||
if (flags & (TypeFlags.StringLiteral | TypeFlags.TemplateLiteral)) {
|
||||
const isEmpty = flags & TypeFlags.StringLiteral && (type as StringLiteralType).value === "";
|
||||
return strictNullChecks ?
|
||||
isEmpty ? TypeFacts.EmptyStringStrictFacts : TypeFacts.NonEmptyStringStrictFacts :
|
||||
isEmpty ? TypeFacts.EmptyStringFacts : TypeFacts.NonEmptyStringFacts;
|
||||
@@ -23571,16 +23567,16 @@ namespace ts {
|
||||
(type === falseType || type === regularFalseType) ? TypeFacts.FalseFacts : TypeFacts.TrueFacts;
|
||||
}
|
||||
if (flags & TypeFlags.Object) {
|
||||
if (ignoreObjects) {
|
||||
return TypeFacts.AndFactsMask; // This is the identity element for computing type facts of intersection.
|
||||
}
|
||||
return getObjectFlags(type) & ObjectFlags.Anonymous && isEmptyObjectType(type as ObjectType) ?
|
||||
strictNullChecks ? TypeFacts.EmptyObjectStrictFacts : TypeFacts.EmptyObjectFacts :
|
||||
isFunctionObjectType(type as ObjectType) ?
|
||||
strictNullChecks ? TypeFacts.FunctionStrictFacts : TypeFacts.FunctionFacts :
|
||||
strictNullChecks ? TypeFacts.ObjectStrictFacts : TypeFacts.ObjectFacts;
|
||||
}
|
||||
if (flags & (TypeFlags.Void | TypeFlags.Undefined)) {
|
||||
if (flags & TypeFlags.Void) {
|
||||
return TypeFacts.VoidFacts;
|
||||
}
|
||||
if (flags & TypeFlags.Undefined) {
|
||||
return TypeFacts.UndefinedFacts;
|
||||
}
|
||||
if (flags & TypeFlags.Null) {
|
||||
@@ -23595,31 +23591,29 @@ namespace ts {
|
||||
if (flags & TypeFlags.Never) {
|
||||
return TypeFacts.None;
|
||||
}
|
||||
if (flags & TypeFlags.Instantiable) {
|
||||
return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType, ignoreObjects) :
|
||||
strictNullChecks ? TypeFacts.NonEmptyStringStrictFacts : TypeFacts.NonEmptyStringFacts;
|
||||
}
|
||||
if (flags & TypeFlags.Union) {
|
||||
return reduceLeft((type as UnionType).types, (facts, t) => facts | getTypeFacts(t, ignoreObjects), TypeFacts.None);
|
||||
return reduceLeft((type as UnionType).types, (facts, t) => facts | getTypeFacts(t), TypeFacts.None);
|
||||
}
|
||||
if (flags & TypeFlags.Intersection) {
|
||||
// When an intersection contains a primitive type we ignore object type constituents as they are
|
||||
// presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type.
|
||||
ignoreObjects ||= maybeTypeOfKind(type, TypeFlags.Primitive);
|
||||
return getIntersectionTypeFacts(type as IntersectionType, ignoreObjects);
|
||||
return getIntersectionTypeFacts(type as IntersectionType);
|
||||
}
|
||||
return TypeFacts.All;
|
||||
return TypeFacts.UnknownFacts;
|
||||
}
|
||||
|
||||
function getIntersectionTypeFacts(type: IntersectionType, ignoreObjects: boolean): TypeFacts {
|
||||
function getIntersectionTypeFacts(type: IntersectionType): TypeFacts {
|
||||
// When an intersection contains a primitive type we ignore object type constituents as they are
|
||||
// presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type.
|
||||
const ignoreObjects = maybeTypeOfKind(type, TypeFlags.Primitive);
|
||||
// When computing the type facts of an intersection type, certain type facts are computed as `and`
|
||||
// and others are computed as `or`.
|
||||
let oredFacts = TypeFacts.None;
|
||||
let andedFacts = TypeFacts.All;
|
||||
for (const t of type.types) {
|
||||
const f = getTypeFacts(t, ignoreObjects);
|
||||
oredFacts |= f;
|
||||
andedFacts &= f;
|
||||
if (!(ignoreObjects && t.flags & TypeFlags.Object)) {
|
||||
const f = getTypeFacts(t);
|
||||
oredFacts |= f;
|
||||
andedFacts &= f;
|
||||
}
|
||||
}
|
||||
return oredFacts & TypeFacts.OrFactsMask | andedFacts & TypeFacts.AndFactsMask;
|
||||
}
|
||||
@@ -23628,7 +23622,10 @@ namespace ts {
|
||||
return filterType(type, t => (getTypeFacts(t) & include) !== 0);
|
||||
}
|
||||
|
||||
function getIntersectionWithFacts(type: Type, facts: TypeFacts) {
|
||||
// This function is similar to getTypeWithFacts, except that in strictNullChecks mode it replaces type
|
||||
// unknown with the union {} | null | undefined (and reduces that accordingly), and it intersects remaining
|
||||
// instantiable types with {}, {} | null, or {} | undefined in order to remove null and/or undefined.
|
||||
function getAdjustedTypeWithFacts(type: Type, facts: TypeFacts) {
|
||||
const reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & TypeFlags.Unknown ? unknownUnionType : type, facts));
|
||||
if (strictNullChecks) {
|
||||
switch (facts) {
|
||||
@@ -24887,10 +24884,10 @@ namespace ts {
|
||||
|
||||
function narrowTypeByTruthiness(type: Type, expr: Expression, assumeTrue: boolean): Type {
|
||||
if (isMatchingReference(reference, expr)) {
|
||||
return getIntersectionWithFacts(type, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy);
|
||||
return getAdjustedTypeWithFacts(type, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy);
|
||||
}
|
||||
if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
|
||||
type = getTypeWithFacts(type, TypeFacts.NEUndefinedOrNull);
|
||||
type = getAdjustedTypeWithFacts(type, TypeFacts.NEUndefinedOrNull);
|
||||
}
|
||||
const access = getDiscriminantPropertyAccess(expr, type);
|
||||
if (access) {
|
||||
@@ -25036,7 +25033,7 @@ namespace ts {
|
||||
// Note that we include any and unknown in the exclusion test because their domain includes null and undefined.
|
||||
const removeNullable = equalsOperator !== assumeTrue && everyType(valueType, t => !!(t.flags & nullableFlags)) ||
|
||||
equalsOperator === assumeTrue && everyType(valueType, t => !(t.flags & (TypeFlags.AnyOrUnknown | nullableFlags)));
|
||||
return removeNullable ? getTypeWithFacts(type, TypeFacts.NEUndefinedOrNull) : type;
|
||||
return removeNullable ? getAdjustedTypeWithFacts(type, TypeFacts.NEUndefinedOrNull) : type;
|
||||
}
|
||||
|
||||
function narrowTypeByEquality(type: Type, operator: SyntaxKind, value: Expression, assumeTrue: boolean): Type {
|
||||
@@ -25066,7 +25063,7 @@ namespace ts {
|
||||
valueType.flags & TypeFlags.Null ?
|
||||
assumeTrue ? TypeFacts.EQNull : TypeFacts.NENull :
|
||||
assumeTrue ? TypeFacts.EQUndefined : TypeFacts.NEUndefined;
|
||||
return getIntersectionWithFacts(type, facts);
|
||||
return getAdjustedTypeWithFacts(type, facts);
|
||||
}
|
||||
if (assumeTrue) {
|
||||
const filterFn: (t: Type) => boolean = operator === SyntaxKind.EqualsEqualsToken ?
|
||||
@@ -25088,7 +25085,7 @@ namespace ts {
|
||||
const target = getReferenceCandidate(typeOfExpr.expression);
|
||||
if (!isMatchingReference(reference, target)) {
|
||||
if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) {
|
||||
return getTypeWithFacts(type, TypeFacts.NEUndefinedOrNull);
|
||||
return getAdjustedTypeWithFacts(type, TypeFacts.NEUndefinedOrNull);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
@@ -25308,7 +25305,7 @@ namespace ts {
|
||||
const left = getReferenceCandidate(expr.left);
|
||||
if (!isMatchingReference(reference, left)) {
|
||||
if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) {
|
||||
return getTypeWithFacts(type, TypeFacts.NEUndefinedOrNull);
|
||||
return getAdjustedTypeWithFacts(type, TypeFacts.NEUndefinedOrNull);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
@@ -25405,7 +25402,7 @@ namespace ts {
|
||||
}
|
||||
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
|
||||
!(getTypeFacts(predicate.type) & TypeFacts.EQUndefined)) {
|
||||
type = getTypeWithFacts(type, TypeFacts.NEUndefinedOrNull);
|
||||
type = getAdjustedTypeWithFacts(type, TypeFacts.NEUndefinedOrNull);
|
||||
}
|
||||
const access = getDiscriminantPropertyAccess(predicateArgument, type);
|
||||
if (access) {
|
||||
@@ -25464,7 +25461,7 @@ namespace ts {
|
||||
|
||||
function narrowTypeByOptionality(type: Type, expr: Expression, assumePresent: boolean): Type {
|
||||
if (isMatchingReference(reference, expr)) {
|
||||
return getTypeWithFacts(type, assumePresent ? TypeFacts.NEUndefinedOrNull : TypeFacts.EQUndefinedOrNull);
|
||||
return getAdjustedTypeWithFacts(type, assumePresent ? TypeFacts.NEUndefinedOrNull : TypeFacts.EQUndefinedOrNull);
|
||||
}
|
||||
const access = getDiscriminantPropertyAccess(expr, type);
|
||||
if (access) {
|
||||
@@ -25556,8 +25553,8 @@ namespace ts {
|
||||
const annotationIncludesUndefined = strictNullChecks &&
|
||||
declaration.kind === SyntaxKind.Parameter &&
|
||||
declaration.initializer &&
|
||||
getFalsyFlags(declaredType) & TypeFlags.Undefined &&
|
||||
!(getFalsyFlags(checkExpression(declaration.initializer)) & TypeFlags.Undefined);
|
||||
getTypeFacts(declaredType) & TypeFacts.IsUndefined &&
|
||||
!(getTypeFacts(checkExpression(declaration.initializer)) & TypeFacts.IsUndefined);
|
||||
popTypeResolution();
|
||||
|
||||
return annotationIncludesUndefined ? getTypeWithFacts(declaredType, TypeFacts.NEUndefined) : declaredType;
|
||||
@@ -25914,7 +25911,7 @@ namespace ts {
|
||||
return convertAutoToAny(flowType);
|
||||
}
|
||||
}
|
||||
else if (!assumeInitialized && !(getFalsyFlags(type) & TypeFlags.Undefined) && getFalsyFlags(flowType) & TypeFlags.Undefined) {
|
||||
else if (!assumeInitialized && !(getTypeFacts(type) & TypeFacts.IsUndefined) && getTypeFacts(flowType) & TypeFacts.IsUndefined) {
|
||||
error(node, Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
|
||||
// Return the declared type to reduce follow-on errors
|
||||
return type;
|
||||
@@ -28891,23 +28888,23 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isNullableType(type: Type) {
|
||||
return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & TypeFlags.Nullable);
|
||||
return !!(getTypeFacts(type) & TypeFacts.IsUndefinedOrNull);
|
||||
}
|
||||
|
||||
function getNonNullableTypeIfNeeded(type: Type) {
|
||||
return isNullableType(type) ? getNonNullableType(type) : type;
|
||||
}
|
||||
|
||||
function reportObjectPossiblyNullOrUndefinedError(node: Node, flags: TypeFlags) {
|
||||
error(node, flags & TypeFlags.Undefined ? flags & TypeFlags.Null ?
|
||||
function reportObjectPossiblyNullOrUndefinedError(node: Node, facts: TypeFacts) {
|
||||
error(node, facts & TypeFacts.IsUndefined ? facts & TypeFacts.IsNull ?
|
||||
Diagnostics.Object_is_possibly_null_or_undefined :
|
||||
Diagnostics.Object_is_possibly_undefined :
|
||||
Diagnostics.Object_is_possibly_null
|
||||
);
|
||||
}
|
||||
|
||||
function reportCannotInvokePossiblyNullOrUndefinedError(node: Node, flags: TypeFlags) {
|
||||
error(node, flags & TypeFlags.Undefined ? flags & TypeFlags.Null ?
|
||||
function reportCannotInvokePossiblyNullOrUndefinedError(node: Node, facts: TypeFacts) {
|
||||
error(node, facts & TypeFacts.IsUndefined ? facts & TypeFacts.IsNull ?
|
||||
Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined :
|
||||
Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined :
|
||||
Diagnostics.Cannot_invoke_an_object_which_is_possibly_null
|
||||
@@ -28917,15 +28914,15 @@ namespace ts {
|
||||
function checkNonNullTypeWithReporter(
|
||||
type: Type,
|
||||
node: Node,
|
||||
reportError: (node: Node, kind: TypeFlags) => void
|
||||
reportError: (node: Node, facts: TypeFacts) => void
|
||||
): Type {
|
||||
if (strictNullChecks && type.flags & TypeFlags.Unknown) {
|
||||
error(node, Diagnostics.Object_is_of_type_unknown);
|
||||
return errorType;
|
||||
}
|
||||
const kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & TypeFlags.Nullable;
|
||||
if (kind) {
|
||||
reportError(node, kind);
|
||||
const facts = getTypeFacts(type);
|
||||
if (facts & TypeFacts.IsUndefinedOrNull) {
|
||||
reportError(node, facts);
|
||||
const t = getNonNullableType(type);
|
||||
return t.flags & (TypeFlags.Nullable | TypeFlags.Never) ? errorType : t;
|
||||
}
|
||||
@@ -29271,7 +29268,7 @@ namespace ts {
|
||||
assumeUninitialized = true;
|
||||
}
|
||||
const flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType);
|
||||
if (assumeUninitialized && !(getFalsyFlags(propType) & TypeFlags.Undefined) && getFalsyFlags(flowType) & TypeFlags.Undefined) {
|
||||
if (assumeUninitialized && !(getTypeFacts(propType) & TypeFacts.IsUndefined) && getTypeFacts(flowType) & TypeFacts.IsUndefined) {
|
||||
error(errorNode, Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop!)); // TODO: GH#18217
|
||||
// Return the declared type to reduce follow-on errors
|
||||
return propType;
|
||||
@@ -33258,7 +33255,7 @@ namespace ts {
|
||||
const type = getTypeOfSymbol(symbol);
|
||||
if (strictNullChecks &&
|
||||
!(type.flags & (TypeFlags.AnyOrUnknown | TypeFlags.Never)) &&
|
||||
!(exactOptionalPropertyTypes ? symbol.flags & SymbolFlags.Optional : getFalsyFlags(type) & TypeFlags.Undefined)) {
|
||||
!(exactOptionalPropertyTypes ? symbol.flags & SymbolFlags.Optional : getTypeFacts(type) & TypeFacts.IsUndefined)) {
|
||||
error(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
|
||||
}
|
||||
}
|
||||
@@ -33695,7 +33692,7 @@ namespace ts {
|
||||
// In strict null checking mode, if a default value of a non-undefined type is specified, remove
|
||||
// undefined from the final type.
|
||||
if (strictNullChecks &&
|
||||
!(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & TypeFlags.Undefined)) {
|
||||
!(getTypeFacts(checkExpression(prop.objectAssignmentInitializer)) & TypeFacts.IsUndefined)) {
|
||||
sourceType = getTypeWithFacts(sourceType, TypeFacts.NEUndefined);
|
||||
}
|
||||
checkBinaryLikeExpression(prop.name, prop.equalsToken!, prop.objectAssignmentInitializer, checkMode);
|
||||
@@ -33709,6 +33706,10 @@ namespace ts {
|
||||
if (target.kind === SyntaxKind.BinaryExpression && (target as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken) {
|
||||
checkBinaryExpression(target as BinaryExpression, checkMode);
|
||||
target = (target as BinaryExpression).left;
|
||||
// A default value is specified, so remove undefined from the final type.
|
||||
if (strictNullChecks) {
|
||||
sourceType = getTypeWithFacts(sourceType, TypeFacts.NEUndefined);
|
||||
}
|
||||
}
|
||||
if (target.kind === SyntaxKind.ObjectLiteralExpression) {
|
||||
return checkObjectLiteralAssignment(target as ObjectLiteralExpression, sourceType, rightIsThis);
|
||||
@@ -34154,7 +34155,7 @@ namespace ts {
|
||||
case SyntaxKind.BarBarToken:
|
||||
case SyntaxKind.BarBarEqualsToken: {
|
||||
const resultType = getTypeFacts(leftType) & TypeFacts.Falsy ?
|
||||
getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], UnionReduction.Subtype) :
|
||||
getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], UnionReduction.Subtype) :
|
||||
leftType;
|
||||
if (operator === SyntaxKind.BarBarEqualsToken) {
|
||||
checkAssignmentOperator(rightType);
|
||||
@@ -36030,8 +36031,11 @@ namespace ts {
|
||||
if (node.assertions) {
|
||||
const override = getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode);
|
||||
if (override) {
|
||||
if (!isNightly()) {
|
||||
grammarErrorOnNode(node.assertions.assertClause, Diagnostics.resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next);
|
||||
}
|
||||
if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node16 && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) {
|
||||
grammarErrorOnNode(node.assertions.assertClause, Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
|
||||
grammarErrorOnNode(node.assertions.assertClause, Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38109,7 +38113,7 @@ namespace ts {
|
||||
if (isModuleExportsAccessExpression(location)) return;
|
||||
const type = checkTruthinessExpression(location);
|
||||
const isPropertyExpressionCast = isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
||||
if (getFalsyFlags(type) || isPropertyExpressionCast) return;
|
||||
if (!(getTypeFacts(type) & TypeFacts.Truthy) || isPropertyExpressionCast) return;
|
||||
|
||||
// While it technically should be invalid for any known-truthy value
|
||||
// to be tested, we de-scope to functions and Promises unreferenced in
|
||||
@@ -40102,10 +40106,13 @@ namespace ts {
|
||||
const derivedPropertyFlags = derived.flags & SymbolFlags.PropertyOrAccessor;
|
||||
if (basePropertyFlags && derivedPropertyFlags) {
|
||||
// property/accessor is overridden with property/accessor
|
||||
if (baseDeclarationFlags & ModifierFlags.Abstract && !(base.valueDeclaration && isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer)
|
||||
|| base.valueDeclaration && base.valueDeclaration.parent.kind === SyntaxKind.InterfaceDeclaration
|
||||
if ((getCheckFlags(base) & CheckFlags.Synthetic
|
||||
? base.declarations?.some(d => isPropertyAbstractOrInterface(d, baseDeclarationFlags))
|
||||
: base.declarations?.every(d => isPropertyAbstractOrInterface(d, baseDeclarationFlags)))
|
||||
|| getCheckFlags(base) & CheckFlags.Mapped
|
||||
|| derived.valueDeclaration && isBinaryExpression(derived.valueDeclaration)) {
|
||||
// when the base property is abstract or from an interface, base/derived flags don't need to match
|
||||
// for intersection properties, this must be true of *any* of the declarations, for others it must be true of *all*
|
||||
// same when the derived property is from an assignment
|
||||
continue;
|
||||
}
|
||||
@@ -40163,7 +40170,12 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getNonInterhitedProperties(type: InterfaceType, baseTypes: BaseType[], properties: Symbol[]) {
|
||||
function isPropertyAbstractOrInterface(declaration: Declaration, baseDeclarationFlags: ModifierFlags) {
|
||||
return baseDeclarationFlags & ModifierFlags.Abstract && (!isPropertyDeclaration(declaration) || !declaration.initializer)
|
||||
|| isInterfaceDeclaration(declaration.parent);
|
||||
}
|
||||
|
||||
function getNonInheritedProperties(type: InterfaceType, baseTypes: BaseType[], properties: Symbol[]) {
|
||||
if (!length(baseTypes)) {
|
||||
return properties;
|
||||
}
|
||||
@@ -40237,7 +40249,7 @@ namespace ts {
|
||||
const propName = (member as PropertyDeclaration).name;
|
||||
if (isIdentifier(propName) || isPrivateIdentifier(propName) || isComputedPropertyName(propName)) {
|
||||
const type = getTypeOfSymbol(getSymbolOfNode(member));
|
||||
if (!(type.flags & TypeFlags.AnyOrUnknown || getFalsyFlags(type) & TypeFlags.Undefined)) {
|
||||
if (!(type.flags & TypeFlags.AnyOrUnknown || getTypeFacts(type) & TypeFacts.IsUndefined)) {
|
||||
if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
|
||||
error(member.name, Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, declarationNameToString(propName));
|
||||
}
|
||||
@@ -40263,7 +40275,7 @@ namespace ts {
|
||||
setParent(reference, staticBlock);
|
||||
reference.flowNode = staticBlock.returnFlowNode;
|
||||
const flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
|
||||
if (!(getFalsyFlags(flowType) & TypeFlags.Undefined)) {
|
||||
if (!(getTypeFacts(flowType) & TypeFacts.IsUndefined)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -40279,7 +40291,7 @@ namespace ts {
|
||||
setParent(reference, constructor);
|
||||
reference.flowNode = constructor.returnFlowNode;
|
||||
const flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
|
||||
return !(getFalsyFlags(flowType) & TypeFlags.Undefined);
|
||||
return !(getTypeFacts(flowType) & TypeFacts.IsUndefined);
|
||||
}
|
||||
|
||||
|
||||
@@ -40954,11 +40966,11 @@ namespace ts {
|
||||
const override = getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
|
||||
if (validForTypeAssertions && override) {
|
||||
if (!isNightly()) {
|
||||
grammarErrorOnNode(declaration.assertClause, Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next);
|
||||
grammarErrorOnNode(declaration.assertClause, Diagnostics.resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next);
|
||||
}
|
||||
|
||||
if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node16 && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) {
|
||||
return grammarErrorOnNode(declaration.assertClause, Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
|
||||
return grammarErrorOnNode(declaration.assertClause, Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
|
||||
}
|
||||
return; // Other grammar checks do not apply to type-only imports with resolution mode assertions
|
||||
}
|
||||
|
||||
@@ -651,6 +651,10 @@
|
||||
"category": "Error",
|
||||
"code": 1208
|
||||
},
|
||||
"Invalid optional chain from new expression. Did you mean to call '{0}()'?": {
|
||||
"category": "Error",
|
||||
"code": 1209
|
||||
},
|
||||
"Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of '{0}'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.": {
|
||||
"category": "Error",
|
||||
"code": 1210
|
||||
@@ -1436,7 +1440,7 @@
|
||||
"category": "Error",
|
||||
"code": 1451
|
||||
},
|
||||
"Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`.": {
|
||||
"'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.": {
|
||||
"category": "Error",
|
||||
"code": 1452
|
||||
},
|
||||
@@ -3475,6 +3479,14 @@
|
||||
"category": "Error",
|
||||
"code": 2839
|
||||
},
|
||||
"An interface cannot extend a primitive type like '{0}'; an interface can only extend named types and classes": {
|
||||
"category": "Error",
|
||||
"code": 2840
|
||||
},
|
||||
"The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'.": {
|
||||
"category": "Error",
|
||||
"code": 2841
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
@@ -3904,7 +3916,7 @@
|
||||
"category": "Error",
|
||||
"code": 4124
|
||||
},
|
||||
"Resolution mode assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'.": {
|
||||
"'resolution-mode' assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'.": {
|
||||
"category": "Error",
|
||||
"code": 4125
|
||||
},
|
||||
|
||||
@@ -597,6 +597,10 @@ namespace ts {
|
||||
return node.kind === SyntaxKind.ImportClause;
|
||||
}
|
||||
|
||||
export function isImportTypeAssertionContainer(node: Node): node is ImportTypeAssertionContainer {
|
||||
return node.kind === SyntaxKind.ImportTypeAssertionContainer;
|
||||
}
|
||||
|
||||
export function isAssertClause(node: Node): node is AssertClause {
|
||||
return node.kind === SyntaxKind.AssertClause;
|
||||
}
|
||||
|
||||
@@ -2064,6 +2064,24 @@ namespace ts {
|
||||
return toSearchResult(/*value*/ undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
|
||||
* "longest" has some nuance as to what "longest" means in the presence of pattern trailers
|
||||
*/
|
||||
function comparePatternKeys(a: string, b: string) {
|
||||
const aPatternIndex = a.indexOf("*");
|
||||
const bPatternIndex = b.indexOf("*");
|
||||
const baseLenA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
|
||||
const baseLenB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
|
||||
if (baseLenA > baseLenB) return -1;
|
||||
if (baseLenB > baseLenA) return 1;
|
||||
if (aPatternIndex === -1) return 1;
|
||||
if (bPatternIndex === -1) return -1;
|
||||
if (a.length > b.length) return -1;
|
||||
if (b.length > a.length) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
function loadModuleFromImportsOrExports(extensions: Extensions, state: ModuleResolutionState, cache: ModuleResolutionCache | undefined, redirectedReference: ResolvedProjectReference | undefined, moduleName: string, lookupTable: object, scope: PackageJsonInfo, isImports: boolean): SearchResult<Resolved> | undefined {
|
||||
const loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
||||
|
||||
@@ -2071,7 +2089,7 @@ namespace ts {
|
||||
const target = (lookupTable as {[idx: string]: unknown})[moduleName];
|
||||
return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
|
||||
}
|
||||
const expandingKeys = sort(filter(getOwnKeys(lookupTable as MapLike<unknown>), k => k.indexOf("*") !== -1 || endsWith(k, "/")), (a, b) => a.length - b.length);
|
||||
const expandingKeys = sort(filter(getOwnKeys(lookupTable as MapLike<unknown>), k => k.indexOf("*") !== -1 || endsWith(k, "/")), comparePatternKeys);
|
||||
for (const potentialTarget of expandingKeys) {
|
||||
if (state.features & NodeResolutionFeatures.ExportsPatternTrailers && matchesPatternWithTrailer(potentialTarget, moduleName)) {
|
||||
const target = (lookupTable as {[idx: string]: unknown})[potentialTarget];
|
||||
@@ -2413,8 +2431,8 @@ namespace ts {
|
||||
);
|
||||
if (
|
||||
!pathAndExtension && packageInfo
|
||||
&& packageInfo.packageJsonContent.exports === undefined
|
||||
&& packageInfo.packageJsonContent.main === undefined
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
&& (packageInfo.packageJsonContent.exports === undefined || packageInfo.packageJsonContent.exports === null)
|
||||
&& state.features & NodeResolutionFeatures.EsmMode
|
||||
) {
|
||||
// EsmMode disables index lookup in `loadNodeModuleFromDirectoryWorker` generally, however non-relative package resolutions still assume
|
||||
|
||||
@@ -5942,6 +5942,9 @@ namespace ts {
|
||||
typeArguments = (expression as ExpressionWithTypeArguments).typeArguments;
|
||||
expression = (expression as ExpressionWithTypeArguments).expression;
|
||||
}
|
||||
if (token() === SyntaxKind.QuestionDotToken) {
|
||||
parseErrorAtCurrentToken(Diagnostics.Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0, getTextOfNodeFromSourceText(sourceText, expression));
|
||||
}
|
||||
const argumentList = token() === SyntaxKind.OpenParenToken ? parseArgumentList() : undefined;
|
||||
return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos);
|
||||
}
|
||||
|
||||
+36
-9
@@ -536,20 +536,39 @@ namespace ts {
|
||||
return resolutions;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
interface SourceFileImportsList {
|
||||
imports: SourceFile["imports"];
|
||||
moduleAugmentations: SourceFile["moduleAugmentations"];
|
||||
/**
|
||||
* Subset of a SourceFile used to calculate index-based resolutions
|
||||
* This includes some internal fields, so unless you have very good reason,
|
||||
* (and are willing to use some less stable internals) you should probably just pass a SourceFile.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export interface SourceFileImportsList {
|
||||
/* @internal */ imports: SourceFile["imports"];
|
||||
/* @internal */ moduleAugmentations: SourceFile["moduleAugmentations"];
|
||||
impliedNodeFormat?: SourceFile["impliedNodeFormat"];
|
||||
};
|
||||
|
||||
/* @internal */
|
||||
/**
|
||||
* Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
|
||||
* provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
|
||||
*/
|
||||
export function getModeForFileReference(ref: FileReference | string, containingFileMode: SourceFile["impliedNodeFormat"]) {
|
||||
return (isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number) {
|
||||
/**
|
||||
* Calculates the final resolution mode for an import at some index within a file's imports list. This is generally the explicitly
|
||||
* defined mode of the import if provided, or, if not, the mode of the containing file (with some exceptions: import=require is always commonjs, dynamic import is always esm).
|
||||
* If you have an actual import node, prefer using getModeForUsageLocation on the reference string node.
|
||||
* @param file File to fetch the resolution mode within
|
||||
* @param index Index into the file's complete resolution list to get the resolution of - this is a concatenation of the file's imports and module augmentations
|
||||
*/
|
||||
export function getModeForResolutionAtIndex(file: SourceFile, index: number): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
|
||||
/** @internal */
|
||||
// eslint-disable-next-line @typescript-eslint/unified-signatures
|
||||
export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
|
||||
export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number): ModuleKind.CommonJS | ModuleKind.ESNext | undefined {
|
||||
if (file.impliedNodeFormat === undefined) return undefined;
|
||||
// we ensure all elements of file.imports and file.moduleAugmentations have the relevant parent pointers set during program setup,
|
||||
// so it's safe to use them even pre-bind
|
||||
@@ -567,7 +586,15 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
/**
|
||||
* Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
|
||||
* one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
|
||||
* Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
|
||||
* `moduleResolution` is `node16`+.
|
||||
* @param file The file the import or import-like reference is contained within
|
||||
* @param usage The module reference string
|
||||
* @returns The final resolution mode of the import
|
||||
*/
|
||||
export function getModeForUsageLocation(file: {impliedNodeFormat?: SourceFile["impliedNodeFormat"]}, usage: StringLiteralLike) {
|
||||
if (file.impliedNodeFormat === undefined) return undefined;
|
||||
if ((isImportDeclaration(usage.parent) || isExportDeclaration(usage.parent))) {
|
||||
@@ -3121,7 +3148,7 @@ namespace ts {
|
||||
setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
|
||||
const mode = ref.resolutionMode || file.impliedNodeFormat;
|
||||
if (mode && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Node16 && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeNext) {
|
||||
programDiagnostics.add(createDiagnosticForRange(file, ref, Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
|
||||
programDiagnostics.add(createDiagnosticForRange(file, ref, Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
|
||||
}
|
||||
processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: FileIncludeKind.TypeReferenceDirective, file: file.path, index, });
|
||||
}
|
||||
|
||||
@@ -78,7 +78,8 @@ namespace ts {
|
||||
trackReferencedAmbientModule,
|
||||
trackExternalModuleSymbolOfImportTypeNode,
|
||||
reportNonlocalAugmentation,
|
||||
reportNonSerializableProperty
|
||||
reportNonSerializableProperty,
|
||||
reportImportTypeNodeResolutionModeOverride,
|
||||
};
|
||||
let errorNameNode: DeclarationName | undefined;
|
||||
let errorFallbackNode: Declaration | undefined;
|
||||
@@ -235,6 +236,12 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function reportImportTypeNodeResolutionModeOverride() {
|
||||
if (!isNightly() && (errorNameNode || errorFallbackNode)) {
|
||||
context.addDiagnostic(createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next));
|
||||
}
|
||||
}
|
||||
|
||||
function transformDeclarationsForJS(sourceFile: SourceFile, bundled?: boolean) {
|
||||
const oldDiag = getSymbolAccessibilityDiagnostic;
|
||||
getSymbolAccessibilityDiagnostic = (s) => (s.errorNode && canProduceDiagnostics(s.errorNode) ? createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({
|
||||
@@ -792,7 +799,7 @@ namespace ts {
|
||||
const mode = getResolutionModeOverrideForClause(assertClause);
|
||||
if (mode !== undefined) {
|
||||
if (!isNightly()) {
|
||||
context.addDiagnostic(createDiagnosticForNode(assertClause!, Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next));
|
||||
context.addDiagnostic(createDiagnosticForNode(assertClause!, Diagnostics.resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next));
|
||||
}
|
||||
return assertClause;
|
||||
}
|
||||
|
||||
@@ -8524,6 +8524,7 @@ namespace ts {
|
||||
trackExternalModuleSymbolOfImportTypeNode?(symbol: Symbol): void;
|
||||
reportNonlocalAugmentation?(containingFile: SourceFile, parentSymbol: Symbol, augmentingSymbol: Symbol): void;
|
||||
reportNonSerializableProperty?(propertyName: string): void;
|
||||
reportImportTypeNodeResolutionModeOverride?(): void;
|
||||
}
|
||||
|
||||
export interface TextSpan {
|
||||
|
||||
@@ -2016,6 +2016,8 @@ namespace ts {
|
||||
case SyntaxKind.AwaitExpression:
|
||||
case SyntaxKind.MetaProperty:
|
||||
return true;
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return !isHeritageClause(node.parent);
|
||||
case SyntaxKind.QualifiedName:
|
||||
while (node.parent.kind === SyntaxKind.QualifiedName) {
|
||||
node = node.parent;
|
||||
|
||||
@@ -617,7 +617,6 @@ namespace ts.formatting {
|
||||
case SyntaxKind.JsxOpeningElement:
|
||||
case SyntaxKind.JsxClosingElement:
|
||||
case SyntaxKind.JsxSelfClosingElement:
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@@ -835,7 +834,7 @@ namespace ts.formatting {
|
||||
const listEndToken = getCloseTokenForOpenToken(listStartToken);
|
||||
if (listEndToken !== SyntaxKind.Unknown && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) {
|
||||
let tokenInfo: TokenInfo | undefined = formattingScanner.readTokenInfo(parent);
|
||||
if (tokenInfo.token.kind === SyntaxKind.CommaToken && isCallLikeExpression(parent)) {
|
||||
if (tokenInfo.token.kind === SyntaxKind.CommaToken) {
|
||||
// consume the comma
|
||||
consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent);
|
||||
tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined;
|
||||
@@ -1311,6 +1310,12 @@ namespace ts.formatting {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
if ((node as FunctionDeclaration).typeParameters === list) {
|
||||
return SyntaxKind.LessThanToken;
|
||||
}
|
||||
@@ -1327,7 +1332,19 @@ namespace ts.formatting {
|
||||
return SyntaxKind.OpenParenToken;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
if ((node as ClassDeclaration).typeParameters === list) {
|
||||
return SyntaxKind.LessThanToken;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.TypeReference:
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
case SyntaxKind.TypeQuery:
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
case SyntaxKind.ImportType:
|
||||
if ((node as TypeReferenceNode).typeArguments === list) {
|
||||
return SyntaxKind.LessThanToken;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace ts.InlayHints {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isTypeNode(node)) {
|
||||
if (isTypeNode(node) && !isExpressionWithTypeArguments(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +131,30 @@ describe("unittests:: Public APIs:: getTypeAtLocation", () => {
|
||||
assert.equal(type.flags, ts.TypeFlags.Any);
|
||||
});
|
||||
|
||||
it("works on ExpressionWithTypeArguments", () => {
|
||||
const content = `
|
||||
function fn<T>(value: T) {
|
||||
return { value };
|
||||
}
|
||||
const foo = fn<string>;
|
||||
`;
|
||||
const host = new fakes.CompilerHost(vfs.createFromFileSystem(
|
||||
Harness.IO,
|
||||
/*ignoreCase*/ true,
|
||||
{ documents: [new documents.TextDocument("/file.ts", content)], cwd: "/" }));
|
||||
|
||||
const program = ts.createProgram({
|
||||
host,
|
||||
rootNames: ["/file.ts"],
|
||||
options: { noLib: true }
|
||||
});
|
||||
|
||||
const checker = program.getTypeChecker();
|
||||
const file = program.getSourceFile("/file.ts")!;
|
||||
const [declaration] = (ts.findLast(file.statements, ts.isVariableStatement) as ts.VariableStatement).declarationList.declarations;
|
||||
assert.equal(checker.getTypeAtLocation(declaration.initializer!).flags, ts.TypeFlags.Object);
|
||||
});
|
||||
|
||||
it("returns an errorType for VariableDeclaration with BindingPattern name", () => {
|
||||
const content = "const foo = [1];\n" + "const [a] = foo;";
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
//// [accessorsOverrideProperty8.ts]
|
||||
type Types = 'boolean' | 'unknown' | 'string';
|
||||
|
||||
type Properties<T extends { [key: string]: Types }> = {
|
||||
readonly [key in keyof T]: T[key] extends 'boolean' ? boolean : T[key] extends 'string' ? string : unknown
|
||||
}
|
||||
|
||||
type AnyCtor<P extends object> = new (...a: any[]) => P
|
||||
|
||||
declare function classWithProperties<T extends { [key: string]: Types }, P extends object>(properties: T, klass: AnyCtor<P>): {
|
||||
new(): P & Properties<T>;
|
||||
prototype: P & Properties<T>
|
||||
};
|
||||
|
||||
const Base = classWithProperties({
|
||||
get x() { return 'boolean' as const },
|
||||
y: 'string',
|
||||
}, class Base {
|
||||
});
|
||||
|
||||
class MyClass extends Base {
|
||||
get x() {
|
||||
return false;
|
||||
}
|
||||
get y() {
|
||||
return 'hi'
|
||||
}
|
||||
}
|
||||
|
||||
const mine = new MyClass();
|
||||
const value = mine.x;
|
||||
|
||||
|
||||
|
||||
//// [accessorsOverrideProperty8.js]
|
||||
const Base = classWithProperties({
|
||||
get x() { return 'boolean'; },
|
||||
y: 'string',
|
||||
}, class Base {
|
||||
});
|
||||
class MyClass extends Base {
|
||||
get x() {
|
||||
return false;
|
||||
}
|
||||
get y() {
|
||||
return 'hi';
|
||||
}
|
||||
}
|
||||
const mine = new MyClass();
|
||||
const value = mine.x;
|
||||
@@ -0,0 +1,93 @@
|
||||
=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty8.ts ===
|
||||
type Types = 'boolean' | 'unknown' | 'string';
|
||||
>Types : Symbol(Types, Decl(accessorsOverrideProperty8.ts, 0, 0))
|
||||
|
||||
type Properties<T extends { [key: string]: Types }> = {
|
||||
>Properties : Symbol(Properties, Decl(accessorsOverrideProperty8.ts, 0, 46))
|
||||
>T : Symbol(T, Decl(accessorsOverrideProperty8.ts, 2, 16))
|
||||
>key : Symbol(key, Decl(accessorsOverrideProperty8.ts, 2, 29))
|
||||
>Types : Symbol(Types, Decl(accessorsOverrideProperty8.ts, 0, 0))
|
||||
|
||||
readonly [key in keyof T]: T[key] extends 'boolean' ? boolean : T[key] extends 'string' ? string : unknown
|
||||
>key : Symbol(key, Decl(accessorsOverrideProperty8.ts, 3, 14))
|
||||
>T : Symbol(T, Decl(accessorsOverrideProperty8.ts, 2, 16))
|
||||
>T : Symbol(T, Decl(accessorsOverrideProperty8.ts, 2, 16))
|
||||
>key : Symbol(key, Decl(accessorsOverrideProperty8.ts, 3, 14))
|
||||
>T : Symbol(T, Decl(accessorsOverrideProperty8.ts, 2, 16))
|
||||
>key : Symbol(key, Decl(accessorsOverrideProperty8.ts, 3, 14))
|
||||
}
|
||||
|
||||
type AnyCtor<P extends object> = new (...a: any[]) => P
|
||||
>AnyCtor : Symbol(AnyCtor, Decl(accessorsOverrideProperty8.ts, 4, 1))
|
||||
>P : Symbol(P, Decl(accessorsOverrideProperty8.ts, 6, 13))
|
||||
>a : Symbol(a, Decl(accessorsOverrideProperty8.ts, 6, 38))
|
||||
>P : Symbol(P, Decl(accessorsOverrideProperty8.ts, 6, 13))
|
||||
|
||||
declare function classWithProperties<T extends { [key: string]: Types }, P extends object>(properties: T, klass: AnyCtor<P>): {
|
||||
>classWithProperties : Symbol(classWithProperties, Decl(accessorsOverrideProperty8.ts, 6, 55))
|
||||
>T : Symbol(T, Decl(accessorsOverrideProperty8.ts, 8, 37))
|
||||
>key : Symbol(key, Decl(accessorsOverrideProperty8.ts, 8, 50))
|
||||
>Types : Symbol(Types, Decl(accessorsOverrideProperty8.ts, 0, 0))
|
||||
>P : Symbol(P, Decl(accessorsOverrideProperty8.ts, 8, 72))
|
||||
>properties : Symbol(properties, Decl(accessorsOverrideProperty8.ts, 8, 91))
|
||||
>T : Symbol(T, Decl(accessorsOverrideProperty8.ts, 8, 37))
|
||||
>klass : Symbol(klass, Decl(accessorsOverrideProperty8.ts, 8, 105))
|
||||
>AnyCtor : Symbol(AnyCtor, Decl(accessorsOverrideProperty8.ts, 4, 1))
|
||||
>P : Symbol(P, Decl(accessorsOverrideProperty8.ts, 8, 72))
|
||||
|
||||
new(): P & Properties<T>;
|
||||
>P : Symbol(P, Decl(accessorsOverrideProperty8.ts, 8, 72))
|
||||
>Properties : Symbol(Properties, Decl(accessorsOverrideProperty8.ts, 0, 46))
|
||||
>T : Symbol(T, Decl(accessorsOverrideProperty8.ts, 8, 37))
|
||||
|
||||
prototype: P & Properties<T>
|
||||
>prototype : Symbol(prototype, Decl(accessorsOverrideProperty8.ts, 9, 29))
|
||||
>P : Symbol(P, Decl(accessorsOverrideProperty8.ts, 8, 72))
|
||||
>Properties : Symbol(Properties, Decl(accessorsOverrideProperty8.ts, 0, 46))
|
||||
>T : Symbol(T, Decl(accessorsOverrideProperty8.ts, 8, 37))
|
||||
|
||||
};
|
||||
|
||||
const Base = classWithProperties({
|
||||
>Base : Symbol(Base, Decl(accessorsOverrideProperty8.ts, 13, 5))
|
||||
>classWithProperties : Symbol(classWithProperties, Decl(accessorsOverrideProperty8.ts, 6, 55))
|
||||
|
||||
get x() { return 'boolean' as const },
|
||||
>x : Symbol(x, Decl(accessorsOverrideProperty8.ts, 13, 34))
|
||||
>const : Symbol(const)
|
||||
|
||||
y: 'string',
|
||||
>y : Symbol(y, Decl(accessorsOverrideProperty8.ts, 14, 42))
|
||||
|
||||
}, class Base {
|
||||
>Base : Symbol(Base, Decl(accessorsOverrideProperty8.ts, 16, 2))
|
||||
|
||||
});
|
||||
|
||||
class MyClass extends Base {
|
||||
>MyClass : Symbol(MyClass, Decl(accessorsOverrideProperty8.ts, 17, 3))
|
||||
>Base : Symbol(Base, Decl(accessorsOverrideProperty8.ts, 13, 5))
|
||||
|
||||
get x() {
|
||||
>x : Symbol(MyClass.x, Decl(accessorsOverrideProperty8.ts, 19, 28))
|
||||
|
||||
return false;
|
||||
}
|
||||
get y() {
|
||||
>y : Symbol(MyClass.y, Decl(accessorsOverrideProperty8.ts, 22, 5))
|
||||
|
||||
return 'hi'
|
||||
}
|
||||
}
|
||||
|
||||
const mine = new MyClass();
|
||||
>mine : Symbol(mine, Decl(accessorsOverrideProperty8.ts, 28, 5))
|
||||
>MyClass : Symbol(MyClass, Decl(accessorsOverrideProperty8.ts, 17, 3))
|
||||
|
||||
const value = mine.x;
|
||||
>value : Symbol(value, Decl(accessorsOverrideProperty8.ts, 29, 5))
|
||||
>mine.x : Symbol(MyClass.x, Decl(accessorsOverrideProperty8.ts, 19, 28))
|
||||
>mine : Symbol(mine, Decl(accessorsOverrideProperty8.ts, 28, 5))
|
||||
>x : Symbol(MyClass.x, Decl(accessorsOverrideProperty8.ts, 19, 28))
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty8.ts ===
|
||||
type Types = 'boolean' | 'unknown' | 'string';
|
||||
>Types : "string" | "boolean" | "unknown"
|
||||
|
||||
type Properties<T extends { [key: string]: Types }> = {
|
||||
>Properties : Properties<T>
|
||||
>key : string
|
||||
|
||||
readonly [key in keyof T]: T[key] extends 'boolean' ? boolean : T[key] extends 'string' ? string : unknown
|
||||
}
|
||||
|
||||
type AnyCtor<P extends object> = new (...a: any[]) => P
|
||||
>AnyCtor : AnyCtor<P>
|
||||
>a : any[]
|
||||
|
||||
declare function classWithProperties<T extends { [key: string]: Types }, P extends object>(properties: T, klass: AnyCtor<P>): {
|
||||
>classWithProperties : <T extends { [key: string]: Types; }, P extends object>(properties: T, klass: AnyCtor<P>) => { new (): P & Properties<T>; prototype: P & Properties<T>;}
|
||||
>key : string
|
||||
>properties : T
|
||||
>klass : AnyCtor<P>
|
||||
|
||||
new(): P & Properties<T>;
|
||||
prototype: P & Properties<T>
|
||||
>prototype : P & Properties<T>
|
||||
|
||||
};
|
||||
|
||||
const Base = classWithProperties({
|
||||
>Base : { new (): Base & Properties<{ readonly x: "boolean"; y: "string"; }>; prototype: Base & Properties<{ readonly x: "boolean"; y: "string"; }>; }
|
||||
>classWithProperties({ get x() { return 'boolean' as const }, y: 'string',}, class Base {}) : { new (): Base & Properties<{ readonly x: "boolean"; y: "string"; }>; prototype: Base & Properties<{ readonly x: "boolean"; y: "string"; }>; }
|
||||
>classWithProperties : <T extends { [key: string]: Types; }, P extends object>(properties: T, klass: AnyCtor<P>) => { new (): P & Properties<T>; prototype: P & Properties<T>; }
|
||||
>{ get x() { return 'boolean' as const }, y: 'string',} : { readonly x: "boolean"; y: "string"; }
|
||||
|
||||
get x() { return 'boolean' as const },
|
||||
>x : "boolean"
|
||||
>'boolean' as const : "boolean"
|
||||
>'boolean' : "boolean"
|
||||
|
||||
y: 'string',
|
||||
>y : "string"
|
||||
>'string' : "string"
|
||||
|
||||
}, class Base {
|
||||
>class Base {} : typeof Base
|
||||
>Base : typeof Base
|
||||
|
||||
});
|
||||
|
||||
class MyClass extends Base {
|
||||
>MyClass : MyClass
|
||||
>Base : Base & Properties<{ readonly x: "boolean"; y: "string"; }>
|
||||
|
||||
get x() {
|
||||
>x : boolean
|
||||
|
||||
return false;
|
||||
>false : false
|
||||
}
|
||||
get y() {
|
||||
>y : string
|
||||
|
||||
return 'hi'
|
||||
>'hi' : "hi"
|
||||
}
|
||||
}
|
||||
|
||||
const mine = new MyClass();
|
||||
>mine : MyClass
|
||||
>new MyClass() : MyClass
|
||||
>MyClass : typeof MyClass
|
||||
|
||||
const value = mine.x;
|
||||
>value : boolean
|
||||
>mine.x : boolean
|
||||
>mine : MyClass
|
||||
>x : boolean
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
//// [accessorsOverrideProperty9.ts]
|
||||
// #41347, based on microsoft/rushstack
|
||||
|
||||
// Mixin utilities
|
||||
export type Constructor<T = {}> = new (...args: any[]) => T;
|
||||
export type PropertiesOf<T> = { [K in keyof T]: T[K] };
|
||||
|
||||
interface IApiItemConstructor extends Constructor<ApiItem>, PropertiesOf<typeof ApiItem> {}
|
||||
|
||||
// Base class
|
||||
class ApiItem {
|
||||
public get members(): ReadonlyArray<ApiItem> {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// Normal subclass
|
||||
class ApiEnumMember extends ApiItem {
|
||||
}
|
||||
|
||||
// Mixin base class
|
||||
interface ApiItemContainerMixin extends ApiItem {
|
||||
readonly members: ReadonlyArray<ApiItem>;
|
||||
}
|
||||
|
||||
function ApiItemContainerMixin<TBaseClass extends IApiItemConstructor>(
|
||||
baseClass: TBaseClass
|
||||
): TBaseClass & (new (...args: any[]) => ApiItemContainerMixin) {
|
||||
abstract class MixedClass extends baseClass implements ApiItemContainerMixin {
|
||||
public constructor(...args: any[]) {
|
||||
super(...args);
|
||||
}
|
||||
|
||||
public get members(): ReadonlyArray<ApiItem> {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
return MixedClass;
|
||||
}
|
||||
|
||||
// Subclass inheriting from mixin
|
||||
export class ApiEnum extends ApiItemContainerMixin(ApiItem) {
|
||||
// This worked prior to TypeScript 4.0:
|
||||
public get members(): ReadonlyArray<ApiEnumMember> {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [accessorsOverrideProperty9.js]
|
||||
// #41347, based on microsoft/rushstack
|
||||
// Base class
|
||||
class ApiItem {
|
||||
get members() {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
// Normal subclass
|
||||
class ApiEnumMember extends ApiItem {
|
||||
}
|
||||
function ApiItemContainerMixin(baseClass) {
|
||||
class MixedClass extends baseClass {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
}
|
||||
get members() {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
return MixedClass;
|
||||
}
|
||||
// Subclass inheriting from mixin
|
||||
export class ApiEnum extends ApiItemContainerMixin(ApiItem) {
|
||||
// This worked prior to TypeScript 4.0:
|
||||
get members() {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty9.ts ===
|
||||
// #41347, based on microsoft/rushstack
|
||||
|
||||
// Mixin utilities
|
||||
export type Constructor<T = {}> = new (...args: any[]) => T;
|
||||
>Constructor : Symbol(Constructor, Decl(accessorsOverrideProperty9.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(accessorsOverrideProperty9.ts, 3, 24))
|
||||
>args : Symbol(args, Decl(accessorsOverrideProperty9.ts, 3, 39))
|
||||
>T : Symbol(T, Decl(accessorsOverrideProperty9.ts, 3, 24))
|
||||
|
||||
export type PropertiesOf<T> = { [K in keyof T]: T[K] };
|
||||
>PropertiesOf : Symbol(PropertiesOf, Decl(accessorsOverrideProperty9.ts, 3, 60))
|
||||
>T : Symbol(T, Decl(accessorsOverrideProperty9.ts, 4, 25))
|
||||
>K : Symbol(K, Decl(accessorsOverrideProperty9.ts, 4, 33))
|
||||
>T : Symbol(T, Decl(accessorsOverrideProperty9.ts, 4, 25))
|
||||
>T : Symbol(T, Decl(accessorsOverrideProperty9.ts, 4, 25))
|
||||
>K : Symbol(K, Decl(accessorsOverrideProperty9.ts, 4, 33))
|
||||
|
||||
interface IApiItemConstructor extends Constructor<ApiItem>, PropertiesOf<typeof ApiItem> {}
|
||||
>IApiItemConstructor : Symbol(IApiItemConstructor, Decl(accessorsOverrideProperty9.ts, 4, 55))
|
||||
>Constructor : Symbol(Constructor, Decl(accessorsOverrideProperty9.ts, 0, 0))
|
||||
>ApiItem : Symbol(ApiItem, Decl(accessorsOverrideProperty9.ts, 6, 91))
|
||||
>PropertiesOf : Symbol(PropertiesOf, Decl(accessorsOverrideProperty9.ts, 3, 60))
|
||||
>ApiItem : Symbol(ApiItem, Decl(accessorsOverrideProperty9.ts, 6, 91))
|
||||
|
||||
// Base class
|
||||
class ApiItem {
|
||||
>ApiItem : Symbol(ApiItem, Decl(accessorsOverrideProperty9.ts, 6, 91))
|
||||
|
||||
public get members(): ReadonlyArray<ApiItem> {
|
||||
>members : Symbol(ApiItem.members, Decl(accessorsOverrideProperty9.ts, 9, 15))
|
||||
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))
|
||||
>ApiItem : Symbol(ApiItem, Decl(accessorsOverrideProperty9.ts, 6, 91))
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// Normal subclass
|
||||
class ApiEnumMember extends ApiItem {
|
||||
>ApiEnumMember : Symbol(ApiEnumMember, Decl(accessorsOverrideProperty9.ts, 13, 1))
|
||||
>ApiItem : Symbol(ApiItem, Decl(accessorsOverrideProperty9.ts, 6, 91))
|
||||
}
|
||||
|
||||
// Mixin base class
|
||||
interface ApiItemContainerMixin extends ApiItem {
|
||||
>ApiItemContainerMixin : Symbol(ApiItemContainerMixin, Decl(accessorsOverrideProperty9.ts, 22, 1), Decl(accessorsOverrideProperty9.ts, 17, 1))
|
||||
>ApiItem : Symbol(ApiItem, Decl(accessorsOverrideProperty9.ts, 6, 91))
|
||||
|
||||
readonly members: ReadonlyArray<ApiItem>;
|
||||
>members : Symbol(ApiItemContainerMixin.members, Decl(accessorsOverrideProperty9.ts, 20, 49))
|
||||
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))
|
||||
>ApiItem : Symbol(ApiItem, Decl(accessorsOverrideProperty9.ts, 6, 91))
|
||||
}
|
||||
|
||||
function ApiItemContainerMixin<TBaseClass extends IApiItemConstructor>(
|
||||
>ApiItemContainerMixin : Symbol(ApiItemContainerMixin, Decl(accessorsOverrideProperty9.ts, 22, 1), Decl(accessorsOverrideProperty9.ts, 17, 1))
|
||||
>TBaseClass : Symbol(TBaseClass, Decl(accessorsOverrideProperty9.ts, 24, 31))
|
||||
>IApiItemConstructor : Symbol(IApiItemConstructor, Decl(accessorsOverrideProperty9.ts, 4, 55))
|
||||
|
||||
baseClass: TBaseClass
|
||||
>baseClass : Symbol(baseClass, Decl(accessorsOverrideProperty9.ts, 24, 71))
|
||||
>TBaseClass : Symbol(TBaseClass, Decl(accessorsOverrideProperty9.ts, 24, 31))
|
||||
|
||||
): TBaseClass & (new (...args: any[]) => ApiItemContainerMixin) {
|
||||
>TBaseClass : Symbol(TBaseClass, Decl(accessorsOverrideProperty9.ts, 24, 31))
|
||||
>args : Symbol(args, Decl(accessorsOverrideProperty9.ts, 26, 22))
|
||||
>ApiItemContainerMixin : Symbol(ApiItemContainerMixin, Decl(accessorsOverrideProperty9.ts, 22, 1), Decl(accessorsOverrideProperty9.ts, 17, 1))
|
||||
|
||||
abstract class MixedClass extends baseClass implements ApiItemContainerMixin {
|
||||
>MixedClass : Symbol(MixedClass, Decl(accessorsOverrideProperty9.ts, 26, 65))
|
||||
>baseClass : Symbol(baseClass, Decl(accessorsOverrideProperty9.ts, 24, 71))
|
||||
>ApiItemContainerMixin : Symbol(ApiItemContainerMixin, Decl(accessorsOverrideProperty9.ts, 22, 1), Decl(accessorsOverrideProperty9.ts, 17, 1))
|
||||
|
||||
public constructor(...args: any[]) {
|
||||
>args : Symbol(args, Decl(accessorsOverrideProperty9.ts, 28, 23))
|
||||
|
||||
super(...args);
|
||||
>super : Symbol(TBaseClass, Decl(accessorsOverrideProperty9.ts, 24, 31))
|
||||
>args : Symbol(args, Decl(accessorsOverrideProperty9.ts, 28, 23))
|
||||
}
|
||||
|
||||
public get members(): ReadonlyArray<ApiItem> {
|
||||
>members : Symbol(MixedClass.members, Decl(accessorsOverrideProperty9.ts, 30, 5))
|
||||
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))
|
||||
>ApiItem : Symbol(ApiItem, Decl(accessorsOverrideProperty9.ts, 6, 91))
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
return MixedClass;
|
||||
>MixedClass : Symbol(MixedClass, Decl(accessorsOverrideProperty9.ts, 26, 65))
|
||||
}
|
||||
|
||||
// Subclass inheriting from mixin
|
||||
export class ApiEnum extends ApiItemContainerMixin(ApiItem) {
|
||||
>ApiEnum : Symbol(ApiEnum, Decl(accessorsOverrideProperty9.ts, 38, 1))
|
||||
>ApiItemContainerMixin : Symbol(ApiItemContainerMixin, Decl(accessorsOverrideProperty9.ts, 22, 1), Decl(accessorsOverrideProperty9.ts, 17, 1))
|
||||
>ApiItem : Symbol(ApiItem, Decl(accessorsOverrideProperty9.ts, 6, 91))
|
||||
|
||||
// This worked prior to TypeScript 4.0:
|
||||
public get members(): ReadonlyArray<ApiEnumMember> {
|
||||
>members : Symbol(ApiEnum.members, Decl(accessorsOverrideProperty9.ts, 41, 61))
|
||||
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --))
|
||||
>ApiEnumMember : Symbol(ApiEnumMember, Decl(accessorsOverrideProperty9.ts, 13, 1))
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty9.ts ===
|
||||
// #41347, based on microsoft/rushstack
|
||||
|
||||
// Mixin utilities
|
||||
export type Constructor<T = {}> = new (...args: any[]) => T;
|
||||
>Constructor : Constructor<T>
|
||||
>args : any[]
|
||||
|
||||
export type PropertiesOf<T> = { [K in keyof T]: T[K] };
|
||||
>PropertiesOf : PropertiesOf<T>
|
||||
|
||||
interface IApiItemConstructor extends Constructor<ApiItem>, PropertiesOf<typeof ApiItem> {}
|
||||
>ApiItem : typeof ApiItem
|
||||
|
||||
// Base class
|
||||
class ApiItem {
|
||||
>ApiItem : ApiItem
|
||||
|
||||
public get members(): ReadonlyArray<ApiItem> {
|
||||
>members : readonly ApiItem[]
|
||||
|
||||
return [];
|
||||
>[] : never[]
|
||||
}
|
||||
}
|
||||
|
||||
// Normal subclass
|
||||
class ApiEnumMember extends ApiItem {
|
||||
>ApiEnumMember : ApiEnumMember
|
||||
>ApiItem : ApiItem
|
||||
}
|
||||
|
||||
// Mixin base class
|
||||
interface ApiItemContainerMixin extends ApiItem {
|
||||
readonly members: ReadonlyArray<ApiItem>;
|
||||
>members : readonly ApiItem[]
|
||||
}
|
||||
|
||||
function ApiItemContainerMixin<TBaseClass extends IApiItemConstructor>(
|
||||
>ApiItemContainerMixin : <TBaseClass extends IApiItemConstructor>(baseClass: TBaseClass) => TBaseClass & (new (...args: any[]) => ApiItemContainerMixin)
|
||||
|
||||
baseClass: TBaseClass
|
||||
>baseClass : TBaseClass
|
||||
|
||||
): TBaseClass & (new (...args: any[]) => ApiItemContainerMixin) {
|
||||
>args : any[]
|
||||
|
||||
abstract class MixedClass extends baseClass implements ApiItemContainerMixin {
|
||||
>MixedClass : MixedClass
|
||||
>baseClass : ApiItem
|
||||
|
||||
public constructor(...args: any[]) {
|
||||
>args : any[]
|
||||
|
||||
super(...args);
|
||||
>super(...args) : void
|
||||
>super : TBaseClass
|
||||
>...args : any
|
||||
>args : any[]
|
||||
}
|
||||
|
||||
public get members(): ReadonlyArray<ApiItem> {
|
||||
>members : readonly ApiItem[]
|
||||
|
||||
return [];
|
||||
>[] : never[]
|
||||
}
|
||||
}
|
||||
|
||||
return MixedClass;
|
||||
>MixedClass : ((abstract new (...args: any[]) => MixedClass) & { prototype: ApiItemContainerMixin<any>.MixedClass; }) & TBaseClass
|
||||
}
|
||||
|
||||
// Subclass inheriting from mixin
|
||||
export class ApiEnum extends ApiItemContainerMixin(ApiItem) {
|
||||
>ApiEnum : ApiEnum
|
||||
>ApiItemContainerMixin(ApiItem) : ApiItem & ApiItemContainerMixin
|
||||
>ApiItemContainerMixin : <TBaseClass extends IApiItemConstructor>(baseClass: TBaseClass) => TBaseClass & (new (...args: any[]) => ApiItemContainerMixin)
|
||||
>ApiItem : typeof ApiItem
|
||||
|
||||
// This worked prior to TypeScript 4.0:
|
||||
public get members(): ReadonlyArray<ApiEnumMember> {
|
||||
>members : readonly ApiEnumMember[]
|
||||
|
||||
return [];
|
||||
>[] : never[]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4724,6 +4724,7 @@ declare namespace ts {
|
||||
function isImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration;
|
||||
function isImportDeclaration(node: Node): node is ImportDeclaration;
|
||||
function isImportClause(node: Node): node is ImportClause;
|
||||
function isImportTypeAssertionContainer(node: Node): node is ImportTypeAssertionContainer;
|
||||
function isAssertClause(node: Node): node is AssertClause;
|
||||
function isAssertEntry(node: Node): node is AssertEntry;
|
||||
function isNamespaceImport(node: Node): node is NamespaceImport;
|
||||
@@ -5102,6 +5103,31 @@ declare namespace ts {
|
||||
export function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string;
|
||||
export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string;
|
||||
export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string;
|
||||
/**
|
||||
* Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
|
||||
* provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
|
||||
*/
|
||||
export function getModeForFileReference(ref: FileReference | string, containingFileMode: SourceFile["impliedNodeFormat"]): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
|
||||
/**
|
||||
* Calculates the final resolution mode for an import at some index within a file's imports list. This is generally the explicitly
|
||||
* defined mode of the import if provided, or, if not, the mode of the containing file (with some exceptions: import=require is always commonjs, dynamic import is always esm).
|
||||
* If you have an actual import node, prefer using getModeForUsageLocation on the reference string node.
|
||||
* @param file File to fetch the resolution mode within
|
||||
* @param index Index into the file's complete resolution list to get the resolution of - this is a concatenation of the file's imports and module augmentations
|
||||
*/
|
||||
export function getModeForResolutionAtIndex(file: SourceFile, index: number): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
|
||||
/**
|
||||
* Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
|
||||
* one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
|
||||
* Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
|
||||
* `moduleResolution` is `node16`+.
|
||||
* @param file The file the import or import-like reference is contained within
|
||||
* @param usage The module reference string
|
||||
* @returns The final resolution mode of the import
|
||||
*/
|
||||
export function getModeForUsageLocation(file: {
|
||||
impliedNodeFormat?: SourceFile["impliedNodeFormat"];
|
||||
}, usage: StringLiteralLike): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
|
||||
export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[];
|
||||
/**
|
||||
* A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the
|
||||
|
||||
+26
@@ -4724,6 +4724,7 @@ declare namespace ts {
|
||||
function isImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration;
|
||||
function isImportDeclaration(node: Node): node is ImportDeclaration;
|
||||
function isImportClause(node: Node): node is ImportClause;
|
||||
function isImportTypeAssertionContainer(node: Node): node is ImportTypeAssertionContainer;
|
||||
function isAssertClause(node: Node): node is AssertClause;
|
||||
function isAssertEntry(node: Node): node is AssertEntry;
|
||||
function isNamespaceImport(node: Node): node is NamespaceImport;
|
||||
@@ -5102,6 +5103,31 @@ declare namespace ts {
|
||||
export function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string;
|
||||
export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string;
|
||||
export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string;
|
||||
/**
|
||||
* Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
|
||||
* provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
|
||||
*/
|
||||
export function getModeForFileReference(ref: FileReference | string, containingFileMode: SourceFile["impliedNodeFormat"]): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
|
||||
/**
|
||||
* Calculates the final resolution mode for an import at some index within a file's imports list. This is generally the explicitly
|
||||
* defined mode of the import if provided, or, if not, the mode of the containing file (with some exceptions: import=require is always commonjs, dynamic import is always esm).
|
||||
* If you have an actual import node, prefer using getModeForUsageLocation on the reference string node.
|
||||
* @param file File to fetch the resolution mode within
|
||||
* @param index Index into the file's complete resolution list to get the resolution of - this is a concatenation of the file's imports and module augmentations
|
||||
*/
|
||||
export function getModeForResolutionAtIndex(file: SourceFile, index: number): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
|
||||
/**
|
||||
* Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
|
||||
* one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
|
||||
* Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
|
||||
* `moduleResolution` is `node16`+.
|
||||
* @param file The file the import or import-like reference is contained within
|
||||
* @param usage The module reference string
|
||||
* @returns The final resolution mode of the import
|
||||
*/
|
||||
export function getModeForUsageLocation(file: {
|
||||
impliedNodeFormat?: SourceFile["impliedNodeFormat"];
|
||||
}, usage: StringLiteralLike): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
|
||||
export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[];
|
||||
/**
|
||||
* A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
tests/cases/compiler/b.ts(2,14): error TS4118: The type of this node cannot be serialized because its property '[timestampSymbol]' cannot be serialized.
|
||||
tests/cases/compiler/c.ts(3,14): error TS4118: The type of this node cannot be serialized because its property '[timestampSymbol]' cannot be serialized.
|
||||
|
||||
|
||||
==== tests/cases/compiler/a.d.ts (0 errors) ====
|
||||
export declare const timestampSymbol: unique symbol;
|
||||
|
||||
export declare const Timestamp: {
|
||||
[TKey in typeof timestampSymbol]: true;
|
||||
};
|
||||
|
||||
export declare function now(): typeof Timestamp;
|
||||
|
||||
==== tests/cases/compiler/b.ts (1 errors) ====
|
||||
import * as x from "./a";
|
||||
export const timestamp = x.now();
|
||||
~~~~~~~~~
|
||||
!!! error TS4118: The type of this node cannot be serialized because its property '[timestampSymbol]' cannot be serialized.
|
||||
|
||||
==== tests/cases/compiler/c.ts (1 errors) ====
|
||||
import { now } from "./a";
|
||||
|
||||
export const timestamp = now();
|
||||
~~~~~~~~~
|
||||
!!! error TS4118: The type of this node cannot be serialized because its property '[timestampSymbol]' cannot be serialized.
|
||||
@@ -0,0 +1,32 @@
|
||||
//// [tests/cases/compiler/declarationEmitMappedTypeTemplateTypeofSymbol.ts] ////
|
||||
|
||||
//// [a.d.ts]
|
||||
export declare const timestampSymbol: unique symbol;
|
||||
|
||||
export declare const Timestamp: {
|
||||
[TKey in typeof timestampSymbol]: true;
|
||||
};
|
||||
|
||||
export declare function now(): typeof Timestamp;
|
||||
|
||||
//// [b.ts]
|
||||
import * as x from "./a";
|
||||
export const timestamp = x.now();
|
||||
|
||||
//// [c.ts]
|
||||
import { now } from "./a";
|
||||
|
||||
export const timestamp = now();
|
||||
|
||||
//// [b.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.timestamp = void 0;
|
||||
var x = require("./a");
|
||||
exports.timestamp = x.now();
|
||||
//// [c.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.timestamp = void 0;
|
||||
var a_1 = require("./a");
|
||||
exports.timestamp = (0, a_1.now)();
|
||||
@@ -0,0 +1,35 @@
|
||||
=== tests/cases/compiler/a.d.ts ===
|
||||
export declare const timestampSymbol: unique symbol;
|
||||
>timestampSymbol : Symbol(timestampSymbol, Decl(a.d.ts, 0, 20))
|
||||
|
||||
export declare const Timestamp: {
|
||||
>Timestamp : Symbol(Timestamp, Decl(a.d.ts, 2, 20))
|
||||
|
||||
[TKey in typeof timestampSymbol]: true;
|
||||
>TKey : Symbol(TKey, Decl(a.d.ts, 3, 5))
|
||||
>timestampSymbol : Symbol(timestampSymbol, Decl(a.d.ts, 0, 20))
|
||||
|
||||
};
|
||||
|
||||
export declare function now(): typeof Timestamp;
|
||||
>now : Symbol(now, Decl(a.d.ts, 4, 2))
|
||||
>Timestamp : Symbol(Timestamp, Decl(a.d.ts, 2, 20))
|
||||
|
||||
=== tests/cases/compiler/b.ts ===
|
||||
import * as x from "./a";
|
||||
>x : Symbol(x, Decl(b.ts, 0, 6))
|
||||
|
||||
export const timestamp = x.now();
|
||||
>timestamp : Symbol(timestamp, Decl(b.ts, 1, 12))
|
||||
>x.now : Symbol(x.now, Decl(a.d.ts, 4, 2))
|
||||
>x : Symbol(x, Decl(b.ts, 0, 6))
|
||||
>now : Symbol(x.now, Decl(a.d.ts, 4, 2))
|
||||
|
||||
=== tests/cases/compiler/c.ts ===
|
||||
import { now } from "./a";
|
||||
>now : Symbol(now, Decl(c.ts, 0, 8))
|
||||
|
||||
export const timestamp = now();
|
||||
>timestamp : Symbol(timestamp, Decl(c.ts, 2, 12))
|
||||
>now : Symbol(now, Decl(c.ts, 0, 8))
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
=== tests/cases/compiler/a.d.ts ===
|
||||
export declare const timestampSymbol: unique symbol;
|
||||
>timestampSymbol : unique symbol
|
||||
|
||||
export declare const Timestamp: {
|
||||
>Timestamp : { [timestampSymbol]: true; }
|
||||
|
||||
[TKey in typeof timestampSymbol]: true;
|
||||
>timestampSymbol : unique symbol
|
||||
>true : true
|
||||
|
||||
};
|
||||
|
||||
export declare function now(): typeof Timestamp;
|
||||
>now : () => typeof Timestamp
|
||||
>Timestamp : { [timestampSymbol]: true; }
|
||||
|
||||
=== tests/cases/compiler/b.ts ===
|
||||
import * as x from "./a";
|
||||
>x : typeof x
|
||||
|
||||
export const timestamp = x.now();
|
||||
>timestamp : { [x.timestampSymbol]: true; }
|
||||
>x.now() : { [x.timestampSymbol]: true; }
|
||||
>x.now : () => { [x.timestampSymbol]: true; }
|
||||
>x : typeof x
|
||||
>now : () => { [x.timestampSymbol]: true; }
|
||||
|
||||
=== tests/cases/compiler/c.ts ===
|
||||
import { now } from "./a";
|
||||
>now : () => { [timestampSymbol]: true; }
|
||||
|
||||
export const timestamp = now();
|
||||
>timestamp : { [timestampSymbol]: true; }
|
||||
>now() : { [timestampSymbol]: true; }
|
||||
>now : () => { [timestampSymbol]: true; }
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
tests/cases/compiler/destructuringAssignmentWithDefault2.ts(11,4): error TS2322: Type 'undefined' is not assignable to type 'number'.
|
||||
tests/cases/compiler/destructuringAssignmentWithDefault2.ts(11,4): error TS2322: Type 'number | undefined' is not assignable to type 'number'.
|
||||
Type 'undefined' is not assignable to type 'number'.
|
||||
tests/cases/compiler/destructuringAssignmentWithDefault2.ts(12,7): error TS2322: Type 'undefined' is not assignable to type 'number'.
|
||||
tests/cases/compiler/destructuringAssignmentWithDefault2.ts(13,7): error TS2322: Type 'undefined' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/destructuringAssignmentWithDefault2.ts (4 errors) ====
|
||||
const a: { x?: number; y?: number } = { };
|
||||
|
||||
let x: number;
|
||||
|
||||
// Should not error out
|
||||
({ x = 0 } = a);
|
||||
({ x: x = 0} = a);
|
||||
({ y: x = 0} = a);
|
||||
|
||||
// Should be error
|
||||
({ x = undefined } = a);
|
||||
~
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'number'.
|
||||
~
|
||||
!!! error TS2322: Type 'number | undefined' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'number'.
|
||||
({ x: x = undefined } = a);
|
||||
~
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'number'.
|
||||
({ y: x = undefined } = a);
|
||||
~
|
||||
!!! error TS2322: Type 'undefined' is not assignable to type 'number'.
|
||||
|
||||
const { x: z1 } = a;
|
||||
const { x: z2 = 0 } = a;
|
||||
const { x: z3 = undefined } = a;
|
||||
|
||||
|
||||
declare const r: Iterator<number>;
|
||||
let done: boolean;
|
||||
let value;
|
||||
|
||||
({ done = false, value } = r.next());
|
||||
({ done: done = false, value } = r.next());
|
||||
@@ -0,0 +1,46 @@
|
||||
//// [destructuringAssignmentWithDefault2.ts]
|
||||
const a: { x?: number; y?: number } = { };
|
||||
|
||||
let x: number;
|
||||
|
||||
// Should not error out
|
||||
({ x = 0 } = a);
|
||||
({ x: x = 0} = a);
|
||||
({ y: x = 0} = a);
|
||||
|
||||
// Should be error
|
||||
({ x = undefined } = a);
|
||||
({ x: x = undefined } = a);
|
||||
({ y: x = undefined } = a);
|
||||
|
||||
const { x: z1 } = a;
|
||||
const { x: z2 = 0 } = a;
|
||||
const { x: z3 = undefined } = a;
|
||||
|
||||
|
||||
declare const r: Iterator<number>;
|
||||
let done: boolean;
|
||||
let value;
|
||||
|
||||
({ done = false, value } = r.next());
|
||||
({ done: done = false, value } = r.next());
|
||||
|
||||
//// [destructuringAssignmentWithDefault2.js]
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
||||
var a = {};
|
||||
var x;
|
||||
// Should not error out
|
||||
(_a = a.x, x = _a === void 0 ? 0 : _a);
|
||||
(_b = a.x, x = _b === void 0 ? 0 : _b);
|
||||
(_c = a.y, x = _c === void 0 ? 0 : _c);
|
||||
// Should be error
|
||||
(_d = a.x, x = _d === void 0 ? undefined : _d);
|
||||
(_e = a.x, x = _e === void 0 ? undefined : _e);
|
||||
(_f = a.y, x = _f === void 0 ? undefined : _f);
|
||||
var z1 = a.x;
|
||||
var _l = a.x, z2 = _l === void 0 ? 0 : _l;
|
||||
var _m = a.x, z3 = _m === void 0 ? undefined : _m;
|
||||
var done;
|
||||
var value;
|
||||
(_g = r.next(), _h = _g.done, done = _h === void 0 ? false : _h, value = _g.value);
|
||||
(_j = r.next(), _k = _j.done, done = _k === void 0 ? false : _k, value = _j.value);
|
||||
@@ -0,0 +1,84 @@
|
||||
=== tests/cases/compiler/destructuringAssignmentWithDefault2.ts ===
|
||||
const a: { x?: number; y?: number } = { };
|
||||
>a : Symbol(a, Decl(destructuringAssignmentWithDefault2.ts, 0, 5))
|
||||
>x : Symbol(x, Decl(destructuringAssignmentWithDefault2.ts, 0, 10))
|
||||
>y : Symbol(y, Decl(destructuringAssignmentWithDefault2.ts, 0, 22))
|
||||
|
||||
let x: number;
|
||||
>x : Symbol(x, Decl(destructuringAssignmentWithDefault2.ts, 2, 3))
|
||||
|
||||
// Should not error out
|
||||
({ x = 0 } = a);
|
||||
>x : Symbol(x, Decl(destructuringAssignmentWithDefault2.ts, 5, 2))
|
||||
>a : Symbol(a, Decl(destructuringAssignmentWithDefault2.ts, 0, 5))
|
||||
|
||||
({ x: x = 0} = a);
|
||||
>x : Symbol(x, Decl(destructuringAssignmentWithDefault2.ts, 6, 2))
|
||||
>x : Symbol(x, Decl(destructuringAssignmentWithDefault2.ts, 2, 3))
|
||||
>a : Symbol(a, Decl(destructuringAssignmentWithDefault2.ts, 0, 5))
|
||||
|
||||
({ y: x = 0} = a);
|
||||
>y : Symbol(y, Decl(destructuringAssignmentWithDefault2.ts, 7, 2))
|
||||
>x : Symbol(x, Decl(destructuringAssignmentWithDefault2.ts, 2, 3))
|
||||
>a : Symbol(a, Decl(destructuringAssignmentWithDefault2.ts, 0, 5))
|
||||
|
||||
// Should be error
|
||||
({ x = undefined } = a);
|
||||
>x : Symbol(x, Decl(destructuringAssignmentWithDefault2.ts, 10, 2))
|
||||
>undefined : Symbol(undefined)
|
||||
>a : Symbol(a, Decl(destructuringAssignmentWithDefault2.ts, 0, 5))
|
||||
|
||||
({ x: x = undefined } = a);
|
||||
>x : Symbol(x, Decl(destructuringAssignmentWithDefault2.ts, 11, 2))
|
||||
>x : Symbol(x, Decl(destructuringAssignmentWithDefault2.ts, 2, 3))
|
||||
>undefined : Symbol(undefined)
|
||||
>a : Symbol(a, Decl(destructuringAssignmentWithDefault2.ts, 0, 5))
|
||||
|
||||
({ y: x = undefined } = a);
|
||||
>y : Symbol(y, Decl(destructuringAssignmentWithDefault2.ts, 12, 2))
|
||||
>x : Symbol(x, Decl(destructuringAssignmentWithDefault2.ts, 2, 3))
|
||||
>undefined : Symbol(undefined)
|
||||
>a : Symbol(a, Decl(destructuringAssignmentWithDefault2.ts, 0, 5))
|
||||
|
||||
const { x: z1 } = a;
|
||||
>x : Symbol(x, Decl(destructuringAssignmentWithDefault2.ts, 0, 10))
|
||||
>z1 : Symbol(z1, Decl(destructuringAssignmentWithDefault2.ts, 14, 7))
|
||||
>a : Symbol(a, Decl(destructuringAssignmentWithDefault2.ts, 0, 5))
|
||||
|
||||
const { x: z2 = 0 } = a;
|
||||
>x : Symbol(x, Decl(destructuringAssignmentWithDefault2.ts, 0, 10))
|
||||
>z2 : Symbol(z2, Decl(destructuringAssignmentWithDefault2.ts, 15, 7))
|
||||
>a : Symbol(a, Decl(destructuringAssignmentWithDefault2.ts, 0, 5))
|
||||
|
||||
const { x: z3 = undefined } = a;
|
||||
>x : Symbol(x, Decl(destructuringAssignmentWithDefault2.ts, 0, 10))
|
||||
>z3 : Symbol(z3, Decl(destructuringAssignmentWithDefault2.ts, 16, 7))
|
||||
>undefined : Symbol(undefined)
|
||||
>a : Symbol(a, Decl(destructuringAssignmentWithDefault2.ts, 0, 5))
|
||||
|
||||
|
||||
declare const r: Iterator<number>;
|
||||
>r : Symbol(r, Decl(destructuringAssignmentWithDefault2.ts, 19, 13))
|
||||
>Iterator : Symbol(Iterator, Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
|
||||
let done: boolean;
|
||||
>done : Symbol(done, Decl(destructuringAssignmentWithDefault2.ts, 20, 3))
|
||||
|
||||
let value;
|
||||
>value : Symbol(value, Decl(destructuringAssignmentWithDefault2.ts, 21, 3))
|
||||
|
||||
({ done = false, value } = r.next());
|
||||
>done : Symbol(done, Decl(destructuringAssignmentWithDefault2.ts, 23, 2))
|
||||
>value : Symbol(value, Decl(destructuringAssignmentWithDefault2.ts, 23, 16))
|
||||
>r.next : Symbol(Iterator.next, Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>r : Symbol(r, Decl(destructuringAssignmentWithDefault2.ts, 19, 13))
|
||||
>next : Symbol(Iterator.next, Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
|
||||
({ done: done = false, value } = r.next());
|
||||
>done : Symbol(done, Decl(destructuringAssignmentWithDefault2.ts, 24, 2))
|
||||
>done : Symbol(done, Decl(destructuringAssignmentWithDefault2.ts, 20, 3))
|
||||
>value : Symbol(value, Decl(destructuringAssignmentWithDefault2.ts, 24, 22))
|
||||
>r.next : Symbol(Iterator.next, Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>r : Symbol(r, Decl(destructuringAssignmentWithDefault2.ts, 19, 13))
|
||||
>next : Symbol(Iterator.next, Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
=== tests/cases/compiler/destructuringAssignmentWithDefault2.ts ===
|
||||
const a: { x?: number; y?: number } = { };
|
||||
>a : { x?: number | undefined; y?: number | undefined; }
|
||||
>x : number | undefined
|
||||
>y : number | undefined
|
||||
>{ } : {}
|
||||
|
||||
let x: number;
|
||||
>x : number
|
||||
|
||||
// Should not error out
|
||||
({ x = 0 } = a);
|
||||
>({ x = 0 } = a) : { x?: number | undefined; y?: number | undefined; }
|
||||
>{ x = 0 } = a : { x?: number | undefined; y?: number | undefined; }
|
||||
>{ x = 0 } : { x?: number; }
|
||||
>x : number
|
||||
>0 : 0
|
||||
>a : { x?: number | undefined; y?: number | undefined; }
|
||||
|
||||
({ x: x = 0} = a);
|
||||
>({ x: x = 0} = a) : { x?: number | undefined; y?: number | undefined; }
|
||||
>{ x: x = 0} = a : { x?: number | undefined; y?: number | undefined; }
|
||||
>{ x: x = 0} : { x?: number; }
|
||||
>x : number
|
||||
>x = 0 : 0
|
||||
>x : number
|
||||
>0 : 0
|
||||
>a : { x?: number | undefined; y?: number | undefined; }
|
||||
|
||||
({ y: x = 0} = a);
|
||||
>({ y: x = 0} = a) : { x?: number | undefined; y?: number | undefined; }
|
||||
>{ y: x = 0} = a : { x?: number | undefined; y?: number | undefined; }
|
||||
>{ y: x = 0} : { y?: number; }
|
||||
>y : number
|
||||
>x = 0 : 0
|
||||
>x : number
|
||||
>0 : 0
|
||||
>a : { x?: number | undefined; y?: number | undefined; }
|
||||
|
||||
// Should be error
|
||||
({ x = undefined } = a);
|
||||
>({ x = undefined } = a) : { x?: number | undefined; y?: number | undefined; }
|
||||
>{ x = undefined } = a : { x?: number | undefined; y?: number | undefined; }
|
||||
>{ x = undefined } : { x?: number; }
|
||||
>x : number
|
||||
>undefined : undefined
|
||||
>a : { x?: number | undefined; y?: number | undefined; }
|
||||
|
||||
({ x: x = undefined } = a);
|
||||
>({ x: x = undefined } = a) : { x?: number | undefined; y?: number | undefined; }
|
||||
>{ x: x = undefined } = a : { x?: number | undefined; y?: number | undefined; }
|
||||
>{ x: x = undefined } : { x?: undefined; }
|
||||
>x : undefined
|
||||
>x = undefined : undefined
|
||||
>x : number
|
||||
>undefined : undefined
|
||||
>a : { x?: number | undefined; y?: number | undefined; }
|
||||
|
||||
({ y: x = undefined } = a);
|
||||
>({ y: x = undefined } = a) : { x?: number | undefined; y?: number | undefined; }
|
||||
>{ y: x = undefined } = a : { x?: number | undefined; y?: number | undefined; }
|
||||
>{ y: x = undefined } : { y?: undefined; }
|
||||
>y : undefined
|
||||
>x = undefined : undefined
|
||||
>x : number
|
||||
>undefined : undefined
|
||||
>a : { x?: number | undefined; y?: number | undefined; }
|
||||
|
||||
const { x: z1 } = a;
|
||||
>x : any
|
||||
>z1 : number | undefined
|
||||
>a : { x?: number | undefined; y?: number | undefined; }
|
||||
|
||||
const { x: z2 = 0 } = a;
|
||||
>x : any
|
||||
>z2 : number
|
||||
>0 : 0
|
||||
>a : { x?: number | undefined; y?: number | undefined; }
|
||||
|
||||
const { x: z3 = undefined } = a;
|
||||
>x : any
|
||||
>z3 : number | undefined
|
||||
>undefined : undefined
|
||||
>a : { x?: number | undefined; y?: number | undefined; }
|
||||
|
||||
|
||||
declare const r: Iterator<number>;
|
||||
>r : Iterator<number, any, undefined>
|
||||
|
||||
let done: boolean;
|
||||
>done : boolean
|
||||
|
||||
let value;
|
||||
>value : any
|
||||
|
||||
({ done = false, value } = r.next());
|
||||
>({ done = false, value } = r.next()) : IteratorResult<number, any>
|
||||
>{ done = false, value } = r.next() : IteratorResult<number, any>
|
||||
>{ done = false, value } : { done?: boolean; value: any; }
|
||||
>done : boolean
|
||||
>false : false
|
||||
>value : any
|
||||
>r.next() : IteratorResult<number, any>
|
||||
>r.next : (...args: [] | [undefined]) => IteratorResult<number, any>
|
||||
>r : Iterator<number, any, undefined>
|
||||
>next : (...args: [] | [undefined]) => IteratorResult<number, any>
|
||||
|
||||
({ done: done = false, value } = r.next());
|
||||
>({ done: done = false, value } = r.next()) : IteratorResult<number, any>
|
||||
>{ done: done = false, value } = r.next() : IteratorResult<number, any>
|
||||
>{ done: done = false, value } : { done?: boolean; value: any; }
|
||||
>done : boolean
|
||||
>done = false : false
|
||||
>done : boolean
|
||||
>false : false
|
||||
>value : any
|
||||
>r.next() : IteratorResult<number, any>
|
||||
>r.next : (...args: [] | [undefined]) => IteratorResult<number, any>
|
||||
>r : Iterator<number, any, undefined>
|
||||
>next : (...args: [] | [undefined]) => IteratorResult<number, any>
|
||||
|
||||
@@ -14,8 +14,8 @@ function Menu<MenuItemVariant extends ListItemVariant = ListItemVariant.OneLine>
|
||||
>data : IData<MenuItemVariant>
|
||||
|
||||
const listItemVariant = data.menuItemsVariant ?? ListItemVariant.OneLine;
|
||||
>listItemVariant : ListItemVariant.OneLine | NonNullable<MenuItemVariant>
|
||||
>data.menuItemsVariant ?? ListItemVariant.OneLine : ListItemVariant.OneLine | NonNullable<MenuItemVariant>
|
||||
>listItemVariant : ListItemVariant.OneLine | MenuItemVariant
|
||||
>data.menuItemsVariant ?? ListItemVariant.OneLine : ListItemVariant.OneLine | MenuItemVariant
|
||||
>data.menuItemsVariant : MenuItemVariant | undefined
|
||||
>data : IData<MenuItemVariant>
|
||||
>menuItemsVariant : MenuItemVariant | undefined
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/errorLocationForInterfaceExtension.ts(3,21): error TS2693: 'string' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/errorLocationForInterfaceExtension.ts(3,21): error TS2840: An interface cannot extend a primitive type like 'string'; an interface can only extend named types and classes
|
||||
|
||||
|
||||
==== tests/cases/compiler/errorLocationForInterfaceExtension.ts (1 errors) ====
|
||||
@@ -6,5 +6,5 @@ tests/cases/compiler/errorLocationForInterfaceExtension.ts(3,21): error TS2693:
|
||||
|
||||
interface x extends string { }
|
||||
~~~~~~
|
||||
!!! error TS2693: 'string' only refers to a type, but is being used as a value here.
|
||||
!!! error TS2840: An interface cannot extend a primitive type like 'string'; an interface can only extend named types and classes
|
||||
|
||||
@@ -7,6 +7,7 @@ function f<X, Y>(x: X, y: Y) {
|
||||
|
||||
f<number,string>.
|
||||
>f<number,string>. : any
|
||||
>f<number,string> : (x: number, y: string) => void
|
||||
>f : <X, Y>(x: X, y: Y) => void
|
||||
> : any
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
=== tests/cases/conformance/types/import/importWithTypeArguments.ts ===
|
||||
import<T>
|
||||
>import<T> : any
|
||||
|
||||
const a = import<string, number>
|
||||
>a : any
|
||||
>import<string, number> : any
|
||||
|
||||
|
||||
@@ -7,10 +7,12 @@ declare let f: { <T>(): T, g<U>(): U };
|
||||
|
||||
const a1 = f<number>; // { (): number; g<U>(): U; }
|
||||
>a1 : { (): number; g<U>(): U; }
|
||||
>f<number> : { (): number; g<U>(): U; }
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
|
||||
const a2 = f.g<number>; // () => number
|
||||
>a2 : () => number
|
||||
>f.g<number> : () => number
|
||||
>f.g : <U>() => U
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
>g : <U>() => U
|
||||
@@ -18,17 +20,21 @@ const a2 = f.g<number>; // () => number
|
||||
const a3 = f<number>.g; // <U>() => U
|
||||
>a3 : <U>() => U
|
||||
>f<number>.g : <U>() => U
|
||||
>f<number> : { (): number; g<U>(): U; }
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
>g : <U>() => U
|
||||
|
||||
const a4 = f<number>.g<number>; // () => number
|
||||
>a4 : () => number
|
||||
>f<number>.g<number> : () => number
|
||||
>f<number>.g : <U>() => U
|
||||
>f<number> : { (): number; g<U>(): U; }
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
>g : <U>() => U
|
||||
|
||||
const a5 = f['g']<number>; // () => number
|
||||
>a5 : () => number
|
||||
>f['g']<number> : () => number
|
||||
>f['g'] : <U>() => U
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
>'g' : "g"
|
||||
@@ -48,6 +54,7 @@ const a7 = (f<number>)['g'];
|
||||
>a7 : <U>() => U
|
||||
>(f<number>)['g'] : <U>() => U
|
||||
>(f<number>) : { (): number; g<U>(): U; }
|
||||
>f<number> : { (): number; g<U>(): U; }
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
>'g' : "g"
|
||||
|
||||
@@ -64,7 +71,9 @@ const a8 = f<number><number>; // Relational operator error
|
||||
|
||||
const a9 = (f<number>)<number>; // Error, no applicable signatures
|
||||
>a9 : { g<U>(): U; }
|
||||
>(f<number>)<number> : { g<U>(): U; }
|
||||
>(f<number>) : { (): number; g<U>(): U; }
|
||||
>f<number> : { (): number; g<U>(): U; }
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
|
||||
// Type arguments with `?.` token
|
||||
@@ -82,11 +91,13 @@ const b2 = f?.<number>();
|
||||
const b3 = f<number>?.();
|
||||
>b3 : number
|
||||
>f<number>?.() : number
|
||||
>f<number> : { (): number; g<U>(): U; }
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
|
||||
const b4 = f<number>?.<number>(); // Error, expected no type arguments
|
||||
>b4 : number
|
||||
>f<number>?.<number>() : number
|
||||
>f<number> : { (): number; g<U>(): U; }
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
|
||||
// Parsed as function call, even though this differs from JavaScript
|
||||
@@ -116,6 +127,7 @@ true;
|
||||
|
||||
const x3 = f<true>;
|
||||
>x3 : { (): true; g<U>(): U; }
|
||||
>f<true> : { (): true; g<U>(): U; }
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
>true : true
|
||||
|
||||
@@ -126,6 +138,7 @@ true;
|
||||
|
||||
const x4 = f<true>
|
||||
>x4 : { (): true; g<U>(): U; }
|
||||
>f<true> : { (): true; g<U>(): U; }
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
>true : true
|
||||
|
||||
|
||||
@@ -17,18 +17,22 @@ function f1() {
|
||||
|
||||
let f0 = fx<>; // Error
|
||||
>f0 : { <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }
|
||||
>fx<> : { <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }
|
||||
>fx : { <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }
|
||||
|
||||
let f1 = fx<string>; // { (x: string): string; (x: string, n: number): string; }
|
||||
>f1 : { (x: string): string; (x: string, n: number): string; }
|
||||
>fx<string> : { (x: string): string; (x: string, n: number): string; }
|
||||
>fx : { <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }
|
||||
|
||||
let f2 = fx<string, number>; // (t: [string, number]) => [string, number]
|
||||
>f2 : (t: [string, number]) => [string, number]
|
||||
>fx<string, number> : (t: [string, number]) => [string, number]
|
||||
>fx : { <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }
|
||||
|
||||
let f3 = fx<string, number, boolean>; // Error
|
||||
>f3 : {}
|
||||
>fx<string, number, boolean> : {}
|
||||
>fx : { <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }
|
||||
}
|
||||
|
||||
@@ -53,14 +57,17 @@ function f2() {
|
||||
|
||||
const A0 = Array<>; // Error
|
||||
>A0 : ArrayConstructor
|
||||
>Array<> : ArrayConstructor
|
||||
>Array : ArrayConstructor
|
||||
|
||||
const A1 = Array<string>; // new (...) => string[]
|
||||
>A1 : { (arrayLength: number): string[]; (...items: string[]): string[]; new (arrayLength: number): string[]; new (...items: string[]): string[]; isArray(arg: any): arg is any[]; readonly prototype: any[]; }
|
||||
>Array<string> : { (arrayLength: number): string[]; (...items: string[]): string[]; new (arrayLength: number): string[]; new (...items: string[]): string[]; isArray(arg: any): arg is any[]; readonly prototype: any[]; }
|
||||
>Array : ArrayConstructor
|
||||
|
||||
const A2 = Array<string, number>; // Error
|
||||
>A2 : { isArray(arg: any): arg is any[]; readonly prototype: any[]; }
|
||||
>Array<string, number> : { isArray(arg: any): arg is any[]; readonly prototype: any[]; }
|
||||
>Array : ArrayConstructor
|
||||
}
|
||||
|
||||
@@ -92,10 +99,12 @@ function f3() {
|
||||
|
||||
let c1 = C<string>; // { new (x: string): C<string>; f<U>(x: U): T[]; prototype: C<any>; }
|
||||
>c1 : { new (x: string): C<string>; prototype: C<any>; f<U>(x: U): U[]; }
|
||||
>C<string> : { new (x: string): C<string>; prototype: C<any>; f<U>(x: U): U[]; }
|
||||
>C : typeof C
|
||||
|
||||
let f1 = C.f<string>; // (x: string) => string[]
|
||||
>f1 : (x: string) => string[]
|
||||
>C.f<string> : (x: string) => string[]
|
||||
>C.f : <U>(x: U) => U[]
|
||||
>C : typeof C
|
||||
>f : <U>(x: U) => U[]
|
||||
@@ -110,6 +119,7 @@ function f10(f: { <T>(a: T): T, <U>(a: U, b: number): U[] }) {
|
||||
|
||||
let fs = f<string>; // { (a: string): string; (a: string, b: number): string[]; }
|
||||
>fs : { (a: string): string; (a: string, b: number): string[]; }
|
||||
>f<string> : { (a: string): string; (a: string, b: number): string[]; }
|
||||
>f : { <T>(a: T): T; <U>(a: U, b: number): U[]; }
|
||||
}
|
||||
|
||||
@@ -122,6 +132,7 @@ function f11(f: { <T>(a: T): T, (a: string, b: number): string[] }) {
|
||||
|
||||
let fs = f<string>; // (a: string) => string
|
||||
>fs : (a: string) => string
|
||||
>f<string> : (a: string) => string
|
||||
>f : { <T>(a: T): T; (a: string, b: number): string[]; }
|
||||
}
|
||||
|
||||
@@ -133,6 +144,7 @@ function f12(f: { <T>(a: T): T, x: string }) {
|
||||
|
||||
let fs = f<string>; // { (a: string): string; x: string; }
|
||||
>fs : { (a: string): string; x: string; }
|
||||
>f<string> : { (a: string): string; x: string; }
|
||||
>f : { <T>(a: T): T; x: string; }
|
||||
}
|
||||
|
||||
@@ -144,6 +156,7 @@ function f13(f: { x: string, y: string }) {
|
||||
|
||||
let fs = f<string>; // Error, no applicable signatures
|
||||
>fs : { x: string; y: string; }
|
||||
>f<string> : { x: string; y: string; }
|
||||
>f : { x: string; y: string; }
|
||||
}
|
||||
|
||||
@@ -156,6 +169,7 @@ function f14(f: { new <T>(a: T): T, new <U>(a: U, b: number): U[] }) {
|
||||
|
||||
let fs = f<string>; // { new (a: string): string; new (a: string, b: number): string[]; }
|
||||
>fs : { new (a: string): string; new (a: string, b: number): string[]; }
|
||||
>f<string> : { new (a: string): string; new (a: string, b: number): string[]; }
|
||||
>f : { new <T>(a: T): T; new <U>(a: U, b: number): U[]; }
|
||||
}
|
||||
|
||||
@@ -168,6 +182,7 @@ function f15(f: { new <T>(a: T): T, <U>(a: U, b: number): U[] }) {
|
||||
|
||||
let fs = f<string>; // { new (a: string): string; (a: string, b: number): string[]; }
|
||||
>fs : { (a: string, b: number): string[]; new (a: string): string; }
|
||||
>f<string> : { (a: string, b: number): string[]; new (a: string): string; }
|
||||
>f : { <U>(a: U, b: number): U[]; new <T>(a: T): T; }
|
||||
}
|
||||
|
||||
@@ -180,6 +195,7 @@ function f16(f: { new <T>(a: T): T, (a: string, b: number): string[] }) {
|
||||
|
||||
let fs = f<string>; // new (a: string) => string
|
||||
>fs : new (a: string) => string
|
||||
>f<string> : new (a: string) => string
|
||||
>f : { (a: string, b: number): string[]; new <T>(a: T): T; }
|
||||
}
|
||||
|
||||
@@ -192,6 +208,7 @@ function f17(f: { <T>(a: T): T, new (a: string, b: number): string[] }) {
|
||||
|
||||
let fs = f<string>; // (a: string) => string
|
||||
>fs : (a: string) => string
|
||||
>f<string> : (a: string) => string
|
||||
>f : { <T>(a: T): T; new (a: string, b: number): string[]; }
|
||||
}
|
||||
|
||||
@@ -204,6 +221,7 @@ function f20(f: (<T>(a: T) => T) & (<U>(a: U, b: number) => U[])) {
|
||||
|
||||
let fs = f<string>; // ((a: string) => string) & ((a: string, b: number) => string[]])
|
||||
>fs : ((a: string) => string) & ((a: string, b: number) => string[])
|
||||
>f<string> : ((a: string) => string) & ((a: string, b: number) => string[])
|
||||
>f : (<T>(a: T) => T) & (<U>(a: U, b: number) => U[])
|
||||
}
|
||||
|
||||
@@ -216,6 +234,7 @@ function f21(f: (<T>(a: T) => T) & ((a: string, b: number) => string[])) {
|
||||
|
||||
let fs = f<string>; // (a: string) => string
|
||||
>fs : (a: string) => string
|
||||
>f<string> : (a: string) => string
|
||||
>f : (<T>(a: T) => T) & ((a: string, b: number) => string[])
|
||||
}
|
||||
|
||||
@@ -227,6 +246,7 @@ function f22(f: (<T>(a: T) => T) & { x: string }) {
|
||||
|
||||
let fs = f<string>; // ((a: string) => string) & { x: string }
|
||||
>fs : ((a: string) => string) & { x: string; }
|
||||
>f<string> : ((a: string) => string) & { x: string; }
|
||||
>f : (<T>(a: T) => T) & { x: string; }
|
||||
}
|
||||
|
||||
@@ -238,6 +258,7 @@ function f23(f: { x: string } & { y: string }) {
|
||||
|
||||
let fs = f<string>; // Error, no applicable signatures
|
||||
>fs : { x: string; } & { y: string; }
|
||||
>f<string> : { x: string; } & { y: string; }
|
||||
>f : { x: string; } & { y: string; }
|
||||
}
|
||||
|
||||
@@ -250,6 +271,7 @@ function f24(f: (new <T>(a: T) => T) & (new <U>(a: U, b: number) => U[])) {
|
||||
|
||||
let fs = f<string>; // (new (a: string) => string) & ((a: string, b: number) => string[]])
|
||||
>fs : (new (a: string) => string) & (new (a: string, b: number) => string[])
|
||||
>f<string> : (new (a: string) => string) & (new (a: string, b: number) => string[])
|
||||
>f : (new <T>(a: T) => T) & (new <U>(a: U, b: number) => U[])
|
||||
}
|
||||
|
||||
@@ -262,6 +284,7 @@ function f25(f: (new <T>(a: T) => T) & (<U>(a: U, b: number) => U[])) {
|
||||
|
||||
let fs = f<string>; // (new (a: string) => string) & ((a: string, b: number) => string[]])
|
||||
>fs : (new (a: string) => string) & ((a: string, b: number) => string[])
|
||||
>f<string> : (new (a: string) => string) & ((a: string, b: number) => string[])
|
||||
>f : (new <T>(a: T) => T) & (<U>(a: U, b: number) => U[])
|
||||
}
|
||||
|
||||
@@ -274,6 +297,7 @@ function f26(f: (new <T>(a: T) => T) & ((a: string, b: number) => string[])) {
|
||||
|
||||
let fs = f<string>; // new (a: string) => string
|
||||
>fs : new (a: string) => string
|
||||
>f<string> : new (a: string) => string
|
||||
>f : (new <T>(a: T) => T) & ((a: string, b: number) => string[])
|
||||
}
|
||||
|
||||
@@ -286,6 +310,7 @@ function f27(f: (<T>(a: T) => T) & (new (a: string, b: number) => string[])) {
|
||||
|
||||
let fs = f<string>; // (a: string) => string
|
||||
>fs : (a: string) => string
|
||||
>f<string> : (a: string) => string
|
||||
>f : (<T>(a: T) => T) & (new (a: string, b: number) => string[])
|
||||
}
|
||||
|
||||
@@ -298,6 +323,7 @@ function f30(f: (<T>(a: T) => T) | (<U>(a: U, b: number) => U[])) {
|
||||
|
||||
let fs = f<string>; // ((a: string) => string) | ((a: string, b: number) => string[]])
|
||||
>fs : ((a: string) => string) | ((a: string, b: number) => string[])
|
||||
>f<string> : ((a: string) => string) | ((a: string, b: number) => string[])
|
||||
>f : (<T>(a: T) => T) | (<U>(a: U, b: number) => U[])
|
||||
}
|
||||
|
||||
@@ -310,6 +336,7 @@ function f31(f: (<T>(a: T) => T) | ((a: string, b: number) => string[])) {
|
||||
|
||||
let fs = f<string>; // Error, '(a: string, b: number) => string[]' has no applicable signatures
|
||||
>fs : ((a: string) => string) | {}
|
||||
>f<string> : ((a: string) => string) | {}
|
||||
>f : (<T>(a: T) => T) | ((a: string, b: number) => string[])
|
||||
}
|
||||
|
||||
@@ -321,6 +348,7 @@ function f32(f: (<T>(a: T) => T) | { x: string }) {
|
||||
|
||||
let fs = f<string>; // ((a: string) => string) | { x: string }
|
||||
>fs : { x: string; } | ((a: string) => string)
|
||||
>f<string> : { x: string; } | ((a: string) => string)
|
||||
>f : { x: string; } | (<T>(a: T) => T)
|
||||
}
|
||||
|
||||
@@ -332,6 +360,7 @@ function f33(f: { x: string } | { y: string }) {
|
||||
|
||||
let fs = f<string>; // Error, no applicable signatures
|
||||
>fs : { x: string; } | { y: string; }
|
||||
>f<string> : { x: string; } | { y: string; }
|
||||
>f : { x: string; } | { y: string; }
|
||||
}
|
||||
|
||||
@@ -344,6 +373,7 @@ function f34(f: (new <T>(a: T) => T) | (new <U>(a: U, b: number) => U[])) {
|
||||
|
||||
let fs = f<string>; // (new (a: string) => string) | ((a: string, b: number) => string[]])
|
||||
>fs : (new (a: string) => string) | (new (a: string, b: number) => string[])
|
||||
>f<string> : (new (a: string) => string) | (new (a: string, b: number) => string[])
|
||||
>f : (new <T>(a: T) => T) | (new <U>(a: U, b: number) => U[])
|
||||
}
|
||||
|
||||
@@ -356,6 +386,7 @@ function f35(f: (new <T>(a: T) => T) | (<U>(a: U, b: number) => U[])) {
|
||||
|
||||
let fs = f<string>; // (new (a: string) => string) | ((a: string, b: number) => string[]])
|
||||
>fs : (new (a: string) => string) | ((a: string, b: number) => string[])
|
||||
>f<string> : (new (a: string) => string) | ((a: string, b: number) => string[])
|
||||
>f : (new <T>(a: T) => T) | (<U>(a: U, b: number) => U[])
|
||||
}
|
||||
|
||||
@@ -368,6 +399,7 @@ function f36(f: (new <T>(a: T) => T) | ((a: string, b: number) => string[])) {
|
||||
|
||||
let fs = f<string>; // Error, '(a: string, b: number) => string[]' has no applicable signatures
|
||||
>fs : (new (a: string) => string) | {}
|
||||
>f<string> : (new (a: string) => string) | {}
|
||||
>f : (new <T>(a: T) => T) | ((a: string, b: number) => string[])
|
||||
}
|
||||
|
||||
@@ -380,6 +412,7 @@ function f37(f: (<T>(a: T) => T) | (new (a: string, b: number) => string[])) {
|
||||
|
||||
let fs = f<string>; // Error, 'new (a: string, b: number) => string[]' has no applicable signatures
|
||||
>fs : ((a: string) => string) | {}
|
||||
>f<string> : ((a: string) => string) | {}
|
||||
>f : (<T>(a: T) => T) | (new (a: string, b: number) => string[])
|
||||
}
|
||||
|
||||
@@ -392,6 +425,7 @@ function f38<T extends (<A>(x: A) => A) | (<B>(x: B) => B[]), U>(f: T | U | (<C>
|
||||
|
||||
let fs = f<string>; // U | ((x: string) => string) | ((x: string) => string[]) | ((x: string) => string[][])
|
||||
>fs : U | ((x: string) => string) | ((x: string) => string[]) | ((x: string) => string[][])
|
||||
>f<string> : U | ((x: string) => string) | ((x: string) => string[]) | ((x: string) => string[][])
|
||||
>f : T | U | (<C>(x: C) => C[][])
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,11 @@ tests/cases/compiler/interfacedeclWithIndexerErrors.ts(14,5): error TS2411: Prop
|
||||
tests/cases/compiler/interfacedeclWithIndexerErrors.ts(15,5): error TS2411: Property 'p5' of type '(s: number) => string' is not assignable to 'string' index type '() => string'.
|
||||
tests/cases/compiler/interfacedeclWithIndexerErrors.ts(19,5): error TS2411: Property 'f3' of type '(a: string) => number' is not assignable to 'string' index type '() => string'.
|
||||
tests/cases/compiler/interfacedeclWithIndexerErrors.ts(20,5): error TS2411: Property 'f4' of type '(s: number) => string' is not assignable to 'string' index type '() => string'.
|
||||
tests/cases/compiler/interfacedeclWithIndexerErrors.ts(44,21): error TS2840: An interface cannot extend a primitive type like 'number'; an interface can only extend named types and classes
|
||||
tests/cases/compiler/interfacedeclWithIndexerErrors.ts(48,18): error TS2693: 'string' only refers to a type, but is being used as a value here.
|
||||
|
||||
|
||||
==== tests/cases/compiler/interfacedeclWithIndexerErrors.ts (5 errors) ====
|
||||
==== tests/cases/compiler/interfacedeclWithIndexerErrors.ts (7 errors) ====
|
||||
interface a0 {
|
||||
(): string;
|
||||
(a, b, c?: string): number;
|
||||
@@ -59,6 +61,17 @@ tests/cases/compiler/interfacedeclWithIndexerErrors.ts(20,5): error TS2411: Prop
|
||||
interface d extends a {
|
||||
}
|
||||
|
||||
interface e extends number {
|
||||
~~~~~~
|
||||
!!! error TS2840: An interface cannot extend a primitive type like 'number'; an interface can only extend named types and classes
|
||||
}
|
||||
|
||||
interface f {
|
||||
prop: typeof string;
|
||||
~~~~~~
|
||||
!!! error TS2693: 'string' only refers to a type, but is being used as a value here.
|
||||
}
|
||||
|
||||
class c1 implements a {
|
||||
}
|
||||
var instance2 = new c1();
|
||||
@@ -42,6 +42,13 @@ interface c extends a, b {
|
||||
interface d extends a {
|
||||
}
|
||||
|
||||
interface e extends number {
|
||||
}
|
||||
|
||||
interface f {
|
||||
prop: typeof string;
|
||||
}
|
||||
|
||||
class c1 implements a {
|
||||
}
|
||||
var instance2 = new c1();
|
||||
|
||||
@@ -84,11 +84,22 @@ interface d extends a {
|
||||
>a : Symbol(a, Decl(interfacedeclWithIndexerErrors.ts, 29, 1))
|
||||
}
|
||||
|
||||
interface e extends number {
|
||||
>e : Symbol(e, Decl(interfacedeclWithIndexerErrors.ts, 41, 1))
|
||||
}
|
||||
|
||||
interface f {
|
||||
>f : Symbol(f, Decl(interfacedeclWithIndexerErrors.ts, 44, 1))
|
||||
|
||||
prop: typeof string;
|
||||
>prop : Symbol(f.prop, Decl(interfacedeclWithIndexerErrors.ts, 46, 13))
|
||||
}
|
||||
|
||||
class c1 implements a {
|
||||
>c1 : Symbol(c1, Decl(interfacedeclWithIndexerErrors.ts, 41, 1))
|
||||
>c1 : Symbol(c1, Decl(interfacedeclWithIndexerErrors.ts, 48, 1))
|
||||
>a : Symbol(a, Decl(interfacedeclWithIndexerErrors.ts, 29, 1))
|
||||
}
|
||||
var instance2 = new c1();
|
||||
>instance2 : Symbol(instance2, Decl(interfacedeclWithIndexerErrors.ts, 45, 3))
|
||||
>c1 : Symbol(c1, Decl(interfacedeclWithIndexerErrors.ts, 41, 1))
|
||||
>instance2 : Symbol(instance2, Decl(interfacedeclWithIndexerErrors.ts, 52, 3))
|
||||
>c1 : Symbol(c1, Decl(interfacedeclWithIndexerErrors.ts, 48, 1))
|
||||
|
||||
|
||||
@@ -70,6 +70,15 @@ interface c extends a, b {
|
||||
interface d extends a {
|
||||
}
|
||||
|
||||
interface e extends number {
|
||||
}
|
||||
|
||||
interface f {
|
||||
prop: typeof string;
|
||||
>prop : any
|
||||
>string : any
|
||||
}
|
||||
|
||||
class c1 implements a {
|
||||
>c1 : c1
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
tests/cases/compiler/invalidOptionalChainFromNewExpression.ts(5,6): error TS1209: Invalid optional chain from new expression. Did you mean to call 'A()'?
|
||||
|
||||
|
||||
==== tests/cases/compiler/invalidOptionalChainFromNewExpression.ts (1 errors) ====
|
||||
class A {
|
||||
b() {}
|
||||
}
|
||||
|
||||
new A?.b() // error
|
||||
~~
|
||||
!!! error TS1209: Invalid optional chain from new expression. Did you mean to call 'A()'?
|
||||
new A()?.b() // ok
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [invalidOptionalChainFromNewExpression.ts]
|
||||
class A {
|
||||
b() {}
|
||||
}
|
||||
|
||||
new A?.b() // error
|
||||
new A()?.b() // ok
|
||||
|
||||
|
||||
//// [invalidOptionalChainFromNewExpression.js]
|
||||
var _a, _b;
|
||||
var A = /** @class */ (function () {
|
||||
function A() {
|
||||
}
|
||||
A.prototype.b = function () { };
|
||||
return A;
|
||||
}());
|
||||
(_a = new A) === null || _a === void 0 ? void 0 : _a.b(); // error
|
||||
(_b = new A()) === null || _b === void 0 ? void 0 : _b.b(); // ok
|
||||
@@ -0,0 +1,18 @@
|
||||
=== tests/cases/compiler/invalidOptionalChainFromNewExpression.ts ===
|
||||
class A {
|
||||
>A : Symbol(A, Decl(invalidOptionalChainFromNewExpression.ts, 0, 0))
|
||||
|
||||
b() {}
|
||||
>b : Symbol(A.b, Decl(invalidOptionalChainFromNewExpression.ts, 0, 9))
|
||||
}
|
||||
|
||||
new A?.b() // error
|
||||
>new A?.b : Symbol(A.b, Decl(invalidOptionalChainFromNewExpression.ts, 0, 9))
|
||||
>A : Symbol(A, Decl(invalidOptionalChainFromNewExpression.ts, 0, 0))
|
||||
>b : Symbol(A.b, Decl(invalidOptionalChainFromNewExpression.ts, 0, 9))
|
||||
|
||||
new A()?.b() // ok
|
||||
>new A()?.b : Symbol(A.b, Decl(invalidOptionalChainFromNewExpression.ts, 0, 9))
|
||||
>A : Symbol(A, Decl(invalidOptionalChainFromNewExpression.ts, 0, 0))
|
||||
>b : Symbol(A.b, Decl(invalidOptionalChainFromNewExpression.ts, 0, 9))
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
=== tests/cases/compiler/invalidOptionalChainFromNewExpression.ts ===
|
||||
class A {
|
||||
>A : A
|
||||
|
||||
b() {}
|
||||
>b : () => void
|
||||
}
|
||||
|
||||
new A?.b() // error
|
||||
>new A?.b() : void
|
||||
>new A?.b : () => void
|
||||
>new A : A
|
||||
>A : typeof A
|
||||
>b : () => void
|
||||
|
||||
new A()?.b() // ok
|
||||
>new A()?.b() : void
|
||||
>new A()?.b : () => void
|
||||
>new A() : A
|
||||
>A : typeof A
|
||||
>b : () => void
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
//// [mappedTypeGenericIndexedAccess.ts]
|
||||
// Repro from #49242
|
||||
|
||||
type Types = {
|
||||
first: { a1: true };
|
||||
second: { a2: true };
|
||||
third: { a3: true };
|
||||
}
|
||||
|
||||
class Test {
|
||||
entries: { [T in keyof Types]?: Types[T][] };
|
||||
|
||||
constructor() {
|
||||
this.entries = {};
|
||||
}
|
||||
|
||||
addEntry<T extends keyof Types>(name: T, entry: Types[T]) {
|
||||
if (!this.entries[name]) {
|
||||
this.entries[name] = [];
|
||||
}
|
||||
this.entries[name]?.push(entry);
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #49338
|
||||
|
||||
type TypesMap = {
|
||||
[0]: { foo: 'bar'; };
|
||||
[1]: { a: 'b'; };
|
||||
};
|
||||
|
||||
type P<T extends keyof TypesMap> = { t: T; } & TypesMap[T];
|
||||
|
||||
type TypeHandlers = {
|
||||
[T in keyof TypesMap]?: (p: P<T>) => void;
|
||||
};
|
||||
|
||||
const typeHandlers: TypeHandlers = {
|
||||
[0]: (p) => console.log(p.foo),
|
||||
[1]: (p) => console.log(p.a),
|
||||
};
|
||||
|
||||
const onSomeEvent = <T extends keyof TypesMap>(p: P<T>) =>
|
||||
typeHandlers[p.t]?.(p);
|
||||
|
||||
|
||||
//// [mappedTypeGenericIndexedAccess.js]
|
||||
"use strict";
|
||||
// Repro from #49242
|
||||
var _a;
|
||||
var Test = /** @class */ (function () {
|
||||
function Test() {
|
||||
this.entries = {};
|
||||
}
|
||||
Test.prototype.addEntry = function (name, entry) {
|
||||
var _a;
|
||||
if (!this.entries[name]) {
|
||||
this.entries[name] = [];
|
||||
}
|
||||
(_a = this.entries[name]) === null || _a === void 0 ? void 0 : _a.push(entry);
|
||||
};
|
||||
return Test;
|
||||
}());
|
||||
var typeHandlers = (_a = {},
|
||||
_a[0] = function (p) { return console.log(p.foo); },
|
||||
_a[1] = function (p) { return console.log(p.a); },
|
||||
_a);
|
||||
var onSomeEvent = function (p) { var _a; return (_a = typeHandlers[p.t]) === null || _a === void 0 ? void 0 : _a.call(typeHandlers, p); };
|
||||
|
||||
|
||||
//// [mappedTypeGenericIndexedAccess.d.ts]
|
||||
declare type Types = {
|
||||
first: {
|
||||
a1: true;
|
||||
};
|
||||
second: {
|
||||
a2: true;
|
||||
};
|
||||
third: {
|
||||
a3: true;
|
||||
};
|
||||
};
|
||||
declare class Test {
|
||||
entries: {
|
||||
[T in keyof Types]?: Types[T][];
|
||||
};
|
||||
constructor();
|
||||
addEntry<T extends keyof Types>(name: T, entry: Types[T]): void;
|
||||
}
|
||||
declare type TypesMap = {
|
||||
[0]: {
|
||||
foo: 'bar';
|
||||
};
|
||||
[1]: {
|
||||
a: 'b';
|
||||
};
|
||||
};
|
||||
declare type P<T extends keyof TypesMap> = {
|
||||
t: T;
|
||||
} & TypesMap[T];
|
||||
declare type TypeHandlers = {
|
||||
[T in keyof TypesMap]?: (p: P<T>) => void;
|
||||
};
|
||||
declare const typeHandlers: TypeHandlers;
|
||||
declare const onSomeEvent: <T extends keyof TypesMap>(p: P<T>) => void | undefined;
|
||||
@@ -0,0 +1,150 @@
|
||||
=== tests/cases/compiler/mappedTypeGenericIndexedAccess.ts ===
|
||||
// Repro from #49242
|
||||
|
||||
type Types = {
|
||||
>Types : Symbol(Types, Decl(mappedTypeGenericIndexedAccess.ts, 0, 0))
|
||||
|
||||
first: { a1: true };
|
||||
>first : Symbol(first, Decl(mappedTypeGenericIndexedAccess.ts, 2, 14))
|
||||
>a1 : Symbol(a1, Decl(mappedTypeGenericIndexedAccess.ts, 3, 12))
|
||||
|
||||
second: { a2: true };
|
||||
>second : Symbol(second, Decl(mappedTypeGenericIndexedAccess.ts, 3, 24))
|
||||
>a2 : Symbol(a2, Decl(mappedTypeGenericIndexedAccess.ts, 4, 13))
|
||||
|
||||
third: { a3: true };
|
||||
>third : Symbol(third, Decl(mappedTypeGenericIndexedAccess.ts, 4, 25))
|
||||
>a3 : Symbol(a3, Decl(mappedTypeGenericIndexedAccess.ts, 5, 12))
|
||||
}
|
||||
|
||||
class Test {
|
||||
>Test : Symbol(Test, Decl(mappedTypeGenericIndexedAccess.ts, 6, 1))
|
||||
|
||||
entries: { [T in keyof Types]?: Types[T][] };
|
||||
>entries : Symbol(Test.entries, Decl(mappedTypeGenericIndexedAccess.ts, 8, 12))
|
||||
>T : Symbol(T, Decl(mappedTypeGenericIndexedAccess.ts, 9, 16))
|
||||
>Types : Symbol(Types, Decl(mappedTypeGenericIndexedAccess.ts, 0, 0))
|
||||
>Types : Symbol(Types, Decl(mappedTypeGenericIndexedAccess.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(mappedTypeGenericIndexedAccess.ts, 9, 16))
|
||||
|
||||
constructor() {
|
||||
this.entries = {};
|
||||
>this.entries : Symbol(Test.entries, Decl(mappedTypeGenericIndexedAccess.ts, 8, 12))
|
||||
>this : Symbol(Test, Decl(mappedTypeGenericIndexedAccess.ts, 6, 1))
|
||||
>entries : Symbol(Test.entries, Decl(mappedTypeGenericIndexedAccess.ts, 8, 12))
|
||||
}
|
||||
|
||||
addEntry<T extends keyof Types>(name: T, entry: Types[T]) {
|
||||
>addEntry : Symbol(Test.addEntry, Decl(mappedTypeGenericIndexedAccess.ts, 13, 5))
|
||||
>T : Symbol(T, Decl(mappedTypeGenericIndexedAccess.ts, 15, 13))
|
||||
>Types : Symbol(Types, Decl(mappedTypeGenericIndexedAccess.ts, 0, 0))
|
||||
>name : Symbol(name, Decl(mappedTypeGenericIndexedAccess.ts, 15, 36))
|
||||
>T : Symbol(T, Decl(mappedTypeGenericIndexedAccess.ts, 15, 13))
|
||||
>entry : Symbol(entry, Decl(mappedTypeGenericIndexedAccess.ts, 15, 44))
|
||||
>Types : Symbol(Types, Decl(mappedTypeGenericIndexedAccess.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(mappedTypeGenericIndexedAccess.ts, 15, 13))
|
||||
|
||||
if (!this.entries[name]) {
|
||||
>this.entries : Symbol(Test.entries, Decl(mappedTypeGenericIndexedAccess.ts, 8, 12))
|
||||
>this : Symbol(Test, Decl(mappedTypeGenericIndexedAccess.ts, 6, 1))
|
||||
>entries : Symbol(Test.entries, Decl(mappedTypeGenericIndexedAccess.ts, 8, 12))
|
||||
>name : Symbol(name, Decl(mappedTypeGenericIndexedAccess.ts, 15, 36))
|
||||
|
||||
this.entries[name] = [];
|
||||
>this.entries : Symbol(Test.entries, Decl(mappedTypeGenericIndexedAccess.ts, 8, 12))
|
||||
>this : Symbol(Test, Decl(mappedTypeGenericIndexedAccess.ts, 6, 1))
|
||||
>entries : Symbol(Test.entries, Decl(mappedTypeGenericIndexedAccess.ts, 8, 12))
|
||||
>name : Symbol(name, Decl(mappedTypeGenericIndexedAccess.ts, 15, 36))
|
||||
}
|
||||
this.entries[name]?.push(entry);
|
||||
>this.entries[name]?.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
|
||||
>this.entries : Symbol(Test.entries, Decl(mappedTypeGenericIndexedAccess.ts, 8, 12))
|
||||
>this : Symbol(Test, Decl(mappedTypeGenericIndexedAccess.ts, 6, 1))
|
||||
>entries : Symbol(Test.entries, Decl(mappedTypeGenericIndexedAccess.ts, 8, 12))
|
||||
>name : Symbol(name, Decl(mappedTypeGenericIndexedAccess.ts, 15, 36))
|
||||
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
|
||||
>entry : Symbol(entry, Decl(mappedTypeGenericIndexedAccess.ts, 15, 44))
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #49338
|
||||
|
||||
type TypesMap = {
|
||||
>TypesMap : Symbol(TypesMap, Decl(mappedTypeGenericIndexedAccess.ts, 21, 1))
|
||||
|
||||
[0]: { foo: 'bar'; };
|
||||
>[0] : Symbol([0], Decl(mappedTypeGenericIndexedAccess.ts, 25, 17))
|
||||
>0 : Symbol([0], Decl(mappedTypeGenericIndexedAccess.ts, 25, 17))
|
||||
>foo : Symbol(foo, Decl(mappedTypeGenericIndexedAccess.ts, 26, 10))
|
||||
|
||||
[1]: { a: 'b'; };
|
||||
>[1] : Symbol([1], Decl(mappedTypeGenericIndexedAccess.ts, 26, 25))
|
||||
>1 : Symbol([1], Decl(mappedTypeGenericIndexedAccess.ts, 26, 25))
|
||||
>a : Symbol(a, Decl(mappedTypeGenericIndexedAccess.ts, 27, 10))
|
||||
|
||||
};
|
||||
|
||||
type P<T extends keyof TypesMap> = { t: T; } & TypesMap[T];
|
||||
>P : Symbol(P, Decl(mappedTypeGenericIndexedAccess.ts, 28, 2))
|
||||
>T : Symbol(T, Decl(mappedTypeGenericIndexedAccess.ts, 30, 7))
|
||||
>TypesMap : Symbol(TypesMap, Decl(mappedTypeGenericIndexedAccess.ts, 21, 1))
|
||||
>t : Symbol(t, Decl(mappedTypeGenericIndexedAccess.ts, 30, 36))
|
||||
>T : Symbol(T, Decl(mappedTypeGenericIndexedAccess.ts, 30, 7))
|
||||
>TypesMap : Symbol(TypesMap, Decl(mappedTypeGenericIndexedAccess.ts, 21, 1))
|
||||
>T : Symbol(T, Decl(mappedTypeGenericIndexedAccess.ts, 30, 7))
|
||||
|
||||
type TypeHandlers = {
|
||||
>TypeHandlers : Symbol(TypeHandlers, Decl(mappedTypeGenericIndexedAccess.ts, 30, 59))
|
||||
|
||||
[T in keyof TypesMap]?: (p: P<T>) => void;
|
||||
>T : Symbol(T, Decl(mappedTypeGenericIndexedAccess.ts, 33, 5))
|
||||
>TypesMap : Symbol(TypesMap, Decl(mappedTypeGenericIndexedAccess.ts, 21, 1))
|
||||
>p : Symbol(p, Decl(mappedTypeGenericIndexedAccess.ts, 33, 29))
|
||||
>P : Symbol(P, Decl(mappedTypeGenericIndexedAccess.ts, 28, 2))
|
||||
>T : Symbol(T, Decl(mappedTypeGenericIndexedAccess.ts, 33, 5))
|
||||
|
||||
};
|
||||
|
||||
const typeHandlers: TypeHandlers = {
|
||||
>typeHandlers : Symbol(typeHandlers, Decl(mappedTypeGenericIndexedAccess.ts, 36, 5))
|
||||
>TypeHandlers : Symbol(TypeHandlers, Decl(mappedTypeGenericIndexedAccess.ts, 30, 59))
|
||||
|
||||
[0]: (p) => console.log(p.foo),
|
||||
>[0] : Symbol([0], Decl(mappedTypeGenericIndexedAccess.ts, 36, 36))
|
||||
>0 : Symbol([0], Decl(mappedTypeGenericIndexedAccess.ts, 36, 36))
|
||||
>p : Symbol(p, Decl(mappedTypeGenericIndexedAccess.ts, 37, 10))
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>p.foo : Symbol(foo, Decl(mappedTypeGenericIndexedAccess.ts, 26, 10))
|
||||
>p : Symbol(p, Decl(mappedTypeGenericIndexedAccess.ts, 37, 10))
|
||||
>foo : Symbol(foo, Decl(mappedTypeGenericIndexedAccess.ts, 26, 10))
|
||||
|
||||
[1]: (p) => console.log(p.a),
|
||||
>[1] : Symbol([1], Decl(mappedTypeGenericIndexedAccess.ts, 37, 35))
|
||||
>1 : Symbol([1], Decl(mappedTypeGenericIndexedAccess.ts, 37, 35))
|
||||
>p : Symbol(p, Decl(mappedTypeGenericIndexedAccess.ts, 38, 10))
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>p.a : Symbol(a, Decl(mappedTypeGenericIndexedAccess.ts, 27, 10))
|
||||
>p : Symbol(p, Decl(mappedTypeGenericIndexedAccess.ts, 38, 10))
|
||||
>a : Symbol(a, Decl(mappedTypeGenericIndexedAccess.ts, 27, 10))
|
||||
|
||||
};
|
||||
|
||||
const onSomeEvent = <T extends keyof TypesMap>(p: P<T>) =>
|
||||
>onSomeEvent : Symbol(onSomeEvent, Decl(mappedTypeGenericIndexedAccess.ts, 41, 5))
|
||||
>T : Symbol(T, Decl(mappedTypeGenericIndexedAccess.ts, 41, 21))
|
||||
>TypesMap : Symbol(TypesMap, Decl(mappedTypeGenericIndexedAccess.ts, 21, 1))
|
||||
>p : Symbol(p, Decl(mappedTypeGenericIndexedAccess.ts, 41, 47))
|
||||
>P : Symbol(P, Decl(mappedTypeGenericIndexedAccess.ts, 28, 2))
|
||||
>T : Symbol(T, Decl(mappedTypeGenericIndexedAccess.ts, 41, 21))
|
||||
|
||||
typeHandlers[p.t]?.(p);
|
||||
>typeHandlers : Symbol(typeHandlers, Decl(mappedTypeGenericIndexedAccess.ts, 36, 5))
|
||||
>p.t : Symbol(t, Decl(mappedTypeGenericIndexedAccess.ts, 30, 36))
|
||||
>p : Symbol(p, Decl(mappedTypeGenericIndexedAccess.ts, 41, 47))
|
||||
>t : Symbol(t, Decl(mappedTypeGenericIndexedAccess.ts, 30, 36))
|
||||
>p : Symbol(p, Decl(mappedTypeGenericIndexedAccess.ts, 41, 47))
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
=== tests/cases/compiler/mappedTypeGenericIndexedAccess.ts ===
|
||||
// Repro from #49242
|
||||
|
||||
type Types = {
|
||||
>Types : { first: { a1: true;}; second: { a2: true;}; third: { a3: true;}; }
|
||||
|
||||
first: { a1: true };
|
||||
>first : { a1: true; }
|
||||
>a1 : true
|
||||
>true : true
|
||||
|
||||
second: { a2: true };
|
||||
>second : { a2: true; }
|
||||
>a2 : true
|
||||
>true : true
|
||||
|
||||
third: { a3: true };
|
||||
>third : { a3: true; }
|
||||
>a3 : true
|
||||
>true : true
|
||||
}
|
||||
|
||||
class Test {
|
||||
>Test : Test
|
||||
|
||||
entries: { [T in keyof Types]?: Types[T][] };
|
||||
>entries : { first?: { a1: true; }[] | undefined; second?: { a2: true; }[] | undefined; third?: { a3: true; }[] | undefined; }
|
||||
|
||||
constructor() {
|
||||
this.entries = {};
|
||||
>this.entries = {} : {}
|
||||
>this.entries : { first?: { a1: true; }[] | undefined; second?: { a2: true; }[] | undefined; third?: { a3: true; }[] | undefined; }
|
||||
>this : this
|
||||
>entries : { first?: { a1: true; }[] | undefined; second?: { a2: true; }[] | undefined; third?: { a3: true; }[] | undefined; }
|
||||
>{} : {}
|
||||
}
|
||||
|
||||
addEntry<T extends keyof Types>(name: T, entry: Types[T]) {
|
||||
>addEntry : <T extends keyof Types>(name: T, entry: Types[T]) => void
|
||||
>name : T
|
||||
>entry : Types[T]
|
||||
|
||||
if (!this.entries[name]) {
|
||||
>!this.entries[name] : boolean
|
||||
>this.entries[name] : { first?: { a1: true; }[] | undefined; second?: { a2: true; }[] | undefined; third?: { a3: true; }[] | undefined; }[T]
|
||||
>this.entries : { first?: { a1: true; }[] | undefined; second?: { a2: true; }[] | undefined; third?: { a3: true; }[] | undefined; }
|
||||
>this : this
|
||||
>entries : { first?: { a1: true; }[] | undefined; second?: { a2: true; }[] | undefined; third?: { a3: true; }[] | undefined; }
|
||||
>name : T
|
||||
|
||||
this.entries[name] = [];
|
||||
>this.entries[name] = [] : never[]
|
||||
>this.entries[name] : { first?: { a1: true; }[] | undefined; second?: { a2: true; }[] | undefined; third?: { a3: true; }[] | undefined; }[T]
|
||||
>this.entries : { first?: { a1: true; }[] | undefined; second?: { a2: true; }[] | undefined; third?: { a3: true; }[] | undefined; }
|
||||
>this : this
|
||||
>entries : { first?: { a1: true; }[] | undefined; second?: { a2: true; }[] | undefined; third?: { a3: true; }[] | undefined; }
|
||||
>name : T
|
||||
>[] : never[]
|
||||
}
|
||||
this.entries[name]?.push(entry);
|
||||
>this.entries[name]?.push(entry) : number | undefined
|
||||
>this.entries[name]?.push : ((...items: Types[T][]) => number) | undefined
|
||||
>this.entries[name] : Types[T][] | undefined
|
||||
>this.entries : { first?: { a1: true; }[] | undefined; second?: { a2: true; }[] | undefined; third?: { a3: true; }[] | undefined; }
|
||||
>this : this
|
||||
>entries : { first?: { a1: true; }[] | undefined; second?: { a2: true; }[] | undefined; third?: { a3: true; }[] | undefined; }
|
||||
>name : T
|
||||
>push : ((...items: Types[T][]) => number) | undefined
|
||||
>entry : Types[T]
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #49338
|
||||
|
||||
type TypesMap = {
|
||||
>TypesMap : { 0: { foo: 'bar';}; 1: { a: 'b';}; }
|
||||
|
||||
[0]: { foo: 'bar'; };
|
||||
>[0] : { foo: 'bar'; }
|
||||
>0 : 0
|
||||
>foo : "bar"
|
||||
|
||||
[1]: { a: 'b'; };
|
||||
>[1] : { a: 'b'; }
|
||||
>1 : 1
|
||||
>a : "b"
|
||||
|
||||
};
|
||||
|
||||
type P<T extends keyof TypesMap> = { t: T; } & TypesMap[T];
|
||||
>P : P<T>
|
||||
>t : T
|
||||
|
||||
type TypeHandlers = {
|
||||
>TypeHandlers : { 0?: ((p: P<0>) => void) | undefined; 1?: ((p: P<1>) => void) | undefined; }
|
||||
|
||||
[T in keyof TypesMap]?: (p: P<T>) => void;
|
||||
>p : P<T>
|
||||
|
||||
};
|
||||
|
||||
const typeHandlers: TypeHandlers = {
|
||||
>typeHandlers : TypeHandlers
|
||||
>{ [0]: (p) => console.log(p.foo), [1]: (p) => console.log(p.a),} : { 0: (p: P<0>) => void; 1: (p: P<1>) => void; }
|
||||
|
||||
[0]: (p) => console.log(p.foo),
|
||||
>[0] : (p: P<0>) => void
|
||||
>0 : 0
|
||||
>(p) => console.log(p.foo) : (p: P<0>) => void
|
||||
>p : P<0>
|
||||
>console.log(p.foo) : void
|
||||
>console.log : (...data: any[]) => void
|
||||
>console : Console
|
||||
>log : (...data: any[]) => void
|
||||
>p.foo : "bar"
|
||||
>p : P<0>
|
||||
>foo : "bar"
|
||||
|
||||
[1]: (p) => console.log(p.a),
|
||||
>[1] : (p: P<1>) => void
|
||||
>1 : 1
|
||||
>(p) => console.log(p.a) : (p: P<1>) => void
|
||||
>p : P<1>
|
||||
>console.log(p.a) : void
|
||||
>console.log : (...data: any[]) => void
|
||||
>console : Console
|
||||
>log : (...data: any[]) => void
|
||||
>p.a : "b"
|
||||
>p : P<1>
|
||||
>a : "b"
|
||||
|
||||
};
|
||||
|
||||
const onSomeEvent = <T extends keyof TypesMap>(p: P<T>) =>
|
||||
>onSomeEvent : <T extends keyof TypesMap>(p: P<T>) => void | undefined
|
||||
><T extends keyof TypesMap>(p: P<T>) => typeHandlers[p.t]?.(p) : <T extends keyof TypesMap>(p: P<T>) => void | undefined
|
||||
>p : P<T>
|
||||
|
||||
typeHandlers[p.t]?.(p);
|
||||
>typeHandlers[p.t]?.(p) : void | undefined
|
||||
>typeHandlers[p.t] : ((p: P<T>) => void) | undefined
|
||||
>typeHandlers : TypeHandlers
|
||||
>p.t : T
|
||||
>p : { t: T; } & ({ foo: "bar"; } | { a: "b"; })
|
||||
>t : T
|
||||
>p : P<T>
|
||||
|
||||
@@ -30,14 +30,14 @@ function boxify<T>(obj: T): Boxified<T> {
|
||||
>obj : (T & null) | (T & object)
|
||||
|
||||
result[k] = { value: obj[k] };
|
||||
>result[k] = { value: obj[k] } : { value: NonNullable<T & object>[Extract<keyof T, string>]; }
|
||||
>result[k] = { value: obj[k] } : { value: (T & object)[Extract<keyof T, string>]; }
|
||||
>result[k] : Boxified<T>[Extract<keyof T, string>]
|
||||
>result : Boxified<T>
|
||||
>k : Extract<keyof T, string>
|
||||
>{ value: obj[k] } : { value: NonNullable<T & object>[Extract<keyof T, string>]; }
|
||||
>value : NonNullable<T & object>[Extract<keyof T, string>]
|
||||
>obj[k] : NonNullable<T & object>[Extract<keyof T, string>]
|
||||
>obj : NonNullable<T & object>
|
||||
>{ value: obj[k] } : { value: (T & object)[Extract<keyof T, string>]; }
|
||||
>value : (T & object)[Extract<keyof T, string>]
|
||||
>obj[k] : (T & object)[Extract<keyof T, string>]
|
||||
>obj : T & object
|
||||
>k : Extract<keyof T, string>
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -180,7 +180,7 @@ declare function infiniteLoop1(): void;
|
||||
declare function infiniteLoop2(): never;
|
||||
declare function move1(direction: "up" | "down"): 1 | -1;
|
||||
declare function move2(direction: "up" | "down"): 1 | -1;
|
||||
declare function check<T>(x: T | undefined): T;
|
||||
declare function check<T>(x: T | undefined): NonNullable<T>;
|
||||
declare class C {
|
||||
void1(): void;
|
||||
void2(): void;
|
||||
|
||||
@@ -112,11 +112,11 @@ function move2(direction: "up" | "down") {
|
||||
}
|
||||
|
||||
function check<T>(x: T | undefined) {
|
||||
>check : <T>(x: T | undefined) => T
|
||||
>check : <T>(x: T | undefined) => NonNullable<T>
|
||||
>x : T | undefined
|
||||
|
||||
return x || error("Undefined value");
|
||||
>x || error("Undefined value") : T
|
||||
>x || error("Undefined value") : NonNullable<T>
|
||||
>x : T | undefined
|
||||
>error("Undefined value") : never
|
||||
>error : (message: string) => never
|
||||
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
tests/cases/conformance/node/allowJs/index.cjs(2,23): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(3,23): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(4,24): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.js(2,23): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.js(3,23): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.js(4,24): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(2,23): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(3,23): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(4,24): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.cts(2,22): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.cts(3,22): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.cts(4,23): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.mts(2,22): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.mts(3,22): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.mts(4,23): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.ts(2,22): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.ts(3,22): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.ts(4,23): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
|
||||
|
||||
==== tests/cases/conformance/node/allowJs/index.js (3 errors) ====
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
==== tests/cases/conformance/node/allowJs/index.mjs (3 errors) ====
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
==== tests/cases/conformance/node/allowJs/index.cjs (3 errors) ====
|
||||
// cjs format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
==== tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.ts (3 errors) ====
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as type from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
==== tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.mts (3 errors) ====
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as type from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
==== tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.cts (3 errors) ====
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as type from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
|
||||
{
|
||||
"name": "package",
|
||||
"private": true,
|
||||
"type": "module"
|
||||
}
|
||||
==== tests/cases/conformance/node/allowJs/node_modules/inner/package.json (0 errors) ====
|
||||
{
|
||||
"name": "inner",
|
||||
"private": true,
|
||||
"exports": {
|
||||
"./cjs/*": "./*.cjs",
|
||||
"./cjs/exclude/*": null,
|
||||
"./mjs/*": "./*.mjs",
|
||||
"./mjs/exclude/*": null,
|
||||
"./js/*": "./*.js",
|
||||
"./js/exclude/*": null
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExportsExclude.ts] ////
|
||||
|
||||
//// [index.js]
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
//// [index.mjs]
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
//// [index.cjs]
|
||||
// cjs format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
//// [index.d.ts]
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
import * as type from "inner/js/exclude/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
//// [index.d.mts]
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
import * as type from "inner/js/exclude/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
//// [index.d.cts]
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
import * as type from "inner/js/exclude/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "package",
|
||||
"private": true,
|
||||
"type": "module"
|
||||
}
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "inner",
|
||||
"private": true,
|
||||
"exports": {
|
||||
"./cjs/*": "./*.cjs",
|
||||
"./cjs/exclude/*": null,
|
||||
"./mjs/*": "./*.mjs",
|
||||
"./mjs/exclude/*": null,
|
||||
"./js/*": "./*.js",
|
||||
"./js/exclude/*": null
|
||||
}
|
||||
}
|
||||
|
||||
//// [index.js]
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
//// [index.mjs]
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
//// [index.cjs]
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// cjs format file
|
||||
const cjsi = __importStar(require("inner/cjs/exclude/index"));
|
||||
const mjsi = __importStar(require("inner/mjs/exclude/index"));
|
||||
const typei = __importStar(require("inner/js/exclude/index"));
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
|
||||
|
||||
//// [index.d.ts]
|
||||
export {};
|
||||
//// [index.d.mts]
|
||||
export {};
|
||||
//// [index.d.cts]
|
||||
export {};
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
=== tests/cases/conformance/node/allowJs/index.js ===
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : Symbol(cjsi, Decl(index.js, 1, 6))
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : Symbol(mjsi, Decl(index.js, 2, 6))
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : Symbol(typei, Decl(index.js, 3, 6))
|
||||
|
||||
cjsi;
|
||||
>cjsi : Symbol(cjsi, Decl(index.js, 1, 6))
|
||||
|
||||
mjsi;
|
||||
>mjsi : Symbol(mjsi, Decl(index.js, 2, 6))
|
||||
|
||||
typei;
|
||||
>typei : Symbol(typei, Decl(index.js, 3, 6))
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/index.mjs ===
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : Symbol(cjsi, Decl(index.mjs, 1, 6))
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : Symbol(mjsi, Decl(index.mjs, 2, 6))
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : Symbol(typei, Decl(index.mjs, 3, 6))
|
||||
|
||||
cjsi;
|
||||
>cjsi : Symbol(cjsi, Decl(index.mjs, 1, 6))
|
||||
|
||||
mjsi;
|
||||
>mjsi : Symbol(mjsi, Decl(index.mjs, 2, 6))
|
||||
|
||||
typei;
|
||||
>typei : Symbol(typei, Decl(index.mjs, 3, 6))
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/index.cjs ===
|
||||
// cjs format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : Symbol(cjsi, Decl(index.cjs, 1, 6))
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : Symbol(mjsi, Decl(index.cjs, 2, 6))
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : Symbol(typei, Decl(index.cjs, 3, 6))
|
||||
|
||||
cjsi;
|
||||
>cjsi : Symbol(cjsi, Decl(index.cjs, 1, 6))
|
||||
|
||||
mjsi;
|
||||
>mjsi : Symbol(mjsi, Decl(index.cjs, 2, 6))
|
||||
|
||||
typei;
|
||||
>typei : Symbol(typei, Decl(index.cjs, 3, 6))
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.ts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : Symbol(type, Decl(index.d.ts, 3, 6))
|
||||
|
||||
export { cjs };
|
||||
>cjs : Symbol(cjs, Decl(index.d.ts, 4, 8))
|
||||
|
||||
export { mjs };
|
||||
>mjs : Symbol(mjs, Decl(index.d.ts, 5, 8))
|
||||
|
||||
export { type };
|
||||
>type : Symbol(type, Decl(index.d.ts, 6, 8))
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.mts ===
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : Symbol(type, Decl(index.d.mts, 3, 6))
|
||||
|
||||
export { cjs };
|
||||
>cjs : Symbol(cjs, Decl(index.d.mts, 4, 8))
|
||||
|
||||
export { mjs };
|
||||
>mjs : Symbol(mjs, Decl(index.d.mts, 5, 8))
|
||||
|
||||
export { type };
|
||||
>type : Symbol(type, Decl(index.d.mts, 6, 8))
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.cts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : Symbol(type, Decl(index.d.cts, 3, 6))
|
||||
|
||||
export { cjs };
|
||||
>cjs : Symbol(cjs, Decl(index.d.cts, 4, 8))
|
||||
|
||||
export { mjs };
|
||||
>mjs : Symbol(mjs, Decl(index.d.cts, 5, 8))
|
||||
|
||||
export { type };
|
||||
>type : Symbol(type, Decl(index.d.cts, 6, 8))
|
||||
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
=== tests/cases/conformance/node/allowJs/index.js ===
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : any
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : any
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : any
|
||||
|
||||
cjsi;
|
||||
>cjsi : any
|
||||
|
||||
mjsi;
|
||||
>mjsi : any
|
||||
|
||||
typei;
|
||||
>typei : any
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/index.mjs ===
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : any
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : any
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : any
|
||||
|
||||
cjsi;
|
||||
>cjsi : any
|
||||
|
||||
mjsi;
|
||||
>mjsi : any
|
||||
|
||||
typei;
|
||||
>typei : any
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/index.cjs ===
|
||||
// cjs format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : any
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : any
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : any
|
||||
|
||||
cjsi;
|
||||
>cjsi : any
|
||||
|
||||
mjsi;
|
||||
>mjsi : any
|
||||
|
||||
typei;
|
||||
>typei : any
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.ts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : any
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : any
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : any
|
||||
|
||||
export { cjs };
|
||||
>cjs : any
|
||||
|
||||
export { mjs };
|
||||
>mjs : any
|
||||
|
||||
export { type };
|
||||
>type : any
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.mts ===
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : any
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : any
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : any
|
||||
|
||||
export { cjs };
|
||||
>cjs : any
|
||||
|
||||
export { mjs };
|
||||
>mjs : any
|
||||
|
||||
export { type };
|
||||
>type : any
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.cts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : any
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : any
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : any
|
||||
|
||||
export { cjs };
|
||||
>cjs : any
|
||||
|
||||
export { mjs };
|
||||
>mjs : any
|
||||
|
||||
export { type };
|
||||
>type : any
|
||||
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
tests/cases/conformance/node/allowJs/index.cjs(2,23): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(3,23): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(4,24): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.js(2,23): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.js(3,23): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.js(4,24): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(2,23): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(3,23): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(4,24): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.cts(2,22): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.cts(3,22): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.cts(4,23): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.mts(2,22): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.mts(3,22): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.mts(4,23): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.ts(2,22): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.ts(3,22): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.ts(4,23): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
|
||||
|
||||
==== tests/cases/conformance/node/allowJs/index.js (3 errors) ====
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
==== tests/cases/conformance/node/allowJs/index.mjs (3 errors) ====
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
==== tests/cases/conformance/node/allowJs/index.cjs (3 errors) ====
|
||||
// cjs format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
==== tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.ts (3 errors) ====
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as type from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
==== tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.mts (3 errors) ====
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as type from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
==== tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.cts (3 errors) ====
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as type from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
==== tests/cases/conformance/node/allowJs/package.json (0 errors) ====
|
||||
{
|
||||
"name": "package",
|
||||
"private": true,
|
||||
"type": "module"
|
||||
}
|
||||
==== tests/cases/conformance/node/allowJs/node_modules/inner/package.json (0 errors) ====
|
||||
{
|
||||
"name": "inner",
|
||||
"private": true,
|
||||
"exports": {
|
||||
"./cjs/*": "./*.cjs",
|
||||
"./cjs/exclude/*": null,
|
||||
"./mjs/*": "./*.mjs",
|
||||
"./mjs/exclude/*": null,
|
||||
"./js/*": "./*.js",
|
||||
"./js/exclude/*": null
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExportsExclude.ts] ////
|
||||
|
||||
//// [index.js]
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
//// [index.mjs]
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
//// [index.cjs]
|
||||
// cjs format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
//// [index.d.ts]
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
import * as type from "inner/js/exclude/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
//// [index.d.mts]
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
import * as type from "inner/js/exclude/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
//// [index.d.cts]
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
import * as type from "inner/js/exclude/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "package",
|
||||
"private": true,
|
||||
"type": "module"
|
||||
}
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "inner",
|
||||
"private": true,
|
||||
"exports": {
|
||||
"./cjs/*": "./*.cjs",
|
||||
"./cjs/exclude/*": null,
|
||||
"./mjs/*": "./*.mjs",
|
||||
"./mjs/exclude/*": null,
|
||||
"./js/*": "./*.js",
|
||||
"./js/exclude/*": null
|
||||
}
|
||||
}
|
||||
|
||||
//// [index.js]
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
//// [index.mjs]
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
//// [index.cjs]
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// cjs format file
|
||||
const cjsi = __importStar(require("inner/cjs/exclude/index"));
|
||||
const mjsi = __importStar(require("inner/mjs/exclude/index"));
|
||||
const typei = __importStar(require("inner/js/exclude/index"));
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
|
||||
|
||||
//// [index.d.ts]
|
||||
export {};
|
||||
//// [index.d.mts]
|
||||
export {};
|
||||
//// [index.d.cts]
|
||||
export {};
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
=== tests/cases/conformance/node/allowJs/index.js ===
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : Symbol(cjsi, Decl(index.js, 1, 6))
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : Symbol(mjsi, Decl(index.js, 2, 6))
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : Symbol(typei, Decl(index.js, 3, 6))
|
||||
|
||||
cjsi;
|
||||
>cjsi : Symbol(cjsi, Decl(index.js, 1, 6))
|
||||
|
||||
mjsi;
|
||||
>mjsi : Symbol(mjsi, Decl(index.js, 2, 6))
|
||||
|
||||
typei;
|
||||
>typei : Symbol(typei, Decl(index.js, 3, 6))
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/index.mjs ===
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : Symbol(cjsi, Decl(index.mjs, 1, 6))
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : Symbol(mjsi, Decl(index.mjs, 2, 6))
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : Symbol(typei, Decl(index.mjs, 3, 6))
|
||||
|
||||
cjsi;
|
||||
>cjsi : Symbol(cjsi, Decl(index.mjs, 1, 6))
|
||||
|
||||
mjsi;
|
||||
>mjsi : Symbol(mjsi, Decl(index.mjs, 2, 6))
|
||||
|
||||
typei;
|
||||
>typei : Symbol(typei, Decl(index.mjs, 3, 6))
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/index.cjs ===
|
||||
// cjs format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : Symbol(cjsi, Decl(index.cjs, 1, 6))
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : Symbol(mjsi, Decl(index.cjs, 2, 6))
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : Symbol(typei, Decl(index.cjs, 3, 6))
|
||||
|
||||
cjsi;
|
||||
>cjsi : Symbol(cjsi, Decl(index.cjs, 1, 6))
|
||||
|
||||
mjsi;
|
||||
>mjsi : Symbol(mjsi, Decl(index.cjs, 2, 6))
|
||||
|
||||
typei;
|
||||
>typei : Symbol(typei, Decl(index.cjs, 3, 6))
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.ts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : Symbol(type, Decl(index.d.ts, 3, 6))
|
||||
|
||||
export { cjs };
|
||||
>cjs : Symbol(cjs, Decl(index.d.ts, 4, 8))
|
||||
|
||||
export { mjs };
|
||||
>mjs : Symbol(mjs, Decl(index.d.ts, 5, 8))
|
||||
|
||||
export { type };
|
||||
>type : Symbol(type, Decl(index.d.ts, 6, 8))
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.mts ===
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : Symbol(type, Decl(index.d.mts, 3, 6))
|
||||
|
||||
export { cjs };
|
||||
>cjs : Symbol(cjs, Decl(index.d.mts, 4, 8))
|
||||
|
||||
export { mjs };
|
||||
>mjs : Symbol(mjs, Decl(index.d.mts, 5, 8))
|
||||
|
||||
export { type };
|
||||
>type : Symbol(type, Decl(index.d.mts, 6, 8))
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.cts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : Symbol(type, Decl(index.d.cts, 3, 6))
|
||||
|
||||
export { cjs };
|
||||
>cjs : Symbol(cjs, Decl(index.d.cts, 4, 8))
|
||||
|
||||
export { mjs };
|
||||
>mjs : Symbol(mjs, Decl(index.d.cts, 5, 8))
|
||||
|
||||
export { type };
|
||||
>type : Symbol(type, Decl(index.d.cts, 6, 8))
|
||||
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
=== tests/cases/conformance/node/allowJs/index.js ===
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : any
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : any
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : any
|
||||
|
||||
cjsi;
|
||||
>cjsi : any
|
||||
|
||||
mjsi;
|
||||
>mjsi : any
|
||||
|
||||
typei;
|
||||
>typei : any
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/index.mjs ===
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : any
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : any
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : any
|
||||
|
||||
cjsi;
|
||||
>cjsi : any
|
||||
|
||||
mjsi;
|
||||
>mjsi : any
|
||||
|
||||
typei;
|
||||
>typei : any
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/index.cjs ===
|
||||
// cjs format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : any
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : any
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : any
|
||||
|
||||
cjsi;
|
||||
>cjsi : any
|
||||
|
||||
mjsi;
|
||||
>mjsi : any
|
||||
|
||||
typei;
|
||||
>typei : any
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.ts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : any
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : any
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : any
|
||||
|
||||
export { cjs };
|
||||
>cjs : any
|
||||
|
||||
export { mjs };
|
||||
>mjs : any
|
||||
|
||||
export { type };
|
||||
>type : any
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.mts ===
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : any
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : any
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : any
|
||||
|
||||
export { cjs };
|
||||
>cjs : any
|
||||
|
||||
export { mjs };
|
||||
>mjs : any
|
||||
|
||||
export { type };
|
||||
>type : any
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/node_modules/inner/exclude/index.d.cts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : any
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : any
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : any
|
||||
|
||||
export { cjs };
|
||||
>cjs : any
|
||||
|
||||
export { mjs };
|
||||
>mjs : any
|
||||
|
||||
export { type };
|
||||
>type : any
|
||||
|
||||
+177
@@ -0,0 +1,177 @@
|
||||
tests/cases/conformance/node/index.cts(2,23): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/index.cts(3,23): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/index.cts(4,24): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/index.cts(9,24): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/index.mts(2,23): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/index.mts(3,23): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/index.mts(4,24): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/index.ts(2,23): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/index.ts(3,23): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/index.ts(4,24): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/exclude/index.d.cts(2,22): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/exclude/index.d.cts(3,22): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/exclude/index.d.cts(4,23): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/exclude/index.d.mts(2,22): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/exclude/index.d.mts(3,22): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/exclude/index.d.mts(4,23): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/exclude/index.d.ts(2,22): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/exclude/index.d.ts(3,22): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/exclude/index.d.ts(4,23): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
|
||||
tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
|
||||
|
||||
==== tests/cases/conformance/node/index.ts (3 errors) ====
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
import * as typei2 from "inner/js/index";
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
==== tests/cases/conformance/node/index.mts (3 errors) ====
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
import * as typei2 from "inner/js/index";
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
==== tests/cases/conformance/node/index.cts (4 errors) ====
|
||||
// cjs format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import * as typei2 from "inner/js/index";
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
==== tests/cases/conformance/node/node_modules/inner/exclude/index.d.ts (3 errors) ====
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as type from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
==== tests/cases/conformance/node/node_modules/inner/exclude/index.d.mts (3 errors) ====
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as type from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
==== tests/cases/conformance/node/node_modules/inner/exclude/index.d.cts (3 errors) ====
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as type from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
==== tests/cases/conformance/node/node_modules/inner/index.d.ts (2 errors) ====
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
~~~
|
||||
!!! error TS2303: Circular definition of import alias 'cjs'.
|
||||
import * as mjs from "inner/mjs/index";
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import * as type from "inner/js/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
==== tests/cases/conformance/node/node_modules/inner/index.d.mts (0 errors) ====
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
import * as mjs from "inner/mjs/index";
|
||||
import * as type from "inner/js/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
==== tests/cases/conformance/node/node_modules/inner/index.d.cts (1 errors) ====
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
import * as mjs from "inner/mjs/index";
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import * as type from "inner/js/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
==== tests/cases/conformance/node/package.json (0 errors) ====
|
||||
{
|
||||
"name": "package",
|
||||
"private": true,
|
||||
"type": "module"
|
||||
}
|
||||
==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ====
|
||||
{
|
||||
"name": "inner",
|
||||
"private": true,
|
||||
"exports": {
|
||||
"./cjs/*": "./*.cjs",
|
||||
"./cjs/exclude/*": null,
|
||||
"./mjs/*": "./*.mjs",
|
||||
"./mjs/exclude/*": null,
|
||||
"./js/*": "./*.js",
|
||||
"./js/exclude/*": null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
//// [tests/cases/conformance/node/nodeModulesPackagePatternExportsExclude.ts] ////
|
||||
|
||||
//// [index.ts]
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
import * as typei2 from "inner/js/index";
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
//// [index.mts]
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
import * as typei2 from "inner/js/index";
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
//// [index.cts]
|
||||
// cjs format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
import * as typei2 from "inner/js/index";
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
//// [index.d.ts]
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
import * as type from "inner/js/exclude/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
//// [index.d.mts]
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
import * as type from "inner/js/exclude/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
//// [index.d.cts]
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
import * as type from "inner/js/exclude/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
//// [index.d.ts]
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
import * as mjs from "inner/mjs/index";
|
||||
import * as type from "inner/js/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
//// [index.d.mts]
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
import * as mjs from "inner/mjs/index";
|
||||
import * as type from "inner/js/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
//// [index.d.cts]
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
import * as mjs from "inner/mjs/index";
|
||||
import * as type from "inner/js/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "package",
|
||||
"private": true,
|
||||
"type": "module"
|
||||
}
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "inner",
|
||||
"private": true,
|
||||
"exports": {
|
||||
"./cjs/*": "./*.cjs",
|
||||
"./cjs/exclude/*": null,
|
||||
"./mjs/*": "./*.mjs",
|
||||
"./mjs/exclude/*": null,
|
||||
"./js/*": "./*.js",
|
||||
"./js/exclude/*": null
|
||||
}
|
||||
}
|
||||
|
||||
//// [index.js]
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
import * as typei2 from "inner/js/index";
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
//// [index.mjs]
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
import * as typei2 from "inner/js/index";
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
//// [index.cjs]
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// cjs format file
|
||||
const cjsi = __importStar(require("inner/cjs/exclude/index"));
|
||||
const mjsi = __importStar(require("inner/mjs/exclude/index"));
|
||||
const typei = __importStar(require("inner/js/exclude/index"));
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
const cjsi2 = __importStar(require("inner/cjs/index"));
|
||||
const mjsi2 = __importStar(require("inner/mjs/index"));
|
||||
const typei2 = __importStar(require("inner/js/index"));
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
|
||||
|
||||
//// [index.d.ts]
|
||||
export {};
|
||||
//// [index.d.mts]
|
||||
export {};
|
||||
//// [index.d.cts]
|
||||
export {};
|
||||
+234
@@ -0,0 +1,234 @@
|
||||
=== tests/cases/conformance/node/index.ts ===
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : Symbol(cjsi, Decl(index.ts, 1, 6))
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : Symbol(mjsi, Decl(index.ts, 2, 6))
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : Symbol(typei, Decl(index.ts, 3, 6))
|
||||
|
||||
cjsi;
|
||||
>cjsi : Symbol(cjsi, Decl(index.ts, 1, 6))
|
||||
|
||||
mjsi;
|
||||
>mjsi : Symbol(mjsi, Decl(index.ts, 2, 6))
|
||||
|
||||
typei;
|
||||
>typei : Symbol(typei, Decl(index.ts, 3, 6))
|
||||
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
>cjsi2 : Symbol(cjsi2, Decl(index.ts, 7, 6))
|
||||
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
>mjsi2 : Symbol(mjsi2, Decl(index.ts, 8, 6))
|
||||
|
||||
import * as typei2 from "inner/js/index";
|
||||
>typei2 : Symbol(typei2, Decl(index.ts, 9, 6))
|
||||
|
||||
cjsi2;
|
||||
>cjsi2 : Symbol(cjsi2, Decl(index.ts, 7, 6))
|
||||
|
||||
mjsi2;
|
||||
>mjsi2 : Symbol(mjsi2, Decl(index.ts, 8, 6))
|
||||
|
||||
typei2;
|
||||
>typei2 : Symbol(typei2, Decl(index.ts, 9, 6))
|
||||
|
||||
=== tests/cases/conformance/node/index.mts ===
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : Symbol(cjsi, Decl(index.mts, 1, 6))
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : Symbol(mjsi, Decl(index.mts, 2, 6))
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : Symbol(typei, Decl(index.mts, 3, 6))
|
||||
|
||||
cjsi;
|
||||
>cjsi : Symbol(cjsi, Decl(index.mts, 1, 6))
|
||||
|
||||
mjsi;
|
||||
>mjsi : Symbol(mjsi, Decl(index.mts, 2, 6))
|
||||
|
||||
typei;
|
||||
>typei : Symbol(typei, Decl(index.mts, 3, 6))
|
||||
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
>cjsi2 : Symbol(cjsi2, Decl(index.mts, 7, 6))
|
||||
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
>mjsi2 : Symbol(mjsi2, Decl(index.mts, 8, 6))
|
||||
|
||||
import * as typei2 from "inner/js/index";
|
||||
>typei2 : Symbol(typei2, Decl(index.mts, 9, 6))
|
||||
|
||||
cjsi2;
|
||||
>cjsi2 : Symbol(cjsi2, Decl(index.mts, 7, 6))
|
||||
|
||||
mjsi2;
|
||||
>mjsi2 : Symbol(mjsi2, Decl(index.mts, 8, 6))
|
||||
|
||||
typei2;
|
||||
>typei2 : Symbol(typei2, Decl(index.mts, 9, 6))
|
||||
|
||||
=== tests/cases/conformance/node/index.cts ===
|
||||
// cjs format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : Symbol(cjsi, Decl(index.cts, 1, 6))
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : Symbol(mjsi, Decl(index.cts, 2, 6))
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : Symbol(typei, Decl(index.cts, 3, 6))
|
||||
|
||||
cjsi;
|
||||
>cjsi : Symbol(cjsi, Decl(index.cts, 1, 6))
|
||||
|
||||
mjsi;
|
||||
>mjsi : Symbol(mjsi, Decl(index.cts, 2, 6))
|
||||
|
||||
typei;
|
||||
>typei : Symbol(typei, Decl(index.cts, 3, 6))
|
||||
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
>cjsi2 : Symbol(cjsi2, Decl(index.cts, 7, 6))
|
||||
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
>mjsi2 : Symbol(mjsi2, Decl(index.cts, 8, 6))
|
||||
|
||||
import * as typei2 from "inner/js/index";
|
||||
>typei2 : Symbol(typei2, Decl(index.cts, 9, 6))
|
||||
|
||||
cjsi2;
|
||||
>cjsi2 : Symbol(cjsi2, Decl(index.cts, 7, 6))
|
||||
|
||||
mjsi2;
|
||||
>mjsi2 : Symbol(mjsi2, Decl(index.cts, 8, 6))
|
||||
|
||||
typei2;
|
||||
>typei2 : Symbol(typei2, Decl(index.cts, 9, 6))
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/exclude/index.d.ts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : Symbol(type, Decl(index.d.ts, 3, 6))
|
||||
|
||||
export { cjs };
|
||||
>cjs : Symbol(cjs, Decl(index.d.ts, 4, 8))
|
||||
|
||||
export { mjs };
|
||||
>mjs : Symbol(mjs, Decl(index.d.ts, 5, 8))
|
||||
|
||||
export { type };
|
||||
>type : Symbol(type, Decl(index.d.ts, 6, 8))
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/exclude/index.d.mts ===
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : Symbol(type, Decl(index.d.mts, 3, 6))
|
||||
|
||||
export { cjs };
|
||||
>cjs : Symbol(cjs, Decl(index.d.mts, 4, 8))
|
||||
|
||||
export { mjs };
|
||||
>mjs : Symbol(mjs, Decl(index.d.mts, 5, 8))
|
||||
|
||||
export { type };
|
||||
>type : Symbol(type, Decl(index.d.mts, 6, 8))
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/exclude/index.d.cts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : Symbol(type, Decl(index.d.cts, 3, 6))
|
||||
|
||||
export { cjs };
|
||||
>cjs : Symbol(cjs, Decl(index.d.cts, 4, 8))
|
||||
|
||||
export { mjs };
|
||||
>mjs : Symbol(mjs, Decl(index.d.cts, 5, 8))
|
||||
|
||||
export { type };
|
||||
>type : Symbol(type, Decl(index.d.cts, 6, 8))
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
|
||||
|
||||
import * as mjs from "inner/mjs/index";
|
||||
>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
|
||||
|
||||
import * as type from "inner/js/index";
|
||||
>type : Symbol(type, Decl(index.d.ts, 3, 6))
|
||||
|
||||
export { cjs };
|
||||
>cjs : Symbol(mjs.cjs.cjs.type.cjs, Decl(index.d.ts, 4, 8))
|
||||
|
||||
export { mjs };
|
||||
>mjs : Symbol(mjs.cjs.cjs.type.mjs, Decl(index.d.ts, 5, 8))
|
||||
|
||||
export { type };
|
||||
>type : Symbol(mjs.cjs.cjs.type.type, Decl(index.d.ts, 6, 8))
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
|
||||
|
||||
import * as mjs from "inner/mjs/index";
|
||||
>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
|
||||
|
||||
import * as type from "inner/js/index";
|
||||
>type : Symbol(type, Decl(index.d.mts, 3, 6))
|
||||
|
||||
export { cjs };
|
||||
>cjs : Symbol(cjs.cjs.mjs.cjs, Decl(index.d.mts, 4, 8))
|
||||
|
||||
export { mjs };
|
||||
>mjs : Symbol(cjs.cjs.mjs.mjs, Decl(index.d.mts, 5, 8))
|
||||
|
||||
export { type };
|
||||
>type : Symbol(cjs.cjs.mjs.type, Decl(index.d.mts, 6, 8))
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
|
||||
|
||||
import * as mjs from "inner/mjs/index";
|
||||
>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
|
||||
|
||||
import * as type from "inner/js/index";
|
||||
>type : Symbol(type, Decl(index.d.cts, 3, 6))
|
||||
|
||||
export { cjs };
|
||||
>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 4, 8))
|
||||
|
||||
export { mjs };
|
||||
>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 5, 8))
|
||||
|
||||
export { type };
|
||||
>type : Symbol(cjs.type, Decl(index.d.cts, 6, 8))
|
||||
|
||||
+234
@@ -0,0 +1,234 @@
|
||||
=== tests/cases/conformance/node/index.ts ===
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : any
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : any
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : any
|
||||
|
||||
cjsi;
|
||||
>cjsi : any
|
||||
|
||||
mjsi;
|
||||
>mjsi : any
|
||||
|
||||
typei;
|
||||
>typei : any
|
||||
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
>cjsi2 : typeof cjsi2
|
||||
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
>mjsi2 : typeof cjsi2.cjs.mjs
|
||||
|
||||
import * as typei2 from "inner/js/index";
|
||||
>typei2 : typeof typei2
|
||||
|
||||
cjsi2;
|
||||
>cjsi2 : typeof cjsi2
|
||||
|
||||
mjsi2;
|
||||
>mjsi2 : typeof cjsi2.cjs.mjs
|
||||
|
||||
typei2;
|
||||
>typei2 : typeof typei2
|
||||
|
||||
=== tests/cases/conformance/node/index.mts ===
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : any
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : any
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : any
|
||||
|
||||
cjsi;
|
||||
>cjsi : any
|
||||
|
||||
mjsi;
|
||||
>mjsi : any
|
||||
|
||||
typei;
|
||||
>typei : any
|
||||
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
>cjsi2 : typeof cjsi2
|
||||
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
>mjsi2 : typeof cjsi2.cjs.mjs
|
||||
|
||||
import * as typei2 from "inner/js/index";
|
||||
>typei2 : typeof typei2
|
||||
|
||||
cjsi2;
|
||||
>cjsi2 : typeof cjsi2
|
||||
|
||||
mjsi2;
|
||||
>mjsi2 : typeof cjsi2.cjs.mjs
|
||||
|
||||
typei2;
|
||||
>typei2 : typeof typei2
|
||||
|
||||
=== tests/cases/conformance/node/index.cts ===
|
||||
// cjs format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : any
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : any
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : any
|
||||
|
||||
cjsi;
|
||||
>cjsi : any
|
||||
|
||||
mjsi;
|
||||
>mjsi : any
|
||||
|
||||
typei;
|
||||
>typei : any
|
||||
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
>cjsi2 : typeof cjsi2
|
||||
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
>mjsi2 : typeof cjsi2.mjs
|
||||
|
||||
import * as typei2 from "inner/js/index";
|
||||
>typei2 : typeof cjsi2.mjs.cjs.type
|
||||
|
||||
cjsi2;
|
||||
>cjsi2 : typeof cjsi2
|
||||
|
||||
mjsi2;
|
||||
>mjsi2 : typeof cjsi2.mjs
|
||||
|
||||
typei2;
|
||||
>typei2 : typeof cjsi2.mjs.cjs.type
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/exclude/index.d.ts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : any
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : any
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : any
|
||||
|
||||
export { cjs };
|
||||
>cjs : any
|
||||
|
||||
export { mjs };
|
||||
>mjs : any
|
||||
|
||||
export { type };
|
||||
>type : any
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/exclude/index.d.mts ===
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : any
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : any
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : any
|
||||
|
||||
export { cjs };
|
||||
>cjs : any
|
||||
|
||||
export { mjs };
|
||||
>mjs : any
|
||||
|
||||
export { type };
|
||||
>type : any
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/exclude/index.d.cts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : any
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : any
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : any
|
||||
|
||||
export { cjs };
|
||||
>cjs : any
|
||||
|
||||
export { mjs };
|
||||
>mjs : any
|
||||
|
||||
export { type };
|
||||
>type : any
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
>cjs : any
|
||||
|
||||
import * as mjs from "inner/mjs/index";
|
||||
>mjs : typeof mjs
|
||||
|
||||
import * as type from "inner/js/index";
|
||||
>type : typeof mjs.cjs.cjs.type
|
||||
|
||||
export { cjs };
|
||||
>cjs : any
|
||||
|
||||
export { mjs };
|
||||
>mjs : typeof mjs
|
||||
|
||||
export { type };
|
||||
>type : typeof mjs.cjs.cjs.type
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
>cjs : typeof cjs
|
||||
|
||||
import * as mjs from "inner/mjs/index";
|
||||
>mjs : typeof cjs.cjs.mjs
|
||||
|
||||
import * as type from "inner/js/index";
|
||||
>type : typeof cjs.cjs.mjs.type
|
||||
|
||||
export { cjs };
|
||||
>cjs : typeof cjs
|
||||
|
||||
export { mjs };
|
||||
>mjs : typeof cjs.cjs.mjs
|
||||
|
||||
export { type };
|
||||
>type : typeof cjs.cjs.mjs.type
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
>cjs : typeof cjs
|
||||
|
||||
import * as mjs from "inner/mjs/index";
|
||||
>mjs : typeof cjs.mjs
|
||||
|
||||
import * as type from "inner/js/index";
|
||||
>type : typeof cjs.mjs.cjs.type
|
||||
|
||||
export { cjs };
|
||||
>cjs : typeof cjs
|
||||
|
||||
export { mjs };
|
||||
>mjs : typeof cjs.mjs
|
||||
|
||||
export { type };
|
||||
>type : typeof cjs.mjs.cjs.type
|
||||
|
||||
+177
@@ -0,0 +1,177 @@
|
||||
tests/cases/conformance/node/index.cts(2,23): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/index.cts(3,23): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/index.cts(4,24): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/index.cts(9,24): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/index.mts(2,23): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/index.mts(3,23): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/index.mts(4,24): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/index.ts(2,23): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/index.ts(3,23): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/index.ts(4,24): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/exclude/index.d.cts(2,22): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/exclude/index.d.cts(3,22): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/exclude/index.d.cts(4,23): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/exclude/index.d.mts(2,22): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/exclude/index.d.mts(3,22): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/exclude/index.d.mts(4,23): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/exclude/index.d.ts(2,22): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/exclude/index.d.ts(3,22): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/exclude/index.d.ts(4,23): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'.
|
||||
tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
|
||||
|
||||
==== tests/cases/conformance/node/index.ts (3 errors) ====
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
import * as typei2 from "inner/js/index";
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
==== tests/cases/conformance/node/index.mts (3 errors) ====
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
import * as typei2 from "inner/js/index";
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
==== tests/cases/conformance/node/index.cts (4 errors) ====
|
||||
// cjs format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import * as typei2 from "inner/js/index";
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
==== tests/cases/conformance/node/node_modules/inner/exclude/index.d.ts (3 errors) ====
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as type from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
==== tests/cases/conformance/node/node_modules/inner/exclude/index.d.mts (3 errors) ====
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as type from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
==== tests/cases/conformance/node/node_modules/inner/exclude/index.d.cts (3 errors) ====
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations.
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations.
|
||||
import * as type from "inner/js/exclude/index";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations.
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
==== tests/cases/conformance/node/node_modules/inner/index.d.ts (2 errors) ====
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
~~~
|
||||
!!! error TS2303: Circular definition of import alias 'cjs'.
|
||||
import * as mjs from "inner/mjs/index";
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import * as type from "inner/js/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
==== tests/cases/conformance/node/node_modules/inner/index.d.mts (0 errors) ====
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
import * as mjs from "inner/mjs/index";
|
||||
import * as type from "inner/js/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
==== tests/cases/conformance/node/node_modules/inner/index.d.cts (1 errors) ====
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
import * as mjs from "inner/mjs/index";
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import * as type from "inner/js/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
==== tests/cases/conformance/node/package.json (0 errors) ====
|
||||
{
|
||||
"name": "package",
|
||||
"private": true,
|
||||
"type": "module"
|
||||
}
|
||||
==== tests/cases/conformance/node/node_modules/inner/package.json (0 errors) ====
|
||||
{
|
||||
"name": "inner",
|
||||
"private": true,
|
||||
"exports": {
|
||||
"./cjs/*": "./*.cjs",
|
||||
"./cjs/exclude/*": null,
|
||||
"./mjs/*": "./*.mjs",
|
||||
"./mjs/exclude/*": null,
|
||||
"./js/*": "./*.js",
|
||||
"./js/exclude/*": null
|
||||
}
|
||||
}
|
||||
+187
@@ -0,0 +1,187 @@
|
||||
//// [tests/cases/conformance/node/nodeModulesPackagePatternExportsExclude.ts] ////
|
||||
|
||||
//// [index.ts]
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
import * as typei2 from "inner/js/index";
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
//// [index.mts]
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
import * as typei2 from "inner/js/index";
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
//// [index.cts]
|
||||
// cjs format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
import * as typei2 from "inner/js/index";
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
//// [index.d.ts]
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
import * as type from "inner/js/exclude/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
//// [index.d.mts]
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
import * as type from "inner/js/exclude/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
//// [index.d.cts]
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
import * as type from "inner/js/exclude/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
//// [index.d.ts]
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
import * as mjs from "inner/mjs/index";
|
||||
import * as type from "inner/js/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
//// [index.d.mts]
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
import * as mjs from "inner/mjs/index";
|
||||
import * as type from "inner/js/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
//// [index.d.cts]
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
import * as mjs from "inner/mjs/index";
|
||||
import * as type from "inner/js/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "package",
|
||||
"private": true,
|
||||
"type": "module"
|
||||
}
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "inner",
|
||||
"private": true,
|
||||
"exports": {
|
||||
"./cjs/*": "./*.cjs",
|
||||
"./cjs/exclude/*": null,
|
||||
"./mjs/*": "./*.mjs",
|
||||
"./mjs/exclude/*": null,
|
||||
"./js/*": "./*.js",
|
||||
"./js/exclude/*": null
|
||||
}
|
||||
}
|
||||
|
||||
//// [index.js]
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
import * as typei2 from "inner/js/index";
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
//// [index.mjs]
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
import * as typei2 from "inner/js/index";
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
//// [index.cjs]
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// cjs format file
|
||||
const cjsi = __importStar(require("inner/cjs/exclude/index"));
|
||||
const mjsi = __importStar(require("inner/mjs/exclude/index"));
|
||||
const typei = __importStar(require("inner/js/exclude/index"));
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
const cjsi2 = __importStar(require("inner/cjs/index"));
|
||||
const mjsi2 = __importStar(require("inner/mjs/index"));
|
||||
const typei2 = __importStar(require("inner/js/index"));
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
|
||||
|
||||
//// [index.d.ts]
|
||||
export {};
|
||||
//// [index.d.mts]
|
||||
export {};
|
||||
//// [index.d.cts]
|
||||
export {};
|
||||
+234
@@ -0,0 +1,234 @@
|
||||
=== tests/cases/conformance/node/index.ts ===
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : Symbol(cjsi, Decl(index.ts, 1, 6))
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : Symbol(mjsi, Decl(index.ts, 2, 6))
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : Symbol(typei, Decl(index.ts, 3, 6))
|
||||
|
||||
cjsi;
|
||||
>cjsi : Symbol(cjsi, Decl(index.ts, 1, 6))
|
||||
|
||||
mjsi;
|
||||
>mjsi : Symbol(mjsi, Decl(index.ts, 2, 6))
|
||||
|
||||
typei;
|
||||
>typei : Symbol(typei, Decl(index.ts, 3, 6))
|
||||
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
>cjsi2 : Symbol(cjsi2, Decl(index.ts, 7, 6))
|
||||
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
>mjsi2 : Symbol(mjsi2, Decl(index.ts, 8, 6))
|
||||
|
||||
import * as typei2 from "inner/js/index";
|
||||
>typei2 : Symbol(typei2, Decl(index.ts, 9, 6))
|
||||
|
||||
cjsi2;
|
||||
>cjsi2 : Symbol(cjsi2, Decl(index.ts, 7, 6))
|
||||
|
||||
mjsi2;
|
||||
>mjsi2 : Symbol(mjsi2, Decl(index.ts, 8, 6))
|
||||
|
||||
typei2;
|
||||
>typei2 : Symbol(typei2, Decl(index.ts, 9, 6))
|
||||
|
||||
=== tests/cases/conformance/node/index.mts ===
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : Symbol(cjsi, Decl(index.mts, 1, 6))
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : Symbol(mjsi, Decl(index.mts, 2, 6))
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : Symbol(typei, Decl(index.mts, 3, 6))
|
||||
|
||||
cjsi;
|
||||
>cjsi : Symbol(cjsi, Decl(index.mts, 1, 6))
|
||||
|
||||
mjsi;
|
||||
>mjsi : Symbol(mjsi, Decl(index.mts, 2, 6))
|
||||
|
||||
typei;
|
||||
>typei : Symbol(typei, Decl(index.mts, 3, 6))
|
||||
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
>cjsi2 : Symbol(cjsi2, Decl(index.mts, 7, 6))
|
||||
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
>mjsi2 : Symbol(mjsi2, Decl(index.mts, 8, 6))
|
||||
|
||||
import * as typei2 from "inner/js/index";
|
||||
>typei2 : Symbol(typei2, Decl(index.mts, 9, 6))
|
||||
|
||||
cjsi2;
|
||||
>cjsi2 : Symbol(cjsi2, Decl(index.mts, 7, 6))
|
||||
|
||||
mjsi2;
|
||||
>mjsi2 : Symbol(mjsi2, Decl(index.mts, 8, 6))
|
||||
|
||||
typei2;
|
||||
>typei2 : Symbol(typei2, Decl(index.mts, 9, 6))
|
||||
|
||||
=== tests/cases/conformance/node/index.cts ===
|
||||
// cjs format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : Symbol(cjsi, Decl(index.cts, 1, 6))
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : Symbol(mjsi, Decl(index.cts, 2, 6))
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : Symbol(typei, Decl(index.cts, 3, 6))
|
||||
|
||||
cjsi;
|
||||
>cjsi : Symbol(cjsi, Decl(index.cts, 1, 6))
|
||||
|
||||
mjsi;
|
||||
>mjsi : Symbol(mjsi, Decl(index.cts, 2, 6))
|
||||
|
||||
typei;
|
||||
>typei : Symbol(typei, Decl(index.cts, 3, 6))
|
||||
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
>cjsi2 : Symbol(cjsi2, Decl(index.cts, 7, 6))
|
||||
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
>mjsi2 : Symbol(mjsi2, Decl(index.cts, 8, 6))
|
||||
|
||||
import * as typei2 from "inner/js/index";
|
||||
>typei2 : Symbol(typei2, Decl(index.cts, 9, 6))
|
||||
|
||||
cjsi2;
|
||||
>cjsi2 : Symbol(cjsi2, Decl(index.cts, 7, 6))
|
||||
|
||||
mjsi2;
|
||||
>mjsi2 : Symbol(mjsi2, Decl(index.cts, 8, 6))
|
||||
|
||||
typei2;
|
||||
>typei2 : Symbol(typei2, Decl(index.cts, 9, 6))
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/exclude/index.d.ts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : Symbol(type, Decl(index.d.ts, 3, 6))
|
||||
|
||||
export { cjs };
|
||||
>cjs : Symbol(cjs, Decl(index.d.ts, 4, 8))
|
||||
|
||||
export { mjs };
|
||||
>mjs : Symbol(mjs, Decl(index.d.ts, 5, 8))
|
||||
|
||||
export { type };
|
||||
>type : Symbol(type, Decl(index.d.ts, 6, 8))
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/exclude/index.d.mts ===
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : Symbol(type, Decl(index.d.mts, 3, 6))
|
||||
|
||||
export { cjs };
|
||||
>cjs : Symbol(cjs, Decl(index.d.mts, 4, 8))
|
||||
|
||||
export { mjs };
|
||||
>mjs : Symbol(mjs, Decl(index.d.mts, 5, 8))
|
||||
|
||||
export { type };
|
||||
>type : Symbol(type, Decl(index.d.mts, 6, 8))
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/exclude/index.d.cts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : Symbol(type, Decl(index.d.cts, 3, 6))
|
||||
|
||||
export { cjs };
|
||||
>cjs : Symbol(cjs, Decl(index.d.cts, 4, 8))
|
||||
|
||||
export { mjs };
|
||||
>mjs : Symbol(mjs, Decl(index.d.cts, 5, 8))
|
||||
|
||||
export { type };
|
||||
>type : Symbol(type, Decl(index.d.cts, 6, 8))
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
>cjs : Symbol(cjs, Decl(index.d.ts, 1, 6))
|
||||
|
||||
import * as mjs from "inner/mjs/index";
|
||||
>mjs : Symbol(mjs, Decl(index.d.ts, 2, 6))
|
||||
|
||||
import * as type from "inner/js/index";
|
||||
>type : Symbol(type, Decl(index.d.ts, 3, 6))
|
||||
|
||||
export { cjs };
|
||||
>cjs : Symbol(mjs.cjs.cjs.type.cjs, Decl(index.d.ts, 4, 8))
|
||||
|
||||
export { mjs };
|
||||
>mjs : Symbol(mjs.cjs.cjs.type.mjs, Decl(index.d.ts, 5, 8))
|
||||
|
||||
export { type };
|
||||
>type : Symbol(mjs.cjs.cjs.type.type, Decl(index.d.ts, 6, 8))
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
>cjs : Symbol(cjs, Decl(index.d.mts, 1, 6))
|
||||
|
||||
import * as mjs from "inner/mjs/index";
|
||||
>mjs : Symbol(mjs, Decl(index.d.mts, 2, 6))
|
||||
|
||||
import * as type from "inner/js/index";
|
||||
>type : Symbol(type, Decl(index.d.mts, 3, 6))
|
||||
|
||||
export { cjs };
|
||||
>cjs : Symbol(cjs.cjs.mjs.cjs, Decl(index.d.mts, 4, 8))
|
||||
|
||||
export { mjs };
|
||||
>mjs : Symbol(cjs.cjs.mjs.mjs, Decl(index.d.mts, 5, 8))
|
||||
|
||||
export { type };
|
||||
>type : Symbol(cjs.cjs.mjs.type, Decl(index.d.mts, 6, 8))
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
>cjs : Symbol(cjs, Decl(index.d.cts, 1, 6))
|
||||
|
||||
import * as mjs from "inner/mjs/index";
|
||||
>mjs : Symbol(mjs, Decl(index.d.cts, 2, 6))
|
||||
|
||||
import * as type from "inner/js/index";
|
||||
>type : Symbol(type, Decl(index.d.cts, 3, 6))
|
||||
|
||||
export { cjs };
|
||||
>cjs : Symbol(cjs.cjs, Decl(index.d.cts, 4, 8))
|
||||
|
||||
export { mjs };
|
||||
>mjs : Symbol(cjs.mjs, Decl(index.d.cts, 5, 8))
|
||||
|
||||
export { type };
|
||||
>type : Symbol(cjs.type, Decl(index.d.cts, 6, 8))
|
||||
|
||||
+234
@@ -0,0 +1,234 @@
|
||||
=== tests/cases/conformance/node/index.ts ===
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : any
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : any
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : any
|
||||
|
||||
cjsi;
|
||||
>cjsi : any
|
||||
|
||||
mjsi;
|
||||
>mjsi : any
|
||||
|
||||
typei;
|
||||
>typei : any
|
||||
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
>cjsi2 : typeof cjsi2
|
||||
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
>mjsi2 : typeof cjsi2.cjs.mjs
|
||||
|
||||
import * as typei2 from "inner/js/index";
|
||||
>typei2 : typeof typei2
|
||||
|
||||
cjsi2;
|
||||
>cjsi2 : typeof cjsi2
|
||||
|
||||
mjsi2;
|
||||
>mjsi2 : typeof cjsi2.cjs.mjs
|
||||
|
||||
typei2;
|
||||
>typei2 : typeof typei2
|
||||
|
||||
=== tests/cases/conformance/node/index.mts ===
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : any
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : any
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : any
|
||||
|
||||
cjsi;
|
||||
>cjsi : any
|
||||
|
||||
mjsi;
|
||||
>mjsi : any
|
||||
|
||||
typei;
|
||||
>typei : any
|
||||
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
>cjsi2 : typeof cjsi2
|
||||
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
>mjsi2 : typeof cjsi2.cjs.mjs
|
||||
|
||||
import * as typei2 from "inner/js/index";
|
||||
>typei2 : typeof typei2
|
||||
|
||||
cjsi2;
|
||||
>cjsi2 : typeof cjsi2
|
||||
|
||||
mjsi2;
|
||||
>mjsi2 : typeof cjsi2.cjs.mjs
|
||||
|
||||
typei2;
|
||||
>typei2 : typeof typei2
|
||||
|
||||
=== tests/cases/conformance/node/index.cts ===
|
||||
// cjs format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
>cjsi : any
|
||||
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
>mjsi : any
|
||||
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
>typei : any
|
||||
|
||||
cjsi;
|
||||
>cjsi : any
|
||||
|
||||
mjsi;
|
||||
>mjsi : any
|
||||
|
||||
typei;
|
||||
>typei : any
|
||||
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
>cjsi2 : typeof cjsi2
|
||||
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
>mjsi2 : typeof cjsi2.mjs
|
||||
|
||||
import * as typei2 from "inner/js/index";
|
||||
>typei2 : typeof cjsi2.mjs.cjs.type
|
||||
|
||||
cjsi2;
|
||||
>cjsi2 : typeof cjsi2
|
||||
|
||||
mjsi2;
|
||||
>mjsi2 : typeof cjsi2.mjs
|
||||
|
||||
typei2;
|
||||
>typei2 : typeof cjsi2.mjs.cjs.type
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/exclude/index.d.ts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : any
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : any
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : any
|
||||
|
||||
export { cjs };
|
||||
>cjs : any
|
||||
|
||||
export { mjs };
|
||||
>mjs : any
|
||||
|
||||
export { type };
|
||||
>type : any
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/exclude/index.d.mts ===
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : any
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : any
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : any
|
||||
|
||||
export { cjs };
|
||||
>cjs : any
|
||||
|
||||
export { mjs };
|
||||
>mjs : any
|
||||
|
||||
export { type };
|
||||
>type : any
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/exclude/index.d.cts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
>cjs : any
|
||||
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
>mjs : any
|
||||
|
||||
import * as type from "inner/js/exclude/index";
|
||||
>type : any
|
||||
|
||||
export { cjs };
|
||||
>cjs : any
|
||||
|
||||
export { mjs };
|
||||
>mjs : any
|
||||
|
||||
export { type };
|
||||
>type : any
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/index.d.ts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
>cjs : any
|
||||
|
||||
import * as mjs from "inner/mjs/index";
|
||||
>mjs : typeof mjs
|
||||
|
||||
import * as type from "inner/js/index";
|
||||
>type : typeof mjs.cjs.cjs.type
|
||||
|
||||
export { cjs };
|
||||
>cjs : any
|
||||
|
||||
export { mjs };
|
||||
>mjs : typeof mjs
|
||||
|
||||
export { type };
|
||||
>type : typeof mjs.cjs.cjs.type
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/index.d.mts ===
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
>cjs : typeof cjs
|
||||
|
||||
import * as mjs from "inner/mjs/index";
|
||||
>mjs : typeof cjs.cjs.mjs
|
||||
|
||||
import * as type from "inner/js/index";
|
||||
>type : typeof cjs.cjs.mjs.type
|
||||
|
||||
export { cjs };
|
||||
>cjs : typeof cjs
|
||||
|
||||
export { mjs };
|
||||
>mjs : typeof cjs.cjs.mjs
|
||||
|
||||
export { type };
|
||||
>type : typeof cjs.cjs.mjs.type
|
||||
|
||||
=== tests/cases/conformance/node/node_modules/inner/index.d.cts ===
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
>cjs : typeof cjs
|
||||
|
||||
import * as mjs from "inner/mjs/index";
|
||||
>mjs : typeof cjs.mjs
|
||||
|
||||
import * as type from "inner/js/index";
|
||||
>type : typeof cjs.mjs.cjs.type
|
||||
|
||||
export { cjs };
|
||||
>cjs : typeof cjs
|
||||
|
||||
export { mjs };
|
||||
>mjs : typeof cjs.mjs
|
||||
|
||||
export { type };
|
||||
>type : typeof cjs.mjs.cjs.type
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
/index.ts(1,23): error TS1452: Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`.
|
||||
/index.ts(1,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
|
||||
/index.ts(1,23): error TS2688: Cannot find type definition file for 'pkg'.
|
||||
/index.ts(2,23): error TS1452: Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`.
|
||||
/index.ts(2,23): error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
|
||||
/index.ts(2,23): error TS2688: Cannot find type definition file for 'pkg'.
|
||||
/index.ts(3,1): error TS2304: Cannot find name 'foo'.
|
||||
/index.ts(4,1): error TS2304: Cannot find name 'bar'.
|
||||
@@ -9,12 +9,12 @@
|
||||
==== /index.ts (6 errors) ====
|
||||
/// <reference types="pkg" resolution-mode="require" />
|
||||
~~~
|
||||
!!! error TS1452: Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`.
|
||||
!!! error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
|
||||
~~~
|
||||
!!! error TS2688: Cannot find type definition file for 'pkg'.
|
||||
/// <reference types="pkg" resolution-mode="import" />
|
||||
~~~
|
||||
!!! error TS1452: Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`.
|
||||
!!! error TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.
|
||||
~~~
|
||||
!!! error TS2688: Cannot find type definition file for 'pkg'.
|
||||
foo; // `resolution-mode` is an error in old resolution settings, which resolves is arbitrary
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/index.cts(4,21): error TS2307: Cannot find module 'dedent4' or its corresponding type declarations.
|
||||
/index.mts(4,21): error TS2307: Cannot find module 'dedent4' or its corresponding type declarations.
|
||||
|
||||
|
||||
==== /node_modules/@types/dedent/package.json (0 errors) ====
|
||||
{ "name": "@types/dedent", "version": "1.0.0", "main": "" }
|
||||
|
||||
==== /node_modules/@types/dedent2/package.json (0 errors) ====
|
||||
{ "name": "@types/dedent2", "version": "1.0.0", "main": "asdfasdfasdf" }
|
||||
|
||||
==== /node_modules/@types/dedent3/package.json (0 errors) ====
|
||||
{ "name": "@types/dedent3", "version": "1.0.0", "main": "asdfasdfasdf", "exports": null }
|
||||
|
||||
==== /node_modules/@types/dedent4/package.json (0 errors) ====
|
||||
{ "name": "@types/dedent4", "version": "1.0.0", "main": "asdfasdfasdf", "exports": "./asdfasdfasdf" }
|
||||
|
||||
==== /node_modules/@types/dedent/index.d.ts (0 errors) ====
|
||||
export {};
|
||||
|
||||
==== /node_modules/@types/dedent2/index.d.ts (0 errors) ====
|
||||
export {};
|
||||
|
||||
==== /node_modules/@types/dedent3/index.d.ts (0 errors) ====
|
||||
export {};
|
||||
|
||||
==== /node_modules/@types/dedent4/index.d.ts (0 errors) ====
|
||||
export {};
|
||||
|
||||
==== /index.mts (1 errors) ====
|
||||
import dedent from "dedent";
|
||||
import dedent2 from "dedent2";
|
||||
import dedent3 from "dedent3";
|
||||
import dedent4 from "dedent4"; // Error
|
||||
~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'dedent4' or its corresponding type declarations.
|
||||
|
||||
==== /index.cts (1 errors) ====
|
||||
import dedent from "dedent";
|
||||
import dedent2 from "dedent2";
|
||||
import dedent3 from "dedent3";
|
||||
import dedent4 from "dedent4"; // Error
|
||||
~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'dedent4' or its corresponding type declarations.
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
//// [tests/cases/compiler/nodeNextImportModeImplicitIndexResolution2.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{ "name": "@types/dedent", "version": "1.0.0", "main": "" }
|
||||
|
||||
//// [package.json]
|
||||
{ "name": "@types/dedent2", "version": "1.0.0", "main": "asdfasdfasdf" }
|
||||
|
||||
//// [package.json]
|
||||
{ "name": "@types/dedent3", "version": "1.0.0", "main": "asdfasdfasdf", "exports": null }
|
||||
|
||||
//// [package.json]
|
||||
{ "name": "@types/dedent4", "version": "1.0.0", "main": "asdfasdfasdf", "exports": "./asdfasdfasdf" }
|
||||
|
||||
//// [index.d.ts]
|
||||
export {};
|
||||
|
||||
//// [index.d.ts]
|
||||
export {};
|
||||
|
||||
//// [index.d.ts]
|
||||
export {};
|
||||
|
||||
//// [index.d.ts]
|
||||
export {};
|
||||
|
||||
//// [index.mts]
|
||||
import dedent from "dedent";
|
||||
import dedent2 from "dedent2";
|
||||
import dedent3 from "dedent3";
|
||||
import dedent4 from "dedent4"; // Error
|
||||
|
||||
//// [index.cts]
|
||||
import dedent from "dedent";
|
||||
import dedent2 from "dedent2";
|
||||
import dedent3 from "dedent3";
|
||||
import dedent4 from "dedent4"; // Error
|
||||
|
||||
|
||||
//// [index.mjs]
|
||||
export {};
|
||||
//// [index.cjs]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
@@ -0,0 +1,38 @@
|
||||
=== /node_modules/@types/dedent/index.d.ts ===
|
||||
export {};
|
||||
No type information for this code.
|
||||
No type information for this code.=== /node_modules/@types/dedent2/index.d.ts ===
|
||||
export {};
|
||||
No type information for this code.
|
||||
No type information for this code.=== /node_modules/@types/dedent3/index.d.ts ===
|
||||
export {};
|
||||
No type information for this code.
|
||||
No type information for this code.=== /node_modules/@types/dedent4/index.d.ts ===
|
||||
export {};
|
||||
No type information for this code.
|
||||
No type information for this code.=== /index.mts ===
|
||||
import dedent from "dedent";
|
||||
>dedent : Symbol(dedent, Decl(index.mts, 0, 6))
|
||||
|
||||
import dedent2 from "dedent2";
|
||||
>dedent2 : Symbol(dedent2, Decl(index.mts, 1, 6))
|
||||
|
||||
import dedent3 from "dedent3";
|
||||
>dedent3 : Symbol(dedent3, Decl(index.mts, 2, 6))
|
||||
|
||||
import dedent4 from "dedent4"; // Error
|
||||
>dedent4 : Symbol(dedent4, Decl(index.mts, 3, 6))
|
||||
|
||||
=== /index.cts ===
|
||||
import dedent from "dedent";
|
||||
>dedent : Symbol(dedent, Decl(index.cts, 0, 6))
|
||||
|
||||
import dedent2 from "dedent2";
|
||||
>dedent2 : Symbol(dedent2, Decl(index.cts, 1, 6))
|
||||
|
||||
import dedent3 from "dedent3";
|
||||
>dedent3 : Symbol(dedent3, Decl(index.cts, 2, 6))
|
||||
|
||||
import dedent4 from "dedent4"; // Error
|
||||
>dedent4 : Symbol(dedent4, Decl(index.cts, 3, 6))
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
=== /node_modules/@types/dedent/index.d.ts ===
|
||||
export {};
|
||||
No type information for this code.
|
||||
No type information for this code.=== /node_modules/@types/dedent2/index.d.ts ===
|
||||
export {};
|
||||
No type information for this code.
|
||||
No type information for this code.=== /node_modules/@types/dedent3/index.d.ts ===
|
||||
export {};
|
||||
No type information for this code.
|
||||
No type information for this code.=== /node_modules/@types/dedent4/index.d.ts ===
|
||||
export {};
|
||||
No type information for this code.
|
||||
No type information for this code.=== /index.mts ===
|
||||
import dedent from "dedent";
|
||||
>dedent : typeof dedent
|
||||
|
||||
import dedent2 from "dedent2";
|
||||
>dedent2 : typeof dedent2
|
||||
|
||||
import dedent3 from "dedent3";
|
||||
>dedent3 : typeof dedent3
|
||||
|
||||
import dedent4 from "dedent4"; // Error
|
||||
>dedent4 : any
|
||||
|
||||
=== /index.cts ===
|
||||
import dedent from "dedent";
|
||||
>dedent : typeof dedent
|
||||
|
||||
import dedent2 from "dedent2";
|
||||
>dedent2 : typeof dedent2
|
||||
|
||||
import dedent3 from "dedent3";
|
||||
>dedent3 : typeof dedent3
|
||||
|
||||
import dedent4 from "dedent4"; // Error
|
||||
>dedent4 : any
|
||||
|
||||
@@ -25,7 +25,7 @@ function fn<T extends string | undefined, U extends string>(one: T, two: U) {
|
||||
foo(two!);
|
||||
>foo(two!) : void
|
||||
>foo : (p: string) => void
|
||||
>two! : NonNullable<U>
|
||||
>two! : U
|
||||
>two : U
|
||||
|
||||
foo(three!); // this line is the important one
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
//// [nonNullableTypes1.ts]
|
||||
function f1<T>(x: T) {
|
||||
let y = x || "hello"; // NonNullable<T> | string
|
||||
}
|
||||
|
||||
function error(): never {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
function f2<T>(x: T) { // NonNullable<T>
|
||||
return x || error();
|
||||
}
|
||||
|
||||
function f3(x: unknown) {
|
||||
let y = x!; // {}
|
||||
}
|
||||
|
||||
function f4<T extends { x: string } | undefined>(obj: T) {
|
||||
if (obj?.x === "hello") {
|
||||
obj; // NonNullable<T>
|
||||
}
|
||||
if (obj?.x) {
|
||||
obj; // NonNullable<T>
|
||||
}
|
||||
if (typeof obj?.x === "string") {
|
||||
obj; // NonNullable<T>
|
||||
}
|
||||
}
|
||||
|
||||
class A {
|
||||
x = "hello";
|
||||
foo() {
|
||||
let zz = this?.x; // string
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [nonNullableTypes1.js]
|
||||
"use strict";
|
||||
function f1(x) {
|
||||
var y = x || "hello"; // NonNullable<T> | string
|
||||
}
|
||||
function error() {
|
||||
throw new Error();
|
||||
}
|
||||
function f2(x) {
|
||||
return x || error();
|
||||
}
|
||||
function f3(x) {
|
||||
var y = x; // {}
|
||||
}
|
||||
function f4(obj) {
|
||||
if ((obj === null || obj === void 0 ? void 0 : obj.x) === "hello") {
|
||||
obj; // NonNullable<T>
|
||||
}
|
||||
if (obj === null || obj === void 0 ? void 0 : obj.x) {
|
||||
obj; // NonNullable<T>
|
||||
}
|
||||
if (typeof (obj === null || obj === void 0 ? void 0 : obj.x) === "string") {
|
||||
obj; // NonNullable<T>
|
||||
}
|
||||
}
|
||||
var A = /** @class */ (function () {
|
||||
function A() {
|
||||
this.x = "hello";
|
||||
}
|
||||
A.prototype.foo = function () {
|
||||
var zz = this === null || this === void 0 ? void 0 : this.x; // string
|
||||
};
|
||||
return A;
|
||||
}());
|
||||
|
||||
|
||||
//// [nonNullableTypes1.d.ts]
|
||||
declare function f1<T>(x: T): void;
|
||||
declare function error(): never;
|
||||
declare function f2<T>(x: T): NonNullable<T>;
|
||||
declare function f3(x: unknown): void;
|
||||
declare function f4<T extends {
|
||||
x: string;
|
||||
} | undefined>(obj: T): void;
|
||||
declare class A {
|
||||
x: string;
|
||||
foo(): void;
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
=== tests/cases/compiler/nonNullableTypes1.ts ===
|
||||
function f1<T>(x: T) {
|
||||
>f1 : Symbol(f1, Decl(nonNullableTypes1.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(nonNullableTypes1.ts, 0, 12))
|
||||
>x : Symbol(x, Decl(nonNullableTypes1.ts, 0, 15))
|
||||
>T : Symbol(T, Decl(nonNullableTypes1.ts, 0, 12))
|
||||
|
||||
let y = x || "hello"; // NonNullable<T> | string
|
||||
>y : Symbol(y, Decl(nonNullableTypes1.ts, 1, 7))
|
||||
>x : Symbol(x, Decl(nonNullableTypes1.ts, 0, 15))
|
||||
}
|
||||
|
||||
function error(): never {
|
||||
>error : Symbol(error, Decl(nonNullableTypes1.ts, 2, 1))
|
||||
|
||||
throw new Error();
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
|
||||
function f2<T>(x: T) { // NonNullable<T>
|
||||
>f2 : Symbol(f2, Decl(nonNullableTypes1.ts, 6, 1))
|
||||
>T : Symbol(T, Decl(nonNullableTypes1.ts, 8, 12))
|
||||
>x : Symbol(x, Decl(nonNullableTypes1.ts, 8, 15))
|
||||
>T : Symbol(T, Decl(nonNullableTypes1.ts, 8, 12))
|
||||
|
||||
return x || error();
|
||||
>x : Symbol(x, Decl(nonNullableTypes1.ts, 8, 15))
|
||||
>error : Symbol(error, Decl(nonNullableTypes1.ts, 2, 1))
|
||||
}
|
||||
|
||||
function f3(x: unknown) {
|
||||
>f3 : Symbol(f3, Decl(nonNullableTypes1.ts, 10, 1))
|
||||
>x : Symbol(x, Decl(nonNullableTypes1.ts, 12, 12))
|
||||
|
||||
let y = x!; // {}
|
||||
>y : Symbol(y, Decl(nonNullableTypes1.ts, 13, 7))
|
||||
>x : Symbol(x, Decl(nonNullableTypes1.ts, 12, 12))
|
||||
}
|
||||
|
||||
function f4<T extends { x: string } | undefined>(obj: T) {
|
||||
>f4 : Symbol(f4, Decl(nonNullableTypes1.ts, 14, 1))
|
||||
>T : Symbol(T, Decl(nonNullableTypes1.ts, 16, 12))
|
||||
>x : Symbol(x, Decl(nonNullableTypes1.ts, 16, 23))
|
||||
>obj : Symbol(obj, Decl(nonNullableTypes1.ts, 16, 49))
|
||||
>T : Symbol(T, Decl(nonNullableTypes1.ts, 16, 12))
|
||||
|
||||
if (obj?.x === "hello") {
|
||||
>obj?.x : Symbol(x, Decl(nonNullableTypes1.ts, 16, 23))
|
||||
>obj : Symbol(obj, Decl(nonNullableTypes1.ts, 16, 49))
|
||||
>x : Symbol(x, Decl(nonNullableTypes1.ts, 16, 23))
|
||||
|
||||
obj; // NonNullable<T>
|
||||
>obj : Symbol(obj, Decl(nonNullableTypes1.ts, 16, 49))
|
||||
}
|
||||
if (obj?.x) {
|
||||
>obj?.x : Symbol(x, Decl(nonNullableTypes1.ts, 16, 23))
|
||||
>obj : Symbol(obj, Decl(nonNullableTypes1.ts, 16, 49))
|
||||
>x : Symbol(x, Decl(nonNullableTypes1.ts, 16, 23))
|
||||
|
||||
obj; // NonNullable<T>
|
||||
>obj : Symbol(obj, Decl(nonNullableTypes1.ts, 16, 49))
|
||||
}
|
||||
if (typeof obj?.x === "string") {
|
||||
>obj?.x : Symbol(x, Decl(nonNullableTypes1.ts, 16, 23))
|
||||
>obj : Symbol(obj, Decl(nonNullableTypes1.ts, 16, 49))
|
||||
>x : Symbol(x, Decl(nonNullableTypes1.ts, 16, 23))
|
||||
|
||||
obj; // NonNullable<T>
|
||||
>obj : Symbol(obj, Decl(nonNullableTypes1.ts, 16, 49))
|
||||
}
|
||||
}
|
||||
|
||||
class A {
|
||||
>A : Symbol(A, Decl(nonNullableTypes1.ts, 26, 1))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(A.x, Decl(nonNullableTypes1.ts, 28, 9))
|
||||
|
||||
foo() {
|
||||
>foo : Symbol(A.foo, Decl(nonNullableTypes1.ts, 29, 16))
|
||||
|
||||
let zz = this?.x; // string
|
||||
>zz : Symbol(zz, Decl(nonNullableTypes1.ts, 31, 11))
|
||||
>this?.x : Symbol(A.x, Decl(nonNullableTypes1.ts, 28, 9))
|
||||
>this : Symbol(A, Decl(nonNullableTypes1.ts, 26, 1))
|
||||
>x : Symbol(A.x, Decl(nonNullableTypes1.ts, 28, 9))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
=== tests/cases/compiler/nonNullableTypes1.ts ===
|
||||
function f1<T>(x: T) {
|
||||
>f1 : <T>(x: T) => void
|
||||
>x : T
|
||||
|
||||
let y = x || "hello"; // NonNullable<T> | string
|
||||
>y : string | NonNullable<T>
|
||||
>x || "hello" : "hello" | NonNullable<T>
|
||||
>x : T
|
||||
>"hello" : "hello"
|
||||
}
|
||||
|
||||
function error(): never {
|
||||
>error : () => never
|
||||
|
||||
throw new Error();
|
||||
>new Error() : Error
|
||||
>Error : ErrorConstructor
|
||||
}
|
||||
|
||||
function f2<T>(x: T) { // NonNullable<T>
|
||||
>f2 : <T>(x: T) => NonNullable<T>
|
||||
>x : T
|
||||
|
||||
return x || error();
|
||||
>x || error() : NonNullable<T>
|
||||
>x : T
|
||||
>error() : never
|
||||
>error : () => never
|
||||
}
|
||||
|
||||
function f3(x: unknown) {
|
||||
>f3 : (x: unknown) => void
|
||||
>x : unknown
|
||||
|
||||
let y = x!; // {}
|
||||
>y : {}
|
||||
>x! : {}
|
||||
>x : unknown
|
||||
}
|
||||
|
||||
function f4<T extends { x: string } | undefined>(obj: T) {
|
||||
>f4 : <T extends { x: string; } | undefined>(obj: T) => void
|
||||
>x : string
|
||||
>obj : T
|
||||
|
||||
if (obj?.x === "hello") {
|
||||
>obj?.x === "hello" : boolean
|
||||
>obj?.x : string | undefined
|
||||
>obj : { x: string; } | undefined
|
||||
>x : string | undefined
|
||||
>"hello" : "hello"
|
||||
|
||||
obj; // NonNullable<T>
|
||||
>obj : NonNullable<T>
|
||||
}
|
||||
if (obj?.x) {
|
||||
>obj?.x : string | undefined
|
||||
>obj : { x: string; } | undefined
|
||||
>x : string | undefined
|
||||
|
||||
obj; // NonNullable<T>
|
||||
>obj : NonNullable<T>
|
||||
}
|
||||
if (typeof obj?.x === "string") {
|
||||
>typeof obj?.x === "string" : boolean
|
||||
>typeof obj?.x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
|
||||
>obj?.x : string | undefined
|
||||
>obj : { x: string; } | undefined
|
||||
>x : string | undefined
|
||||
>"string" : "string"
|
||||
|
||||
obj; // NonNullable<T>
|
||||
>obj : NonNullable<T>
|
||||
}
|
||||
}
|
||||
|
||||
class A {
|
||||
>A : A
|
||||
|
||||
x = "hello";
|
||||
>x : string
|
||||
>"hello" : "hello"
|
||||
|
||||
foo() {
|
||||
>foo : () => void
|
||||
|
||||
let zz = this?.x; // string
|
||||
>zz : string
|
||||
>this?.x : string
|
||||
>this : this
|
||||
>x : string
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ const aa6 = a6 ?? 'whatever'
|
||||
>'whatever' : "whatever"
|
||||
|
||||
const aa7 = a7 ?? 'whatever'
|
||||
>aa7 : unknown
|
||||
>a7 ?? 'whatever' : unknown
|
||||
>aa7 : {}
|
||||
>a7 ?? 'whatever' : {}
|
||||
>a7 : unknown
|
||||
>'whatever' : "whatever"
|
||||
|
||||
|
||||
@@ -75,8 +75,8 @@ const aa6 = a6 ?? 'whatever'
|
||||
>'whatever' : "whatever"
|
||||
|
||||
const aa7 = a7 ?? 'whatever'
|
||||
>aa7 : unknown
|
||||
>a7 ?? 'whatever' : unknown
|
||||
>aa7 : {}
|
||||
>a7 ?? 'whatever' : {}
|
||||
>a7 : unknown
|
||||
>'whatever' : "whatever"
|
||||
|
||||
|
||||
@@ -12,12 +12,14 @@ Foo.Bar<T>();
|
||||
Foo<T>.Bar();
|
||||
>Foo<T>.Bar() : any
|
||||
>Foo<T>.Bar : any
|
||||
>Foo<T> : any
|
||||
>Foo : any
|
||||
>Bar : any
|
||||
|
||||
Foo<T>.Bar<T>();
|
||||
>Foo<T>.Bar<T>() : any
|
||||
>Foo<T>.Bar : any
|
||||
>Foo<T> : any
|
||||
>Foo : any
|
||||
>Bar : any
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ var v = List<number>.makeChild();
|
||||
>v : any
|
||||
>List<number>.makeChild() : any
|
||||
>List<number>.makeChild : any
|
||||
>List<number> : any
|
||||
>List : any
|
||||
>makeChild : any
|
||||
|
||||
|
||||
@@ -28,10 +28,10 @@ class A {
|
||||
|
||||
this?.getA().#b; // Error
|
||||
>this?.getA().#b : A | undefined
|
||||
>this?.getA() : A | undefined
|
||||
>this?.getA : (() => A) | undefined
|
||||
>this?.getA() : A
|
||||
>this?.getA : () => A
|
||||
>this : this
|
||||
>getA : (() => A) | undefined
|
||||
>getA : () => A
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ function JustConditional<T>(): ConditionalType<T> {
|
||||
>JustConditional : <T>() => ConditionalType<T>
|
||||
|
||||
return ConditionalOrUndefined<T>()!; // shouldn't error
|
||||
>ConditionalOrUndefined<T>()! : NonNullable<ConditionalType<T>>
|
||||
>ConditionalOrUndefined<T>()! : ConditionalType<T>
|
||||
>ConditionalOrUndefined<T>() : ConditionalType<T> | undefined
|
||||
>ConditionalOrUndefined : <T>() => ConditionalType<T> | undefined
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// @strict: true
|
||||
// @declaration: true
|
||||
// @filename: a.d.ts
|
||||
export declare const timestampSymbol: unique symbol;
|
||||
|
||||
export declare const Timestamp: {
|
||||
[TKey in typeof timestampSymbol]: true;
|
||||
};
|
||||
|
||||
export declare function now(): typeof Timestamp;
|
||||
|
||||
// @filename: b.ts
|
||||
import * as x from "./a";
|
||||
export const timestamp = x.now();
|
||||
|
||||
// @filename: c.ts
|
||||
import { now } from "./a";
|
||||
|
||||
export const timestamp = now();
|
||||
@@ -0,0 +1,27 @@
|
||||
// @lib: es2015
|
||||
// @strictNullChecks: true
|
||||
const a: { x?: number; y?: number } = { };
|
||||
|
||||
let x: number;
|
||||
|
||||
// Should not error out
|
||||
({ x = 0 } = a);
|
||||
({ x: x = 0} = a);
|
||||
({ y: x = 0} = a);
|
||||
|
||||
// Should be error
|
||||
({ x = undefined } = a);
|
||||
({ x: x = undefined } = a);
|
||||
({ y: x = undefined } = a);
|
||||
|
||||
const { x: z1 } = a;
|
||||
const { x: z2 = 0 } = a;
|
||||
const { x: z3 = undefined } = a;
|
||||
|
||||
|
||||
declare const r: Iterator<number>;
|
||||
let done: boolean;
|
||||
let value;
|
||||
|
||||
({ done = false, value } = r.next());
|
||||
({ done: done = false, value } = r.next());
|
||||
@@ -41,6 +41,13 @@ interface c extends a, b {
|
||||
interface d extends a {
|
||||
}
|
||||
|
||||
interface e extends number {
|
||||
}
|
||||
|
||||
interface f {
|
||||
prop: typeof string;
|
||||
}
|
||||
|
||||
class c1 implements a {
|
||||
}
|
||||
var instance2 = new c1();
|
||||
@@ -0,0 +1,6 @@
|
||||
class A {
|
||||
b() {}
|
||||
}
|
||||
|
||||
new A?.b() // error
|
||||
new A()?.b() // ok
|
||||
@@ -0,0 +1,46 @@
|
||||
// @strict: true
|
||||
// @declaration: true
|
||||
|
||||
// Repro from #49242
|
||||
|
||||
type Types = {
|
||||
first: { a1: true };
|
||||
second: { a2: true };
|
||||
third: { a3: true };
|
||||
}
|
||||
|
||||
class Test {
|
||||
entries: { [T in keyof Types]?: Types[T][] };
|
||||
|
||||
constructor() {
|
||||
this.entries = {};
|
||||
}
|
||||
|
||||
addEntry<T extends keyof Types>(name: T, entry: Types[T]) {
|
||||
if (!this.entries[name]) {
|
||||
this.entries[name] = [];
|
||||
}
|
||||
this.entries[name]?.push(entry);
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #49338
|
||||
|
||||
type TypesMap = {
|
||||
[0]: { foo: 'bar'; };
|
||||
[1]: { a: 'b'; };
|
||||
};
|
||||
|
||||
type P<T extends keyof TypesMap> = { t: T; } & TypesMap[T];
|
||||
|
||||
type TypeHandlers = {
|
||||
[T in keyof TypesMap]?: (p: P<T>) => void;
|
||||
};
|
||||
|
||||
const typeHandlers: TypeHandlers = {
|
||||
[0]: (p) => console.log(p.foo),
|
||||
[1]: (p) => console.log(p.a),
|
||||
};
|
||||
|
||||
const onSomeEvent = <T extends keyof TypesMap>(p: P<T>) =>
|
||||
typeHandlers[p.t]?.(p);
|
||||
@@ -0,0 +1,37 @@
|
||||
// @module: nodenext
|
||||
|
||||
// @Filename: /node_modules/@types/dedent/package.json
|
||||
{ "name": "@types/dedent", "version": "1.0.0", "main": "" }
|
||||
|
||||
// @Filename: /node_modules/@types/dedent2/package.json
|
||||
{ "name": "@types/dedent2", "version": "1.0.0", "main": "asdfasdfasdf" }
|
||||
|
||||
// @Filename: /node_modules/@types/dedent3/package.json
|
||||
{ "name": "@types/dedent3", "version": "1.0.0", "main": "asdfasdfasdf", "exports": null }
|
||||
|
||||
// @Filename: /node_modules/@types/dedent4/package.json
|
||||
{ "name": "@types/dedent4", "version": "1.0.0", "main": "asdfasdfasdf", "exports": "./asdfasdfasdf" }
|
||||
|
||||
// @Filename: /node_modules/@types/dedent/index.d.ts
|
||||
export {};
|
||||
|
||||
// @Filename: /node_modules/@types/dedent2/index.d.ts
|
||||
export {};
|
||||
|
||||
// @Filename: /node_modules/@types/dedent3/index.d.ts
|
||||
export {};
|
||||
|
||||
// @Filename: /node_modules/@types/dedent4/index.d.ts
|
||||
export {};
|
||||
|
||||
// @Filename: /index.mts
|
||||
import dedent from "dedent";
|
||||
import dedent2 from "dedent2";
|
||||
import dedent3 from "dedent3";
|
||||
import dedent4 from "dedent4"; // Error
|
||||
|
||||
// @Filename: /index.cts
|
||||
import dedent from "dedent";
|
||||
import dedent2 from "dedent2";
|
||||
import dedent3 from "dedent3";
|
||||
import dedent4 from "dedent4"; // Error
|
||||
@@ -0,0 +1,37 @@
|
||||
// @strict: true
|
||||
// @declaration: true
|
||||
|
||||
function f1<T>(x: T) {
|
||||
let y = x || "hello"; // NonNullable<T> | string
|
||||
}
|
||||
|
||||
function error(): never {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
function f2<T>(x: T) { // NonNullable<T>
|
||||
return x || error();
|
||||
}
|
||||
|
||||
function f3(x: unknown) {
|
||||
let y = x!; // {}
|
||||
}
|
||||
|
||||
function f4<T extends { x: string } | undefined>(obj: T) {
|
||||
if (obj?.x === "hello") {
|
||||
obj; // NonNullable<T>
|
||||
}
|
||||
if (obj?.x) {
|
||||
obj; // NonNullable<T>
|
||||
}
|
||||
if (typeof obj?.x === "string") {
|
||||
obj; // NonNullable<T>
|
||||
}
|
||||
}
|
||||
|
||||
class A {
|
||||
x = "hello";
|
||||
foo() {
|
||||
let zz = this?.x; // string
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// @target: es2019
|
||||
type Types = 'boolean' | 'unknown' | 'string';
|
||||
|
||||
type Properties<T extends { [key: string]: Types }> = {
|
||||
readonly [key in keyof T]: T[key] extends 'boolean' ? boolean : T[key] extends 'string' ? string : unknown
|
||||
}
|
||||
|
||||
type AnyCtor<P extends object> = new (...a: any[]) => P
|
||||
|
||||
declare function classWithProperties<T extends { [key: string]: Types }, P extends object>(properties: T, klass: AnyCtor<P>): {
|
||||
new(): P & Properties<T>;
|
||||
prototype: P & Properties<T>
|
||||
};
|
||||
|
||||
const Base = classWithProperties({
|
||||
get x() { return 'boolean' as const },
|
||||
y: 'string',
|
||||
}, class Base {
|
||||
});
|
||||
|
||||
class MyClass extends Base {
|
||||
get x() {
|
||||
return false;
|
||||
}
|
||||
get y() {
|
||||
return 'hi'
|
||||
}
|
||||
}
|
||||
|
||||
const mine = new MyClass();
|
||||
const value = mine.x;
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
// @strict: true
|
||||
// @target: es2017
|
||||
// #41347, based on microsoft/rushstack
|
||||
|
||||
// Mixin utilities
|
||||
export type Constructor<T = {}> = new (...args: any[]) => T;
|
||||
export type PropertiesOf<T> = { [K in keyof T]: T[K] };
|
||||
|
||||
interface IApiItemConstructor extends Constructor<ApiItem>, PropertiesOf<typeof ApiItem> {}
|
||||
|
||||
// Base class
|
||||
class ApiItem {
|
||||
public get members(): ReadonlyArray<ApiItem> {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// Normal subclass
|
||||
class ApiEnumMember extends ApiItem {
|
||||
}
|
||||
|
||||
// Mixin base class
|
||||
interface ApiItemContainerMixin extends ApiItem {
|
||||
readonly members: ReadonlyArray<ApiItem>;
|
||||
}
|
||||
|
||||
function ApiItemContainerMixin<TBaseClass extends IApiItemConstructor>(
|
||||
baseClass: TBaseClass
|
||||
): TBaseClass & (new (...args: any[]) => ApiItemContainerMixin) {
|
||||
abstract class MixedClass extends baseClass implements ApiItemContainerMixin {
|
||||
public constructor(...args: any[]) {
|
||||
super(...args);
|
||||
}
|
||||
|
||||
public get members(): ReadonlyArray<ApiItem> {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
return MixedClass;
|
||||
}
|
||||
|
||||
// Subclass inheriting from mixin
|
||||
export class ApiEnum extends ApiItemContainerMixin(ApiItem) {
|
||||
// This worked prior to TypeScript 4.0:
|
||||
public get members(): ReadonlyArray<ApiEnumMember> {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
// @module: node16,nodenext
|
||||
// @declaration: true
|
||||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
// @outDir: out
|
||||
// @filename: index.js
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
// @filename: index.mjs
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
// @filename: index.cjs
|
||||
// cjs format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
// @filename: node_modules/inner/exclude/index.d.ts
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
import * as type from "inner/js/exclude/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
// @filename: node_modules/inner/exclude/index.d.mts
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
import * as type from "inner/js/exclude/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
// @filename: node_modules/inner/exclude/index.d.cts
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
import * as type from "inner/js/exclude/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
// @filename: package.json
|
||||
{
|
||||
"name": "package",
|
||||
"private": true,
|
||||
"type": "module"
|
||||
}
|
||||
// @filename: node_modules/inner/package.json
|
||||
{
|
||||
"name": "inner",
|
||||
"private": true,
|
||||
"exports": {
|
||||
"./cjs/*": "./*.cjs",
|
||||
"./cjs/exclude/*": null,
|
||||
"./mjs/*": "./*.mjs",
|
||||
"./mjs/exclude/*": null,
|
||||
"./js/*": "./*.js",
|
||||
"./js/exclude/*": null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
// @module: node16,nodenext
|
||||
// @declaration: true
|
||||
// @outDir: out
|
||||
// @filename: index.ts
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
import * as typei2 from "inner/js/index";
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
// @filename: index.mts
|
||||
// esm format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
import * as typei2 from "inner/js/index";
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
// @filename: index.cts
|
||||
// cjs format file
|
||||
import * as cjsi from "inner/cjs/exclude/index";
|
||||
import * as mjsi from "inner/mjs/exclude/index";
|
||||
import * as typei from "inner/js/exclude/index";
|
||||
cjsi;
|
||||
mjsi;
|
||||
typei;
|
||||
import * as cjsi2 from "inner/cjs/index";
|
||||
import * as mjsi2 from "inner/mjs/index";
|
||||
import * as typei2 from "inner/js/index";
|
||||
cjsi2;
|
||||
mjsi2;
|
||||
typei2;
|
||||
// @filename: node_modules/inner/exclude/index.d.ts
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
import * as type from "inner/js/exclude/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
// @filename: node_modules/inner/exclude/index.d.mts
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
import * as type from "inner/js/exclude/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
// @filename: node_modules/inner/exclude/index.d.cts
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/exclude/index";
|
||||
import * as mjs from "inner/mjs/exclude/index";
|
||||
import * as type from "inner/js/exclude/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
// @filename: node_modules/inner/index.d.ts
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
import * as mjs from "inner/mjs/index";
|
||||
import * as type from "inner/js/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
// @filename: node_modules/inner/index.d.mts
|
||||
// esm format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
import * as mjs from "inner/mjs/index";
|
||||
import * as type from "inner/js/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
// @filename: node_modules/inner/index.d.cts
|
||||
// cjs format file
|
||||
import * as cjs from "inner/cjs/index";
|
||||
import * as mjs from "inner/mjs/index";
|
||||
import * as type from "inner/js/index";
|
||||
export { cjs };
|
||||
export { mjs };
|
||||
export { type };
|
||||
// @filename: package.json
|
||||
{
|
||||
"name": "package",
|
||||
"private": true,
|
||||
"type": "module"
|
||||
}
|
||||
// @filename: node_modules/inner/package.json
|
||||
{
|
||||
"name": "inner",
|
||||
"private": true,
|
||||
"exports": {
|
||||
"./cjs/*": "./*.cjs",
|
||||
"./cjs/exclude/*": null,
|
||||
"./mjs/*": "./*.mjs",
|
||||
"./mjs/exclude/*": null,
|
||||
"./js/*": "./*.js",
|
||||
"./js/exclude/*": null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////
|
||||
//// class Foo <
|
||||
//// T1 extends unknown,
|
||||
//// T2
|
||||
//// > {
|
||||
//// public method <
|
||||
//// T3,
|
||||
//// > (a: T1, b: Array <
|
||||
//// string
|
||||
//// > ): Map <
|
||||
//// T1 ,
|
||||
//// Array < T3 >
|
||||
//// > { throw new Error(); }
|
||||
//// }
|
||||
////
|
||||
//// interface IFoo<
|
||||
//// T,
|
||||
//// > {
|
||||
//// new < T
|
||||
//// > ( a: T);
|
||||
//// op?<
|
||||
//// T,
|
||||
//// M
|
||||
//// > (a: T, b : M );
|
||||
//// <
|
||||
//// T,
|
||||
//// >(x: T): T;
|
||||
//// }
|
||||
////
|
||||
//// type foo<
|
||||
//// T
|
||||
//// > = Foo <
|
||||
//// number, Array < number > > ;
|
||||
////
|
||||
//// function bar <
|
||||
//// T, U extends T
|
||||
//// > () {
|
||||
//// return class <
|
||||
//// T2,
|
||||
//// > {
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
//// bar<
|
||||
//// string,
|
||||
//// "s"
|
||||
//// > ();
|
||||
////
|
||||
//// declare const func: <
|
||||
//// T extends number[],
|
||||
//// > (x: T) => new <
|
||||
//// U
|
||||
//// > () => U;
|
||||
////
|
||||
//// class A < T > extends bar <
|
||||
//// T,number
|
||||
//// >( ) < T
|
||||
//// > {
|
||||
//// }
|
||||
////
|
||||
//// function s<T, U>(x: TemplateStringsArray, ...args: any[]) { return x.join(); }
|
||||
////
|
||||
//// const t = s<
|
||||
//// number ,
|
||||
//// string[] & ArrayLike<any>
|
||||
//// >`abc${1}def` ;
|
||||
////
|
||||
|
||||
|
||||
format.document();
|
||||
|
||||
verify.currentFileContentIs(`
|
||||
class Foo<
|
||||
T1 extends unknown,
|
||||
T2
|
||||
> {
|
||||
public method<
|
||||
T3,
|
||||
>(a: T1, b: Array<
|
||||
string
|
||||
>): Map<
|
||||
T1,
|
||||
Array<T3>
|
||||
> { throw new Error(); }
|
||||
}
|
||||
|
||||
interface IFoo<
|
||||
T,
|
||||
> {
|
||||
new <T
|
||||
>(a: T);
|
||||
op?<
|
||||
T,
|
||||
M
|
||||
>(a: T, b: M);
|
||||
<
|
||||
T,
|
||||
>(x: T): T;
|
||||
}
|
||||
|
||||
type foo<
|
||||
T
|
||||
> = Foo<
|
||||
number, Array<number>>;
|
||||
|
||||
function bar<
|
||||
T, U extends T
|
||||
>() {
|
||||
return class <
|
||||
T2,
|
||||
> {
|
||||
}
|
||||
}
|
||||
|
||||
bar<
|
||||
string,
|
||||
"s"
|
||||
>();
|
||||
|
||||
declare const func: <
|
||||
T extends number[],
|
||||
> (x: T) => new <
|
||||
U
|
||||
> () => U;
|
||||
|
||||
class A<T> extends bar<
|
||||
T, number
|
||||
>()<T
|
||||
> {
|
||||
}
|
||||
|
||||
function s<T, U>(x: TemplateStringsArray, ...args: any[]) { return x.join(); }
|
||||
|
||||
const t = s<
|
||||
number,
|
||||
string[] & ArrayLike<any>
|
||||
>\`abc\${1}def\`;
|
||||
`);
|
||||
@@ -0,0 +1,25 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////const foo = (a = 1) => class { }
|
||||
////
|
||||
////const C1 = class extends foo(/*1*/1) { }
|
||||
////class C2 extends foo(/*2*/1) { }
|
||||
|
||||
const markers = test.markers();
|
||||
|
||||
verify.getInlayHints([
|
||||
{
|
||||
text: 'a:',
|
||||
position: markers[0].position,
|
||||
kind: ts.InlayHintKind.Parameter,
|
||||
whitespaceAfter: true
|
||||
},
|
||||
{
|
||||
text: 'a:',
|
||||
position: markers[1].position,
|
||||
kind: ts.InlayHintKind.Parameter,
|
||||
whitespaceAfter: true
|
||||
},
|
||||
], undefined, {
|
||||
includeInlayParameterNameHints: "literals"
|
||||
});
|
||||
Reference in New Issue
Block a user