From 93dbec5e710a8cb28ca8b7f0c70b9ade4a8fc911 Mon Sep 17 00:00:00 2001
Date: Sat, 15 Jan 2022 21:39:48 +0800
Subject: [PATCH] test patch
.../ambient/ambientDeclarations.ts | 1 +
.../ambientDeclarationsPatterns.ts | 11 +
.../declarations.d.ts | 18 +
.../ambient/ambientInsideNonAmbient.ts | 2 +
.../ambientInsideNonAmbientExternalModule.ts | 4 +-
.../ambientShorthand_merging.ts | 6 +
.../declarations1.d.ts | 2 +
.../declarations2.d.ts | 4 +
.../ambientShorthand_reExport.ts | 5 +
.../declarations.d.ts | 2 +
.../ambientShorthand_reExport/jquery.d.ts | 2 +
.../ambientShorthand_reExport/reExportAll.ts | 2 +
.../ambientShorthand_reExport/reExportX.ts | 2 +
.../async/es5/asyncMethodWithSuper_es5.ts | 1 +
.../asyncOrYieldAsBindingIdentifier1.ts | 49 ++
.../classAbstractAsIdentifier.ts | 2 +-
.../classBody/classWithEmptyBody.ts | 4 +-
.../classDeclarations/classInsideBlock.ts | 1 +
.../classWithPredefinedTypesAsNames.ts | 4 +-
.../classWithSemicolonClassElement1.ts | 3 +-
.../classWithSemicolonClassElement2.ts | 3 +-
.../classExpressions/classExpression2.ts | 4 +-
.../classStaticBlock/classStaticBlock1.ts | 11 +
.../classStaticBlock/classStaticBlock10.ts | 30 ++
.../classStaticBlock/classStaticBlock11.ts | 15 +
.../classStaticBlock/classStaticBlock12.ts | 10 +
.../classStaticBlock/classStaticBlock13.ts | 14 +
.../classStaticBlock/classStaticBlock14.ts | 15 +
.../classStaticBlock/classStaticBlock15.ts | 18 +
.../classStaticBlock/classStaticBlock16.ts | 26 +
.../classStaticBlock/classStaticBlock17.ts | 33 ++
.../classStaticBlock/classStaticBlock18.ts | 15 +
.../classStaticBlock/classStaticBlock19.ts | 6 +
.../classStaticBlock/classStaticBlock2.ts | 20 +
.../classStaticBlock/classStaticBlock20.ts | 13 +
.../classStaticBlock/classStaticBlock21.ts | 7 +
.../classStaticBlock/classStaticBlock22.ts | 72 +++
.../classStaticBlock/classStaticBlock23.ts | 21 +
.../classStaticBlock/classStaticBlock24.ts | 8 +
.../classStaticBlock/classStaticBlock25.ts | 23 +
.../classStaticBlock/classStaticBlock26.ts | 30 ++
.../classStaticBlock/classStaticBlock27.ts | 17 +
.../classStaticBlock/classStaticBlock3.ts | 19 +
.../classStaticBlock/classStaticBlock4.ts | 16 +
.../classStaticBlock/classStaticBlock5.ts | 19 +
.../classStaticBlock/classStaticBlock6.ts | 62 +++
.../classStaticBlock/classStaticBlock7.ts | 43 ++
.../classStaticBlock/classStaticBlock8.ts | 48 ++
.../classStaticBlock/classStaticBlock9.ts | 8 +
.../classStaticBlockUseBeforeDef1.ts | 15 +
.../classStaticBlockUseBeforeDef2.ts | 10 +
.../classConstructorAccessibility4.ts | 4 +-
...structorImplementationWithDefaultValues.ts | 6 +-
.../declarationEmitReadonly.ts | 3 +-
.../quotedConstructors.ts | 4 +
...idesIndexersWithAssignmentCompatibility.ts | 4 +-
.../superInStaticMembers1.ts | 492 ++++++++++++++++++
.../thisAndSuperInStaticMembers1.ts | 42 ++
.../thisAndSuperInStaticMembers2.ts | 42 ++
.../thisAndSuperInStaticMembers3.ts | 26 +
.../thisAndSuperInStaticMembers4.ts | 26 +
.../typeOfThisInStaticMembers.ts | 3 +-
.../typeOfThisInStaticMembers10.ts | 51 ++
.../typeOfThisInStaticMembers11.ts | 51 ++
.../typeOfThisInStaticMembers12.ts | 10 +
.../typeOfThisInStaticMembers13.ts | 10 +
.../typeOfThisInStaticMembers3.ts | 12 +
.../typeOfThisInStaticMembers4.ts | 12 +
.../typeOfThisInStaticMembers5.ts | 9 +
.../typeOfThisInStaticMembers6.ts | 7 +
.../typeOfThisInStaticMembers7.ts | 12 +
.../typeOfThisInStaticMembers8.ts | 19 +
.../typeOfThisInStaticMembers9.ts | 22 +
.../privateNameComputedPropertyName3.ts | 2 +
.../privateNames/privateNameFieldAccess.ts | 1 +
.../privateNames/privateNameHashCharName.ts | 11 +
.../privateNames/privateNameInInExpression.ts | 119 +++++
.../privateNameInInExpressionTransform.ts | 47 ++
.../privateNameInInExpressionUnused.ts | 13 +
.../privateNamesIncompatibleModifiersJs.ts | 65 +++
.../classes/mixinClassesAnnotated.ts | 3 +
.../classes/mixinClassesAnonymous.ts | 2 +
.../classes/mixinClassesMembers.ts | 5 +
.../abstractProperty.ts | 3 +
.../abstractPropertyInitializer.ts | 5 +
.../instanceMemberInitialization.ts | 7 +-
...instanceMemberWithComputedPropertyName2.ts | 1 +
.../staticFactory1.ts | 3 +-
.../staticAndNonStaticPropertiesSameName.ts | 3 +-
.../staticPropertyAndFunctionWithSameName.ts | 4 +-
...icPropertyNameConflictsInAmbientContext.ts | 10 +
.../controlFlow/assertionTypePredicates2.ts | 27 +
.../controlFlow/controlFlowAliasing.ts | 285 ++++++++++
.../controlFlowAliasingCatchVariables.ts | 28 +
.../controlFlow/controlFlowElementAccess2.ts | 2 +-
.../controlFlow/controlFlowForInStatement2.ts | 25 +
.../controlFlow/controlFlowInOperator.ts | 26 +
.../controlFlowInstanceofExtendsFunction.ts | 4 +-
.../controlFlowSuperPropertyAccess.ts | 1 +
.../controlFlow/controlFlowTypeofObject.ts | 71 +++
.../dependentDestructuredVariables.ts | 161 ++++++
.../typeGuardsNestedAssignments.ts | 3 +-
.../controlFlow/typeGuardsTypeParameters.ts | 1 +
.../declarationEmitWorkWithInlineComments.ts | 5 +-
.../declarationEmitThisPredicates01.ts | 3 +-
...tionEmitThisPredicatesWithPrivateName01.ts | 3 +-
.../typeReferenceRelatedFiles/fs.d.ts | 5 +
.../typeReferenceRelatedFiles/main.ts | 2 +
.../typeReferenceRelatedFiles/package.json | 4 +
.../typeReferenceRelatedFiles.ts | 18 +
.../decoratorOnClassConstructorParameter5.ts | 15 +
.../class/decoratedBlockScopedClass1.ts | 16 +
.../class/decoratedBlockScopedClass2.ts | 19 +
.../class/decoratedBlockScopedClass3.ts | 27 +
.../class/method/decoratorOnClassMethod14.ts | 14 +
.../class/method/decoratorOnClassMethod15.ts | 12 +
.../class/method/decoratorOnClassMethod16.ts | 12 +
.../class/method/decoratorOnClassMethod17.ts | 11 +
.../class/method/decoratorOnClassMethod18.ts | 11 +
.../decoratorMetadataWithTypeOnlyImport2.ts | 17 +
...ter.asyncGenerators.classMethods.es2015.ts | 11 +
.../conformance/es2018/es2018IntlAPIs.ts | 7 +
.../conformance/es2020/es2020IntlAPIs.ts | 45 ++
...tionWithPropertyAccessInHeritageClause1.ts | 4 +-
.../superCallBeforeThisAccessing1.ts | 1 +
.../superCallBeforeThisAccessing2.ts | 1 +
.../superCallBeforeThisAccessing5.ts | 1 +
.../superCallBeforeThisAccessing8.ts | 1 +
.../es6/spread/arraySpreadImportHelpers.ts | 16 +
...mplateStringWithCommentsInArrowFunction.ts | 14 +
.../expressions/asOperator/asOperatorASI.ts | 1 +
.../comparisonOperatorWithIdenticalObjects.ts | 6 +-
.../comparisonOperatorWithIntersectionType.ts | 5 +
...nshipObjectsOnInstantiatedCallSignature.ts | 4 +-
...jectsOnInstantiatedConstructorSignature.ts | 4 +-
...peratorWithSubtypeObjectOnCallSignature.ts | 3 +-
...WithSubtypeObjectOnConstructorSignature.ts | 3 +-
...eratorWithSubtypeObjectOnIndexSignature.ts | 3 +-
...ubtypeObjectOnInstantiatedCallSignature.ts | 3 +-
...bjectOnInstantiatedConstructorSignature.ts | 3 +-
...isonOperatorWithSubtypeObjectOnProperty.ts | 6 +-
...anceofOperatorWithInvalidStaticToString.ts | 3 +
.../instanceofOperatorWithLHSIsObject.ts | 1 +
...ommaOperatorWithSecondOperandObjectType.ts | 1 +
.../conditionalOperatorWithIdenticalBCT.ts | 3 +
.../superCallParameterContextualTyping1.ts | 2 +
.../superCallParameterContextualTyping3.ts | 3 +-
.../functionCalls/callWithSpread.ts | 1 +
.../functions/arrowFunctionExpressions.ts | 1 +
.../newOperator/newOperatorConformance.ts | 1 +
.../expressions/superCalls/superCalls.ts | 2 +
.../thisKeyword/typeOfThisGeneral.ts | 178 +++++++
.../typeGuards/TypeGuardWithArrayUnion.ts | 1 +
.../typeGuards/typeGuardFunction.ts | 6 +-
.../typeGuards/typeGuardFunctionGenerics.ts | 4 +-
.../typeGuardOfFormExpr1AndExpr2.ts | 3 +-
.../typeGuards/typeGuardOfFormExpr1OrExpr2.ts | 3 +-
.../typeGuards/typeGuardOfFormInstanceOf.ts | 45 +-
.../typeGuards/typeGuardOfFormIsType.ts | 5 +-
.../typeGuardOfFormTypeOfBoolean.ts | 1 +
.../typeGuards/typeGuardOfFormTypeOfNumber.ts | 1 +
.../typeGuards/typeGuardOfFormTypeOfString.ts | 1 +
.../typeGuardOfFromPropNameInUnionType.ts | 9 +
.../typeGuards/typeGuardsInClassAccessors.ts | 1 +
.../typeGuards/typeGuardsInClassMethods.ts | 1 +
.../typeGuards/typeGuardsInProperties.ts | 3 +-
.../typeGuards/typeGuardsOnClassProperty.ts | 3 +-
.../bitwiseNotOperatorWithNumberType.ts | 3 +-
.../bitwiseNotOperatorWithStringType.ts | 3 +-
.../externalModules/exportNonVisibleType.ts | 1 +
.../moduleResolutionWithoutExtension1.ts | 12 +
.../moduleResolutionWithoutExtension2.ts | 6 +
.../moduleResolutionWithoutExtension3.ts | 12 +
.../moduleResolutionWithoutExtension4.ts | 12 +
.../moduleResolutionWithoutExtension5.ts | 6 +
.../moduleResolutionWithoutExtension6.ts | 8 +
.../moduleResolutionWithoutExtension7.ts | 6 +
.../moduleResolutionWithoutExtension8.ts | 6 +
.../typeOnly/exportSpecifiers.ts | 21 +
.../typeOnly/importDefaultNamedType/a.ts | 2 +
.../importDefaultNamedType.ts | 5 +
.../typeOnly/importSpecifiers1.ts | 46 ++
.../typeOnly/preserveValueImports.ts | 28 +
.../typeOnly/preserveValueImports_errors.ts | 47 ++
...erveValueImports_importsNotUsedAsValues.ts | 14 +
.../preserveValueImports_mixedImports.ts | 13 +
.../typeOnly/preserveValueImports_module.ts | 4 +
.../importAssertion/importAssertion1.ts | 37 ++
.../importAssertion/importAssertion2.ts | 17 +
.../importAssertion/importAssertion3.ts | 15 +
.../importAssertion/importAssertion4.ts | 1 +
.../importAssertion/importAssertion5.ts | 1 +
.../mergedInterfacesWithMultipleBases3.ts | 6 +-
.../interfaceExtendsObjectIntersection.ts | 12 +
.../interfaceWithPropertyOfEveryType.ts | 3 +-
...duleAndAmbientWithSameNameAndCommonRoot.ts | 1 -
...onAmbientClassWithSameNameAndCommonRoot.ts | 1 +
...ionAndNonExportedFunctionThatShareAName.ts | 4 +-
...ortedAndNonExportedClassesOfTheSameName.ts | 4 +
...rgeEachWithExportedModulesOfTheSameName.ts | 2 +
.../codeGeneration/exportCodeGen.ts | 2 +
.../codeGeneration/nameCollision.ts | 1 +
.../jsdoc/constructorTagOnClassConstructor.ts | 4 +-
...bclassWithExplicitNoArgumentConstructor.ts | 3 +-
.../declarations/jsDeclarationsThisTypes.ts | 4 +-
.../jsdoc/enumTagImported/enumTagImported.ts | 23 +
tests/cases/conformance/jsdoc/extendsTag1.ts | 1 +
.../jsdocAugments_qualifiedName.ts | 10 +
.../jsdoc/jsdocAugments_withTypeParameter.ts | 1 +
.../jsdocImplements_namespacedInterface.ts | 2 +
.../jsdoc/jsdocTemplateTagDefault.ts | 71 +++
.../jsdoc/jsdocTemplateTagNameResolution.ts | 16 +
.../jsdoc/jsdocTypeReferenceUseBeforeDef.ts | 1 +
.../conformance/jsdoc/jsdocVariadicType.ts | 12 +
tests/cases/conformance/jsdoc/seeTag3.ts | 7 +
tests/cases/conformance/jsdoc/thisTag2.ts | 11 +
.../conformance/jsx/jsxParsingError4.tsx | 18 +
.../jsx/jsxUnclosedParserRecovery.ts | 140 +++++
.../jsx/tsxReactEmitSpreadAttribute.ts | 32 ++
.../declarationNotFoundPackageBundlesTypes.ts | 23 +
.../scopedPackages/index.d.ts | 3 +
.../scopedPackages/scopedPackages.ts | 12 +
.../moduleResolution/scopedPackages/z.d.ts | 2 +
.../scopedPackagesClassic/index.d.ts | 2 +
.../scopedPackagesClassic.ts | 9 +
.../untypedModuleImport_allowJs.ts | 12 +
.../declarations.d.ts | 4 +
.../untypedModuleImport_vsAmbient.ts | 12 +
.../allowJs/nodeAllowJsPackageSelfName.ts | 24 +
.../node/allowJs/nodeModulesAllowJs1.ts | 324 ++++++++++++
.../allowJs/nodeModulesAllowJsCjsFromJs.ts | 8 +
...ModulesAllowJsConditionalPackageExports.ts | 126 +++++
.../nodeModulesAllowJsDynamicImport.ts | 27 +
.../nodeModulesAllowJsExportAssignment.ts | 32 ++
...deModulesAllowJsGeneratedNameCollisions.ts | 29 ++
.../nodeModulesAllowJsImportAssignment.ts | 34 ++
...eModulesAllowJsImportHelpersCollisions1.ts | 34 ++
...eModulesAllowJsImportHelpersCollisions2.ts | 30 ++
...eModulesAllowJsImportHelpersCollisions3.ts | 32 ++
.../allowJs/nodeModulesAllowJsImportMeta.ts | 23 +
.../nodeModulesAllowJsPackageExports.ts | 92 ++++
.../nodeModulesAllowJsPackageImports.ts | 41 ++
...nodeModulesAllowJsPackagePatternExports.ts | 69 +++
...lesAllowJsPackagePatternExportsTrailers.ts | 69 +++
...nodeModulesAllowJsSynchronousCallErrors.ts | 37 ++
.../nodeModulesAllowJsTopLevelAwait.ts | 25 +
...lesExportsSpecifierGenerationConditions.ts | 33 ++
tests/cases/conformance/node/nodeModules1.ts | 321 ++++++++++++
...odeModulesCjsFormatFileAlwaysHasDefault.ts | 19 +
.../nodeModulesConditionalPackageExports.ts | 124 +++++
...tionEmitDynamicImportWithPackageExports.ts | 71 +++
...odulesDeclarationEmitWithPackageExports.ts | 93 ++++
.../node/nodeModulesDynamicImport.ts | 24 +
.../node/nodeModulesExportAssignments.ts | 20 +
...ModulesExportsBlocksSpecifierResolution.ts | 27 +
...lesExportsSpecifierGenerationConditions.ts | 34 ++
...ulesExportsSpecifierGenerationDirectory.ts | 29 ++
...odulesExportsSpecifierGenerationPattern.ts | 29 ++
.../node/nodeModulesForbidenSyntax.ts | 67 +++
.../nodeModulesGeneratedNameCollisions.ts | 26 +
.../node/nodeModulesImportAssertions.ts | 13 +
.../node/nodeModulesImportAssignments.ts | 31 ++
.../nodeModulesImportHelpersCollisions.ts | 31 ++
.../nodeModulesImportHelpersCollisions2.ts | 27 +
.../nodeModulesImportHelpersCollisions3.ts | 25 +
.../conformance/node/nodeModulesImportMeta.ts | 20 +
.../nodeModulesImportResolutionIntoExport.ts | 24 +
.../nodeModulesImportResolutionNoCycle.ts | 24 +
.../node/nodeModulesPackageExports.ts | 90 ++++
.../node/nodeModulesPackageImports.ts | 38 ++
.../node/nodeModulesPackagePatternExports.ts | 67 +++
...odeModulesPackagePatternExportsTrailers.ts | 67 +++
.../node/nodeModulesResolveJsonModule.ts | 29 ++
.../node/nodeModulesSynchronousCallErrors.ts | 34 ++
.../node/nodeModulesTopLevelAwait.ts | 22 +
.../nodeModulesTypesVersionPackageExports.ts | 53 ++
.../conformance/node/nodePackageSelfName.ts | 21 +
.../node/nodePackageSelfNameScoped.ts | 21 +
.../cases/conformance/override/override10.ts | 3 +-
.../cases/conformance/override/override12.ts | 1 +
.../cases/conformance/override/override15.ts | 9 +
.../cases/conformance/override/override16.ts | 1 +
.../cases/conformance/override/override17.ts | 1 +
.../cases/conformance/override/override18.ts | 1 +
.../cases/conformance/override/override19.ts | 20 +
.../cases/conformance/override/override20.ts | 34 ++
.../conformance/override/override_js1.ts | 4 +-
.../conformance/override/override_js4.ts | 14 +
.../parserClassDeclaration16.ts | 3 +-
.../parserClassDeclaration17.ts | 1 +
.../parserClassDeclaration19.ts | 3 +-
.../parserClassDeclaration20.ts | 3 +-
.../parserClassDeclaration23.ts | 3 +-
.../parserClassDeclaration26.ts | 3 +-
.../parserClassDeclarationIndexSignature1.ts | 3 +-
.../parserConstructorDeclaration1.ts | 3 +-
.../parserConstructorDeclaration5.ts | 3 +-
.../parserAccessibilityAfterStatic11.ts | 1 +
.../parserAccessibilityAfterStatic14.ts | 1 +
.../parserAccessibilityAfterStatic2.ts | 1 +
.../parserAccessibilityAfterStatic3.ts | 1 +
.../parserAccessibilityAfterStatic4.ts | 1 +
.../parserAccessibilityAfterStatic5.ts | 1 +
.../Generics/parserGenericClass1.ts | 3 +-
.../Generics/parserGenericClass2.ts | 3 +-
.../Generics/parserGenericConstraint1.ts | 3 +-
.../parserIndexMemberDeclaration1.ts | 3 +-
.../parserIndexMemberDeclaration2.ts | 3 +-
.../parserIndexMemberDeclaration3.ts | 3 +-
.../parserIndexMemberDeclaration4.ts | 3 +-
.../parserIndexMemberDeclaration6.ts | 3 +-
.../parserMemberVariableDeclaration5.ts | 3 +-
.../ecmascript5/Protected/Protected3.ts | 3 +-
.../ecmascript5/Protected/Protected5.ts | 3 +-
.../ecmascript5/Protected/Protected9.ts | 3 +-
.../RegressionTests/parser509546.ts | 1 +
.../RegressionTests/parser509546_1.ts | 1 +
.../RegressionTests/parser509546_2.ts | 1 +
.../parser/ecmascript5/parserUnicode3.ts | 3 +-
.../Iterators/parserForOfStatement22.ts | 4 +
.../Iterators/parserForOfStatement23.ts | 6 +
.../Iterators/parserForOfStatement24.ts | 4 +
.../inferringClassMembersFromAssignments3.ts | 1 +
.../conformance/salsa/plainJSBinderErrors.ts | 44 ++
.../conformance/salsa/plainJSRedeclare.ts | 6 +
.../conformance/salsa/plainJSRedeclare2.ts | 7 +
.../conformance/salsa/plainJSRedeclare3.ts | 7 +
.../salsa/plainJSReservedStrict.ts | 7 +
.../conformance/salsa/spellingUncheckedJS.ts | 51 ++
.../salsa/typeFromJSInitializer2.ts | 18 +
.../salsa/typeFromJSInitializer3.ts | 18 +
.../salsa/typeFromJSInitializer4.ts | 29 ++
.../salsa/typeFromPropertyAssignment23.ts | 3 +
.../for-inStatementsAsyncIdentifier.ts | 4 +
.../returnStatements/returnStatements.ts | 1 +
.../throwInEnclosingStatements.ts | 1 +
.../types/any/anyAsGenericFunctionCall.ts | 4 +-
.../types/any/assignAnyToEveryType.ts | 4 +-
.../types/any/assignEveryTypeToAny.ts | 4 +-
.../conformance/types/conditional/variance.ts | 2 +
...tatedFunctionInferenceWithTypeParameter.ts | 3 +
.../types/import/importTypeAmbient.ts | 5 +-
.../types/import/importTypeGenericTypes.ts | 5 +-
.../types/import/importTypeLocal.ts | 5 +
.../intersectionOfUnionNarrowing.ts | 16 +
.../types/keyof/keyofAndIndexedAccess.ts | 20 +
.../types/literal/literalTypes2.ts | 3 +
.../types/localTypes/localTypes2.ts | 3 +
.../types/localTypes/localTypes3.ts | 3 +
.../mapped/mappedTypeAsClauseRelationships.ts | 27 +
.../types/mapped/mappedTypeProperties.ts | 42 ++
.../conformance/types/mapped/mappedTypes3.ts | 4 +-
.../types/mapped/mappedTypesAndObjects.ts | 2 +
.../members/classWithProtectedProperty.ts | 4 +-
.../types/members/indexSignatures1.ts | 325 ++++++++++++
.../objectTypeHidingMembersOfObject.ts | 4 +-
.../types/members/objectTypePropertyAccess.ts | 2 +
.../members/objectTypeWithNumericProperty.ts | 4 +-
...hStringNamedPropertyOfIllegalCharacters.ts | 2 +
.../typesWithSpecializedCallSignatures.ts | 5 +-
...typesWithSpecializedConstructSignatures.ts | 5 +-
.../namedTypes/classWithOptionalParameter.ts | 5 +-
.../types/namedTypes/optionalMethods.ts | 3 +
.../conformance/types/never/neverType.ts | 2 +
...ureWithoutReturnTypeAnnotationInference.ts | 6 +-
.../callSignaturesWithDuplicateParameters.ts | 4 +-
.../callSignaturesWithOptionalParameters.ts | 2 +
.../callSignaturesWithOptionalParameters2.ts | 4 +-
.../parametersWithNoAnnotationAreAny.ts | 4 +-
...reIsNotSubtypeOfNonSpecializedSignature.ts | 3 +
...atureIsSubtypeOfNonSpecializedSignature.ts | 3 +
...gLiteralTypesInImplementationSignatures.ts | 2 +
.../typeParameterAsTypeArgument.ts | 4 +-
...WithOverloadsThatDifferOnlyByReturnType.ts | 5 +-
.../indexSignatures/numericIndexingResults.ts | 4 +-
.../indexSignatures/stringIndexingResults.ts | 2 +
.../propertyNameWithoutTypeAnnotation.ts | 4 +-
.../propertyNamesOfReservedWords.ts | 4 +-
.../stringNamedPropertyAccess.ts | 4 +-
.../number/extendNumberInterface.ts | 2 +-
.../undefined/invalidUndefinedValues.ts | 4 +-
.../undefined/validUndefinedAssignments.ts | 4 +-
.../types/rest/objectRestParameter.ts | 1 +
.../typeLiterals/arrayOfFunctionTypes3.ts | 4 +-
.../functionLiteralForOverloads2.ts | 5 +-
.../typeQueries/typeQueryOnClass.ts | 5 +-
.../typeQueries/typeQueryWithReservedWords.ts | 1 +
.../typeQueries/typeofClass2.ts | 5 +-
.../typeQueries/typeofModuleWithoutExports.ts | 3 +-
.../specifyingTypes/typeQueries/typeofThis.ts | 146 ++++++
.../typeQueries/typeofThisWithImplicitThis.ts | 5 +
.../types/spread/spreadDuplicate.ts | 21 +
.../types/spread/spreadDuplicateExact.ts | 22 +
.../conformance/types/spread/spreadUnion4.ts | 4 +
.../types/thisType/fluentClasses.ts | 2 +
.../types/thisType/thisTypeAndConstraints.ts | 3 +
.../types/thisType/thisTypeInClasses.ts | 6 +
.../types/thisType/thisTypeInFunctions3.ts | 3 +
.../thisType/thisTypeInTaggedTemplateCall.ts | 10 +
.../types/tuple/readonlyArraysAndTuples2.ts | 2 +
.../circularTypeAliasForUnionWithClass.ts | 4 +
.../classDoesNotDependOnBaseTypes.ts | 4 +-
.../types/typeAliases/typeAliases.ts | 4 +-
...allGenericFunctionWithZeroTypeArguments.ts | 5 +-
.../functionConstraintSatisfaction.ts | 5 +-
.../functionConstraintSatisfaction3.ts | 5 +-
.../innerTypeParameterShadowingOuterOne2.ts | 4 +-
...rtyAccessOnTypeParameterWithConstraints.ts | 3 +-
...tyAccessOnTypeParameterWithConstraints2.ts | 7 +-
...tyAccessOnTypeParameterWithConstraints3.ts | 4 +-
...AccessOnTypeParameterWithoutConstraints.ts | 4 +-
.../typeParameterUsedAsConstraint.ts | 7 +
.../anyAssignabilityInInheritance.ts | 6 +-
.../anyAssignableToEveryType.ts | 1 +
.../anyAssignableToEveryType2.ts | 3 +
.../assignmentCompatWithObjectMembers.ts | 5 +-
.../assignmentCompatWithObjectMembers2.ts | 2 +
.../assignmentCompatWithObjectMembers3.ts | 2 +
...mentCompatWithObjectMembersNumericNames.ts | 2 +
...allSignatureAssignabilityInInheritance2.ts | 6 +-
...allSignatureAssignabilityInInheritance4.ts | 6 +-
...allSignatureAssignabilityInInheritance5.ts | 5 +-
...uctSignatureAssignabilityInInheritance2.ts | 6 +-
...uctSignatureAssignabilityInInheritance4.ts | 5 +-
...uctSignatureAssignabilityInInheritance5.ts | 5 +-
.../everyTypeAssignableToAny.ts | 2 +
.../nullAssignableToEveryType.ts | 2 +-
.../undefinedAssignableToEveryType.ts | 1 +
.../bestCommonTypeOfConditionalExpressions.ts | 5 +-
...bestCommonTypeOfConditionalExpressions2.ts | 4 +-
.../heterogeneousArrayLiterals.ts | 2 +
.../narrowingConstrainedTypeVariable.ts | 3 +
.../arrayLiteralsWithRecursiveGenerics.ts | 6 +-
.../recursiveTypeInGenericConstraint.ts | 5 +-
.../recursiveTypesUsedAsFunctionParameters.ts | 5 +-
.../nullIsSubtypeOfEverythingButUndefined.ts | 4 +
.../stringLiteralTypeIsSubtypeOfString.ts | 4 +-
.../subtypesAndSuperTypes/subtypesOfAny.ts | 5 +-
...subtypesOfTypeParameterWithConstraints2.ts | 5 +-
.../subtypingWithCallSignatures2.ts | 6 +
.../subtypingWithCallSignatures3.ts | 4 +
.../subtypingWithCallSignatures4.ts | 6 +-
.../subtypingWithConstructSignatures2.ts | 5 +
.../subtypingWithConstructSignatures3.ts | 4 +
.../subtypingWithConstructSignatures4.ts | 6 +-
.../subtypingWithConstructSignatures5.ts | 6 +-
.../subtypingWithObjectMembers4.ts | 6 +-
.../undefinedIsSubtypeOfEverything.ts | 25 +
.../objectTypesIdentity.ts | 6 +-
.../objectTypesIdentity2.ts | 5 +-
.../objectTypesIdentityWithCallSignatures.ts | 5 +-
.../objectTypesIdentityWithCallSignatures2.ts | 5 +-
...yWithCallSignaturesDifferingParamCounts.ts | 5 +-
...IdentityWithCallSignaturesWithOverloads.ts | 6 +-
...ectTypesIdentityWithConstructSignatures.ts | 6 +-
...ctTypesIdentityWithConstructSignatures2.ts | 4 +-
...ConstructSignaturesDifferingParamCounts.ts | 4 +-
...tTypesIdentityWithGenericCallSignatures.ts | 6 +-
...TypesIdentityWithGenericCallSignatures2.ts | 6 +-
...ricCallSignaturesDifferingByConstraints.ts | 6 +-
...icCallSignaturesDifferingByConstraints2.ts | 6 +-
...icCallSignaturesDifferingByConstraints3.ts | 9 +-
...ericCallSignaturesDifferingByReturnType.ts | 5 +-
...ricCallSignaturesDifferingByReturnType2.ts | 6 +-
...lSignaturesDifferingTypeParameterCounts.ts | 6 +-
...llSignaturesDifferingTypeParameterNames.ts | 5 +-
...WithGenericCallSignaturesOptionalParams.ts | 5 +-
...ithGenericCallSignaturesOptionalParams2.ts | 5 +-
...ithGenericCallSignaturesOptionalParams3.ts | 6 +-
...nstructSignaturesDifferingByConstraints.ts | 2 +
...structSignaturesDifferingByConstraints2.ts | 7 +-
...structSignaturesDifferingByConstraints3.ts | 7 +-
...onstructSignaturesDifferingByReturnType.ts | 4 +-
...nstructSignaturesDifferingByReturnType2.ts | 6 +-
...tSignaturesDifferingTypeParameterCounts.ts | 4 +-
...ctSignaturesDifferingTypeParameterNames.ts | 6 +-
...enericConstructSignaturesOptionalParams.ts | 5 +-
...nericConstructSignaturesOptionalParams2.ts | 5 +-
...nericConstructSignaturesOptionalParams3.ts | 4 +-
...objectTypesIdentityWithNumericIndexers1.ts | 3 +
...objectTypesIdentityWithNumericIndexers2.ts | 5 +
...objectTypesIdentityWithNumericIndexers3.ts | 3 +
.../objectTypesIdentityWithOptionality.ts | 6 +-
.../objectTypesIdentityWithPrivates.ts | 4 +-
.../objectTypesIdentityWithPrivates2.ts | 1 +
.../objectTypesIdentityWithPublics.ts | 5 +-
.../objectTypesIdentityWithStringIndexers.ts | 3 +
.../objectTypesIdentityWithStringIndexers2.ts | 5 +
.../typeParametersAreIdenticalToThemselves.ts | 4 +-
...allWithConstraintsTypeArgumentInference.ts | 3 +
.../genericCallWithFunctionTypedArguments4.ts | 4 +-
.../genericCallWithObjectTypeArgs2.ts | 4 +-
...ricCallWithObjectTypeArgsAndConstraints.ts | 10 +-
...icCallWithObjectTypeArgsAndConstraints2.ts | 1 +
...icClassWithObjectTypeArgsAndConstraints.ts | 7 +-
.../keyofInferenceLowerPriorityThanReturn.ts | 4 +
.../types/union/discriminatedUnionTypes3.ts | 19 +
497 files changed, 8097 insertions(+), 197 deletions(-)
create mode 100644 tests/cases/conformance/ambient/ambientDeclarationsPatterns/ambientDeclarationsPatterns.ts
create mode 100644 tests/cases/conformance/ambient/ambientDeclarationsPatterns/declarations.d.ts
create mode 100644 tests/cases/conformance/ambient/ambientShorthand_merging/ambientShorthand_merging.ts
create mode 100644 tests/cases/conformance/ambient/ambientShorthand_merging/declarations1.d.ts
create mode 100644 tests/cases/conformance/ambient/ambientShorthand_merging/declarations2.d.ts
create mode 100644 tests/cases/conformance/ambient/ambientShorthand_reExport/ambientShorthand_reExport.ts
create mode 100644 tests/cases/conformance/ambient/ambientShorthand_reExport/declarations.d.ts
create mode 100644 tests/cases/conformance/ambient/ambientShorthand_reExport/jquery.d.ts
create mode 100644 tests/cases/conformance/ambient/ambientShorthand_reExport/reExportAll.ts
create mode 100644 tests/cases/conformance/ambient/ambientShorthand_reExport/reExportX.ts
create mode 100644 tests/cases/conformance/async/es6/functionDeclarations/asyncOrYieldAsBindingIdentifier1.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock1.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock10.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock11.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock12.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock13.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock14.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock15.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock16.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock17.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock18.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock19.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock2.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock20.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock21.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock22.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock23.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock24.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock25.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock26.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock27.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock3.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock4.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock5.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock6.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock7.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock8.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlock9.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlockUseBeforeDef1.ts
create mode 100644 tests/cases/conformance/classes/classStaticBlock/classStaticBlockUseBeforeDef2.ts
create mode 100644 tests/cases/conformance/classes/members/instanceAndStaticMembers/superInStaticMembers1.ts
create mode 100644 tests/cases/conformance/classes/members/instanceAndStaticMembers/thisAndSuperInStaticMembers1.ts
create mode 100644 tests/cases/conformance/classes/members/instanceAndStaticMembers/thisAndSuperInStaticMembers2.ts
create mode 100644 tests/cases/conformance/classes/members/instanceAndStaticMembers/thisAndSuperInStaticMembers3.ts
create mode 100644 tests/cases/conformance/classes/members/instanceAndStaticMembers/thisAndSuperInStaticMembers4.ts
create mode 100644 tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers10.ts
create mode 100644 tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers11.ts
create mode 100644 tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers12.ts
create mode 100644 tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers13.ts
create mode 100644 tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers3.ts
create mode 100644 tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers4.ts
create mode 100644 tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers5.ts
create mode 100644 tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers6.ts
create mode 100644 tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers7.ts
create mode 100644 tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers8.ts
create mode 100644 tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInStaticMembers9.ts
create mode 100644 tests/cases/conformance/classes/members/privateNames/privateNameHashCharName.ts
create mode 100644 tests/cases/conformance/classes/members/privateNames/privateNameInInExpression.ts
create mode 100644 tests/cases/conformance/classes/members/privateNames/privateNameInInExpressionTransform.ts
create mode 100644 tests/cases/conformance/classes/members/privateNames/privateNameInInExpressionUnused.ts
create mode 100644 tests/cases/conformance/classes/members/privateNames/privateNamesIncompatibleModifiersJs.ts
create mode 100644 tests/cases/conformance/classes/propertyMemberDeclarations/abstractPropertyInitializer.ts
create mode 100644 tests/cases/conformance/controlFlow/assertionTypePredicates2.ts
create mode 100644 tests/cases/conformance/controlFlow/controlFlowAliasing.ts
create mode 100644 tests/cases/conformance/controlFlow/controlFlowAliasingCatchVariables.ts
create mode 100644 tests/cases/conformance/controlFlow/controlFlowForInStatement2.ts
create mode 100644 tests/cases/conformance/controlFlow/controlFlowInOperator.ts
create mode 100644 tests/cases/conformance/controlFlow/controlFlowTypeofObject.ts
create mode 100644 tests/cases/conformance/controlFlow/dependentDestructuredVariables.ts
create mode 100644 tests/cases/conformance/declarationEmit/typeReferenceRelatedFiles/fs.d.ts
create mode 100644 tests/cases/conformance/declarationEmit/typeReferenceRelatedFiles/main.ts
create mode 100644 tests/cases/conformance/declarationEmit/typeReferenceRelatedFiles/package.json
create mode 100644 tests/cases/conformance/declarationEmit/typeReferenceRelatedFiles/typeReferenceRelatedFiles.ts
create mode 100644 tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter5.ts
create mode 100644 tests/cases/conformance/decorators/class/decoratedBlockScopedClass1.ts
create mode 100644 tests/cases/conformance/decorators/class/decoratedBlockScopedClass2.ts
create mode 100644 tests/cases/conformance/decorators/class/decoratedBlockScopedClass3.ts
create mode 100644 tests/cases/conformance/decorators/class/method/decoratorOnClassMethod14.ts
create mode 100644 tests/cases/conformance/decorators/class/method/decoratorOnClassMethod15.ts
create mode 100644 tests/cases/conformance/decorators/class/method/decoratorOnClassMethod16.ts
create mode 100644 tests/cases/conformance/decorators/class/method/decoratorOnClassMethod17.ts
create mode 100644 tests/cases/conformance/decorators/class/method/decoratorOnClassMethod18.ts
create mode 100644 tests/cases/conformance/decorators/decoratorMetadataWithTypeOnlyImport2.ts
create mode 100644 tests/cases/conformance/es2018/es2018IntlAPIs.ts
create mode 100644 tests/cases/conformance/es2020/es2020IntlAPIs.ts
create mode 100644 tests/cases/conformance/es6/spread/arraySpreadImportHelpers.ts
create mode 100644 tests/cases/conformance/es6/templates/templateStringWithCommentsInArrowFunction.ts
create mode 100644 tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIntersectionType.ts
create mode 100644 tests/cases/conformance/expressions/thisKeyword/typeOfThisGeneral.ts
create mode 100644 tests/cases/conformance/externalModules/moduleResolutionWithoutExtension1.ts
create mode 100644 tests/cases/conformance/externalModules/moduleResolutionWithoutExtension2.ts
create mode 100644 tests/cases/conformance/externalModules/moduleResolutionWithoutExtension3.ts
create mode 100644 tests/cases/conformance/externalModules/moduleResolutionWithoutExtension4.ts
create mode 100644 tests/cases/conformance/externalModules/moduleResolutionWithoutExtension5.ts
create mode 100644 tests/cases/conformance/externalModules/moduleResolutionWithoutExtension6.ts
create mode 100644 tests/cases/conformance/externalModules/moduleResolutionWithoutExtension7.ts
create mode 100644 tests/cases/conformance/externalModules/moduleResolutionWithoutExtension8.ts
create mode 100644 tests/cases/conformance/externalModules/typeOnly/exportSpecifiers.ts
create mode 100644 tests/cases/conformance/externalModules/typeOnly/importDefaultNamedType/a.ts
create mode 100644 tests/cases/conformance/externalModules/typeOnly/importDefaultNamedType/importDefaultNamedType.ts
create mode 100644 tests/cases/conformance/externalModules/typeOnly/importSpecifiers1.ts
create mode 100644 tests/cases/conformance/externalModules/typeOnly/preserveValueImports.ts
create mode 100644 tests/cases/conformance/externalModules/typeOnly/preserveValueImports_errors.ts
create mode 100644 tests/cases/conformance/externalModules/typeOnly/preserveValueImports_importsNotUsedAsValues.ts
create mode 100644 tests/cases/conformance/externalModules/typeOnly/preserveValueImports_mixedImports.ts
create mode 100644 tests/cases/conformance/externalModules/typeOnly/preserveValueImports_module.ts
create mode 100644 tests/cases/conformance/importAssertion/importAssertion1.ts
create mode 100644 tests/cases/conformance/importAssertion/importAssertion2.ts
create mode 100644 tests/cases/conformance/importAssertion/importAssertion3.ts
create mode 100644 tests/cases/conformance/importAssertion/importAssertion4.ts
create mode 100644 tests/cases/conformance/importAssertion/importAssertion5.ts
create mode 100644 tests/cases/conformance/jsdoc/enumTagImported/enumTagImported.ts
create mode 100644 tests/cases/conformance/jsdoc/jsdocAugments_qualifiedName/jsdocAugments_qualifiedName.ts
create mode 100644 tests/cases/conformance/jsdoc/jsdocTemplateTagDefault.ts
create mode 100644 tests/cases/conformance/jsdoc/jsdocTemplateTagNameResolution.ts
create mode 100644 tests/cases/conformance/jsdoc/jsdocVariadicType.ts
create mode 100644 tests/cases/conformance/jsdoc/seeTag3.ts
create mode 100644 tests/cases/conformance/jsdoc/thisTag2.ts
create mode 100644 tests/cases/conformance/jsx/jsxParsingError4.tsx
create mode 100644 tests/cases/conformance/jsx/jsxUnclosedParserRecovery.ts
create mode 100644 tests/cases/conformance/jsx/tsxReactEmitSpreadAttribute.ts
create mode 100644 tests/cases/conformance/moduleResolution/declarationNotFoundPackageBundlesTypes.ts
create mode 100644 tests/cases/conformance/moduleResolution/scopedPackages/index.d.ts
create mode 100644 tests/cases/conformance/moduleResolution/scopedPackages/scopedPackages.ts
create mode 100644 tests/cases/conformance/moduleResolution/scopedPackages/z.d.ts
create mode 100644 tests/cases/conformance/moduleResolution/scopedPackagesClassic/index.d.ts
create mode 100644 tests/cases/conformance/moduleResolution/scopedPackagesClassic/scopedPackagesClassic.ts
create mode 100644 tests/cases/conformance/moduleResolution/untypedModuleImport_allowJs/untypedModuleImport_allowJs.ts
create mode 100644 tests/cases/conformance/moduleResolution/untypedModuleImport_vsAmbient/declarations.d.ts
create mode 100644 tests/cases/conformance/moduleResolution/untypedModuleImport_vsAmbient/untypedModuleImport_vsAmbient.ts
create mode 100644 tests/cases/conformance/node/allowJs/nodeAllowJsPackageSelfName.ts
create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts
create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsCjsFromJs.ts
create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsConditionalPackageExports.ts
create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsDynamicImport.ts
create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsExportAssignment.ts
create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsGeneratedNameCollisions.ts
create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportAssignment.ts
create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions1.ts
create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions2.ts
create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions3.ts
create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportMeta.ts
create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageExports.ts
create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackageImports.ts
create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExports.ts
create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsPackagePatternExportsTrailers.ts
create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsSynchronousCallErrors.ts
create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsTopLevelAwait.ts
create mode 100644 tests/cases/conformance/node/legacyNodeModulesExportsSpecifierGenerationConditions.ts
create mode 100644 tests/cases/conformance/node/nodeModules1.ts
create mode 100644 tests/cases/conformance/node/nodeModulesCjsFormatFileAlwaysHasDefault.ts
create mode 100644 tests/cases/conformance/node/nodeModulesConditionalPackageExports.ts
create mode 100644 tests/cases/conformance/node/nodeModulesDeclarationEmitDynamicImportWithPackageExports.ts
create mode 100644 tests/cases/conformance/node/nodeModulesDeclarationEmitWithPackageExports.ts
create mode 100644 tests/cases/conformance/node/nodeModulesDynamicImport.ts
create mode 100644 tests/cases/conformance/node/nodeModulesExportAssignments.ts
create mode 100644 tests/cases/conformance/node/nodeModulesExportsBlocksSpecifierResolution.ts
create mode 100644 tests/cases/conformance/node/nodeModulesExportsSpecifierGenerationConditions.ts
create mode 100644 tests/cases/conformance/node/nodeModulesExportsSpecifierGenerationDirectory.ts
create mode 100644 tests/cases/conformance/node/nodeModulesExportsSpecifierGenerationPattern.ts
create mode 100644 tests/cases/conformance/node/nodeModulesForbidenSyntax.ts
create mode 100644 tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts
create mode 100644 tests/cases/conformance/node/nodeModulesImportAssertions.ts
create mode 100644 tests/cases/conformance/node/nodeModulesImportAssignments.ts
create mode 100644 tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts
create mode 100644 tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts
create mode 100644 tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts
create mode 100644 tests/cases/conformance/node/nodeModulesImportMeta.ts
create mode 100644 tests/cases/conformance/node/nodeModulesImportResolutionIntoExport.ts
create mode 100644 tests/cases/conformance/node/nodeModulesImportResolutionNoCycle.ts
create mode 100644 tests/cases/conformance/node/nodeModulesPackageExports.ts
create mode 100644 tests/cases/conformance/node/nodeModulesPackageImports.ts
create mode 100644 tests/cases/conformance/node/nodeModulesPackagePatternExports.ts
create mode 100644 tests/cases/conformance/node/nodeModulesPackagePatternExportsTrailers.ts
create mode 100644 tests/cases/conformance/node/nodeModulesResolveJsonModule.ts
create mode 100644 tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts
create mode 100644 tests/cases/conformance/node/nodeModulesTopLevelAwait.ts
create mode 100644 tests/cases/conformance/node/nodeModulesTypesVersionPackageExports.ts
create mode 100644 tests/cases/conformance/node/nodePackageSelfName.ts
create mode 100644 tests/cases/conformance/node/nodePackageSelfNameScoped.ts
create mode 100644 tests/cases/conformance/override/override15.ts
create mode 100644 tests/cases/conformance/override/override19.ts
create mode 100644 tests/cases/conformance/override/override20.ts
create mode 100644 tests/cases/conformance/override/override_js4.ts
create mode 100644 tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement22.ts
create mode 100644 tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement23.ts
create mode 100644 tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement24.ts
create mode 100644 tests/cases/conformance/salsa/plainJSBinderErrors.ts
create mode 100644 tests/cases/conformance/salsa/plainJSRedeclare.ts
create mode 100644 tests/cases/conformance/salsa/plainJSRedeclare2.ts
create mode 100644 tests/cases/conformance/salsa/plainJSRedeclare3.ts
create mode 100644 tests/cases/conformance/salsa/plainJSReservedStrict.ts
create mode 100644 tests/cases/conformance/salsa/spellingUncheckedJS.ts
create mode 100644 tests/cases/conformance/salsa/typeFromJSInitializer2.ts
create mode 100644 tests/cases/conformance/salsa/typeFromJSInitializer3.ts
create mode 100644 tests/cases/conformance/salsa/typeFromJSInitializer4.ts
create mode 100644 tests/cases/conformance/statements/for-inStatements/for-inStatementsAsyncIdentifier.ts
create mode 100644 tests/cases/conformance/types/intersection/intersectionOfUnionNarrowing.ts
create mode 100644 tests/cases/conformance/types/mapped/mappedTypeAsClauseRelationships.ts
create mode 100644 tests/cases/conformance/types/mapped/mappedTypeProperties.ts
create mode 100644 tests/cases/conformance/types/members/indexSignatures1.ts
create mode 100644 tests/cases/conformance/types/specifyingTypes/typeQueries/typeofThis.ts
create mode 100644 tests/cases/conformance/types/specifyingTypes/typeQueries/typeofThisWithImplicitThis.ts
create mode 100644 tests/cases/conformance/types/spread/spreadDuplicate.ts
create mode 100644 tests/cases/conformance/types/spread/spreadDuplicateExact.ts
create mode 100644 tests/cases/conformance/types/spread/spreadUnion4.ts
create mode 100644 tests/cases/conformance/types/thisType/thisTypeInTaggedTemplateCall.ts
create mode 100644 tests/cases/conformance/types/union/discriminatedUnionTypes3.ts
@@ -73,3 +73,4 @@ declare module 'external1' {
var q;
}
+let qq2 = new cls();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,11 @@
+// @Filename: user.ts
+///<reference path="declarations.d.ts" />
+import {foo, baz} from "foobarbaz";
+foo(baz);
+
+import {foos} from "foosball";
+foo(foos);
+
+// Works with relative file name
+import fileText from "./file!text";
+foo(fileText);
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,18 @@
+// @Filename: declarations.d.ts
+declare module "foo*baz" {
+ export function foo(s: string): void;
+}
+// Augmentations still work
+declare module "foo*baz" {
+ export const baz: string;
+}
+
+// Longest prefix wins
+declare module "foos*" {
+ export const foos: string;
+}
+
+declare module "*!text" {
+ const x: string;
+ export default x;
+}
@@ -4,6 +4,7 @@ module M {
export declare class C { }
export declare enum E { }
export declare module M { }
+ let qq1 = new C();
}
module M2 {
@@ -12,4 +13,5 @@ module M2 {
declare class C { }
declare enum E { }
declare module M { }
+ let qq1 = new C();
}
\ No newline at end of file
@@ -3,4 +3,6 @@ export declare var x;
export declare function f();
export declare class C { }
export declare enum E { }
-export declare module M { }
\ No newline at end of file
+export declare module M { }
+
+let qq1 = new C();
new file mode 100644
@@ -0,0 +1,6 @@
+// @Filename: user.ts
+///<reference path="declarations1.d.ts" />
+///<reference path="declarations1.d.ts" />
+import foo, {bar} from "foo";
+foo;
+bar;
new file mode 100644
@@ -0,0 +1,2 @@
+// @Filename: declarations1.d.ts
+declare module "foo";
new file mode 100644
@@ -0,0 +1,4 @@
+// @Filename: declarations2.d.ts
+declare module "foo" {
+ export const bar: number;
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,5 @@
+// @Filename: reExportUser.ts
+import {x} from "./reExportX";
+import * as $ from "./reExportAll";
+// '$' is not callable, it is an object.
+x($);
new file mode 100644
@@ -0,0 +1,2 @@
+// @Filename: declarations.d.ts
+declare module "jquery";
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,2 @@
+// @Filename: declarations.d.ts
+declare module "jquery";
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,2 @@
+// @Filename: reExportAll.ts
+export * from "jquery";
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,2 @@
+// @Filename: reExportX.ts
+export {x} from "jquery";
\ No newline at end of file
@@ -55,3 +55,4 @@ class B extends A {
({ f: super["x"] } = { f });
}
}
+let b1 = new B();
new file mode 100644
@@ -0,0 +1,49 @@
+// @target: esnext
+
+function f_let () {
+ let await = 1
+}
+
+function f1_var () {
+ var await = 1
+}
+
+function f1_const () {
+ const await = 1
+}
+
+async function f2_let () {
+ let await = 1
+}
+
+async function f2_var () {
+ var await = 1
+}
+
+async function f2_const () {
+ const await = 1
+}
+
+function f3_let () {
+ let yield = 2
+}
+
+function f3_var () {
+ var yield = 2
+}
+
+function f3_const () {
+ const yield = 2
+}
+
+function * f4_let () {
+ let yield = 2;
+}
+
+function * f4_var () {
+ var yield = 2;
+}
+
+function * f4_const () {
+ const yield = 2;
+}
\ No newline at end of file
@@ -1,5 +1,5 @@
class abstract {
foo() { return 1; }
}
-
+let a = new abstract()
new abstract;
\ No newline at end of file
@@ -17,4 +17,6 @@ var d: D;
var o: {} = d;
d = 1;
d = { foo: '' }
-d = () => { }
\ No newline at end of file
+d = () => { }
+let cc = new C();
+let dd = new D();
\ No newline at end of file
@@ -1,3 +1,4 @@
function foo() {
class C { }
+ let a1 = new C()
}
\ No newline at end of file
@@ -3,4 +3,6 @@
class any { }
class number { }
class boolean { }
-class string { }
\ No newline at end of file
+class string { }
+
+let aa = new any();
\ No newline at end of file
@@ -1,3 +1,4 @@
class C {
;
-}
\ No newline at end of file
+}
+let c9 = new C()
\ No newline at end of file
@@ -1,4 +1,5 @@
class C {
;
;
-}
\ No newline at end of file
+}
+let a15 = new C()
\ No newline at end of file
@@ -1,2 +1,4 @@
class D { }
-var v = class C extends D {};
\ No newline at end of file
+var v = class C extends D {};
+let dd = new D()
+let vv = new v()
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,11 @@
+// @target: esnext, es2015, es5
+const a = 2;
+
+class C {
+ static {
+ const a = 1;
+
+ a;
+ }
+}
+let a1 = new C()
new file mode 100644
@@ -0,0 +1,30 @@
+// @target: esnext, es2015, es5
+var a1 = 1;
+var a2 = 1;
+const b1 = 2;
+const b2 = 2;
+
+function f () {
+ var a1 = 11;
+ const b1 = 22;
+
+ class C1 {
+ static {
+ var a1 = 111;
+ var a2 = 111;
+ const b1 = 222;
+ const b2 = 222;
+ }
+ }
+ let c1 = new C1();
+}
+
+class C2 {
+ static {
+ var a1 = 111;
+ var a2 = 111;
+ const b1 = 222;
+ const b2 = 222;
+ }
+}
+let c2 = new C2();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,15 @@
+// @target: esnext, es2015
+
+let getX;
+class C {
+ #x = 1
+ constructor(x: number) {
+ this.#x = x;
+ }
+
+ static {
+ // getX has privileged access to #x
+ getX = (obj: C) => obj.#x;
+ }
+}
+let cc = new C(1);
new file mode 100644
@@ -0,0 +1,10 @@
+// @useDefineForClassFields: false
+// @target: es2015
+
+class C {
+ static #x = 1;
+
+ static {
+ C.#x;
+ }
+}
new file mode 100644
@@ -0,0 +1,14 @@
+// @target: esnext, es2015
+// @useDefineForClassFields: true
+
+class C {
+ static #x = 123;
+
+ static {
+ console.log(C.#x)
+ }
+
+ foo () {
+ return C.#x;
+ }
+}
new file mode 100644
@@ -0,0 +1,15 @@
+// @useDefineForClassFields: false
+// @target: es2015
+
+class C {
+ static #_1 = 1;
+ static #_3 = 1;
+ static #_5 = 1;
+
+ static {}
+ static {}
+ static {}
+ static {}
+ static {}
+ static {}
+}
new file mode 100644
@@ -0,0 +1,18 @@
+// @target: esnext, es2015
+// @useDefineForClassFields: true
+var _C__1;
+
+class C {
+ static #_1 = 1;
+ static #_3 = 3;
+ static #_5 = 5;
+
+ static {}
+ static {}
+ static {}
+ static {}
+ static {}
+ static {}
+}
+
+console.log(_C__1)
new file mode 100644
@@ -0,0 +1,26 @@
+// @target: es2015
+
+let getX: (c: C) => number;
+class C {
+ #x = 1
+ constructor(x: number) {
+ this.#x = x;
+ }
+
+ static {
+ // getX has privileged access to #x
+ getX = (obj: C) => obj.#x;
+ getY = (obj: D) => obj.#y;
+ }
+}
+
+let getY: (c: D) => number;
+class D {
+ #y = 1
+
+ static {
+ // getY has privileged access to y
+ getX = (obj: C) => obj.#x;
+ getY = (obj: D) => obj.#y;
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,33 @@
+// @target: es2015
+
+let friendA: { getX(o: A): number, setX(o: A, v: number): void };
+
+class A {
+ #x: number;
+
+ constructor (v: number) {
+ this.#x = v;
+ }
+
+ getX () {
+ return this.#x;
+ }
+
+ static {
+ friendA = {
+ getX(obj) { return obj.#x },
+ setX(obj, value) { obj.#x = value }
+ };
+ }
+};
+
+class B {
+ constructor(a: A) {
+ const x = friendA.getX(a); // ok
+ friendA.setX(a, x + 1); // ok
+ }
+};
+
+const a = new A(41);
+const b = new B(a);
+a.getX();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,15 @@
+// @target: esnext, es2015, es5
+
+function foo () {
+ return class {
+ static foo = 1;
+ static {
+ const c = class {
+ static bar = 2;
+ static {
+ // do
+ }
+ }
+ }
+ }
+}
new file mode 100644
@@ -0,0 +1,6 @@
+class C {
+ @decorator
+ static {
+ // something
+ }
+}
new file mode 100644
@@ -0,0 +1,20 @@
+// @target: esnext, es2015, es5
+
+const a = 1;
+const b = 2;
+
+class C {
+ static {
+ const a = 11;
+
+ a;
+ b;
+ }
+
+ static {
+ const a = 11;
+
+ a;
+ b;
+ }
+}
new file mode 100644
@@ -0,0 +1,13 @@
+class C {
+ async static {
+ // something
+ }
+
+ public static {
+ // something
+ }
+
+ readonly private static {
+ // something
+ }
+}
new file mode 100644
@@ -0,0 +1,7 @@
+class C {
+ /* jsdocs */
+ static {
+ // something
+ }
+}
+let cc = new C();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,72 @@
+// @target: esnext
+
+let await: "any";
+class C {
+ static {
+ let await: any; // illegal, cannot declare a new binding for await
+ }
+ static {
+ let { await } = {} as any; // illegal, cannot declare a new binding for await
+ }
+ static {
+ let { await: other } = {} as any; // legal
+ }
+ static {
+ let await; // illegal, cannot declare a new binding for await
+ }
+ static {
+ function await() { }; // illegal
+ }
+ static {
+ class await { }; // illegal
+ }
+
+ static {
+ class D {
+ await = 1; // legal
+ x = await; // legal (initializers have an implicit function boundary)
+ };
+ }
+ static {
+ (function await() { }); // legal, 'await' in function expression name not bound inside of static block
+ }
+ static {
+ (class await { }); // legal, 'await' in class expression name not bound inside of static block
+ }
+ static {
+ (function () { return await; }); // legal, 'await' is inside of a new function boundary
+ }
+ static {
+ (() => await); // legal, 'await' is inside of a new function boundary
+ }
+
+ static {
+ class E {
+ constructor() { await; }
+ method() { await; }
+ get accessor() {
+ await;
+ return 1;
+ }
+ set accessor(v: any) {
+ await;
+ }
+ propLambda = () => { await; }
+ propFunc = function () { await; }
+ }
+ }
+ static {
+ class S {
+ static method() { await; }
+ static get accessor() {
+ await;
+ return 1;
+ }
+ static set accessor(v: any) {
+ await;
+ }
+ static propLambda = () => { await; }
+ static propFunc = function () { await; }
+ }
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,21 @@
+// @target: esnext
+
+const nums = [1, 2, 3].map(n => Promise.resolve(n))
+
+class C {
+ static {
+ for await (const nn of nums) {
+ console.log(nn)
+ }
+ }
+}
+
+async function foo () {
+ class C {
+ static {
+ for await (const nn of nums) {
+ console.log(nn)
+ }
+ }
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,8 @@
+// @module: commonjs, es2015, es2020, UMD, AMD, System, esnext
+
+export class C {
+ static x: number;
+ static {
+ C.x = 1;
+ }
+}
new file mode 100644
@@ -0,0 +1,23 @@
+// @target: esnext
+// @declaration: true
+// @declarationMap: true
+// @sourceMap: true
+
+const a = 1;
+const b = 2;
+
+class C {
+ static {
+ const a = 11;
+
+ a;
+ b;
+ }
+
+ static {
+ const a = 11;
+
+ a;
+ b;
+ }
+}
new file mode 100644
@@ -0,0 +1,30 @@
+// @target: esnext
+
+class C {
+ static {
+ await; // illegal
+ }
+ static {
+ await (1); // illegal
+ }
+ static {
+ ({ [await]: 1 }); // illegal
+ }
+ static {
+ class D {
+ [await] = 1; // illegal (computed property names are evaluated outside of a class body
+ };
+ }
+ static {
+ ({ await }); // illegal short-hand property reference
+ }
+ static {
+ await: // illegal, 'await' cannot be used as a label
+ break await; // illegal, 'await' cannot be used as a label
+ }
+ static {
+ function f(await) { }
+ const ff = (await) => { }
+ const fff = await => { }
+ }
+}
new file mode 100644
@@ -0,0 +1,17 @@
+// https://github.com/microsoft/TypeScript/issues/44872
+
+void class Foo {
+ static prop = 1
+ static {
+ console.log(Foo.prop);
+ Foo.prop++;
+ }
+ static {
+ console.log(Foo.prop);
+ Foo.prop++;
+ }
+ static {
+ console.log(Foo.prop);
+ Foo.prop++;
+ }
+}
new file mode 100644
@@ -0,0 +1,19 @@
+// @target: esnext
+
+const a = 1;
+
+class C {
+ static f1 = 1;
+
+ static {
+ console.log(C.f1, C.f2, C.f3)
+ }
+
+ static f2 = 2;
+
+ static {
+ console.log(C.f1, C.f2, C.f3)
+ }
+
+ static f3 = 3;
+}
new file mode 100644
@@ -0,0 +1,16 @@
+// @target: esnext
+
+class C {
+ static s1 = 1;
+
+ static {
+ this.s1;
+ C.s1;
+
+ this.s2;
+ C.s2;
+ }
+
+ static s2 = 2;
+ static ss2 = this.s1;
+}
new file mode 100644
@@ -0,0 +1,19 @@
+// @target: esnext, es2015, es5
+
+class B {
+ static a = 1;
+ static b = 2;
+}
+
+class C extends B {
+ static b = 3;
+ static c = super.a
+
+ static {
+ this.b;
+ super.b;
+ super.a;
+ }
+}
+
+let cc = new C();
new file mode 100644
@@ -0,0 +1,62 @@
+class B {
+ static a = 1;
+}
+
+class C extends B {
+ static {
+ let await = 1;
+ let arguments = 1;
+ let eval = 1;
+ }
+
+ static {
+ await: if (true) {
+
+ }
+
+ arguments;
+ await;
+ super();
+ }
+}
+
+class CC {
+ constructor () {
+ class C extends B {
+ static {
+ class CC extends B {
+ constructor () {
+ super();
+ }
+ }
+ super();
+ }
+ }
+ }
+}
+
+async function foo () {
+ class C extends B {
+ static {
+ arguments;
+ await;
+
+ async function ff () {
+ arguments;
+ await;
+ }
+ }
+ }
+}
+
+function foo1 () {
+ class C extends B {
+ static {
+ arguments;
+
+ function ff () {
+ arguments;
+ }
+ }
+ }
+}
new file mode 100644
@@ -0,0 +1,43 @@
+class C {
+ static {
+ await 1;
+ yield 1;
+ return 1;
+ }
+}
+
+async function f1 () {
+ class C {
+ static {
+ await 1;
+
+ async function ff () {
+ await 1;
+ }
+ }
+ }
+}
+
+function * f2 () {
+ class C {
+ static {
+ yield 1;
+
+ function * ff () {
+ yield 1;
+ }
+ }
+ }
+}
+
+function f3 () {
+ class C {
+ static {
+ return 1;
+
+ function ff () {
+ return 1
+ }
+ }
+ }
+}
new file mode 100644
@@ -0,0 +1,48 @@
+function foo (v: number) {
+ label: while (v) {
+ class C {
+ static {
+ if (v === 1) {
+ break label;
+ }
+ if (v === 2) {
+ continue label;
+ }
+ if (v === 3) {
+ break
+ }
+ if (v === 4) {
+ continue
+ }
+ }
+ }
+
+ if (v === 5) {
+ break label;
+ }
+ if (v === 6) {
+ continue label;
+ }
+ if (v === 7) {
+ break;
+ }
+ if (v === 8) {
+ continue;
+ }
+ }
+
+ class C {
+ static {
+ outer: break outer; // valid
+ loop: while (v) {
+ if (v === 1) break loop; // valid
+ if (v === 2) continue loop; // valid
+ if (v === 3) break; // valid
+ if (v === 4) continue; // valid
+ }
+ switch (v) {
+ default: break; // valid
+ }
+ }
+ }
+}
new file mode 100644
@@ -0,0 +1,8 @@
+// @target: esnext, es2015, es5
+class A {
+ static bar = A.foo + 1
+ static {
+ A.foo + 2;
+ }
+ static foo = 1;
+}
new file mode 100644
@@ -0,0 +1,15 @@
+// @target: esnext
+// @noEmit: true
+// @strict: true
+
+class C {
+ static x;
+ static {
+ this.x = 1;
+ }
+ static y = this.x;
+ static z;
+ static {
+ this.z = this.y;
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,10 @@
+// @target: esnext
+// @noEmit: true
+// @strict: true
+
+class C {
+ static {
+ this.x = 1;
+ }
+ static x;
+}
\ No newline at end of file
@@ -14,6 +14,7 @@ class A {
}
}
}
+let aa = new A();
class D {
protected constructor() { }
@@ -28,4 +29,5 @@ class D {
class F extends D { // OK
}
}
-}
\ No newline at end of file
+}
+let dd = new D();
\ No newline at end of file
@@ -17,4 +17,8 @@ class E<T extends Date> {
constructor(x: T = null) {
var y = x;
}
-}
\ No newline at end of file
+}
+
+let cc = new C(null);
+let dd = new D(null);
+let ee = new E(null);
\ No newline at end of file
@@ -2,4 +2,5 @@
class C {
constructor(readonly x: number) {}
-}
\ No newline at end of file
+}
+let c7 = new C(1)
\ No newline at end of file
@@ -29,3 +29,7 @@ class F {
console.log(this);
}
}
+let c3 =new C()
+let c4 =new D()
+let c5 =new E()
+let c6 =new F()
\ No newline at end of file
@@ -14,4 +14,6 @@ class Base2 {
// ok, use assignment compatibility
class Derived2 extends Base2 {
[x: number]: any;
-}
\ No newline at end of file
+}
+let c1 = new Derived()
+let c2 = new Derived2()
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,492 @@
+// @target: es5, es2015, es2021, esnext
+// @noTypesAndSymbols: true
+
+// @filename: external.ts
+export class Reflect {}
+export interface Foo {}
+export declare namespace Bar { type _ = unknown; }
+export const enum Baz {}
+export default class {};
+
+// @filename: locals.ts
+export {};
+declare class B { static w(): number; }
+class C extends B {
+ static _ = [
+ (() => {
+ var Reflect; // collision (es2015-es2021 only)
+ super.w();
+ })(),
+ (() => {
+ var { Reflect } = { Reflect: null }; // collision (es2015-es2021 only)
+ super.w();
+ })(),
+ (() => {
+ var [Reflect] = [null]; // collision (es2015-es2021 only)
+ super.w();
+ })(),
+ (() => {
+ class Reflect {} // collision (es2015-es2021 only)
+ super.w();
+ })(),
+ (() => {
+ function Reflect() {} // collision (es2015-es2021 only)
+ super.w();
+ })(),
+ (() => {
+ enum Reflect {} // collision (es2015-es2021 only)
+ super.w();
+ })(),
+ (() => {
+ const enum Reflect {} // collision (es2015-es2021 only)
+ super.w();
+ })(),
+ (() => {
+ type Reflect = unknown; // no collision
+ super.w();
+ })(),
+ (() => {
+ interface Reflect {}; // no collision
+ super.w();
+ })(),
+ (() => {
+ (class Reflect {}); // no collision
+ super.w();
+ })(),
+ (() => {
+ (function Reflect() {}); // no collision
+ super.w();
+ })(),
+ ];
+
+ static {
+ var { Reflect } = { Reflect: null }; // collision (es2015-es2021 only)
+ super.w();
+ }
+
+ static {
+ var [Reflect] = [null]; // collision (es2015-es2021 only)
+ super.w();
+ }
+
+ static {
+ var Reflect; // collision (es2015-es2021 only)
+ super.w();
+ }
+
+ static {
+ class Reflect {} // collision (es2015-es2021 only)
+ super.w();
+ }
+
+ static {
+ function Reflect() {} // collision (es2015-es2021 only)
+ super.w();
+ }
+
+ static {
+ enum Reflect {} // collision (es2015-es2021 only)
+ super.w();
+ }
+
+ static {
+ const enum Reflect {} // collision (es2015-es2021 only)
+ super.w();
+ }
+
+ static {
+ type Reflect = unknown; // no collision
+ super.w();
+ }
+
+ static {
+ interface Reflect {} // no collision
+ super.w();
+ }
+
+ static {
+ (class Reflect {}) // no collision
+ super.w();
+ }
+
+ static {
+ (function Reflect() {}) // no collision
+ super.w();
+ }
+}
+
+// @filename: varInContainingScopeStaticField1.ts
+export {};
+declare class B { static w(): number; }
+var Reflect = null; // collision (es2015-es2021 only)
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: varInContainingScopeStaticField2.ts
+export {};
+declare class B { static w(): number; }
+var { Reflect } = { Reflect: null }; // collision (es2015-es2021 only)
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: varInContainingScopeStaticField3.ts
+export {};
+declare class B { static w(): number; }
+var [Reflect] = [null]; // collision (es2015-es2021 only)
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: varInContainingScopeStaticBlock1.ts
+export {};
+declare class B { static w(): number; }
+var Reflect = null; // collision (es2015-es2021 only)
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: varInContainingScopeStaticBlock2.ts
+export {};
+declare class B { static w(): number; }
+var { Reflect } = { Reflect: null }; // collision (es2015-es2021 only)
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: varInContainingScopeStaticBlock3.ts
+export {};
+declare class B { static w(): number; }
+var [Reflect] = [null]; // collision (es2015-es2021 only)
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: classDeclInContainingScopeStaticField.ts
+export {};
+declare class B { static w(): number; }
+class Reflect {} // collision (es2015-es2021 only)
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: classDeclInContainingScopeStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+class Reflect {} // collision (es2015-es2021 only)
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: funcDeclInContainingScopeStaticField.ts
+export {};
+declare class B { static w(): number; }
+function Reflect() {} // collision (es2015-es2021 only)
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: funcDeclInContainingScopeStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+function Reflect() {} // collision (es2015-es2021 only)
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: valueNamespaceInContainingScopeStaticField.ts
+export {};
+declare class B { static w(): number; }
+namespace Reflect {} // collision (es2015-es2021 only)
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: valueNamespaceInContainingScopeStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+namespace Reflect {} // collision (es2015-es2021 only)
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: enumInContainingScopeStaticField.ts
+export {};
+declare class B { static w(): number; }
+enum Reflect {} // collision (es2015-es2021 only)
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: enumInContainingScopeStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+enum Reflect {} // collision (es2015-es2021 only)
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: constEnumInContainingScopeStaticField.ts
+export {};
+declare class B { static w(): number; }
+const enum Reflect {} // collision (es2015-es2021 only)
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: constEnumInContainingScopeStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+const enum Reflect {} // collision (es2015-es2021 only)
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: namespaceImportInContainingScopeStaticField.ts
+export {};
+declare class B { static w(): number; }
+import * as Reflect from "./external"; // collision (es2015-es2021 only)
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: namespaceImportInContainingScopeStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+import * as Reflect from "./external"; // collision (es2015-es2021 only)
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: namedImportInContainingScopeStaticField.ts
+export {};
+declare class B { static w(): number; }
+import { Reflect } from "./external"; // collision (es2015-es2021 only)
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: namedImportInContainingScopeStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+import { Reflect } from "./external"; // collision (es2015-es2021 only)
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: namedImportOfInterfaceInContainingScopeStaticField.ts
+export {};
+declare class B { static w(): number; }
+import { Foo as Reflect } from "./external"; // collision (es2015-es2021 only, not a type-only import)
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: namedImportOfInterfaceInContainingScopeStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+import { Foo as Reflect } from "./external"; // collision (es2015-es2021 only, not a type-only import)
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: namedImportOfUninstantiatedNamespaceInContainingScopeStaticField.ts
+export {};
+declare class B { static w(): number; }
+import { Bar as Reflect } from "./external"; // collision (es2015-es2021 only, not a type-only import)
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: namedImportOfUninstantiatedNamespaceInContainingScopeStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+import { Bar as Reflect } from "./external"; // collision (es2015-es2021 only, not a type-only import)
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: namedImportOfConstEnumInContainingScopeStaticField.ts
+export {};
+declare class B { static w(): number; }
+import { Baz as Reflect } from "./external"; // collision (es2015-es2021 only)
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: namedImportOfConstEnumInContainingScopeStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+import { Baz as Reflect } from "./external"; // collision (es2015-es2021 only)
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: typeOnlyNamedImportInContainingScopeStaticField.ts
+export {};
+declare class B { static w(): number; }
+import type { Reflect } from "./external"; // no collision
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: typeOnlyNamedImportInContainingScopeStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+import type { Reflect } from "./external"; // no collision
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: defaultImportInContainingScopeStaticField.ts
+export {};
+declare class B { static w(): number; }
+import Reflect from "./external"; // collision (es2015-es2021 only)
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: defaultImportInContainingScopeStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+import Reflect from "./external"; // collision (es2015-es2021 only)
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: typeOnlyDefaultImportInContainingScopeStaticField.ts
+export {};
+declare class B { static w(): number; }
+import type Reflect from "./external"; // no collision
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: typeOnlyDefaultImportInContainingScopeStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+import type Reflect from "./external"; // no collision
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: typeInContainingScopeStaticField.ts
+export {};
+declare class B { static w(): number; }
+type Reflect = unknown; // no collision
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: typeInContainingScopeStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+type Reflect = unknown; // no collision
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: interfaceInContainingScopeStaticField.ts
+export {};
+declare class B { static w(): number; }
+interface Reflect {}; // no collision
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: interfaceInContainingScopeStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+interface Reflect {}; // no collision
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: uninstantiatedNamespaceInContainingScopeStaticField.ts
+export {};
+declare class B { static w(): number; }
+declare namespace Reflect { type _ = unknown; }; // no collision
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: uninstantiatedNamespaceInContainingScopeStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+declare namespace Reflect { type _ = unknown; }; // no collision
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: classExprInContainingScopeStaticField.ts
+export {};
+declare class B { static w(): number; }
+(class Reflect {}); // no collision
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: classExprInContainingScopeStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+(class Reflect {}); // no collision
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: inContainingClassExprStaticField.ts
+export {};
+declare class B { static w(): number; }
+(class Reflect { // collision (es2015-es2021 only)
+ static {
+ class C extends B {
+ static _ = super.w();
+ }
+ }
+});
+
+// @filename: inContainingClassExprStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+(class Reflect { // collision (es2015-es2021 only)
+ static {
+ class C extends B {
+ static { super.w(); }
+ }
+ }
+});
+
+// @filename: funcExprInContainingScopeStaticField.ts
+export {};
+declare class B { static w(): number; }
+(function Reflect() {}); // no collision
+class C extends B {
+ static _ = super.w();
+}
+
+// @filename: funcExprInContainingScopeStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+(function Reflect() {}); // no collision
+class C extends B {
+ static { super.w(); }
+}
+
+// @filename: inContainingFuncExprStaticField.ts
+export {};
+declare class B { static w(): number; }
+(function Reflect() { // collision (es2015-es2021 only)
+ class C extends B {
+ static _ = super.w();
+ }
+});
+
+// @filename: inContainingFuncExprStaticBlock.ts
+export {};
+declare class B { static w(): number; }
+(function Reflect() { // collision (es2015-es2021 only)
+ class C extends B {
+ static { super.w(); }
+ }
+});
new file mode 100644
@@ -0,0 +1,42 @@
+// @target: esnext, es2015
+// @useDefineForClassFields: true
+// @noTypesAndSymbols: true
+
+declare class B {
+ static a: any;
+ static f(): number;
+ a: number;
+ f(): number;
+}
+
+class C extends B {
+ static x: any = undefined!;
+ static y1 = this.x;
+ static y2 = this.x();
+ static y3 = this?.x();
+ static y4 = this[("x")]();
+ static y5 = this?.[("x")]();
+ static z1 = super.a;
+ static z2 = super["a"];
+ static z3 = super.f();
+ static z4 = super["f"]();
+ static z5 = super.a = 0;
+ static z6 = super.a += 1;
+ static z7 = (() => { super.a = 0; })();
+ static z8 = [super.a] = [0];
+ static z9 = [super.a = 0] = [0];
+ static z10 = [...super.a] = [0];
+ static z11 = { x: super.a } = { x: 0 };
+ static z12 = { x: super.a = 0 } = { x: 0 };
+ static z13 = { ...super.a } = { x: 0 };
+ static z14 = ++super.a;
+ static z15 = --super.a;
+ static z16 = ++super[("a")];
+ static z17 = super.a++;
+ static z18 = super.a``;
+
+ // these should be unaffected
+ x = 1;
+ y = this.x;
+ z = super.f();
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,42 @@
+// @target: esnext, es2015
+// @useDefineForClassFields: false
+// @noTypesAndSymbols: true
+
+declare class B {
+ static a: any;
+ static f(): number;
+ a: number;
+ f(): number;
+}
+
+class C extends B {
+ static x: any = undefined!;
+ static y1 = this.x;
+ static y2 = this.x();
+ static y3 = this?.x();
+ static y4 = this[("x")]();
+ static y5 = this?.[("x")]();
+ static z1 = super.a;
+ static z2 = super["a"];
+ static z3 = super.f();
+ static z4 = super["f"]();
+ static z5 = super.a = 0;
+ static z6 = super.a += 1;
+ static z7 = (() => { super.a = 0; })();
+ static z8 = [super.a] = [0];
+ static z9 = [super.a = 0] = [0];
+ static z10 = [...super.a] = [0];
+ static z11 = { x: super.a } = { x: 0 };
+ static z12 = { x: super.a = 0 } = { x: 0 };
+ static z13 = { ...super.a } = { x: 0 };
+ static z14 = ++super.a;
+ static z15 = --super.a;
+ static z16 = ++super[("a")];
+ static z17 = super.a++;
+ static z18 = super.a``;
+
+ // these should be unaffected
+ x = 1;
+ y = this.x;
+ z = super.f();
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,26 @@
+// @target: es5
+// @useDefineForClassFields: true
+// @noTypesAndSymbols: true
+
+declare class B {
+ static a: any;
+ static f(): number;
+ a: number;
+ f(): number;
+}
+
+class C extends B {
+ static x: any = undefined!;
+ static y1 = this.x;
+ static y2 = this.x();
+ static y3 = this?.x();
+ static y4 = this[("x")]();
+ static y5 = this?.[("x")]();
+ static z3 = super.f();
+ static z4 = super["f"]();
+
+ // these should be unaffected
+ x = 1;
+ y = this.x;
+ z = super.f();
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,26 @@
+// @target: es5
+// @useDefineForClassFields: false
+// @noTypesAndSymbols: true
+
+declare class B {
+ static a: any;
+ static f(): number;
+ a: number;
+ f(): number;
+}
+
+class C extends B {
+ static x: any = undefined!;
+ static y1 = this.x;
+ static y2 = this.x();
+ static y3 = this?.x();
+ static y4 = this[("x")]();
+ static y5 = this?.[("x")]();
+ static z3 = super.f();
+ static z4 = super["f"]();
+
+ // these should be unaffected
+ x = 1;
+ y = this.x;
+ z = super.f();
+}
\ No newline at end of file
@@ -30,4 +30,5 @@ var t2 = C2.bar();
var r5 = t2.foo + 1;
var r6 = t2.bar();
var r7 = new t2('');
-
+let b2 = new C(1)
+let b3 = new C2('null')
new file mode 100644
@@ -0,0 +1,51 @@
+// @target: esnext, es6, es5
+// @experimentalDecorators: true
+// @useDefineForClassFields: false
+
+declare const foo: any;
+
+@foo
+class C {
+ static a = 1;
+ static b = this.a + 1;
+}
+
+@foo
+class D extends C {
+ static c = 2;
+ static d = this.c + 1;
+ static e = super.a + this.c + 1;
+ static f = () => this.c + 1;
+ static ff = function () { this.c + 1 }
+ static foo () {
+ return this.c + 1;
+ }
+ static get fa () {
+ return this.c + 1;
+ }
+ static set fa (v: number) {
+ this.c = v + 1;
+ }
+}
+
+class CC {
+ static a = 1;
+ static b = this.a + 1;
+}
+
+class DD extends CC {
+ static c = 2;
+ static d = this.c + 1;
+ static e = super.a + this.c + 1;
+ static f = () => this.c + 1;
+ static ff = function () { this.c + 1 }
+ static foo () {
+ return this.c + 1;
+ }
+ static get fa () {
+ return this.c + 1;
+ }
+ static set fa (v: number) {
+ this.c = v + 1;
+ }
+}
new file mode 100644
@@ -0,0 +1,51 @@
+// @target: esnext, es6, es5
+// @experimentalDecorators: true
+// @useDefineForClassFields: true
+
+declare const foo: any;
+
+@foo
+class C {
+ static a = 1;
+ static b = this.a + 1;
+}
+
+@foo
+class D extends C {
+ static c = 2;
+ static d = this.c + 1;
+ static e = super.a + this.c + 1;
+ static f = () => this.c + 1;
+ static ff = function () { this.c + 1 }
+ static foo () {
+ return this.c + 1;
+ }
+ static get fa () {
+ return this.c + 1;
+ }
+ static set fa (v: number) {
+ this.c = v + 1;
+ }
+}
+
+class CC {
+ static a = 1;
+ static b = this.a + 1;
+}
+
+class DD extends CC {
+ static c = 2;
+ static d = this.c + 1;
+ static e = super.a + this.c + 1;
+ static f = () => this.c + 1;
+ static ff = function () { this.c + 1 }
+ static foo () {
+ return this.c + 1;
+ }
+ static get fa () {
+ return this.c + 1;
+ }
+ static set fa (v: number) {
+ this.c = v + 1;
+ }
+}
new file mode 100644
@@ -0,0 +1,10 @@
+// @target: esnext, es6, es5
+// @useDefineForClassFields: false
+
+class C {
+ static readonly c: "foo" = "foo"
+ static bar = class Inner {
+ static [this.c] = 123;
+ [this.c] = 123;
+ }
+}
new file mode 100644
@@ -0,0 +1,10 @@
+// @target: esnext, es6, es5
+// @useDefineForClassFields: true
+
+class C {
+ static readonly c: "foo" = "foo"
+ static bar = class Inner {
+ static [this.c] = 123;
+ [this.c] = 123;
+ }
+}
new file mode 100644
@@ -0,0 +1,12 @@
+// @target: esnext, es6, es5
+// @useDefineForClassFields: false
+class C {
+ static a = 1;
+ static b = this.a + 1;
+}
+
+class D extends C {
+ static c = 2;
+ static d = this.c + 1;
+ static e = super.a + this.c + 1;
+}
new file mode 100644
@@ -0,0 +1,12 @@
+// @target: esnext, es6, es5
+// @useDefineForClassFields: true
+class C {
+ static a = 1;
+ static b = this.a + 1;
+}
+
+class D extends C {
+ static c = 2;
+ static d = this.c + 1;
+ static e = super.a + this.c + 1;
+}
new file mode 100644
@@ -0,0 +1,9 @@
+// @target: esnext, es6, es5
+
+class C {
+ static create = () => new this("yep")
+
+ constructor (private foo: string) {
+
+ }
+}
new file mode 100644
@@ -0,0 +1,7 @@
+class C {
+ static f = 1
+}
+
+class D extends C {
+ static c = super();
+}
new file mode 100644
@@ -0,0 +1,12 @@
+// @target: esnext, es6, es5
+
+class C {
+ static a = 1;
+ static b = this.a + 1;
+}
+
+class D extends C {
+ static c = 2;
+ static d = this.c + 1;
+ static e = 1 + (super.a) + (this.c + 1) + 1;
+}
new file mode 100644
@@ -0,0 +1,19 @@
+// @target: esnext, es6, es5
+
+class C {
+ static f = 1;
+ static arrowFunctionBoundary = () => this.f + 1;
+ static functionExprBoundary = function () { return this.f + 2 };
+ static classExprBoundary = class { a = this.f + 3 };
+ static functionAndClassDeclBoundary = (() => {
+ function foo () {
+ return this.f + 4
+ }
+ class CC {
+ a = this.f + 5
+ method () {
+ return this.f + 6
+ }
+ }
+ })();
+}
new file mode 100644
@@ -0,0 +1,22 @@
+// @target: esnext, es6, es5
+
+class C {
+ static f = 1
+}
+
+class D extends C {
+ static arrowFunctionBoundary = () => super.f + 1;
+ static functionExprBoundary = function () { return super.f + 2 };
+ static classExprBoundary = class { a = super.f + 3 };
+ static functionAndClassDeclBoundary = (() => {
+ function foo () {
+ return super.f + 4
+ }
+ class C {
+ a = super.f + 5
+ method () {
+ return super.f +6
+ }
+ }
+ })();
+}
@@ -23,3 +23,5 @@ class Foo {
}
console.log(new Foo("NAME").getValue(100));
+
+let ff = new Foo(null)
\ No newline at end of file
@@ -6,3 +6,4 @@ class A {
console.log(this.#myField);
}
}
+let aa = new A();
new file mode 100644
@@ -0,0 +1,11 @@
+// @target: es6
+
+#
+
+class C {
+ #
+
+ m() {
+ this.#
+ }
+}
new file mode 100644
@@ -0,0 +1,119 @@
+// @strict: true
+// @target: esnext
+// @useDefineForClassFields: true
+
+class Foo {
+ #field = 1;
+ static #staticField = 2;
+ #method() {}
+ static #staticMethod() {}
+
+ goodRhs(v: any) {
+ const a = #field in v;
+
+ const b = #field in v.p1.p2;
+
+ const c = #field in (v as {});
+
+ const d = #field in (v as Foo);
+
+ const e = #field in (v as never);
+
+ for (let f in #field in v as any) { /**/ } // unlikely but valid
+ }
+ badRhs(v: any) {
+ const a = #field in (v as unknown); // Bad - RHS of in must be object type or any
+
+ const b = #fiel in v; // Bad - typo in privateID
+
+ const c = (#field) in v; // Bad - privateID is not an expression on its own
+
+ for (#field in v) { /**/ } // Bad - 'in' not allowed
+
+ for (let d in #field in v) { /**/ } // Bad - rhs of in should be a object/any
+ }
+ whitespace(v: any) {
+ const a = v && /*0*/#field/*1*/
+ /*2*/in/*3*/
+ /*4*/v/*5*/
+ }
+ flow(u: unknown, n: never, fb: Foo | Bar, fs: FooSub, b: Bar, fsb: FooSub | Bar, fsfb: Foo | FooSub | Bar) {
+
+ if (typeof u === 'object') {
+ if (#field in n) {
+ n; // good n is never
+ }
+
+ if (#field in u) {
+ u; // good u is Foo
+ } else {
+ u; // good u is object | null
+ }
+
+ if (u !== null) {
+ if (#field in u) {
+ u; // good u is Foo
+ } else {
+ u; // good u is object
+ }
+
+ if (#method in u) {
+ u; // good u is Foo
+ }
+
+ if (#staticField in u) {
+ u; // good u is typeof Foo
+ }
+
+ if (#staticMethod in u) {
+ u; // good u is typeof Foo
+ }
+ }
+ }
+
+ if (#field in fb) {
+ fb; // good fb is Foo
+ } else {
+ fb; // good fb is Bar
+ }
+
+ if (#field in fs) {
+ fs; // good fs is FooSub
+ } else {
+ fs; // good fs is never
+ }
+
+ if (#field in b) {
+ b; // good b is 'Bar & Foo'
+ } else {
+ b; // good b is Bar
+ }
+
+ if (#field in fsb) {
+ fsb; // good fsb is FooSub
+ } else {
+ fsb; // good fsb is Bar
+ }
+
+ if (#field in fsfb) {
+ fsfb; // good fsfb is 'Foo | FooSub'
+ } else {
+ fsfb; // good fsfb is Bar
+ }
+
+ class Nested {
+ m(v: any) {
+ if (#field in v) {
+ v; // good v is Foo
+ }
+ }
+ }
+ }
+}
+
+class FooSub extends Foo { subTypeOfFoo = true }
+class Bar { notFoo = true }
+
+function badSyntax(v: Foo) {
+ return #field in v; // Bad - outside of class
+}
new file mode 100644
@@ -0,0 +1,47 @@
+// @target: esnext, es2020
+
+class Foo {
+ #field = 1;
+ #method() {}
+ static #staticField= 2;
+ static #staticMethod() {}
+
+ check(v: any) {
+ #field in v; // expect Foo's 'field' WeakMap
+ #method in v; // expect Foo's 'instances' WeakSet
+ #staticField in v; // expect Foo's constructor
+ #staticMethod in v; // expect Foo's constructor
+ }
+ precedence(v: any) {
+ // '==' and '||' have lower precedence than 'in'
+ // 'in' naturally has same precedence as 'in'
+ // '<<' has higher precedence than 'in'
+
+ v == #field in v || v; // Good precedence: (v == (#field in v)) || v
+
+ v << #field in v << v; // Good precedence (SyntaxError): (v << #field) in (v << v)
+
+ v << #field in v == v; // Good precedence (SyntaxError): ((v << #field) in v) == v
+
+ v == #field in v in v; // Good precedence: v == ((#field in v) in v)
+
+ #field in v && #field in v; // Good precedence: (#field in v) && (#field in v)
+ }
+ invalidLHS(v: any) {
+ 'prop' in v = 10;
+ #field in v = 10;
+ }
+}
+
+class Bar {
+ #field = 1;
+ check(v: any) {
+ #field in v; // expect Bar's 'field' WeakMap
+ }
+}
+
+function syntaxError(v: Foo) {
+ return #field in v; // expect `return in v` so runtime will have a syntax error
+}
+
+export { }
new file mode 100644
@@ -0,0 +1,13 @@
+// @strict: true
+// @noUnusedLocals: true
+// @target: esnext
+
+class Foo {
+ #unused: undefined; // expect unused error
+ #brand: undefined; // expect no error
+
+ isFoo(v: any): v is Foo {
+ // This should count as using/reading '#brand'
+ return #brand in v;
+ }
+}
new file mode 100644
@@ -0,0 +1,65 @@
+// @allowJs: true
+// @checkJs: true
+// @strict: true
+// @target: es6
+// @outDir: ./out
+// @filename: privateNamesIncompatibleModifiersJs.js
+
+class A {
+ /**
+ * @public
+ */
+ #a = 1;
+
+ /**
+ * @private
+ */
+ #b = 1;
+
+ /**
+ * @protected
+ */
+ #c = 1;
+
+ /**
+ * @public
+ */
+ #aMethod() { return 1; }
+
+ /**
+ * @private
+ */
+ #bMethod() { return 1; }
+
+ /**
+ * @protected
+ */
+ #cMethod() { return 1; }
+
+ /**
+ * @public
+ */
+ get #aProp() { return 1; }
+ /**
+ * @public
+ */
+ set #aProp(value) { }
+
+ /**
+ * @private
+ */
+ get #bProp() { return 1; }
+ /**
+ * @private
+ */
+ set #bProp(value) { }
+
+ /**
+ * @protected
+ */
+ get #cProp() { return 1; }
+ /**
+ * @protected
+ */
+ set #cProp(value) { }
+}
@@ -36,6 +36,7 @@ function Tagged<T extends Constructor<{}>>(superClass: T): Constructor<Tagged> &
this._tag = "hello";
}
}
+ let c = new C();
return C;
}
@@ -65,3 +66,5 @@ class Thing3 extends Thing2 {
this.print();
}
}
+let der = new Derived(1,1,1);
+let th3 = new Thing3('');
\ No newline at end of file
@@ -62,3 +62,5 @@ const Timestamped = <CT extends Constructor<object>>(Base: CT) => {
timestamp = new Date();
};
}
+let aa = new Derived(1,1,1);
+let bb = new Thing3('');
\ No newline at end of file
@@ -97,3 +97,8 @@ class C3 extends Mixed3 {
}
f() { return super.f(); }
}
+let aa = new C1('');
+let bb = new M1();
+let cc = new M2();
+let dd = new C2();
+let ee = new C3();
\ No newline at end of file
@@ -14,3 +14,6 @@ class B extends A {
class C extends A {
protected get x() { return 'C.x' };
}
+
+let b = new B();
+let c = new C();
new file mode 100644
@@ -0,0 +1,5 @@
+// @strict: true
+// @declaration: true
+abstract class C {
+ abstract prop = 1
+}
@@ -4,8 +4,8 @@ class C {
var c = new C();
c.x = 3;
-var c2 = new C();
-var r = c.x === c2.x;
+// var c2 = new C();
+// var r = c.x === c2.x;
// #31792
@@ -14,4 +14,5 @@ var r = c.x
class MyMap<K, V> {
constructor(private readonly Map_: { new<K, V>(): any }) {}
private readonly store = new this.Map_<K, V>();
-}
\ No newline at end of file
+}
+let mm = new MyMap(null)
\ No newline at end of file
@@ -6,3 +6,4 @@ const x = 1;
class C {
[x]: string;
}
+let cc = new C();
\ No newline at end of file
@@ -10,4 +10,5 @@ class Derived extends Base {
}
var d = Derived.create();
-d.foo();
\ No newline at end of file
+d.foo();
+let b1 =new Derived()
\ No newline at end of file
@@ -4,4 +4,5 @@ class C {
f() { }
static f() { }
-}
\ No newline at end of file
+}
+let a4 = new C()
\ No newline at end of file
@@ -6,4 +6,6 @@ class C {
class D {
static f: number;
f() { }
-}
\ No newline at end of file
+}
+let a2 =new C()
+let a3 = new D()
\ No newline at end of file
@@ -54,3 +54,13 @@ declare class StaticArgumentsFn {
static arguments(): any; // ok
arguments(): any; // ok
}
+let a5 =new StaticName()
+let a6 =new StaticNameFn()
+let a7 =new StaticLength()
+let a8 =new StaticLengthFn()
+let a9 =new StaticPrototype()
+let a10 =new StaticPrototypeFn()
+let a11 =new StaticCaller()
+let a12 =new StaticCallerFn()
+let a13 =new StaticArguments()
+let a14 =new StaticArgumentsFn()
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,27 @@
+// @allowJs: true
+// @checkJs: true
+// @outDir: ./out
+// @filename: assertionTypePredicates2.js
+
+/**
+ * @typedef {{ x: number }} A
+ */
+
+/**
+ * @typedef { A & { y: number } } B
+ */
+
+/**
+ * @param {A} a
+ * @returns { asserts a is B }
+ */
+const foo = (a) => {
+ if (/** @type { B } */ (a).y !== 0) throw TypeError();
+ return undefined;
+};
+
+export const main = () => {
+ /** @type { A } */
+ const a = { x: 1 };
+ foo(a);
+};
new file mode 100644
@@ -0,0 +1,285 @@
+// @strict: true
+// @declaration: true
+
+// Narrowing by aliased conditional expressions
+
+function f10(x: string | number) {
+ const isString = typeof x === "string";
+ if (isString) {
+ let t: string = x;
+ }
+ else {
+ let t: number = x;
+ }
+}
+
+function f11(x: unknown) {
+ const isString = typeof x === "string";
+ if (isString) {
+ let t: string = x;
+ }
+}
+
+function f12(x: string | number | boolean) {
+ const isString = typeof x === "string";
+ const isNumber = typeof x === "number";
+ if (isString || isNumber) {
+ let t: string | number = x;
+ }
+ else {
+ let t: boolean = x;
+ }
+}
+
+function f13(x: string | number | boolean) {
+ const isString = typeof x === "string";
+ const isNumber = typeof x === "number";
+ const isStringOrNumber = isString || isNumber;
+ if (isStringOrNumber) {
+ let t: string | number = x;
+ }
+ else {
+ let t: boolean = x;
+ }
+}
+
+function f14(x: number | null | undefined): number | null {
+ const notUndefined = x !== undefined;
+ return notUndefined ? x : 0;
+}
+
+function f15(obj: { readonly x: string | number }) {
+ const isString = typeof obj.x === 'string';
+ if (isString) {
+ let s: string = obj.x;
+ }
+}
+
+function f16(obj: { readonly x: string | number }) {
+ const isString = typeof obj.x === 'string';
+ obj = { x: 42 };
+ if (isString) {
+ let s: string = obj.x; // Not narrowed because of is assigned in function body
+ }
+}
+
+function f17(obj: readonly [string | number]) {
+ const isString = typeof obj[0] === 'string';
+ if (isString) {
+ let s: string = obj[0];
+ }
+}
+
+function f18(obj: readonly [string | number]) {
+ const isString = typeof obj[0] === 'string';
+ obj = [42];
+ if (isString) {
+ let s: string = obj[0]; // Not narrowed because of is assigned in function body
+ }
+}
+
+function f20(obj: { kind: 'foo', foo: string } | { kind: 'bar', bar: number }) {
+ const isFoo = obj.kind === 'foo';
+ if (isFoo) {
+ obj.foo;
+ }
+ else {
+ obj.bar;
+ }
+}
+
+function f21(obj: { kind: 'foo', foo: string } | { kind: 'bar', bar: number }) {
+ const isFoo: boolean = obj.kind === 'foo';
+ if (isFoo) {
+ obj.foo; // Not narrowed because isFoo has type annotation
+ }
+ else {
+ obj.bar; // Not narrowed because isFoo has type annotation
+ }
+}
+
+function f22(obj: { kind: 'foo', foo: string } | { kind: 'bar', bar: number }) {
+ let isFoo = obj.kind === 'foo';
+ if (isFoo) {
+ obj.foo; // Not narrowed because isFoo is mutable
+ }
+ else {
+ obj.bar; // Not narrowed because isFoo is mutable
+ }
+}
+
+function f23(obj: { kind: 'foo', foo: string } | { kind: 'bar', bar: number }) {
+ const isFoo = obj.kind === 'foo';
+ obj = obj;
+ if (isFoo) {
+ obj.foo; // Not narrowed because obj is assigned in function body
+ }
+ else {
+ obj.bar; // Not narrowed because obj is assigned in function body
+ }
+}
+
+function f24(arg: { kind: 'foo', foo: string } | { kind: 'bar', bar: number }) {
+ const obj = arg;
+ const isFoo = obj.kind === 'foo';
+ if (isFoo) {
+ obj.foo;
+ }
+ else {
+ obj.bar;
+ }
+}
+
+function f25(arg: { kind: 'foo', foo: string } | { kind: 'bar', bar: number }) {
+ let obj = arg;
+ const isFoo = obj.kind === 'foo';
+ if (isFoo) {
+ obj.foo; // Not narrowed because obj is mutable
+ }
+ else {
+ obj.bar; // Not narrowed because obj is mutable
+ }
+}
+
+function f26(outer: { readonly obj: { kind: 'foo', foo: string } | { kind: 'bar', bar: number } }) {
+ const isFoo = outer.obj.kind === 'foo';
+ if (isFoo) {
+ outer.obj.foo;
+ }
+ else {
+ outer.obj.bar;
+ }
+}
+
+function f27(outer: { obj: { kind: 'foo', foo: string } | { kind: 'bar', bar: number } }) {
+ const isFoo = outer.obj.kind === 'foo';
+ if (isFoo) {
+ outer.obj.foo; // Not narrowed because obj is mutable
+ }
+ else {
+ outer.obj.bar; // Not narrowed because obj is mutable
+ }
+}
+
+function f28(obj?: { kind: 'foo', foo: string } | { kind: 'bar', bar: number }) {
+ const isFoo = obj && obj.kind === 'foo';
+ const isBar = obj && obj.kind === 'bar';
+ if (isFoo) {
+ obj.foo;
+ }
+ if (isBar) {
+ obj.bar;
+ }
+}
+
+// Narrowing by aliased discriminant property access
+
+function f30(obj: { kind: 'foo', foo: string } | { kind: 'bar', bar: number }) {
+ const kind = obj.kind;
+ if (kind === 'foo') {
+ obj.foo;
+ }
+ else {
+ obj.bar;
+ }
+}
+
+function f31(obj: { kind: 'foo', foo: string } | { kind: 'bar', bar: number }) {
+ const { kind } = obj;
+ if (kind === 'foo') {
+ obj.foo;
+ }
+ else {
+ obj.bar;
+ }
+}
+
+function f32(obj: { kind: 'foo', foo: string } | { kind: 'bar', bar: number }) {
+ const { kind: k } = obj;
+ if (k === 'foo') {
+ obj.foo;
+ }
+ else {
+ obj.bar;
+ }
+}
+
+function f33(obj: { kind: 'foo', foo: string } | { kind: 'bar', bar: number }) {
+ const { kind } = obj;
+ switch (kind) {
+ case 'foo': obj.foo; break;
+ case 'bar': obj.bar; break;
+ }
+}
+
+
+class C10 {
+ constructor(readonly x: string | number) {
+ const thisX_isString = typeof this.x === 'string';
+ const xIsString = typeof x === 'string';
+ if (thisX_isString && xIsString) {
+ let s: string;
+ s = this.x;
+ s = x;
+ }
+ }
+}
+
+class C11 {
+ constructor(readonly x: string | number) {
+ const thisX_isString = typeof this.x === 'string';
+ const xIsString = typeof x === 'string';
+ if (thisX_isString && xIsString) {
+ // Some narrowings may be invalidated due to later assignments.
+ let s: string;
+ s = this.x;
+ s = x;
+ }
+ else {
+ this.x = 10;
+ x = 10;
+ }
+ }
+}
+
+// Mixing of aliased discriminants and conditionals
+
+function f40(obj: { kind: 'foo', foo?: string } | { kind: 'bar', bar?: number }) {
+ const { kind } = obj;
+ const isFoo = kind == 'foo';
+ if (isFoo && obj.foo) {
+ let t: string = obj.foo;
+ }
+}
+
+// Unsupported narrowing of destructured payload by destructured discriminant
+
+type Data = { kind: 'str', payload: string } | { kind: 'num', payload: number };
+
+function gg2(obj: Data) {
+ if (obj.kind === 'str') {
+ let t: string = obj.payload;
+ }
+ else {
+ let t: number = obj.payload;
+ }
+}
+
+function foo({ kind, payload }: Data) {
+ if (kind === 'str') {
+ let t: string = payload;
+ }
+ else {
+ let t: number = payload;
+ }
+}
+
+// Repro from #45830
+
+const obj = {
+ fn: () => true
+};
+
+if (a) { }
+
+const a = obj.fn();
new file mode 100644
@@ -0,0 +1,28 @@
+// @useUnknownInCatchVariables: true,false
+
+try {}
+catch (e) {
+ const isString = typeof e === 'string';
+ if (isString) {
+ e.toUpperCase(); // e string
+ }
+
+ if (typeof e === 'string') {
+ e.toUpperCase(); // e string
+ }
+}
+
+try {}
+catch (e) {
+ const isString = typeof e === 'string';
+
+ e = 1;
+
+ if (isString) {
+ e.toUpperCase(); // e any/unknown
+ }
+
+ if (typeof e === 'string') {
+ e.toUpperCase(); // e string
+ }
+}
@@ -10,4 +10,4 @@ if (typeof config['works'] !== 'boolean') {
if (typeof config.works !== 'boolean') {
config['works'].prop = 'test'; // error, config['works']: boolean | { 'prop': string }
config.works.prop = 'test'; // ok
-}
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,25 @@
+const keywordA = 'a';
+const keywordB = 'b';
+
+type A = { [keywordA]: number };
+type B = { [keywordB]: string };
+
+declare const c: A | B;
+
+if ('a' in c) {
+ c; // narrowed to `A`
+}
+
+if (keywordA in c) {
+ c; // also narrowed to `A`
+}
+
+let stringB: string = 'b';
+
+if ((stringB as 'b') in c) {
+ c; // narrowed to `B`
+}
+
+if ((stringB as ('a' | 'b')) in c) {
+ c; // not narrowed
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,26 @@
+const a = 'a';
+const b = 'b';
+const d = 'd';
+
+type A = { [a]: number; };
+type B = { [b]: string; };
+
+declare const c: A | B;
+
+if ('a' in c) {
+ c; // A
+ c['a']; // number;
+}
+
+if ('d' in c) {
+ c; // never
+}
+
+if (a in c) {
+ c; // A
+ c[a]; // number;
+}
+
+if (d in c) {
+ c; // never
+}
@@ -29,4 +29,6 @@ export const x: X | number = Math.random() > 0.5 ? new X() : 1
if (x instanceof X) {
x.why() // should compile
-}
\ No newline at end of file
+}
+let xx = new X();
+let yy = new Y();
\ No newline at end of file
@@ -7,3 +7,4 @@ class C extends B {
super.m && super.m();
}
}
+let qq3 = new C();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,71 @@
+// @strict: true
+// @declaration: true
+
+declare function obj(x: object): void;
+
+function f1(x: unknown) {
+ if (!x) {
+ return;
+ }
+ if (typeof x === 'object') {
+ obj(x);
+ }
+}
+
+function f2(x: unknown) {
+ if (x === null) {
+ return;
+ }
+ if (typeof x === 'object') {
+ obj(x);
+ }
+}
+
+function f3(x: unknown) {
+ if (x == null) {
+ return;
+ }
+ if (typeof x === 'object') {
+ obj(x);
+ }
+}
+
+function f4(x: unknown) {
+ if (x == undefined) {
+ return;
+ }
+ if (typeof x === 'object') {
+ obj(x);
+ }
+}
+
+function f5(x: unknown) {
+ if (!!true) {
+ if (!x) {
+ return;
+ }
+ }
+ else {
+ if (x === null) {
+ return;
+ }
+ }
+ if (typeof x === 'object') {
+ obj(x);
+ }
+}
+
+function f6(x: unknown) {
+ if (x === null) {
+ x;
+ }
+ else {
+ x;
+ if (typeof x === 'object') {
+ obj(x);
+ }
+ }
+ if (typeof x === 'object') {
+ obj(x); // Error
+ }
+}
new file mode 100644
@@ -0,0 +1,161 @@
+// @strict: true
+// @declaration: true
+// @target: es2015
+
+type Action =
+ | { kind: 'A', payload: number }
+ | { kind: 'B', payload: string };
+
+function f10({ kind, payload }: Action) {
+ if (kind === 'A') {
+ payload.toFixed();
+ }
+ if (kind === 'B') {
+ payload.toUpperCase();
+ }
+}
+
+function f11(action: Action) {
+ const { kind, payload } = action;
+ if (kind === 'A') {
+ payload.toFixed();
+ }
+ if (kind === 'B') {
+ payload.toUpperCase();
+ }
+}
+
+function f12({ kind, payload }: Action) {
+ switch (kind) {
+ case 'A':
+ payload.toFixed();
+ break;
+ case 'B':
+ payload.toUpperCase();
+ break;
+ default:
+ payload; // never
+ }
+}
+
+type Action2 =
+ | { kind: 'A', payload: number | undefined }
+ | { kind: 'B', payload: string | undefined };
+
+function f20({ kind, payload }: Action2) {
+ if (payload) {
+ if (kind === 'A') {
+ payload.toFixed();
+ }
+ if (kind === 'B') {
+ payload.toUpperCase();
+ }
+ }
+}
+
+function f21(action: Action2) {
+ const { kind, payload } = action;
+ if (payload) {
+ if (kind === 'A') {
+ payload.toFixed();
+ }
+ if (kind === 'B') {
+ payload.toUpperCase();
+ }
+ }
+}
+
+function f22(action: Action2) {
+ if (action.payload) {
+ const { kind, payload } = action;
+ if (kind === 'A') {
+ payload.toFixed();
+ }
+ if (kind === 'B') {
+ payload.toUpperCase();
+ }
+ }
+}
+
+function f23({ kind, payload }: Action2) {
+ if (payload) {
+ switch (kind) {
+ case 'A':
+ payload.toFixed();
+ break;
+ case 'B':
+ payload.toUpperCase();
+ break;
+ default:
+ payload; // never
+ }
+ }
+}
+
+type Foo =
+ | { kind: 'A', isA: true }
+ | { kind: 'B', isA: false }
+ | { kind: 'C', isA: false };
+
+function f30({ kind, isA }: Foo) {
+ if (kind === 'A') {
+ isA; // true
+ }
+ if (kind === 'B') {
+ isA; // false
+ }
+ if (kind === 'C') {
+ isA; // false
+ }
+ if (isA) {
+ kind; // 'A'
+ }
+ else {
+ kind; // 'B' | 'C'
+ }
+}
+
+// Repro from #35283
+
+interface A<T> { variant: 'a', value: T }
+
+interface B<T> { variant: 'b', value: Array<T> }
+
+type AB<T> = A<T> | B<T>;
+
+declare function printValue<T>(t: T): void;
+
+declare function printValueList<T>(t: Array<T>): void;
+
+function unrefined1<T>(ab: AB<T>): void {
+ const { variant, value } = ab;
+ if (variant === 'a') {
+ printValue<T>(value);
+ }
+ else {
+ printValueList<T>(value);
+ }
+}
+
+// Repro from #38020
+
+type Action3 =
+ | {type: 'add', payload: { toAdd: number } }
+ | {type: 'remove', payload: { toRemove: number } };
+
+const reducerBroken = (state: number, { type, payload }: Action3) => {
+ switch (type) {
+ case 'add':
+ return state + payload.toAdd;
+ case 'remove':
+ return state - payload.toRemove;
+ }
+}
+
+// Repro from #46143
+
+declare var it: Iterator<number>;
+const { value, done } = it.next();
+if (!done) {
+ value; // number
+}
@@ -44,4 +44,5 @@ let match: RegExpExecArray | null
while ((match = re.exec("xxx")) != null) {
const length = match[1].length + match[2].length
-}
\ No newline at end of file
+}
+let qq4 = new Foo();
\ No newline at end of file
@@ -33,3 +33,4 @@ function fun<T>(item: { [P in keyof T]: T[P] }) {
}
}
}
+let qq6 = new C();
\ No newline at end of file
@@ -34,4 +34,7 @@ export class Baz {
constructor(/* @internal */
public isInternal: string
) {}
-}
\ No newline at end of file
+}
+// let ff = new Foo('','','','','','','','','','')
+// let bar = new Bar('');
+// let baz = new Baz('');
\ No newline at end of file
@@ -8,4 +8,5 @@ export class C {
}
export class D extends C {
-}
\ No newline at end of file
+}
+let qq6 = new D();
\ No newline at end of file
@@ -8,4 +8,5 @@ export class C {
}
class D extends C {
-}
\ No newline at end of file
+}
+let qq7 = new D();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,5 @@
+// @filename: node_modules/@types/node/fs.d.ts
+declare module "fs" {
+ function FSWatcher()
+ // interface FSWatcher {}
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,2 @@
+// @filename: main.ts
+/// <reference types="node" />
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,4 @@
+{
+ "name": "@types/node",
+ "version": "1.0.0"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,18 @@
+// @declaration: true
+// @filename: node_modules/@types/node/index.d.ts
+/// <reference path="fs.d.ts" />
+
+// @filename: node_modules/@types/node/package.json
+// {
+// "name": "@types/node",
+// "version": "1.0.0"
+// }
+// @filename: main.ts
+// / <reference types="node" />
+import { FSWatcher } from "fs";
+
+FSWatcher();
+
+export function f() {
+ // return {} as FSWatcher;
+}
new file mode 100644
@@ -0,0 +1,15 @@
+// @target: es2018
+// @experimentalDecorators: true
+// @noEmitHelpers: true
+// @noTypesAndSymbols: true
+
+// https://github.com/microsoft/TypeScript/issues/44931
+interface IFoo { }
+declare const IFoo: any;
+class BulkEditPreviewProvider {
+ static readonly Schema = 'vscode-bulkeditpreview';
+ static emptyPreview = { scheme: BulkEditPreviewProvider.Schema };
+ constructor(
+ @IFoo private readonly _modeService: IFoo,
+ ) { }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,16 @@
+// @target: es5
+// @experimentaldecorators: true
+// @emitDecoratorMetadata: true
+// @filename: a.ts
+
+function decorator() {
+ return (target: new (...args: any[]) => any) => {}
+}
+
+@decorator()
+class Foo {
+ public static func(): Foo {
+ return new Foo();
+ }
+}
+Foo.func();
new file mode 100644
@@ -0,0 +1,19 @@
+// @target: es5
+// @experimentaldecorators: true
+// @emitDecoratorMetadata: true
+// @filename: a.ts
+
+function decorator() {
+ return (target: new (...args: any[]) => any) => {}
+}
+
+try {
+ @decorator()
+ class Foo {
+ public static func(): Foo {
+ return new Foo();
+ }
+ }
+ Foo.func();
+}
+catch (e) {}
new file mode 100644
@@ -0,0 +1,27 @@
+// @target: es5
+// @experimentaldecorators: true
+// @emitDecoratorMetadata: true
+// @filename: a.ts
+
+function decorator() {
+ return (target: new (...args: any[]) => any) => {}
+}
+
+@decorator()
+class Foo {
+ public static func(): Foo {
+ return new Foo();
+ }
+}
+Foo.func();
+
+try {
+ @decorator()
+ class Foo {
+ public static func(): Foo {
+ return new Foo();
+ }
+ }
+ Foo.func();
+}
+catch (e) {}
new file mode 100644
@@ -0,0 +1,14 @@
+// @target: esnext
+// @experimentaldecorators: true
+// @emitdecoratormetadata: true
+declare var decorator: any;
+
+class Foo {
+ private prop = () => {
+ return 0;
+ }
+ @decorator
+ foo() {
+ return 0;
+ }
+}
new file mode 100644
@@ -0,0 +1,12 @@
+// @target: esnext
+// @experimentaldecorators: true
+// @emitdecoratormetadata: true
+declare var decorator: any;
+
+class Foo {
+ private prop = 1
+ @decorator
+ foo() {
+ return 0;
+ }
+}
new file mode 100644
@@ -0,0 +1,12 @@
+// @target: esnext
+// @experimentaldecorators: true
+// @emitdecoratormetadata: true
+declare var decorator: any;
+
+class Foo {
+ private prop
+ @decorator
+ foo() {
+ return 0;
+ }
+}
new file mode 100644
@@ -0,0 +1,11 @@
+// @target: esnext
+// @experimentaldecorators: true
+// @emitdecoratormetadata: true
+declare var decorator: any;
+
+class Foo {
+ private prop @decorator
+ foo() {
+ return 0;
+ }
+}
new file mode 100644
@@ -0,0 +1,11 @@
+// @target: esnext
+// @experimentaldecorators: true
+// @emitdecoratormetadata: true
+declare var decorator: any;
+
+class Foo {
+ p1
+
+ @decorator()
+ p2;
+}
new file mode 100644
@@ -0,0 +1,17 @@
+// @experimentalDecorators: true
+// @emitDecoratorMetadata: true
+
+
+// @filename: services.ts
+export namespace Services {
+ export class Service {}
+}
+
+// @filename: index.ts
+import type { Services } from './services';
+
+declare const decorator: any;
+export class Main {
+ @decorator()
+ field: Services.Service;
+}
@@ -58,3 +58,14 @@ class C9 extends B9 {
super.g();
}
}
+
+let c1 = new C1();
+let c2 = new C2();
+let c3 = new C3();
+let c4 = new C4();
+let c5 = new C5();
+let c6 = new C6();
+let c7 = new C7();
+let c8 = new C8();
+let c9 = new C9();
+
new file mode 100644
@@ -0,0 +1,7 @@
+// @target: es2018
+
+// Sample from
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/supportedLocalesOf
+const locales = ['ban', 'id-u-co-pinyin', 'de-ID'];
+const options = { localeMatcher: 'lookup' } as const;
+console.log(Intl.PluralRules.supportedLocalesOf(locales, options).join(', '));
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,45 @@
+// @target: es2020
+
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation
+const count = 26254.39;
+const date = new Date("2012-05-24");
+
+function log(locale: string) {
+ console.log(
+ `${new Intl.DateTimeFormat(locale).format(date)} ${new Intl.NumberFormat(locale).format(count)}`
+ );
+}
+
+log("en-US");
+// expected output: 5/24/2012 26,254.39
+
+log("de-DE");
+// expected output: 24.5.2012 26.254,39
+
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat
+const rtf1 = new Intl.RelativeTimeFormat('en', { style: 'narrow' });
+
+console.log(rtf1.format(3, 'quarter'));
+//expected output: "in 3 qtrs."
+
+console.log(rtf1.format(-1, 'day'));
+//expected output: "1 day ago"
+
+const rtf2 = new Intl.RelativeTimeFormat('es', { numeric: 'auto' });
+
+console.log(rtf2.format(2, 'day'));
+//expected output: "pasado mañana"
+
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames
+const regionNamesInEnglish = new Intl.DisplayNames(['en'], { type: 'region' });
+const regionNamesInTraditionalChinese = new Intl.DisplayNames(['zh-Hant'], { type: 'region' });
+
+console.log(regionNamesInEnglish.of('US'));
+// expected output: "United States"
+
+console.log(regionNamesInTraditionalChinese.of('US'));
+// expected output: "美國"
+
+const locales1 = ['ban', 'id-u-co-pinyin', 'de-ID'];
+const options1 = { localeMatcher: 'lookup' } as const;
+console.log(Intl.DisplayNames.supportedLocalesOf(locales1, options1).join(', '));
\ No newline at end of file
@@ -2,4 +2,6 @@ class B {}
function foo() {
return {B: B};
}
-class C extends (foo()).B {}
\ No newline at end of file
+class C extends (foo()).B {}
+let qt6 = new B();
+let qt7 = new C();
\ No newline at end of file
@@ -13,3 +13,4 @@ class D extends Base {
var i = Factory.create(s);
}
}
+let qt2 = new D();
\ No newline at end of file
@@ -7,3 +7,4 @@ class D extends Base {
super(() => { this._t }); // no error. only check when this is directly accessing in constructor
}
}
+let qt5 = new D();
\ No newline at end of file
@@ -4,3 +4,4 @@
this._t; // No error
}
}
+let qt4 = new D();
\ No newline at end of file
@@ -10,3 +10,4 @@ class D extends Base {
}
}
}
+let qt3 = new D();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,16 @@
+// @target: es5
+// @importHelpers: true
+// @isolatedModules: true
+// @noTypesAndSymbols: true
+// @noEmit: true
+// @filename: main.ts
+
+export {};
+const k = [1, , 2];
+const o = [3, ...k, 4];
+
+// @filename: tslib.d.ts
+// this is a pre-TS4.4 versions of emit helper, which always forced array packing
+declare module "tslib" {
+ function __spreadArray(to: any[], from: any[]): any[];
+}
new file mode 100644
@@ -0,0 +1,14 @@
+// @removeComments: false
+
+const a = 1;
+const f1 = () =>
+ `${
+ // a
+ a
+ }a`;
+
+const f2 = () =>
+ `${
+ // a
+ a
+ }`;
@@ -8,3 +8,4 @@ as `Hello world`; // should not error
// Example 2
var y = 20
as(Foo); // should emit
+let qw11 = new Foo();
\ No newline at end of file
@@ -191,4 +191,8 @@ var r8b3 = b2 !== a2;
var r8b4 = b3 !== a3;
var r8b5 = b4 !== a4;
var r8b6 = b5 !== a5;
-var r8b7 = b6 !== a6;
\ No newline at end of file
+var r8b7 = b6 !== a6;
+let qr1 = new A1();
+let qr2 = new B1();
+let qr3 = new A2();
+let qr4 = new B2();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,5 @@
+declare let a: { a: 1 }
+a > 1;
+
+declare let b: { a: 1 } & { b: number }
+b > 1;
@@ -146,4 +146,6 @@ var r8b2 = b2 !== a2;
var r8b3 = b3 !== a3;
var r8b4 = b4 !== a4;
var r8b5 = b5 !== a5;
-var r8b6 = b6 !== a6;
\ No newline at end of file
+var r8b6 = b6 !== a6;
+let qe5 = new Derived();
+let qe6 = new C();
\ No newline at end of file
@@ -146,4 +146,6 @@ var r8b2 = b2 !== a2;
var r8b3 = b3 !== a3;
var r8b4 = b4 !== a4;
var r8b5 = b5 !== a5;
-var r8b6 = b6 !== a6;
\ No newline at end of file
+var r8b6 = b6 !== a6;
+let qe7 = new Derived();
+let qe8 = new C();
\ No newline at end of file
@@ -256,4 +256,5 @@ var r8b8 = b8 !== a8;
var r8b9 = b9 !== a9;
var r8b10 = b10 !== a10;
var r8b11 = b11 !== a11;
-//var r8b12 = b12 !== a12;
\ No newline at end of file
+//var r8b12 = b12 !== a12;
+let qw12 = new Derived();
\ No newline at end of file
@@ -218,4 +218,5 @@ var r8b6 = b6 !== a6;
var r8b7 = b7 !== a7;
var r8b8 = b8 !== a8;
var r8b9 = b9 !== a9;
-//var r8b10 = b10 !== a10;
\ No newline at end of file
+//var r8b10 = b10 !== a10;
+let qe9 = new Derived();
\ No newline at end of file
@@ -104,4 +104,5 @@ var r8a1 = a4 !== b4;
var r8b1 = b1 !== a1;
var r8b1 = b2 !== a2;
var r8b1 = b3 !== a3;
-var r8b1 = b4 !== a4;
\ No newline at end of file
+var r8b1 = b4 !== a4;
+let qr5 = new Derived();
\ No newline at end of file
@@ -161,4 +161,5 @@ var r8b3 = b3 !== a3;
var r8b4 = b4 !== a4;
var r8b5 = b5 !== a5;
var r8b6 = b6 !== a6;
-//var r8b7 = b7 !== a7;
\ No newline at end of file
+//var r8b7 = b7 !== a7;
+let qw14 = new Derived();
\ No newline at end of file
@@ -161,4 +161,5 @@ var r8b3 = b3 !== a3;
var r8b4 = b4 !== a4;
var r8b5 = b5 !== a5;
var r8b6 = b6 !== a6;
-//var r8b7 = b7 !== a7;
\ No newline at end of file
+//var r8b7 = b7 !== a7;
+let qw13 = new Derived();
\ No newline at end of file
@@ -75,4 +75,8 @@ var rg4 = b2
var rh1 = a1 !== b1;
var rh2 = a2 !== b2;
var rh3 = b1 !== a1;
-var rh4 = b2 !== a2;
\ No newline at end of file
+var rh4 = b2 !== a2;
+let qe1 = new Derived();
+let qe2 = new A1();
+let qe3 = new B1();
+let qe4 = new B2();
\ No newline at end of file
@@ -19,3 +19,6 @@ declare class NormalToString {
function baz(normal: NormalToString) {
return normal instanceof NormalToString;
}
+let qr7 = new StaticToString();
+let qr8 = new StaticToNumber();
+let qr9 = new NormalToString();
\ No newline at end of file
@@ -12,3 +12,4 @@ var r1 = a instanceof x1;
var r2 = b instanceof x2;
var r3 = c instanceof x1;
var r4 = d instanceof x1;
+let qr0 = new C();
\ No newline at end of file
@@ -38,3 +38,4 @@ var resultIsObject8 = (true, {});
var resultIsObject9 = (!BOOLEAN, { a: 1, b: "s" });
var resultIsObject10 = ("string", new Date());
var resultIsObject11 = (STRING.toLowerCase(), new CLASS());
+let qw10 = new CLASS();
\ No newline at end of file
@@ -44,3 +44,6 @@ var result10: (t: X) => any = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
//Expr1 and Expr2 are literals
var result11: any = true ? 1 : 'string';
+
+let qq1 = new A();
+let qq0 = new B();
@@ -9,3 +9,5 @@ class B extends A<number, string> {
// Ensure 'value' is of type 'number (and not '{}') by using its 'toExponential()' method.
constructor() { super(value => String(value.toExponential())); }
}
+
+let qr17 = new B();
@@ -28,4 +28,5 @@ class C extends CBase<string> {
}
});
}
-}
\ No newline at end of file
+}
+let qt1 = new C();
\ No newline at end of file
@@ -55,3 +55,4 @@ class D extends C {
super.foo(1, 2, ...a);
}
}
+let qr13 = new D();
\ No newline at end of file
@@ -96,3 +96,4 @@ function tryCatchFn() {
var m = () => this + '';
}
}
+let qr14 = new MyClass();
@@ -60,3 +60,4 @@ var t: any;
var nested = new (new (new nestedCtor())())();
var n = new nested();
var n = new nested();
+let aa1 = new C1(null,null);
\ No newline at end of file
@@ -27,3 +27,5 @@ class OtherDerived extends OtherBase {
super();
}
}
+let qr15 = new Derived(null);
+let qr16 = new OtherDerived();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,178 @@
+// @target: esnext
+// @useDefineForClassFields: false
+class MyTestClass {
+ private canary: number;
+ static staticCanary: number;
+
+ constructor() {
+ //type of 'this' in constructor body is the class instance type
+ var p = this.canary;
+ var p: number;
+ this.canary = 3;
+ }
+
+ //type of 'this' in member function param list is the class instance type
+ memberFunc(t = this) {
+ var t: MyTestClass;
+
+ //type of 'this' in member function body is the class instance type
+ var p = this;
+ var p: MyTestClass;
+ }
+
+ //type of 'this' in member accessor(get and set) body is the class instance type
+ get prop() {
+ var p = this;
+ var p: MyTestClass;
+ return this;
+ }
+ set prop(v) {
+ var p = this;
+ var p: MyTestClass;
+ p = v;
+ v = p;
+ }
+
+ someFunc = () => {
+ //type of 'this' in member variable initializer is the class instance type
+ var t = this;
+ var t: MyTestClass;
+ };
+
+ //type of 'this' in static function param list is constructor function type
+ static staticFn(t = this) {
+ var t: typeof MyTestClass;
+ var t = MyTestClass;
+ t.staticCanary;
+
+ //type of 'this' in static function body is constructor function type
+ var p = this;
+ var p: typeof MyTestClass;
+ var p = MyTestClass;
+ p.staticCanary;
+ }
+
+ static get staticProp() {
+ //type of 'this' in static accessor body is constructor function type
+ var p = this;
+ var p: typeof MyTestClass;
+ var p = MyTestClass;
+ p.staticCanary;
+ return this;
+ }
+ static set staticProp(v: typeof MyTestClass) {
+ //type of 'this' in static accessor body is constructor function type
+ var p = this;
+ var p: typeof MyTestClass;
+ var p = MyTestClass;
+ p.staticCanary;
+ }
+}
+
+class MyGenericTestClass<T, U> {
+ private canary: number;
+ static staticCanary: number;
+
+ constructor() {
+ //type of 'this' in constructor body is the class instance type
+ var p = this.canary;
+ var p: number;
+ this.canary = 3;
+ }
+
+ //type of 'this' in member function param list is the class instance type
+ memberFunc(t = this) {
+ var t: MyGenericTestClass<T, U>;
+
+ //type of 'this' in member function body is the class instance type
+ var p = this;
+ var p: MyGenericTestClass<T, U>;
+ }
+
+ //type of 'this' in member accessor(get and set) body is the class instance type
+ get prop() {
+ var p = this;
+ var p: MyGenericTestClass<T, U>;
+ return this;
+ }
+ set prop(v) {
+ var p = this;
+ var p: MyGenericTestClass<T, U>;
+ p = v;
+ v = p;
+ }
+
+ someFunc = () => {
+ //type of 'this' in member variable initializer is the class instance type
+ var t = this;
+ var t: MyGenericTestClass<T, U>;
+ };
+
+ //type of 'this' in static function param list is constructor function type
+ static staticFn(t = this) {
+ var t: typeof MyGenericTestClass;
+ var t = MyGenericTestClass;
+ t.staticCanary;
+
+ //type of 'this' in static function body is constructor function type
+ var p = this;
+ var p: typeof MyGenericTestClass;
+ var p = MyGenericTestClass;
+ p.staticCanary;
+ }
+
+ static get staticProp() {
+ //type of 'this' in static accessor body is constructor function type
+ var p = this;
+ var p: typeof MyGenericTestClass;
+ var p = MyGenericTestClass;
+ p.staticCanary;
+ return this;
+ }
+ static set staticProp(v: typeof MyGenericTestClass) {
+ //type of 'this' in static accessor body is constructor function type
+ var p = this;
+ var p: typeof MyGenericTestClass;
+ var p = MyGenericTestClass;
+ p.staticCanary;
+ }
+}
+
+//type of 'this' in a function declaration param list is Any
+function fn(s = this) {
+ var s: any;
+ s.spaaaaaaace = 4;
+
+ //type of 'this' in a function declaration body is Any
+ var t: any;
+ var t = this;
+ this.spaaaaace = 4;
+}
+
+//type of 'this' in a function expression param list list is Any
+var q1 = function (s = this) {
+ var s: any;
+ s.spaaaaaaace = 4;
+
+ //type of 'this' in a function expression body is Any
+ var t: any;
+ var t = this;
+ this.spaaaaace = 4;
+}
+
+//type of 'this' in a fat arrow expression param list is typeof globalThis
+var q2 = (s = this) => {
+ var s: typeof globalThis;
+ s.spaaaaaaace = 4;
+
+ //type of 'this' in a fat arrow expression body is typeof globalThis
+ var t: typeof globalThis;
+ var t = this;
+ this.spaaaaace = 4;
+}
+
+//type of 'this' in global module is GlobalThis
+var t: typeof globalThis;
+var t = this;
+this.spaaaaace = 4;
+
@@ -7,3 +7,4 @@ function saySize(message: Message | Message[]) {
return message.length; // Should have type Message[] here
}
}
+let rr5 = new Message();
\ No newline at end of file
@@ -80,4 +80,8 @@ acceptingTypeGuardFunction(isA);
// Binary expressions
let union2: C | B;
-let union3: boolean | B = isA(union2) || union2;
\ No newline at end of file
+let union3: boolean | B = isA(union2) || union2;
+
+let ee2 = new B();
+let ee3 = new C();
+let ee4 = new D();
\ No newline at end of file
@@ -30,4 +30,6 @@ let test2: B = funC(isB);
if (funD(isC, a)) {
a.propC;
}
-let test3: B = funE(isB, 1);
\ No newline at end of file
+let test3: B = funE(isB, 1);
+let qw7 = new B();
+let qw8 = new C();
\ No newline at end of file
@@ -43,4 +43,5 @@ if (typeof strOrNumOrBool !== "string" && numOrBool !== strOrNumOrBool) {
}
else {
var r3: string | number | boolean = strOrNumOrBool; // string | number | boolean
-}
\ No newline at end of file
+}
+let rr1 = new C();
\ No newline at end of file
@@ -43,4 +43,5 @@ if (typeof strOrNumOrBool
}
else {
numOrBool = strOrNumOrBool; // number | boolean
-}
\ No newline at end of file
+}
+let qw2 = new C();
\ No newline at end of file
@@ -1,25 +1,25 @@
-// A type guard of the form x instanceof C, where C is of a subtype of the global type 'Function'
-// and C has a property named 'prototype'
-// - when true, narrows the type of x to the type of the 'prototype' property in C provided
-// it is a subtype of the type of x, or
-// - when false, has no effect on the type of x.
-
-class C1 {
- p1: string;
-}
-class C2 {
- p2: number;
-}
-class D1 extends C1 {
- p3: number;
-}
+// A type guard of the form x instanceof C, where C is of a subtype of the global type 'Function'
+// and C has a property named 'prototype'
+// - when true, narrows the type of x to the type of the 'prototype' property in C provided
+// it is a subtype of the type of x, or
+// - when false, has no effect on the type of x.
+
+class C1 {
+ p1: string;
+}
+class C2 {
+ p2: number;
+}
+class D1 extends C1 {
+ p3: number;
+}
class C3 {
p4: number;
}
-var str: string;
-var num: number;
-var strOrNum: string | number;
-
+var str: string;
+var num: number;
+var strOrNum: string | number;
+
var ctor1: C1 | C2;
str = ctor1 instanceof C1 && ctor1.p1; // C1
num = ctor1 instanceof C2 && ctor1.p2; // C2
@@ -31,7 +31,7 @@ num = ctor2 instanceof C2 && ctor2.p2; // C2
num = ctor2 instanceof D1 && ctor2.p3; // D1
str = ctor2 instanceof D1 && ctor2.p1; // D1
var r2: D1 | C2 = ctor2 instanceof C1 && ctor2; // C2 | D1
-
+
var ctor3: C1 | C2;
if (ctor3 instanceof C1) {
ctor3.p1; // C1
@@ -64,4 +64,7 @@ if (ctor6 instanceof C1 || ctor6 instanceof C2) {
}
else {
ctor6.p4; // C3
-}
\ No newline at end of file
+}
+let qw4 = new C2();
+let qw3 = new D1();
+let qw5 = new C3();
\ No newline at end of file
@@ -34,4 +34,7 @@ var c2Ord1: C2 | D1;
num = isC2(c2Ord1) && c2Ord1.p2; // C2
num = isD1(c2Ord1) && c2Ord1.p3; // D1
str = isD1(c2Ord1) && c2Ord1.p1; // D1
-var r2: C2 | D1 = isC1(c2Ord1) && c2Ord1; // C2 | D1
\ No newline at end of file
+var r2: C2 | D1 = isC1(c2Ord1) && c2Ord1; // C2 | D1
+
+let rr2 = new C2();
+let rr3 = new D1();
\ No newline at end of file
@@ -83,3 +83,4 @@ if (typeof strOrNum !== "boolean") {
else {
let z2: {} = strOrNum; // {}
}
+let qw9 = new C();
\ No newline at end of file
@@ -82,3 +82,4 @@ if (typeof strOrBool !== "number") {
else {
let y2: {} = strOrBool; // {}
}
+let ee6 = new C();
\ No newline at end of file
@@ -82,3 +82,4 @@ if (typeof numOrBool !== "string") {
else {
let x2: {} = numOrBool; // {}
}
+let rr4 = new C();
\ No newline at end of file
@@ -103,3 +103,12 @@ function f(i: Indexed) {
}
return "c" in i && i.c;
}
+let tt1 = new A();
+let tt2 = new B();
+let tt3 = new C();
+let tt4 = new D();
+let tt5 = new AWithOptionalProp();
+let tt6 = new BWithOptionalProp();
+let tt7 = new ClassWithUnionProp();
+let tt8 = new InMemberOfClass();
+let tt9 = new SelfAssert();
\ No newline at end of file
@@ -101,3 +101,4 @@ class ClassWithAccessors {
num = typeof var2
}
}
+let ee1 = new ClassWithAccessors();
\ No newline at end of file
@@ -65,3 +65,4 @@ class C1 {
num = typeof param
}
}
+let qw1 = new C1(null);
\ No newline at end of file
@@ -24,4 +24,5 @@ strOrNum = typeof c1.pp3
var obj1: {
x: string | number;
};
-strOrNum = typeof obj1.x === "string" && obj1.x; // string | number
\ No newline at end of file
+strOrNum = typeof obj1.x === "string" && obj1.x; // string | number
+let ee5 = new C1();
\ No newline at end of file
@@ -25,4 +25,5 @@ var o: {
if (typeof o.prop1
var prop1 = o.prop1;
-if (typeof prop1 === "string" && prop1.toLocaleLowerCase()) { }
\ No newline at end of file
+if (typeof prop1 === "string" && prop1.toLocaleLowerCase()) { }
+let qw6 = new D();
\ No newline at end of file
@@ -43,4 +43,5 @@ var ResultIsNumber13 = ~~~(NUMBER + NUMBER);
~foo();
~objA.a;
~M.n;
-~objA.a, M.n;
\ No newline at end of file
+~objA.a, M.n;
+let qr11 = new A();
\ No newline at end of file
@@ -42,4 +42,5 @@ var ResultIsNumber14 = ~~~(STRING + STRING);
~STRING;
~STRING1;
~foo();
-~objA.a,M.n;
\ No newline at end of file
+~objA.a,M.n;
+let qr12 = new A();
\ No newline at end of file
@@ -31,3 +31,4 @@ class C1 {
}
export = C1; // Should work, private type I1 of visible class C1 only used in private member m1.
+let qt8 = new C1();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,12 @@
+// @moduleResolution: node12
+// @module: node12
+
+// @filename: /src/foo.mts
+export function foo() {
+ return "";
+}
+
+// @filename: /src/bar.mts
+// Extensionless relative path ES import in an ES module
+import { foo } from "./foo"; // should error, suggest adding ".mjs"
+import { baz } from "./baz"; // should error, ask for extension, no extension suggestion
new file mode 100644
@@ -0,0 +1,6 @@
+// @moduleResolution: node12
+// @module: node12
+
+// @filename: /src/buzz.mts
+// Extensionless relative path cjs import in an ES module
+import foo = require("./foo"); // should error, should not ask for extension
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,12 @@
+// @moduleResolution: nodenext
+// @module: nodenext
+// @jsx: preserve
+
+// @filename: /src/foo.tsx
+export function foo() {
+ return "";
+}
+
+// @filename: /src/bar.mts
+// Extensionless relative path ES import in an ES module
+import { foo } from "./foo"; // should error, suggest adding ".jsx"
new file mode 100644
@@ -0,0 +1,12 @@
+// @moduleResolution: nodenext
+// @module: nodenext
+// @jsx: react
+
+// @filename: /src/foo.tsx
+export function foo() {
+ return "";
+}
+
+// @filename: /src/bar.mts
+// Extensionless relative path ES import in an ES module
+import { foo } from "./foo"; // should error, suggest adding ".js"
new file mode 100644
@@ -0,0 +1,6 @@
+// @moduleResolution: node12
+// @module: node12
+
+// @filename: /src/buzz.mts
+// Extensionless relative path dynamic import in an ES module
+import("./foo").then(x => x); // should error, ask for extension
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,8 @@
+// @moduleResolution: node12
+// @module: node12
+
+// @filename: /src/bar.cts
+// Extensionless relative path import statement in a cjs module
+// Import statements are not allowed in cjs files,
+// but other errors should not assume that they are allowed
+import { foo } from "./foo"; // should error, should not ask for extension
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,6 @@
+// @moduleResolution: node12
+// @module: node12
+
+// @filename: /src/bar.cts
+// Extensionless relative path cjs import in a cjs module
+import foo = require("./foo"); // should error, should not ask for extension
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,6 @@
+// @moduleResolution: node12
+// @module: node12
+
+// @filename: /src/bar.cts
+// Extensionless relative path dynamic import in a cjs module
+import("./foo").then(x => x); // should error, ask for extension
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,21 @@
+// @module: esnext
+// @declaration: true
+
+// @Filename: /imports.ts
+import { type, as, something, foo, bar } from "./exports.js";
+type;
+as; // Error (used in emitting position)
+something; // Error (used in emitting position)
+foo; // Error (used in emitting position)
+bar; // Error (used in emitting position)
+
+// @Filename: /exports.ts
+const type = 0;
+const as = 0;
+const something = 0;
+export { type };
+export { type as };
+export { type something };
+export { type type as foo };
+export { type as as bar };
+export type { type something as whatever }; // Error
new file mode 100644
@@ -0,0 +1,2 @@
+// @Filename: /a.ts
+export default class A {}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,5 @@
+
+
+// @Filename: /b.ts
+import type from './a';
+type;
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,46 @@
+// @module: esnext
+// @declaration: true
+
+// @Filename: /mod.ts
+export const as = 0;
+export const type = 0;
+export const something = 0;
+
+// @Filename: /a.ts
+import { type } from "./mod.js";
+import { type as } from "./mod.js";
+type;
+as; // Error (used in emitting position)
+
+// @Filename: /b.ts
+import { type as as } from "./mod.js";
+type; // Error (cannot resolve name)
+as;
+
+// @Filename: /c.ts
+import { type as as as } from "./mod.js";
+type; // Error (cannot resolve name)
+as; // Error (used in emitting position)
+
+// @Filename: /d.ts
+import { type as as as as } from "./mod.js"; // Error
+
+// @Filename: /e.ts
+import { type type as as } from "./mod.js";
+import { type as type } from "./mod.js";
+type;
+as; // Error (used in emitting position)
+
+// @Filename: /f.ts
+import { type import } from "./mod.js"; // Error
+import { type as export } from "./mod.js"; // Error
+import { type as as export } from "./mod.js"; // Error
+import { type something } from "./mod.js";
+import { type something as s } from "./mod.js";
+type; // Error (cannot resolve name)
+as; // Error (cannot resolve name)
+something; // Error (used in emitting position)
+s; // Error (used in emitting position)
+
+// @Filename: /g.ts
+import type { type something } from "./mod.js"; // Error
new file mode 100644
@@ -0,0 +1,28 @@
+// @preserveValueImports: true
+// @isolatedModules: true,false
+// @module: esnext
+
+// @Filename: a.ts
+export default {};
+export const b = 0;
+export const c = 1;
+export interface D {}
+
+// @Filename: b.ts
+import a, { b, c, D } from "./a";
+
+// @Filename: c.ts
+import * as a from "./a";
+
+// @Filename: d.ts
+export = {};
+
+// @Filename: e.ts
+import D = require("./d");
+import DD = require("./d");
+DD;
+
+// @Filename: f.ts
+import type a from "./a";
+import { b, c } from "./a";
+b;
new file mode 100644
@@ -0,0 +1,47 @@
+// @preserveValueImports: true
+// @isolatedModules: true,false
+// @module: esnext
+
+// @Filename: a.ts
+export type A = {};
+export type { A as default };
+
+// @Filename: b.ts
+class B {};
+export type { B, B as default };
+
+// @Filename: c.ts
+import DefaultA from "./a";
+import { A } from "./a";
+import DefaultB from "./b";
+import { B } from "./b";
+
+// @Filename: c.fixed.ts
+import type DefaultA from "./a";
+import type { A } from "./a";
+import type DefaultB from "./b";
+import type { B } from "./b";
+
+// @Filename: d.ts
+export { A as AA } from "./a";
+export { B as BB } from "./b";
+
+// @Filename: d.fixed.ts
+export type { A as AA } from "./a";
+export type { B as BB } from "./b";
+
+// @Filename: e.ts
+import { AA, BB } from "./d";
+
+// @Filename: e.fixed.ts
+import type { AA, BB } from "./d";
+
+// @Filename: f.ts
+import type { A } from "./a";
+import type { B } from "./b";
+export { A, B as BB };
+
+// @Filename: f.fixed.ts
+import type { A } from "./a";
+import type { B } from "./b";
+export type { A, B as BB };
new file mode 100644
@@ -0,0 +1,14 @@
+// @preserveValueImports: true
+// @importsNotUsedAsValues: preserve
+// @module: esnext
+
+// @Filename: /mod.ts
+export type A = unknown;
+export type B = never;
+export type C = any;
+
+// @Filename: /index.ts
+import { type A, type B, type C } from "./mod.js";
+
+// @Filename: /reexport.ts
+export { type A, type B, type C } from "./mod.js";
new file mode 100644
@@ -0,0 +1,13 @@
+// @preserveValueImports: true
+// @isolatedModules: true
+// @module: es2015
+
+// @Filename: /exports.ts
+export function Component() {}
+export interface ComponentProps {}
+
+// @Filename: /index.ts
+import { Component, ComponentProps } from "./exports.js";
+
+// @Filename: /index.fixed.ts
+import { Component, type ComponentProps } from "./exports.js";
new file mode 100644
@@ -0,0 +1,4 @@
+// @preserveValueImports: true
+// @module: amd,system,commonjs,es2015
+// @noTypesAndSymbols: true
+export {};
new file mode 100644
@@ -0,0 +1,37 @@
+// @declaration: true
+// @target: es2015
+// @module: es2015, commonjs, esnext
+
+// @filename: 0.ts
+export const a = 1;
+export const b = 2;
+
+// @filename: 1.ts
+import './0' assert { type: "json" }
+import { a, b } from './0' assert { "type": "json" }
+import * as foo from './0' assert { type: "json" }
+a;
+b;
+foo.a;
+foo.b;
+
+// @filename: 2.ts
+import { a, b } from './0' assert {}
+import { a as c, b as d } from './0' assert { a: "a", b: "b", c: "c" }
+a;
+b;
+c;
+d;
+
+// @filename: 3.ts
+const a = import('./0')
+const b = import('./0', { assert: { type: "json" } })
+const c = import('./0', { assert: { type: "json", ttype: "typo" } })
+const d = import('./0', { assert: {} })
+const dd = import('./0', {})
+declare function foo(): any;
+const e = import('./0', foo())
+const f = import()
+const g = import('./0', {}, {})
+const h = import('./0', { assert: { type: "json" }},)
+
new file mode 100644
@@ -0,0 +1,17 @@
+// @declaration: true
+// @target: es2015
+// @module: es2015, commonjs, esnext
+
+// @filename: 0.ts
+export const a = 1;
+export const b = 2;
+
+// @filename: 1.ts
+export {} from './0' assert { type: "json" }
+export { a, b } from './0' assert { type: "json" }
+export * from './0' assert { type: "json" }
+export * as ns from './0' assert { type: "json" }
+
+// @filename: 2.ts
+export { a, b } from './0' assert {}
+export { a as c, b as d } from './0' assert { a: "a", b: "b", c: "c" }
new file mode 100644
@@ -0,0 +1,15 @@
+// @declaration: true
+// @target: es2015
+// @module: es2015, esnext
+
+// @filename: 0.ts
+export interface I { }
+
+// @filename: 1.ts
+export type {} from './0' assert { type: "json" }
+export type { I } from './0' assert { type: "json" }
+
+// @filename: 2.ts
+import type { I } from './0' assert { type: "json" }
+import type * as foo from './0' assert { type: "json" }
+
new file mode 100644
@@ -0,0 +1 @@
+import * as f from "./first" assert
new file mode 100644
@@ -0,0 +1 @@
+import * as f from "./first" assert {
@@ -32,4 +32,8 @@ class D implements A<boolean> {
d: string;
y: boolean;
z: boolean;
-}
\ No newline at end of file
+}
+let ww1 = new C();
+let ww2 = new C2();
+let ww3 = new C3();
+let ww4 = new C4();
@@ -53,3 +53,15 @@ class C20 extends Constructor<Partial<T1>>() { x: string }
class C21 extends Constructor<Readonly<T1>>() { x: string }
class C22 extends Constructor<Identifiable<T1>>() { x: string }
class C23 extends Constructor<Identifiable<T1 & { b: number}>>() { x: string }
+let c1 = new C1();
+let c2 = new C2();
+let c3 = new C3();
+let c4 = new C4();
+let c5 = new C5();
+let c6 = new C6();
+let c7 = new C7();
+let cx = new CX();
+let c20 = new C20();
+let c21 = new C21();
+let c22 = new C22();
+let c23 = new C23();
\ No newline at end of file
@@ -39,4 +39,5 @@ var a: Foo = {
m: M,
n: {},
o: E.A
-}
\ No newline at end of file
+}
+let cc = new C();
\ No newline at end of file
@@ -21,4 +21,3 @@ declare module A {
var p: { x: number; y: number; }
var p = A.Point.Origin;
var p = new A.Point(0, 0); // unexpected error here, bug 840000
-
\ No newline at end of file
@@ -13,6 +13,7 @@ module A {
export class Point {
constructor(public x: number, public y: number) { }
}
+ let pp = new Point(1,1);
}
// @filename: test.ts
@@ -19,4 +19,6 @@ module A {
export module Point {
function Origin() { return ""; }// not an error since not exported
}
-}
\ No newline at end of file
+ let pp = new Point(1,1);
+}
+let pp1 = new Point(1,1);
\ No newline at end of file
@@ -3,6 +3,7 @@ module A {
x: number;
y: number;
}
+ let pp = new Point();
}
module A {
@@ -11,6 +12,7 @@ module A {
return { x: p.x, y: p.y };
}
}
+ let pp1 = new Point();
}
// ensure merges as expected
@@ -21,6 +23,7 @@ module X.Y.Z {
export class Line {
length: number;
}
+ let ll = new Line();
}
module X {
@@ -29,6 +32,7 @@ module X {
class Line {
name: string;
}
+ let ll1 = new Line()
}
}
}
@@ -16,6 +16,7 @@ module X.Y.Z {
export class Line {
length: number;
}
+ let ll = new Line();
}
module X {
@@ -24,6 +25,7 @@ module X {
export class Line {
name: string;
}
+ let ll1 = new Line();
}
}
}
@@ -39,6 +39,7 @@ module E {
export module M {
export var x = 42;
}
+ let c1 = new C();
}
// validate all exportable statements,
@@ -51,4 +52,5 @@ module F {
module M {
var x = 42;
}
+ let c2 = new C();
}
\ No newline at end of file
@@ -15,6 +15,7 @@ module B {
class B {
name: string;
}
+ let bb = new B();
}
module X {
@@ -11,4 +11,6 @@ export class Beta {
}
}
-const arr = [Alpha, Beta];
+// const arr = [Alpha, Beta];
+let aa = new Alpha();
+let be = new Beta();
\ No newline at end of file
@@ -16,4 +16,5 @@ export class Sub extends Super {
constructor() {
super('first', 'second');
}
-}
\ No newline at end of file
+}
+let ss = new Sub();
\ No newline at end of file
@@ -14,4 +14,6 @@ export class A {
export default class Base extends A {
// This method is required to reproduce #35932
verify() { }
-}
\ No newline at end of file
+}
+
+let b = new Base();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,23 @@
+// @allowJs: true
+// @checkJs: true
+// @noEmit: true
+// @Filename: type.js
+/** @typedef {import("./mod1").TestEnum} TE */
+/** @type {TE} */
+const test = 'add'
+/** @type {import("./mod1").TestEnum} */
+const tost = 'remove'
+
+// @Filename: value.js
+import { TestEnum } from "./mod1"
+/** @type {TestEnum} */
+const tist = TestEnum.ADD
+
+
+// @Filename: mod1.js
+
+/** @enum {string} */
+// export const TestEnum = {
+// ADD: 'add',
+// REMOVE: 'remove'
+// }
@@ -8,3 +8,4 @@
* @extends {Set<T>} Should prefer this Set<T>, not the Set in the heritage clause
*/
class My extends Set {}
+let q4 = new My();
new file mode 100644
@@ -0,0 +1,10 @@
+// @allowJs: true
+// @checkJs: true
+// @noEmit: true
+
+
+// @Filename: /b.js
+import * as a from "./a";
+let b = a.A;
+/** @augments a.A */
+class B {}
@@ -12,3 +12,4 @@ class B extends A {
return this.x;
}
}
+let q7 = new B();
\ No newline at end of file
@@ -26,3 +26,5 @@ class BAT {
return "";
}
}
+let q1 = new B();
+let q2 = new BAT();
new file mode 100644
@@ -0,0 +1,71 @@
+// @allowJs: true
+// @checkJs: true
+// @declaration: true
+// @outDir: out
+// @Filename: file.js
+
+/**
+ * @template {string | number} [T=string] - ok: defaults are permitted
+ * @typedef {[T]} A
+ */
+
+/** @type {A} */ // ok, default for `T` in `A` is `string`
+const aDefault1 = [""];
+/** @type {A} */ // error: `number` is not assignable to string`
+const aDefault2 = [0];
+/** @type {A<string>} */ // ok, `T` is provided for `A`
+const aString = [""];
+/** @type {A<number>} */ // ok, `T` is provided for `A`
+const aNumber = [0];
+
+/**
+ * @template T
+ * @template [U=T] - ok: default can reference earlier type parameter
+ * @typedef {[T, U]} B
+ */
+
+/**
+ * @template {string | number} [T] - error: default requires an `=type`
+ * @typedef {[T]} C
+ */
+
+/**
+ * @template {string | number} [T=] - error: default requires a `type`
+ * @typedef {[T]} D
+ */
+
+/**
+ * @template {string | number} [T=string]
+ * @template U - error: Required type parameters cannot follow optional type parameters
+ * @typedef {[T, U]} E
+ */
+
+/**
+ * @template [T=U] - error: Type parameter defaults can only reference previously declared type parameters.
+ * @template [U=T]
+ * @typedef {[T, U]} G
+ */
+
+/**
+ * @template T
+ * @template [U=T] - ok: default can reference earlier type parameter
+ * @param {T} a
+ * @param {U} b
+ */
+function f1(a, b) {}
+
+ /**
+ * @template {string | number} [T=string]
+ * @template U - error: Required type parameters cannot follow optional type parameters
+ * @param {T} a
+ * @param {U} b
+ */
+function f2(a, b) {}
+
+/**
+ * @template [T=U] - error: Type parameter defaults can only reference previously declared type parameters.
+ * @template [U=T]
+ * @param {T} a
+ * @param {U} b
+ */
+function f3(a, b) {}
new file mode 100644
@@ -0,0 +1,16 @@
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @declaration: true
+// @Filename: file.js
+
+/**
+ * @template T
+ * @template {keyof T} K
+ * @typedef {T[K]} Foo
+ */
+
+const x = { a: 1 };
+
+/** @type {Foo<typeof x, "a">} */
+const y = "a";
\ No newline at end of file
@@ -6,3 +6,4 @@
const c = null
class C {
}
+let q3 = new C();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,12 @@
+// @allowJS: true
+// @checkJs: true
+// @noEmit: true
+
+// @filename: a.js
+/**
+ * @type {function(boolean, string, ...*):void}
+ */
+const foo = function (a, b, ...r) { };
+
+// @filename: b.ts
+foo(false, '');
new file mode 100644
@@ -0,0 +1,7 @@
+// @outdir: out/
+// @checkJs: true
+// @filename: seeTag3.js
+
+/** @see [The typescript web site](https://typescriptlang.org) */
+function theWholeThing() {
+}
new file mode 100644
@@ -0,0 +1,11 @@
+// @target: esnext
+// @allowJs: true
+// @declaration: true
+// @emitDeclarationOnly: true
+// @filename: a.js
+
+/** @this {string} */
+export function f1() {}
+
+/** @this */
+export function f2() {}
new file mode 100644
@@ -0,0 +1,18 @@
+// @strict: true, false
+// @jsx: react
+// @filename: a.tsx
+
+declare const React: any
+declare namespace JSX {
+ interface IntrinsicElements {
+ [k: string]: any
+ }
+}
+
+const a = (
+ <public-foo></public-foo>
+);
+
+const b = (
+ <public></public>
+);
new file mode 100644
@@ -0,0 +1,140 @@
+// @Filename: jsxParserRecovery.tsx
+// @jsx: preserve
+
+// should have no errors here; all these functions should parse and resolve
+noName(); noClose(); noCloseTypeArg(); noCloseAttrs(); noCloseTypeArgAttrs(); noCloseBracket(); noCloseBracketTypeArgAttrs(); noSelfclose(); noSelfcloseTypeArgAttrs();
+noNameTrailingTag(); noCloseTrailingTag(); noCloseTypeArgTrailingTag(); noCloseAttrsTrailingTag(); noCloseTypeArgAttrsTrailingTag(); noCloseBracketTrailingTag(); noCloseBracketTypeArgAttrsTrailingTag(); // noSelfcloseTrailingTag(); noSelfcloseTypeArgAttrsTrailingTag();
+noNameTrailingText(); noCloseTrailingText(); noCloseTypeArgTrailingText(); noCloseAttrsTrailingText(); noCloseTypeArgAttrsTrailingText(); noCloseBracketTrailingText(); noCloseBracketTypeArgAttrsTrailingText(); // noSelfcloseTrailingText(); noSelfcloseTypeArgAttrsTrailingText();
+
+function diddy() {
+ return null;
+}
+
+var donkey = <div>
+ <
+</div>;
+function noName() { }
+var donkey = <div>
+ <diddy
+</div>;
+function noClose() { }
+var donkey = <div>
+ <diddy<boolean>
+</div>;
+function noCloseTypeArg() { }
+var donkey = <div>
+ <diddy bananas="please"
+</div>;
+function noCloseAttrs() { }
+var donkey = <div>
+ <diddy<boolean> bananas="please"
+</div>;
+function noCloseTypeArgAttrs() { }
+var donkey = <div>
+ <diddy/
+</div>;
+function noCloseBracket() { }
+var donkey = <div>
+ <diddy<boolean> bananas="please"/
+</div>;
+function noCloseBracketTypeArgAttrs() { }
+var donkey = <div>
+ <diddy>
+</div>;
+function noSelfclose() { }
+var donkey = <div>
+ <diddy<boolean> bananas="please">
+</div>;
+function noSelfcloseTypeArgAttrs() { }
+
+var donkey = <div>
+ <
+ <diddy/>
+</div>;
+function noNameTrailingTag() { }
+var donkey = <div>
+ <diddy
+ <diddy/>
+</div>;
+function noCloseTrailingTag() { }
+var donkey = <div>
+ <diddy<boolean>
+ <diddy/>
+</div>;
+function noCloseTypeArgTrailingTag() { }
+var donkey = <div>
+ <diddy bananas="please"
+ <diddy/>
+</div>;
+function noCloseAttrsTrailingTag() { }
+var donkey = <div>
+ <diddy<boolean> bananas="please"
+ <diddy/>
+</div>;
+function noCloseTypeArgAttrsTrailingTag() { }
+var donkey = <div>
+ <diddy/
+ <diddy/>
+</div>;
+function noCloseBracketTrailingTag() { }
+var donkey = <div>
+ <diddy<boolean> bananas="please"/
+ <diddy/>
+</div>;
+function noCloseBracketTypeArgAttrsTrailingTag() { }
+var donkey = <div>
+ <diddy>
+ <diddy/>
+</div>;
+function noSelfcloseTrailingTag() { }
+var donkey = <div>
+ <diddy<boolean> bananas="please">
+ <diddy/>
+</div>;
+function noSelfcloseTypeArgAttrsTrailingTag() { }
+
+var donkey = <div>
+ <
+ Cranky Wrinkly Funky
+</div>;
+function noNameTrailingText() { }
+var donkey = <div>
+ <diddy
+ Cranky Wrinkly Funky
+</div>;
+function noCloseTrailingText() { }
+var donkey = <div>
+ <diddy<boolean>
+ Cranky Wrinkly Funky
+</div>;
+function noCloseTypeArgTrailingText() { }
+var donkey = <div>
+ <diddy bananas="please"
+ Cranky Wrinkly Funky
+</div>;
+function noCloseAttrsTrailingText() { }
+var donkey = <div>
+ <diddy<boolean> bananas="please"
+ Cranky Wrinkly Funky
+</div>;
+function noCloseTypeArgAttrsTrailingText() { }
+var donkey = <div>
+ <diddy/
+ Cranky Wrinkly Funky
+</div>;
+function noCloseBracketTrailingText() { }
+var donkey = <div>
+ <diddy<boolean> bananas="please"/
+ Cranky Wrinkly Funky
+</div>;
+function noCloseBracketTypeArgAttrsTrailingText() { }
+var donkey = <div>
+ <diddy>
+ Cranky Wrinkly Funky
+</div>;
+function noSelfcloseTrailingText() { }
+var donkey = <div>
+ <diddy<boolean> bananas="please">
+ Cranky Wrinkly Funky
+</div>;
+function noSelfcloseTypeArgAttrsTrailingText() { }
new file mode 100644
@@ -0,0 +1,32 @@
+// @jsx: react-jsx
+// @target: es2015,es2018,esnext
+// @filename: test.tsx
+/// <reference path="/.lib/react16.d.ts" />
+
+export function T1(a: any) {
+ return <div className={"T1"} { ...a }>T1</div>;
+}
+
+export function T2(a: any, b: any) {
+ return <div className={"T2"} { ...a } { ...b }>T2</div>;
+}
+
+export function T3(a: any, b: any) {
+ return <div { ...a } className={"T3"} { ...b }>T3</div>;
+}
+
+export function T4(a: any, b: any) {
+ return <div className={"T4"} { ...{ ...a, ...b } }>T4</div>;
+}
+
+export function T5(a: any, b: any, c: any, d: any) {
+ return <div className={"T5"} { ...{ ...a, ...b, ...{ c, d } } }>T5</div>;
+}
+
+export function T6(a: any, b: any, c: any, d: any) {
+ return <div className={"T6"} { ...{ ...a, ...b, ...{ ...c, ...d } } }>T6</div>;
+}
+
+export function T7(a: any, b: any, c: any, d: any) {
+ return <div>T7</div>;
+}
new file mode 100644
@@ -0,0 +1,23 @@
+// @noImplicitAny: true
+// @noImplicitReferences: true
+
+// @filename: node_modules/foo/package.json
+{
+ "name": "foo",
+ "version": "1.0.0"
+}
+
+// @filename: node_modules/foo/index.js
+var foo = 0;
+module.exports = foo;
+
+// @filename: node_modules/foo/index.d.ts
+declare const foo: any;
+export = foo;
+
+// @filename: node_modules/foo/other.js
+module.exports = {};
+
+// @filename: index.ts
+import * as Foo from "foo";
+import * as Other from "foo/other"/*1*/;
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,3 @@
+// @filename: /node_modules/@cow/boy/index.d.ts
+export const x: number;
+export const y: number;
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,12 @@
+// @noImplicitReferences: true
+// @traceResolution: true
+// @typeRoots: types
+
+
+// @filename: /a.ts
+import { x } from "./index";
+import { y } from "./index";
+import { z } from "./z";
+x;
+y;
+z;
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,2 @@
+// @filename: /node_modules/@types/be__bop/e/z.d.ts
+export const z: number;
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,2 @@
+// @filename: /node_modules/@types/see__saw/index.d.ts
+export const x = 0;
new file mode 100644
@@ -0,0 +1,9 @@
+// @noImplicitReferences: true
+// @traceResolution: true
+// @typeRoots: types
+// @moduleResolution: classic
+
+
+// @filename: /a.ts
+import { x } from "./index";
+x;
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,12 @@
+// @noImplicitReferences: true
+// @currentDirectory: /
+// @allowJs: true
+// @maxNodeModuleJsDepth: 1
+// Same as untypedModuleImport.ts but with --allowJs, so the package will actually be typed.
+
+// @filename: /node_modules/foo/index.js
+// exports.default = { bar() { return 0; } }
+
+// @filename: /a.ts
+import foo from "foo";
+foo.bar();
new file mode 100644
@@ -0,0 +1,4 @@
+// @filename: /declarations.d.ts
+declare module "foo" {
+ export const x: number;
+}
new file mode 100644
@@ -0,0 +1,12 @@
+// @noImplicitReferences: true
+// @currentDirectory: /
+// This tests that an ambient module declaration overrides an untyped import.
+
+// @filename: /node_modules/foo/index.js
+// This file is not processed.
+
+
+// @filename: /a.ts
+/// <reference path="./declarations.d.ts" />
+import { x } from "foo";
+x;
new file mode 100644
@@ -0,0 +1,24 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: index.js
+// esm format file
+import * as self from "package";
+self;
+// @filename: index.mjs
+// esm format file
+import * as self from "package";
+self;
+// @filename: index.cjs
+// esm format file
+import * as self from "package";
+self;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module",
+ "exports": "./index.js"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,324 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+const x = 1;
+export {x};
+// @filename: subfolder/index.cjs
+// cjs format file
+const x = 1;
+export {x};
+// @filename: subfolder/index.mjs
+// esm format file
+const x = 1;
+export {x};
+// @filename: subfolder2/index.js
+// cjs format file
+const x = 1;
+export {x};
+// @filename: subfolder2/index.cjs
+// cjs format file
+const x = 1;
+export {x};
+// @filename: subfolder2/index.mjs
+// esm format file
+const x = 1;
+export {x};
+// @filename: subfolder2/another/index.js
+// esm format file
+const x = 1;
+export {x};
+// @filename: subfolder2/another/index.cjs
+// cjs format file
+const x = 1;
+export {x};
+// @filename: subfolder2/another/index.mjs
+// esm format file
+const x = 1;
+export {x};
+// @filename: index.js
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// esm format file
+const x = 1;
+export {x};
+// @filename: index.cjs
+// ESM-format imports below should issue errors
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// cjs format file
+const x = 1;
+export {x};
+// @filename: index.mjs
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+
+// esm format file
+const x = 1;
+export {x};
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
+// @filename: subfolder2/package.json
+{
+}
+// @filename: subfolder2/another/package.json
+{
+ "type": "module"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,8 @@
+// @module: node12,nodenext
+// @allowJs: true
+// @noEmit: true
+// @filename: foo.cjs
+exports.foo = "foo"
+// @filename: bar.ts
+import foo from "./foo.cjs"
+foo.foo;
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,126 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: index.js
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+// @filename: index.mjs
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+// @filename: index.cjs
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.cjsSource;
+mjsi.cjsSource;
+typei.implicitCjsSource;
+ts.cjsSource;
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const implicitCjsSource = true;
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const mjsSource = true;
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const cjsSource = true;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module",
+ "exports": {
+ "./cjs": "./index.cjs",
+ "./mjs": "./index.mjs",
+ ".": "./index.js"
+ }
+}
+// @filename: node_modules/inner/package.json
+{
+ "name": "inner",
+ "private": true,
+ "exports": {
+ "./a": {
+ "require": "./index.cjs",
+ "node": "./index.mjs"
+ },
+ "./b": {
+ "import": "./index.mjs",
+ "node": "./index.cjs"
+ },
+ ".": {
+ "import": "./index.mjs",
+ "node": "./index.js"
+ },
+ "./types": {
+ "types": {
+ "import": "./index.d.mts",
+ "require": "./index.d.cts",
+ },
+ "node": {
+ "import": "./index.mjs",
+ "require": "./index.cjs"
+ }
+ }
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,27 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+export async function main() {
+ const { readFile } = await import("fs");
+}
+// @filename: index.js
+// esm format file
+export async function main() {
+ const { readFile } = await import("fs");
+}
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,32 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+const a = {};
+export = a;
+// @filename: subfolder/file.js
+// cjs format file
+const a = {};
+module.exports = a;
+// @filename: index.js
+// esm format file
+const a = {};
+export = a;
+// @filename: file.js
+// esm format file
+import "fs";
+const a = {};
+module.exports = a;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,29 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+function require() {}
+const exports = {};
+class Object {}
+export const __esModule = false;
+export {require, exports, Object};
+// @filename: index.js
+// esm format file
+function require() {}
+const exports = {};
+class Object {}
+export const __esModule = false;
+export {require, exports, Object};
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,34 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+// @filename: index.js
+// esm format file
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+// @filename: file.js
+// esm format file
+const __require = null;
+const _createRequire = null;
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,34 @@
+// @module: node12,nodenext
+// @declaration: true
+// @importHelpers: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+import {default as _fs} from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+// @filename: index.js
+// esm format file
+import {default as _fs} from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
+declare module "tslib" {
+ export {};
+ // intentionally missing all helpers
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,30 @@
+// @module: node12,nodenext
+// @declaration: true
+// @importHelpers: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.ts
+// cjs format file
+export * from "fs";
+export * as fs from "fs";
+// @filename: index.js
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
+declare module "tslib" {
+ export {};
+ // intentionally missing all helpers
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,32 @@
+// @module: node12,nodenext
+// @declaration: true
+// @importHelpers: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+export {default} from "fs";
+export {default as foo} from "fs";
+export {bar as baz} from "fs";
+// @filename: index.js
+// esm format file
+export {default} from "fs";
+export {default as foo} from "fs";
+export {bar as baz} from "fs";
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
+declare module "tslib" {
+ export {};
+ // intentionally missing all helpers
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,23 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+const x = import.meta.url;
+export {x};
+// @filename: index.js
+// esm format file
+const x = import.meta.url;
+export {x};
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,92 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: index.js
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+// @filename: index.mjs
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+// @filename: index.cjs
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module",
+ "exports": {
+ "./cjs": "./index.cjs",
+ "./mjs": "./index.mjs",
+ ".": "./index.js"
+ }
+}
+// @filename: node_modules/inner/package.json
+{
+ "name": "inner",
+ "private": true,
+ "exports": {
+ "./cjs": "./index.cjs",
+ "./mjs": "./index.mjs",
+ ".": "./index.js"
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,41 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: index.js
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+// @filename: index.mjs
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+// @filename: index.cjs
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module",
+ "exports": "./index.js",
+ "imports": {
+ "#cjs": "./index.cjs",
+ "#mjs": "./index.mjs",
+ "#type": "./index.js"
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,69 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: index.js
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+// @filename: index.mjs
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+// @filename: index.cjs
+// cjs format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+// @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",
+ "./mjs/*": "./*.mjs",
+ "./js/*": "./*.js"
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,69 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: index.js
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+// @filename: index.mjs
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+// @filename: index.cjs
+// cjs format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+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",
+ "./mjs/*.mjs": "./*.mjs",
+ "./js/*.js": "./*.js"
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,37 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+import {h} from "../index.js";
+import mod = require("../index.js");
+import {f as _f} from "./index.js";
+import mod2 = require("./index.js");
+export async function f() {
+ const mod3 = await import ("../index.js");
+ const mod4 = await import ("./index.js");
+ h();
+}
+// @filename: index.js
+// esm format file
+import {h as _h} from "./index.js";
+import mod = require("./index.js");
+import {f} from "./subfolder/index.js";
+import mod2 = require("./subfolder/index.js");
+export async function h() {
+ const mod3 = await import ("./index.js");
+ const mod4 = await import ("./subfolder/index.js");
+ f();
+}
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,25 @@
+// @module: node12,nodenext
+// @declaration: true
+// @allowJs: true
+// @checkJs: true
+// @outDir: out
+// @filename: subfolder/index.js
+// cjs format file
+const x = await 1;
+export {x};
+for await (const y of []) {}
+// @filename: index.js
+// esm format file
+const x = await 1;
+export {x};
+for await (const y of []) {}
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,33 @@
+// @module: commonjs
+// @lib: es2020
+// @declaration: true
+// @filename: index.ts
+export const a = async () => (await import("inner")).x();
+// @filename: node_modules/inner/index.d.ts
+export { x } from "./other.js";
+// @filename: node_modules/inner/other.d.ts
+import { Thing } from "./private.js"
+export const x: () => Thing;
+// @filename: node_modules/inner/private.d.ts
+export interface Thing {} // not exported in export map, inaccessible under new module modes
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module",
+ "exports": "./index.js"
+}
+// @filename: node_modules/inner/package.json
+{
+ "name": "inner",
+ "private": true,
+ "type": "module",
+ "exports": {
+ ".": {
+ "default": "./index.js"
+ },
+ "./other": {
+ "default": "./other.js"
+ }
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,321 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: subfolder/index.ts
+// cjs format file
+const x = 1;
+export {x};
+// @filename: subfolder/index.cts
+// cjs format file
+const x = 1;
+export {x};
+// @filename: subfolder/index.mts
+// esm format file
+const x = 1;
+export {x};
+// @filename: subfolder2/index.ts
+// cjs format file
+const x = 1;
+export {x};
+// @filename: subfolder2/index.cts
+// cjs format file
+const x = 1;
+export {x};
+// @filename: subfolder2/index.mts
+// esm format file
+const x = 1;
+export {x};
+// @filename: subfolder2/another/index.ts
+// esm format file
+const x = 1;
+export {x};
+// @filename: subfolder2/another/index.mts
+// esm format file
+const x = 1;
+export {x};
+// @filename: subfolder2/another/index.cts
+// cjs format file
+const x = 1;
+export {x};
+// @filename: index.mts
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should all fail - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+
+// esm format file
+const x = 1;
+export {x};
+// @filename: index.cts
+// ESM-format imports below should issue errors
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file)
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// cjs format file
+const x = 1;
+export {x};
+// @filename: index.ts
+import * as m1 from "./index.js";
+import * as m2 from "./index.mjs";
+import * as m3 from "./index.cjs";
+import * as m4 from "./subfolder/index.js";
+import * as m5 from "./subfolder/index.mjs";
+import * as m6 from "./subfolder/index.cjs";
+import * as m7 from "./subfolder2/index.js";
+import * as m8 from "./subfolder2/index.mjs";
+import * as m9 from "./subfolder2/index.cjs";
+import * as m10 from "./subfolder2/another/index.js";
+import * as m11 from "./subfolder2/another/index.mjs";
+import * as m12 from "./subfolder2/another/index.cjs";
+// The next ones shouldn't all work - esm format files have no index resolution or extension resolution
+import * as m13 from "./";
+import * as m14 from "./index";
+import * as m15 from "./subfolder";
+import * as m16 from "./subfolder/";
+import * as m17 from "./subfolder/index";
+import * as m18 from "./subfolder2";
+import * as m19 from "./subfolder2/";
+import * as m20 from "./subfolder2/index";
+import * as m21 from "./subfolder2/another";
+import * as m22 from "./subfolder2/another/";
+import * as m23 from "./subfolder2/another/index";
+void m1;
+void m2;
+void m3;
+void m4;
+void m5;
+void m6;
+void m7;
+void m8;
+void m9;
+void m10;
+void m11;
+void m12;
+void m13;
+void m14;
+void m15;
+void m16;
+void m17;
+void m18;
+void m19;
+void m20;
+void m21;
+void m22;
+void m23;
+
+// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
+import m24 = require("./");
+import m25 = require("./index");
+import m26 = require("./subfolder");
+import m27 = require("./subfolder/");
+import m28 = require("./subfolder/index");
+import m29 = require("./subfolder2");
+import m30 = require("./subfolder2/");
+import m31 = require("./subfolder2/index");
+import m32 = require("./subfolder2/another");
+import m33 = require("./subfolder2/another/");
+import m34 = require("./subfolder2/another/index");
+void m24;
+void m25;
+void m26;
+void m27;
+void m28;
+void m29;
+void m30;
+void m31;
+void m32;
+void m33;
+void m34;
+
+// These shouldn't work - dynamic `import()` always uses the esm resolver, which does not have extension resolution
+const _m35 = import("./");
+const _m36 = import("./index");
+const _m37 = import("./subfolder");
+const _m38 = import("./subfolder/");
+const _m39 = import("./subfolder/index");
+const _m40 = import("./subfolder2");
+const _m41 = import("./subfolder2/");
+const _m42 = import("./subfolder2/index");
+const _m43 = import("./subfolder2/another");
+const _m44 = import("./subfolder2/another/");
+const _m45 = import("./subfolder2/another/index");
+// esm format file
+const x = 1;
+export {x};
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
+// @filename: subfolder2/package.json
+{
+}
+// @filename: subfolder2/another/package.json
+{
+ "type": "module"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,19 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: subfolder/index.ts
+// cjs format file
+export const a = 1;
+// @filename: index.ts
+// esm format file
+import mod from "./subfolder/index.js";
+mod;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,124 @@
+// @module: node12,nodenext
+// @declaration: true
+// @outDir: out
+// @filename: index.ts
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+// @filename: index.mts
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.mjsSource;
+mjsi.mjsSource;
+typei.mjsSource;
+ts.mjsSource;
+// @filename: index.cts
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/a";
+import * as mjsi from "inner/b";
+import * as typei from "inner";
+import * as ts from "inner/types";
+cjsi.cjsSource;
+mjsi.cjsSource;
+typei.implicitCjsSource;
+ts.cjsSource;
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const implicitCjsSource = true;
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const mjsSource = true;
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+import * as cjs from "inner/a";
+import * as mjs from "inner/b";
+import * as type from "inner";
+import * as ts from "inner/types";
+export { cjs };
+export { mjs };
+export { type };
+export { ts };
+export const cjsSource = true;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module",
+ "exports": {
+ "./cjs": "./index.cjs",
+ "./mjs": "./index.mjs",
+ ".": "./index.js"
+ }
+}
+// @filename: node_modules/inner/package.json
+{
+ "name": "inner",
+ "private": true,
+ "exports": {
+ "./a": {
+ "require": "./index.cjs",
+ "node": "./index.mjs"
+ },
+ "./b": {
+ "import": "./index.mjs",
+ "node": "./index.cjs"
+ },
+ ".": {
+ "import": "./index.mjs",
+ "node": "./index.js"
+ },
+ "./types": {
+ "types": {
+ "import": "./index.d.mts",
+ "require": "./index.d.cts",
+ },
+ "node": {
+ "import": "./index.mjs",
+ "require": "./index.cjs"
+ }
+ }
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,71 @@
+// @module: nodenext
+// @declaration: true
+// @filename: index.ts
+// esm format file
+export {};
+// @filename: index.mts
+// esm format file
+export {};
+// @filename: index.cts
+// cjs format file
+export {};
+// @filename: other.ts
+// esm format file
+export const a = await import("package/cjs");
+export const b = await import("package/mjs");
+export const c = await import("package");
+export const f = await import("inner");
+// @filename: other2.ts
+// esm format file
+export const d = await import("inner/cjs");
+export const e = await import("inner/mjs");
+// @filename: other.mts
+// esm format file
+export const a = await import("package/cjs");
+export const b = await import("package/mjs");
+export const c = await import("package");
+export const f = await import("inner");
+// @filename: other2.mts
+// esm format file
+export const d = await import("inner/cjs");
+export const e = await import("inner/mjs");
+// @filename: other.cts
+// cjs format file, no TLA
+export const a = import("package/cjs");
+export const b = import("package/mjs");
+export const c = import("package");
+export const f = import("inner");
+// @filename: other2.cts
+// cjs format file, no TLA
+export const d = import("inner/cjs");
+export const e = import("inner/mjs");
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+export const cjsMain = true;
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+export const esm = true;
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+export const cjsNonmain = true;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module",
+ "exports": {
+ "./cjs": "./index.cjs",
+ "./mjs": "./index.mjs",
+ ".": "./index.js"
+ }
+}
+// @filename: node_modules/inner/package.json
+{
+ "name": "inner",
+ "private": true,
+ "exports": {
+ "./cjs": "./index.cjs",
+ "./mjs": "./index.mjs",
+ ".": "./index.js"
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,93 @@
+// @module: node12,nodenext
+// @declaration: true
+// @outDir: out
+// @filename: index.ts
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export const a = cjs;
+export const b = mjs;
+export const c = type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export const d = cjsi;
+export const e = mjsi;
+export const f = typei;
+// @filename: index.mts
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export const a = cjs;
+export const b = mjs;
+export const c = type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export const d = cjsi;
+export const e = mjsi;
+export const f = typei;
+// @filename: index.cts
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+export const a = cjs;
+export const b = mjs;
+export const c = type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+export const d = cjsi;
+export const e = mjsi;
+export const f = typei;
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+cjs;
+mjs;
+type;
+export const cjsMain = true;
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+cjs;
+mjs;
+type;
+export const esm = true;
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+cjs;
+mjs;
+type;
+export const cjsNonmain = true;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module",
+ "exports": {
+ "./cjs": "./index.cjs",
+ "./mjs": "./index.mjs",
+ ".": "./index.js"
+ }
+}
+// @filename: node_modules/inner/package.json
+{
+ "name": "inner",
+ "private": true,
+ "exports": {
+ "./cjs": "./index.cjs",
+ "./mjs": "./index.mjs",
+ ".": "./index.js"
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,24 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: subfolder/index.ts
+// cjs format file
+export async function main() {
+ const { readFile } = await import("fs");
+}
+// @filename: index.ts
+// esm format file
+export async function main() {
+ const { readFile } = await import("fs");
+}
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,20 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: subfolder/index.ts
+// cjs format file
+const a = {};
+export = a;
+// @filename: index.ts
+// esm format file
+const a = {};
+export = a;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,27 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: index.ts
+// esm format file
+import { Thing } from "inner/other";
+export const a = (await import("inner")).x();
+// @filename: node_modules/inner/index.d.ts
+// esm format file
+export { x } from "./other.js";
+// @filename: node_modules/inner/other.d.ts
+// esm format file
+export interface Thing {}
+export const x: () => Thing;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module",
+ "exports": "./index.js"
+}
+// @filename: node_modules/inner/package.json
+{
+ "name": "inner",
+ "private": true,
+ "type": "module",
+ "exports": "./index.js"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,34 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: index.ts
+// esm format file
+import { Thing } from "inner/other.js"; // should fail
+export const a = (await import("inner")).x();
+// @filename: node_modules/inner/index.d.ts
+// esm format file
+export { x } from "./other.js";
+// @filename: node_modules/inner/other.d.ts
+// esm format file
+export interface Thing {}
+export const x: () => Thing;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module",
+ "exports": "./index.js"
+}
+// @filename: node_modules/inner/package.json
+{
+ "name": "inner",
+ "private": true,
+ "type": "module",
+ "exports": {
+ ".": {
+ "default": "./index.js"
+ },
+ "./other": {
+ "default": "./other.js"
+ }
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,29 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: index.ts
+// esm format file
+import { Thing } from "inner/other";
+export const a = (await import("inner/index.js")).x();
+// @filename: node_modules/inner/index.d.ts
+// esm format file
+export { x } from "./other.js";
+// @filename: node_modules/inner/other.d.ts
+// esm format file
+export interface Thing {}
+export const x: () => Thing;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module",
+ "exports": "./index.js"
+}
+// @filename: node_modules/inner/package.json
+{
+ "name": "inner",
+ "private": true,
+ "type": "module",
+ "exports": {
+ "./": "./"
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,29 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: index.ts
+// esm format file
+import { Thing } from "inner/other";
+export const a = (await import("inner/index.js")).x();
+// @filename: node_modules/inner/index.d.ts
+// esm format file
+export { x } from "./other.js";
+// @filename: node_modules/inner/other.d.ts
+// esm format file
+export interface Thing {}
+export const x: () => Thing;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module",
+ "exports": "./index.js"
+}
+// @filename: node_modules/inner/package.json
+{
+ "name": "inner",
+ "private": true,
+ "type": "module",
+ "exports": {
+ "./*.js": "./*.js"
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,67 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: subfolder/index.ts
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: subfolder/index.cts
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: subfolder/index.mts
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: subfolder2/index.ts
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: subfolder2/index.cts
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: subfolder2/index.mts
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: subfolder2/another/index.ts
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: subfolder2/another/index.mts
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: subfolder2/another/index.cts
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: index.mts
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: index.cts
+// cjs format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: index.ts
+// esm format file
+const x = <T>() => <T><any>(void 0);
+export {x};
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
+// @filename: subfolder2/package.json
+{
+}
+// @filename: subfolder2/another/package.json
+{
+ "type": "module"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,26 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: subfolder/index.ts
+// cjs format file
+function require() {}
+const exports = {};
+class Object {}
+export const __esModule = false;
+export {require, exports, Object};
+// @filename: index.ts
+// esm format file
+function require() {}
+const exports = {};
+class Object {}
+export const __esModule = false;
+export {require, exports, Object};
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,13 @@
+// @module: node12,nodenext
+// @resolveJsonModule: true
+// @filename: index.ts
+import json from "./package.json" assert { type: "json" };
+// @filename: otherc.cts
+import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions
+const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine
+// @filename: package.json
+{
+ "name": "pkg",
+ "private": true,
+ "type": "module"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,31 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: subfolder/index.ts
+// cjs format file
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+// @filename: index.ts
+// esm format file
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+// @filename: file.ts
+// esm format file
+const __require = null;
+const _createRequire = null;
+import fs = require("fs");
+fs.readFile;
+export import fs2 = require("fs");
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,31 @@
+// @module: node12,nodenext
+// @declaration: true
+// @importHelpers: true
+// @filename: subfolder/index.ts
+// cjs format file
+import {default as _fs} from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+// @filename: index.ts
+// esm format file
+import {default as _fs} from "fs";
+_fs.readFile;
+import * as fs from "fs";
+fs.readFile;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
+declare module "tslib" {
+ export {};
+ // intentionally missing all helpers
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,27 @@
+// @module: node12,nodenext
+// @declaration: true
+// @importHelpers: true
+// @filename: subfolder/index.ts
+// cjs format file
+export * from "fs";
+export * as fs from "fs";
+// @filename: index.ts
+// esm format file
+export * from "fs";
+export * as fs from "fs";
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
+declare module "tslib" {
+ export {};
+ // intentionally missing all helpers
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,25 @@
+// @module: node12,nodenext
+// @declaration: true
+// @importHelpers: true
+// @filename: subfolder/index.ts
+// cjs format file
+export {default} from "fs";
+// @filename: index.ts
+// esm format file
+export {default} from "fs";
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
+// @filename: types.d.ts
+declare module "fs";
+declare module "tslib" {
+ export {};
+ // intentionally missing all helpers
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,20 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: subfolder/index.ts
+// cjs format file
+const x = import.meta.url;
+export {x};
+// @filename: index.ts
+// esm format file
+const x = import.meta.url;
+export {x};
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,24 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: index.ts
+// esm format file
+import * as type from "#type";
+type;
+// @filename: index.mts
+// esm format file
+import * as type from "#type";
+type;
+// @filename: index.cts
+// esm format file
+import * as type from "#type";
+type;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module",
+ "exports": "./index.cjs",
+ "imports": {
+ "#type": "package"
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,24 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: index.ts
+// esm format file
+import * as type from "#type";
+type;
+// @filename: index.mts
+// esm format file
+import * as type from "#type";
+type;
+// @filename: index.cts
+// esm format file
+import * as type from "#type";
+type;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module",
+ "exports": "package",
+ "imports": {
+ "#type": "package"
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,90 @@
+// @module: node12,nodenext
+// @declaration: true
+// @outDir: out
+// @filename: index.ts
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+// @filename: index.mts
+// esm format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+// @filename: index.cts
+// cjs format file
+import * as cjs from "package/cjs";
+import * as mjs from "package/mjs";
+import * as type from "package";
+cjs;
+mjs;
+type;
+import * as cjsi from "inner/cjs";
+import * as mjsi from "inner/mjs";
+import * as typei from "inner";
+cjsi;
+mjsi;
+typei;
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+import * as cjs from "inner/cjs";
+import * as mjs from "inner/mjs";
+import * as type from "inner";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module",
+ "exports": {
+ "./cjs": "./index.cjs",
+ "./mjs": "./index.mjs",
+ ".": "./index.js"
+ }
+}
+// @filename: node_modules/inner/package.json
+{
+ "name": "inner",
+ "private": true,
+ "exports": {
+ "./cjs": "./index.cjs",
+ "./mjs": "./index.mjs",
+ ".": "./index.js"
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,38 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: index.ts
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+// @filename: index.mts
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+// @filename: index.cts
+// esm format file
+import * as cjs from "#cjs";
+import * as mjs from "#mjs";
+import * as type from "#type";
+cjs;
+mjs;
+type;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module",
+ "exports": "./index.js",
+ "imports": {
+ "#cjs": "./index.cjs",
+ "#mjs": "./index.mjs",
+ "#type": "./index.js"
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,67 @@
+// @module: node12,nodenext
+// @declaration: true
+// @outDir: out
+// @filename: index.ts
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+// @filename: index.mts
+// esm format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+// @filename: index.cts
+// cjs format file
+import * as cjsi from "inner/cjs/index";
+import * as mjsi from "inner/mjs/index";
+import * as typei from "inner/js/index";
+cjsi;
+mjsi;
+typei;
+// @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",
+ "./mjs/*": "./*.mjs",
+ "./js/*": "./*.js"
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,67 @@
+// @module: node12,nodenext
+// @declaration: true
+// @outDir: out
+// @filename: index.ts
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+// @filename: index.mts
+// esm format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+// @filename: index.cts
+// cjs format file
+import * as cjsi from "inner/cjs/index.cjs";
+import * as mjsi from "inner/mjs/index.mjs";
+import * as typei from "inner/js/index.js";
+cjsi;
+mjsi;
+typei;
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+export { cjs };
+export { mjs };
+export { type };
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+import * as cjs from "inner/cjs/index.cjs";
+import * as mjs from "inner/mjs/index.mjs";
+import * as type from "inner/js/index.js";
+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",
+ "./mjs/*.mjs": "./*.mjs",
+ "./js/*.js": "./*.js"
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,29 @@
+// @module: node12,nodenext
+// @resolveJsonModule: true
+// @outDir: ./out
+// @declaration: true
+// @filename: index.ts
+import pkg from "./package.json"
+export const name = pkg.name;
+import * as ns from "./package.json";
+export const thing = ns;
+export const name2 = ns.default.name;
+// @filename: index.cts
+import pkg from "./package.json"
+export const name = pkg.name;
+import * as ns from "./package.json";
+export const thing = ns;
+export const name2 = ns.default.name;
+// @filename: index.mts
+import pkg from "./package.json"
+export const name = pkg.name;
+import * as ns from "./package.json";
+export const thing = ns;
+export const name2 = ns.default.name;
+// @filename: package.json
+{
+ "name": "pkg",
+ "version": "0.0.1",
+ "type": "module",
+ "default": "misedirection"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,34 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: subfolder/index.ts
+// cjs format file
+import {h} from "../index.js";
+import mod = require("../index.js");
+import {f as _f} from "./index.js";
+import mod2 = require("./index.js");
+export async function f() {
+ const mod3 = await import ("../index.js");
+ const mod4 = await import ("./index.js");
+ h();
+}
+// @filename: index.ts
+// esm format file
+import {h as _h} from "./index.js";
+import mod = require("./index.js");
+import {f} from "./subfolder/index.js";
+import mod2 = require("./subfolder/index.js");
+export async function h() {
+ const mod3 = await import ("./index.js");
+ const mod4 = await import ("./subfolder/index.js");
+ f();
+}
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,22 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: subfolder/index.ts
+// cjs format file
+const x = await 1;
+export {x};
+for await (const y of []) {}
+// @filename: index.ts
+// esm format file
+const x = await 1;
+export {x};
+for await (const y of []) {}
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module"
+}
+// @filename: subfolder/package.json
+{
+ "type": "commonjs"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,53 @@
+// @module: node12,nodenext
+// @declaration: true
+// @outDir: out
+// @filename: index.ts
+// esm format file
+import * as mod from "inner";
+mod.correctVersionApplied;
+
+// @filename: index.mts
+// esm format file
+import * as mod from "inner";
+mod.correctVersionApplied;
+
+// @filename: index.cts
+// cjs format file
+import * as mod from "inner";
+mod.correctVersionApplied;
+
+// @filename: node_modules/inner/index.d.ts
+// cjs format file
+export const noConditionsApplied = true;
+// @filename: node_modules/inner/index.d.mts
+// esm format file
+export const importConditionApplied = true;
+// @filename: node_modules/inner/index.d.cts
+// cjs format file
+export const wrongConditionApplied = true;
+// @filename: node_modules/inner/old-types.d.ts
+export const noVersionApplied = true;
+// @filename: node_modules/inner/new-types.d.ts
+export const correctVersionApplied = true;
+// @filename: node_modules/inner/future-types.d.ts
+export const futureVersionApplied = true;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module",
+}
+// @filename: node_modules/inner/package.json
+{
+ "name": "inner",
+ "private": true,
+ "exports": {
+ ".": {
+ "types@>=10000": "./future-types.d.ts",
+ "types@>=1": "./new-types.d.ts",
+ "types": "./old-types.d.ts",
+ "import": "./index.mjs",
+ "node": "./index.js"
+ },
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,21 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: index.ts
+// esm format file
+import * as self from "package";
+self;
+// @filename: index.mts
+// esm format file
+import * as self from "package";
+self;
+// @filename: index.cts
+// esm format file
+import * as self from "package";
+self;
+// @filename: package.json
+{
+ "name": "package",
+ "private": true,
+ "type": "module",
+ "exports": "./index.js"
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,21 @@
+// @module: node12,nodenext
+// @declaration: true
+// @filename: index.ts
+// esm format file
+import * as self from "@scope/package";
+self;
+// @filename: index.mts
+// esm format file
+import * as self from "@scope/package";
+self;
+// @filename: index.cts
+// cjs format file
+import * as self from "@scope/package";
+self;
+// @filename: package.json
+{
+ "name": "@scope/package",
+ "private": true,
+ "type": "module",
+ "exports": "./index.js"
+}
\ No newline at end of file
@@ -9,4 +9,5 @@ abstract class Base {
abstract class Sub extends Base {
abstract override foo(): number;
bar() { }
-}
\ No newline at end of file
+}
+let aa =new Sub();
\ No newline at end of file
@@ -24,3 +24,4 @@ class B extends A {
override m3(): void {}
}
+let qq13 = new B();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,9 @@
+// @noImplicitOverride: true
+
+class A {
+ doSomething() {}
+}
+
+class B extends A {
+ override doSomethang() {}
+}
@@ -8,3 +8,4 @@ class A {
class B extends A {
override foo = "string";
}
+let qq12 = new B();
\ No newline at end of file
@@ -25,3 +25,4 @@ class B extends A {
override m3(): void {}
}
+let qq11 = new B();
\ No newline at end of file
@@ -9,3 +9,4 @@ class A {
class B extends A {
override foo = "string";
}
+let qq7 = new B();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,20 @@
+// @target: esnext
+// @noImplicitOverride: true
+
+type Foo = abstract new(...args: any) => any;
+declare function CreateMixin<C extends Foo, T extends Foo>(Context: C, Base: T): T & {
+ new (...args: any[]): { context: InstanceType<C> }
+}
+class Context {}
+
+class A {
+ doSomething() {}
+}
+
+class B extends CreateMixin(Context, A) {
+ override foo() {} // Remove override
+}
+
+class C extends CreateMixin(Context, A) {
+ override doSomethang() {} // Suggestion 'doSomething'
+}
new file mode 100644
@@ -0,0 +1,34 @@
+// @target: esnext
+// @noImplicitOverride: true
+
+const Foo: C1 & C2 =
+ class {
+ m1() { }
+ m2() { }
+ }
+
+interface I1 {
+ m1(): void;
+}
+
+interface I2 {
+ m1(): void;
+ m2(): void;
+}
+
+interface C1 {
+ new(...args: any[]): I1;
+}
+
+interface C2 {
+ new(...args: any[]): I2;
+}
+
+export class Bar extends Foo {
+ m1() {
+ super.m1();
+ }
+ m2() {
+ super.m2();
+ }
+}
@@ -22,4 +22,6 @@ class C {
fooo (v) {}
/** @override */
bar(v) {}
-}
\ No newline at end of file
+}
+let qq8 = new D();
+let qq9 = new C();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,14 @@
+// @noImplicitOverride: true
+// @allowJs: true
+// @checkJs: true
+// @noEmit: true
+
+// @Filename: a.js
+class A {
+ doSomething() {}
+}
+
+class B extends A {
+ /** @override */
+ doSomethang() {}
+}
@@ -1,4 +1,5 @@
class C {
foo();
foo() { }
-}
\ No newline at end of file
+}
+let q19 = new C();
\ No newline at end of file
@@ -5,3 +5,4 @@ declare class Enumerator {
public item(): any;
constructor (o: any);
}
+let q22 = new Enumerator();
\ No newline at end of file
@@ -1,4 +1,5 @@
class C {
foo();
"foo"() { }
-}
\ No newline at end of file
+}
+let q18 = new C();
\ No newline at end of file
@@ -1,4 +1,5 @@
class C {
0();
"0"() { }
-}
\ No newline at end of file
+}
+let q23 = new C();
\ No newline at end of file
@@ -1,2 +1,3 @@
class C\u0032 {
-}
\ No newline at end of file
+}
+let q17 = new C\u0032();
\ No newline at end of file
@@ -1,4 +1,5 @@
class C {
var
public
-}
\ No newline at end of file
+}
+let q20 = new C();
\ No newline at end of file
@@ -1,3 +1,4 @@
class C {
[index:number]:number
-}
\ No newline at end of file
+}
+let q21 = new C();
\ No newline at end of file
@@ -1,3 +1,4 @@
class C {
public constructor() { }
-}
\ No newline at end of file
+}
+let q24 = new C();
\ No newline at end of file
@@ -1,3 +1,4 @@
class C {
private constructor() { }
-}
\ No newline at end of file
+}
+let q25 = new C();
\ No newline at end of file
@@ -2,3 +2,4 @@ class Outer
{
static public() {}
}
+let q12 = new Outer();
\ No newline at end of file
@@ -2,3 +2,4 @@ class Outer
{
static public<T>() {}
}
+let q14 = new Outer();
\ No newline at end of file
@@ -2,3 +2,4 @@ class Outer
{
static public;
}
+let q11 = new Outer();
\ No newline at end of file
@@ -2,3 +2,4 @@ class Outer
{
static public = 1;
}
+let q9 = new Outer();
\ No newline at end of file
@@ -2,3 +2,4 @@ class Outer
{
static public: number;
}
+let q13 = new Outer();
\ No newline at end of file
@@ -2,3 +2,4 @@ class Outer
{
static public
}
+let q0 = new Outer();
\ No newline at end of file
@@ -1,2 +1,3 @@
class C<T> {
-}
\ No newline at end of file
+}
+let q38 = new C();
\ No newline at end of file
@@ -1,2 +1,3 @@
class C<K,V> {
-}
\ No newline at end of file
+}
+let q40 = new C();
\ No newline at end of file
@@ -1,2 +1,3 @@
class C<T extends number> {
-}
\ No newline at end of file
+}
+let q39 = new C();
\ No newline at end of file
@@ -1,3 +1,4 @@
class C {
[a: string]: number
-}
\ No newline at end of file
+}
+let q27 = new C();
\ No newline at end of file
@@ -1,4 +1,5 @@
class C {
[a: string]: number
public v: number
-}
\ No newline at end of file
+}
+let q29 = new C();
\ No newline at end of file
@@ -1,4 +1,5 @@
class C {
[a: string]: number;
public v: number
-}
\ No newline at end of file
+}
+let q30 = new C();
\ No newline at end of file
@@ -1,3 +1,4 @@
class C {
[a: string]: number; public v: number
-}
\ No newline at end of file
+}
+let q28 = new C();
\ No newline at end of file
@@ -1,3 +1,4 @@
class C {
static [x: string]: string;
-}
\ No newline at end of file
+}
+let q26 = new C();
\ No newline at end of file
@@ -1,3 +1,4 @@
class C {
declare Foo;
-}
\ No newline at end of file
+}
+let q8 = new C();
\ No newline at end of file
@@ -1,3 +1,4 @@
class C {
protected constructor() { }
-}
\ No newline at end of file
+}
+let q37 = new C();
\ No newline at end of file
@@ -1,3 +1,4 @@
class C {
protected static m() { }
-}
\ No newline at end of file
+}
+let q34 = new C();
\ No newline at end of file
@@ -1,3 +1,4 @@
class C {
constructor(protected p) { }
-}
\ No newline at end of file
+}
+let q35 = new C(null);
\ No newline at end of file
@@ -1,3 +1,4 @@
export class Logger {
public
}
+let q32 = new Logger();
\ No newline at end of file
@@ -1,3 +1,4 @@
export class Logger {
public
}
+let q31 = new Logger();
\ No newline at end of file
@@ -3,3 +3,4 @@
export class Logger {
public
}
+let q23 = new Logger();
\ No newline at end of file
@@ -1,2 +1,3 @@
class 剩下 {
-}
\ No newline at end of file
+}
+let q5 = new 剩下();
new file mode 100644
@@ -0,0 +1,4 @@
+// @target: esnext
+
+var async;
+for (async of [1, 2]) {}
new file mode 100644
@@ -0,0 +1,6 @@
+// @target: esnext
+
+async function foo(x: any) {
+ var async;
+ for await (async of x) {}
+}
new file mode 100644
@@ -0,0 +1,4 @@
+// @target: esnext
+
+var async;
+for ((async) of [1, 2]);
@@ -14,3 +14,4 @@ class Derived extends Base {
this.p = 1
}
}
+let w1 = new Derived();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,44 @@
+// @outdir: out/
+// @target: esnext
+// @allowJS: true
+// @filename: plainJSBinderErrors.js
+export default 12
+export default 13
+const await = 1
+const yield = 2
+async function f() {
+ const await = 3
+}
+function* g() {
+ const yield = 4
+}
+class C {
+ #constructor = 5
+ deleted() {
+ function container(f) {
+ delete f
+ }
+ var g = 6
+ delete g
+ delete container
+ }
+ evalArguments() {
+ const eval = 7
+ const arguments = 8
+ }
+ withOctal() {
+ const redundant = 010
+ with (redundant) {
+ return toFixed()
+ }
+ }
+ label() {
+ for(;;) {
+ label: var x = 1
+ break label
+ }
+ return x
+ }
+}
+const eval = 9
+const arguments = 10
new file mode 100644
@@ -0,0 +1,6 @@
+// @outdir: out/
+// @allowJS: true
+// @filename: plainJSRedeclare.js
+const orbitol = 1
+var orbitol = 1 + false
+orbitol.toExponential()
new file mode 100644
@@ -0,0 +1,7 @@
+// @outdir: out/
+// @allowJS: true
+// @checkJS: true
+// @filename: plainJSRedeclare.js
+const orbitol = 1
+var orbitol = 1 + false
+orbitol.toExponential()
new file mode 100644
@@ -0,0 +1,7 @@
+// @outdir: out/
+// @allowJS: true
+// @checkJS: false
+// @filename: plainJSRedeclare.js
+const orbitol = 1
+var orbitol = 1 + false
+orbitol.toExponential()
new file mode 100644
@@ -0,0 +1,7 @@
+// @outdir: out/
+// @target: esnext
+// @allowJS: true
+// @filename: plainJSReservedStrict.js
+"use strict"
+const eval = 1
+const arguments = 2
new file mode 100644
@@ -0,0 +1,51 @@
+// @noEmit: true
+// @allowJs: true
+// @filename: spellingUncheckedJS.js
+export var inModule = 1
+inmodule.toFixed()
+
+function f() {
+ var locals = 2 + true
+ locale.toFixed()
+ // @ts-expect-error
+ localf.toExponential()
+ // @ts-expect-error
+ "this is fine"
+}
+class Classe {
+ non = 'oui'
+ methode() {
+ // no error on 'this' references
+ return this.none
+ }
+}
+class Derivee extends Classe {
+ methode() {
+ // no error on 'super' references
+ return super.none
+ }
+}
+
+
+var object = {
+ spaaace: 3
+}
+object.spaaaace // error on read
+object.spaace = 12 // error on write
+object.fresh = 12 // OK
+other.puuuce // OK, from another file
+new Date().getGMTDate() // OK, from another file
+
+// No suggestions for globals from other files
+const atoc = setIntegral(() => console.log('ok'), 500)
+AudioBuffin // etc
+Jimmy
+Jon
+
+// @filename: other.js
+var Jimmy = 1
+var John = 2
+Jon // error, it's from the same file
+var other = {
+ puuce: 4
+}
new file mode 100644
@@ -0,0 +1,18 @@
+// @allowJs: true
+// @checkJs: true
+// @noEmit: true
+// @strictNullChecks: true
+// @noImplicitAny: true
+// @Filename: a.js
+
+/** @type {() => undefined} */
+function f1() {
+ return undefined;
+}
+const a = f1()
+
+/** @type {() => null} */
+function f2() {
+ return null;
+}
+const b = f2()
new file mode 100644
@@ -0,0 +1,18 @@
+// @allowJs: true
+// @checkJs: true
+// @noEmit: true
+// @strictNullChecks: false
+// @noImplicitAny: true
+// @Filename: a.js
+
+/** @type {() => undefined} */
+function f1() {
+ return undefined;
+}
+const a = f1()
+
+/** @type {() => null} */
+function f2() {
+ return null;
+}
+const b = f2()
new file mode 100644
@@ -0,0 +1,29 @@
+// @allowJs: true
+// @checkJs: true
+// @noEmit: true
+// @strictNullChecks: false
+// @noImplicitAny: true
+// @Filename: a.js
+
+/** @type {number | undefined} */
+var n;
+
+// should get any on parameter initialisers
+function f(a = null, b = n, l = []) {
+ // a should be any
+ a = undefined
+ a = null
+ a = 1
+ a = true
+ a = {}
+ a = 'ok'
+
+ // b should be number | undefined, not any
+ b = 1
+ b = undefined
+ b = 'error'
+
+ // l should be any[]
+ l.push(1)
+ l.push('ok')
+}
@@ -35,3 +35,6 @@ class NormalModule extends Module {
return 0
}
}
+let cc = new C();
+let dd = new D();
+let mo = new NormalModule();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,4 @@
+// @target: esnext
+
+var async;
+for (async in { a: 1, b: 2 }) {}
@@ -21,3 +21,4 @@ function fn10(): I { return { id: 12 }; }
function fn11(): I { return new C(); }
function fn12(): C { return new D(); }
function fn13(): C { return null; }
+let q41 = new D();
\ No newline at end of file
@@ -45,3 +45,4 @@ var aa = {
throw this;
}
}
+let q42 = new C();
\ No newline at end of file
@@ -7,4 +7,6 @@ var b = x<string>('hello');
class C { foo: string; }
var c = x<C>(x);
-var d = x<any>(x);
\ No newline at end of file
+var d = x<any>(x);
+
+let c1 = new C();
\ No newline at end of file
@@ -42,4 +42,6 @@ M = x;
function k<T>(a: T) {
a = x;
-}
\ No newline at end of file
+}
+
+let c1 = new C();
\ No newline at end of file
@@ -52,4 +52,6 @@ x = { f<T>(x: T) { return x; } }
function j<T>(a: T) {
x = a;
-}
\ No newline at end of file
+}
+
+let c1 = new C();
\ No newline at end of file
@@ -25,3 +25,5 @@ class Bar<T extends string> {
Bar.instance.push(this);
}
}
+
+let ba = new Bar();
@@ -31,3 +31,6 @@ testRest((t1: D, t2, t3) => {})
testRest((t1, t2: D, t3) => {})
testRest((t2: D, ...t3) => {})
testRest((t2, ...t3: D[]) => {})
+
+
+let d = new D();
@@ -28,8 +28,8 @@ declare module "foo2" {
item: Bar.I;
constructor(input: Baz.J);
}
+
}
-
let y: import("foo2").Bar.I = { a: "", b: 0 };
class Bar2 {
@@ -40,3 +40,6 @@ class Bar2 {
let shim: typeof import("foo2") = {
Bar: Bar2
};
+
+var a;
+let ba1 = new Bar2(a);
@@ -29,9 +29,10 @@ class Bar<T> {
item: Bar.I<T>;
constructor(input: Baz.J<T>) {}
}
+let bbb = new Bar(null);
export { Bar }
-// @filename: usage.ts
+// @filename: usage.
export const x: import("./foo")<{x: number}> = { x: 0, y: 0, data: {x: 12} };
export let y: import("./foo2").Bar.I<{x: number}> = { a: "", b: 0, data: {x: 12} };
@@ -43,3 +44,5 @@ export class Bar2<T> {
export let shim: typeof import("./foo2") = {
Bar: Bar2
};
+
+let ba2 = new Bar2(1);
@@ -26,8 +26,11 @@ class Bar {
item: Bar.I;
constructor(input: Baz.J) {}
}
+let bbb = new Bar(null)
export { Bar }
+
+
// @filename: usage.ts
export const x: import("./foo") = { x: 0, y: 0 };
export let y: import("./foo2").Bar.I = { a: "", b: 0 };
@@ -40,3 +43,5 @@ export class Bar2 {
export let shim: typeof import("./foo2") = {
Bar: Bar2
};
+
+let ba2 = new Bar2();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,16 @@
+// @strict: true
+
+interface X {
+ a?: { aProp: string };
+ b?: { bProp: string };
+}
+type AorB = { a: object; b: undefined } | { a: undefined; b: object };
+
+declare const q: X & AorB;
+
+if (q.a !== undefined) {
+ q.a.aProp;
+} else {
+ // q.b is previously incorrectly inferred as potentially undefined
+ q.b.bProp;
+}
@@ -658,3 +658,23 @@ const cf2 = <T extends { [P in K | "cool"]: string; }, K extends keyof T>(t: T,
const s: string = t[k];
t.cool;
};
+
+let shape = new Shape();
+let ta1 = new TaggedShape();
+let it = new Item();
+let op = new Options();
+let com1 = new Component();
+let c11 = new C();
+let c12 = new C1();
+let ba1 = new Base();
+let per = new Person(1);
+let oth = new OtherPerson(1);
+var aa;
+let com2 = new Component1(aa);
+let com3 = new Component2(aa);
+let a11 = new A();
+let b11 = new B();
+let fo = new Form();
+let sam = new SampleClass(1);
+let ano = new AnotherSampleClass(1);
+let unb = new Unbounded();
@@ -176,3 +176,6 @@ type Bit = 0 | 1;
let aa = makeArray<Bit>(0);
aa = append(aa, 1);
+
+let c1 = new C1();
+let c2 = new C2();
@@ -3,6 +3,7 @@ function f1() {
class C {
constructor(public x: number, public y: number) { }
}
+ let c = new C(1,2);
return C;
}
let C = f();
@@ -17,6 +18,7 @@ function f2() {
public x = x;
constructor(public y: number) { }
}
+ let c = new C(1);
return C;
}
let C = f(10);
@@ -31,6 +33,7 @@ function f3() {
public x = x;
public y = y;
}
+ let c = new C();
return C;
}
let C = f(10, 20);
@@ -3,6 +3,7 @@ function f1() {
class C<X, Y> {
constructor(public x: X, public y: Y) { }
}
+ let c = new C(1,2);
return C;
}
let C = f();
@@ -17,6 +18,7 @@ function f2() {
public x = x;
constructor(public y: Y) { }
}
+ let c = new C(1);
return C;
}
let C = f(10);
@@ -31,6 +33,7 @@ function f3() {
public x = x;
public y = y;
}
+ let c = new C();
return C;
}
let C = f(10, "hello");
new file mode 100644
@@ -0,0 +1,27 @@
+// From original issue #45212:
+type Methods<T> = { [P in keyof T as T[P] extends Function ? P : never]: T[P] };
+type H<T> = T[keyof Methods<T>]; // Ok
+
+// `Filter<T>` only filters out some keys of `T`.
+type Filter<T> = { [P in keyof T as T[P] extends Function ? P : never]: T[P] };
+// `Modify<T>` might modify some keys of `T`.
+type Modify<T> = { [P in keyof T as P extends string? `bool${P}`: P]: T[P] };
+
+function fun<T>(val: T) {
+ let x: Filter<T> = val; // Ok
+ let y: Modify<T> = val; // Error
+}
+
+type FilterInclOpt<T> = { [P in keyof T as T[P] extends Function ? P : never]+?: T[P] };
+type ModifyInclOpt<T> = { [P in keyof T as P extends string? `bool${P}`: never ]+?: T[P] };
+type FilterExclOpt<T> = { [P in keyof T as T[P] extends Function ? P : never]-?: T[P] };
+type ModifyExclOpt<T> = { [P in keyof T as P extends string? `bool${P}`: never ]-?: T[P] };
+
+function fun2<T>(val: T) {
+ let x: FilterInclOpt<T> = val; // Ok
+ let y: ModifyInclOpt<T> = val; // Ok
+ let z: FilterExclOpt<T> = val; // Error
+ let w: ModifyExclOpt<T> = val; // Error
+}
+
+
new file mode 100644
@@ -0,0 +1,42 @@
+// @declaration: true
+export type PlaceType = 'openSky' | 'roofed' | 'garage'
+type Before = {
+ model: 'hour' | 'day';
+ [placeType in PlaceType]: void;
+}
+
+type After = {
+ [placeType in PlaceType]: void;
+ model: 'hour' | 'day'
+}
+
+type AfterQuestion = {
+ [placeType in PlaceType]?: void;
+ model: 'hour' | 'day';
+}
+type AfterMethod = {
+ [placeType in PlaceType]?: void;
+ model(duration: number): 'hour' | 'day';
+}
+
+type AfterImplicit = {
+ [placeType in PlaceType]
+ model: 'hour' | 'day';
+}
+type AfterImplicitQ = {
+ [placeType in PlaceType]?
+ model: 'hour' | 'day'
+}
+
+interface I {
+ [P in PlaceType]: any
+}
+class C {
+ [P in PlaceType]: any
+}
+const D = class {
+ [P in PlaceType]: any
+}
+const E = class {
+ [P in 'a' | 'b']: any
+}
@@ -37,4 +37,6 @@ function f3(bb: BoxifiedBacon) {
let b = unboxify<Bacon>(bb); // Explicit type parameter required
let bool = b.isPerfect;
let weight = bb.weight;
-}
\ No newline at end of file
+}
+
+let box = new Box();
\ No newline at end of file
@@ -43,3 +43,5 @@ interface E3<T> extends Base {
class Form<T> {
private values: {[P in keyof T]?: T[P]} = {}
}
+
+let f = new Form();
\ No newline at end of file
@@ -24,4 +24,6 @@ class D extends C {
var r7: string = C.f();
var r8: string = C.g();
}
-}
\ No newline at end of file
+}
+
+let d = new D();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,325 @@
+// @strict: true
+// @declaration: true
+// @target: esnext
+
+// Symbol index signature checking
+
+const sym = Symbol();
+
+function gg3(x: { [key: string]: string }, y: { [key: symbol]: string }, z: { [sym]: number }) {
+ x = z;
+ y = z; // Error
+}
+
+// Overlapping index signatures
+
+function gg1(x: { [key: `a${string}`]: string, [key: `${string}a`]: string }, y: { [key: `a${string}a`]: string }) {
+ x = y;
+ y = x;
+}
+
+interface IX { [key: `a${string}`]: string, [key: `${string}a`]: string }
+interface IY { [key: `a${string}a`]: string }
+
+function gg2(x: IX, y: IY) {
+ x = y; // Error
+ y = x;
+}
+
+// Intersection of multiple applicable index signatures
+
+declare let combo: { [x: `foo-${string}`]: 'a' | 'b' } & { [x: `${string}-bar`]: 'b' | 'c' };
+const x1 = combo['foo-test']; // 'a' | 'b'
+const x2 = combo['test-bar']; // 'b' | 'c'
+const x3 = combo['foo-test-bar']; // 'b' (('a' | 'b') & ('b' | 'c'))
+
+declare var str: string;
+
+const x4 = combo[`foo-${str}`];
+const x5 = combo[`${str}-bar`];
+const x6 = combo[`foo-${str}-bar`];
+
+declare let combo2: { [x: `${string}xxx${string}` & `${string}yyy${string}`]: string };
+
+const x7 = combo2['axxxbyyyc'];
+const x8 = combo2['ayyyxxxbc'];
+const x9 = combo2['axxxbbbyc']; // Error
+
+// Property access on template pattern index signature
+
+declare let dom: { [x: `data${string}`]: string };
+const y1 = dom['data123'];
+const y2 = dom.data123;
+
+// Excess property checking for template pattern index signature
+
+dom = { data123: 'hello' };
+dom = { date123: 'hello' }; // Error
+
+// Contextual typing by index signature with template literal pattern
+
+type Funcs = {
+ [key: `s${string}`]: (x: string) => void,
+ [key: `n${string}`]: (x: number) => void,
+}
+
+const funcs: Funcs = {
+ sfoo: x => x.length, // x: string
+ nfoo: x => x * 2, // n: number
+}
+
+// Duplicate index signature checking
+
+type Duplicates = {
+ [key: string | number]: any; // Error
+ [key: number | symbol]: any; // Error
+ [key: symbol | `foo${string}`]: any; // Error
+ [key: `foo${string}`]: any; // Error
+}
+
+// Conflicting index signature checking
+
+type Conflicting = {
+ [key: `a${string}`]: 'a';
+ [key: `${string}a`]: 'b';
+ [key: `a${string}a`]: 'c'; // Error
+}
+
+// Invalid index signatures
+
+type Invalid<T extends string> = {
+ [key: 'a' | 'b' | 'c']: string; // Error
+ [key: T | number]: string; // Error
+ [key: Error]: string; // Error
+ [key: T & string]: string; // Error
+}
+
+// Intersections in index signatures
+
+type Tag1 = { __tag1__: void };
+type Tag2 = { __tag2__: void };
+
+type TaggedString1 = string & Tag1;
+type TaggedString2 = string & Tag2;
+
+declare let s0: string;
+declare let s1: TaggedString1;
+declare let s2: TaggedString2;
+declare let s3: TaggedString1 | TaggedString2;
+declare let s4: TaggedString1 & TaggedString2;
+
+interface I1 { [key: TaggedString1]: string }
+interface I2 { [key: TaggedString2]: string }
+interface I3 { [key: TaggedString1 | TaggedString2]: string }
+interface I4 { [key: TaggedString1 & TaggedString2]: string }
+
+declare let i1: I1;
+declare let i2: I2;
+declare let i3: I3;
+declare let i4: I4;
+
+i1[s0]; // Error
+i1[s1];
+i1[s2]; // Error
+i1[s3]; // Error
+i1[s4];
+
+i2[s0]; // Error
+i2[s1]; // Error
+i2[s2];
+i2[s3]; // Error
+i2[s4];
+
+i3[s0]; // Error
+i3[s1];
+i3[s2];
+i3[s3];
+i3[s4];
+
+i4[s0]; // Error
+i4[s1]; // Error
+i4[s2]; // Error
+i4[s3]; // Error
+i4[s4];
+
+i1 = i2; // Error
+i1 = i3;
+i1 = i4; // Error
+
+i2 = i1; // Error
+i2 = i3;
+i2 = i4; // Error
+
+i3 = i1; // Error
+i3 = i2; // Error
+i3 = i4; // Error
+
+i4 = i1;
+i4 = i2;
+i4 = i3;
+
+declare let o1: { [key: TaggedString1]: string };
+declare let o2: { [key: TaggedString2]: string };
+declare let o3: { [key: TaggedString1 | TaggedString2]: string };
+declare let o4: { [key: TaggedString1 & TaggedString2]: string };
+
+o1[s0]; // Error
+o1[s1];
+o1[s2]; // Error
+o1[s3]; // Error
+o1[s4];
+
+o2[s0]; // Error
+o2[s1]; // Error
+o2[s2];
+o2[s3]; // Error
+o2[s4];
+
+o3[s0]; // Error
+o3[s1];
+o3[s2];
+o3[s3];
+o3[s4];
+
+o4[s0]; // Error
+o4[s1]; // Error
+o4[s2]; // Error
+o4[s3]; // Error
+o4[s4];
+
+o1 = o2;
+o1 = o3;
+o1 = o4;
+
+o2 = o1;
+o2 = o3;
+o2 = o4;
+
+o3 = o1;
+o3 = o2;
+o3 = o4;
+
+o4 = o1;
+o4 = o2;
+o4 = o3;
+
+// Index signatures inferred from computed property names
+
+const obj10 = {
+ ['x']: 0 as const,
+ ['a' + 'b']: 1 as const,
+};
+
+const obj11 = {
+ [1]: 2 as const,
+ [1 + 2]: 3 as const,
+};
+
+const obj12 = {
+ [sym]: 4 as const,
+ [Symbol()]: 5 as const,
+};
+
+const obj13 = {
+ ['x']: 0 as const,
+ ['a' + 'b']: 1 as const,
+ [1]: 2 as const,
+ [1 + 2]: 3 as const,
+ [sym]: 4 as const,
+ [Symbol()]: 5 as const,
+};
+
+// Repros from #1863
+
+const system = Symbol('system');
+const SomeSytePlugin = Symbol('SomeSytePlugin');
+
+interface Plugs {
+ [key: symbol]: (...args: any) => unknown;
+}
+
+const plugins = {
+ "user": {} as Plugs,
+ [system]: {} as Plugs
+};
+
+plugins[system][SomeSytePlugin] = () => console.log('awsome');
+plugins[system][SomeSytePlugin]();
+
+var theAnswer: symbol = Symbol('secret');
+var obj = {} as Record<symbol, number>;
+obj[theAnswer] = 42;
+
+// Repro from #26470
+
+const directive = Symbol('directive');
+declare function foo<TArg, TRet, TDir>(options: { [x in string]: (arg: TArg) => TRet } & { [directive]?: TDir }): void;
+
+let case1 = foo({
+ [directive]: (x: string) => 'str',
+ addOne: (x: number) => x + 1,
+ double: (x: number) => x + x,
+});
+
+let case2 = foo({
+ addOne: (x: number) => x + 1,
+ double: (x: number) => x + x,
+ [directive]: (x: string) => 'str',
+});
+
+let case3 = foo({
+ [directive]: 'str',
+ addOne: (x: number) => x + 1,
+ double: (x: number) => x + x,
+});
+
+// Repros from #42192
+
+type Pseudo = `&:${string}`;
+
+const AmIPseudo1: Pseudo = '&:test';
+const AmIPseudo: Pseudo = '&'; // Error
+
+type PseudoDeclaration = { [key in Pseudo]: string };
+
+const test: PseudoDeclaration = { 'someKey' : 'someValue' }; // Error
+
+type FieldPattern = `/${string}`;
+
+const path1: FieldPattern = '/one';
+const path2: FieldPattern = 'two'; // Error
+
+type PathsObject = { [P in FieldPattern]: object; };
+const pathObject: PathsObject = 123; // Error
+
+type IdType = `${number}-${number}-${number}-${number}`
+const id: IdType = '0000-0000-0000-0001';
+
+type A = Record<IdType, string>;
+
+const a: A = { [id]: 'test' }
+
+let aid = a[id];
+
+// Repro from #44793
+
+interface AA {
+ a?: string;
+ b?: number;
+ [key: symbol]: string;
+}
+
+const aa: AA = { [sym]: '123' };
+
+const obj1: { [key: symbol]: string } = { [sym]: 'hello '};
+const obj2: { [key: string]: string } = { [sym]: 'hello '}; // Permitted for backwards compatibility
+const obj3: { [key: number]: string } = { [sym]: 'hello '}; // Error
+
+// Repro from #45772
+
+type Id = string & { __tag: 'id '};
+type Rec1 = { [key: Id]: number };
+type Rec2 = Record<Id, number>;
+
+type K1 = keyof Rec1; // Id
+type K2 = keyof Rec2; // Id
@@ -24,4 +24,6 @@ var b: {
valueOf(): void;
}
-var r4: void = b.valueOf();
\ No newline at end of file
+var r4: void = b.valueOf();
+
+let c1 = new C();
\ No newline at end of file
@@ -26,3 +26,5 @@ var r8 = a.toString();
var r9 = a['toString']();
var r10 = a.foo;
var r11 = a['foo'];
+
+let c1 = new C();
\ No newline at end of file
@@ -40,4 +40,6 @@ var b = {
var r1 = b[1];
var r2 = b[1.1];
var r3 = b['1'];
-var r4 = b['1.1'];
\ No newline at end of file
+var r4 = b['1.1'];
+
+let c1 = new C();
\ No newline at end of file
@@ -50,3 +50,5 @@ var r2 = b[" "];
var r3 = b["a b"];
// BUG 817263
var r4 = b["~!@#$%^&*()_+{}|:'<>?\/.,`"];
+
+let c1 = new C();
\ No newline at end of file
@@ -38,4 +38,7 @@ a = i;
var r1: Derived1 = c.foo('hi');
var r2: Derived2 = c.foo('bye');
-var r3: Base = c.foo('hm');
\ No newline at end of file
+var r3: Base = c.foo('hm');
+
+// let dev1 = new Derived1();
+// let dev2 = new Derived2();
\ No newline at end of file
@@ -36,4 +36,7 @@ a = i;
var r1 = new C('hi');
var r2: Derived2 = new i('bye');
-var r3: Base = new a('hm');
\ No newline at end of file
+var r3: Base = new a('hm');
+
+let dev1 = new Derived1();
+let dev2 = new Derived2();
\ No newline at end of file
@@ -8,4 +8,7 @@ class C {
class C2<T> {
x?: T;
f?(x: T) {}
-}
\ No newline at end of file
+}
+
+let c = new C();
+let c2 = new C2();
\ No newline at end of file
@@ -56,3 +56,6 @@ class Derived extends Base {
a = 1;
f(): number { return 1; }
}
+
+let ba1 = new Bar();
+let dev = new Derived();
@@ -91,3 +91,5 @@ test(() => "hello");
test(() => fail());
test(() => { throw new Error(); })
test(errorCallback);
+
+let c1 = new C();
@@ -77,6 +77,7 @@ module M {
export var x = 1;
export class C { foo: string }
}
+let c2 = new M.C();
function foo11() {
return M;
}
@@ -119,4 +120,7 @@ module e1 { export var y = 1; }
function foo15() {
return e1;
}
-var r15 = foo15();
\ No newline at end of file
+var r15 = foo15();
+
+let c = new C();
+let c11 = new c1(1);
@@ -35,4 +35,6 @@ var b = {
foo(x, x) { },
a: function foo(x: number, x: string) { },
b: <T>(x: T, x: T) => { }
-}
\ No newline at end of file
+}
+
+let c1 = new C();
\ No newline at end of file
@@ -52,3 +52,5 @@ b.a(1);
b.a(1, 2);
b.b();
b.b(1);
+
+let c1 = new C();
@@ -56,4 +56,6 @@ a(1);
a(1, 2);
a.foo(1);
a.foo(1, 2);
-a.foo(1, 2, 3);
\ No newline at end of file
+a.foo(1, 2, 3);
+
+let c1 = new C();
@@ -26,4 +26,6 @@ var b = {
return x;
},
b: (x) => x
-}
\ No newline at end of file
+}
+
+let c1 = new C();
@@ -62,3 +62,6 @@ var a3: {
foo(x: 'a');
foo<T extends String>(x: T);
}
+let c1 = new C();
+let c2 = new C2();
+let c3 = new C3();
@@ -78,3 +78,6 @@ var a3: {
foo(x: 'a');
foo<T extends String>(x: T);
}
+let c1 = new C();
+let c2 = new C2();
+let c3 = new C3();
\ No newline at end of file
@@ -23,3 +23,5 @@ var b = {
a: function foo(x: 'hi', y: 'hi') { },
b: (x: 'hi') => { }
}
+
+let c1 = new C();
@@ -24,4 +24,6 @@ interface I<T, U> {
//interface I<T, U extends T> {
// x: C<U, T>;
-//}
+//}
+
+let c1 = new C();
@@ -29,4 +29,7 @@ var a: {
var b: {
new <T>(x: T, y: string): C2<T>;
new <T>(x: T, y: string): C; // error
-}
\ No newline at end of file
+}
+
+let c1 = new C(1);
+let c2 = new C2(1);
\ No newline at end of file
@@ -53,4 +53,6 @@ var r2b = b2['2'];
var r3 = b2['3'];
var r4 = b2[1];
var r5 = b2[2];
-var r6 = b2[3];
\ No newline at end of file
+var r6 = b2[3];
+
+let c1 = new C();
@@ -32,3 +32,5 @@ var b: { [x: string]: string } = { y: '' }
var r10 = b['y'];
var r11 = b['a'];
var r12 = b[1];
+
+let c1 = new C();
\ No newline at end of file
@@ -18,4 +18,6 @@ var b = {
var r1 = (new C()).foo;
var r2 = (<I>null).foo;
var r3 = a.foo;
-var r4 = b.foo;
\ No newline at end of file
+var r4 = b.foo;
+
+let c1 = new C();
\ No newline at end of file
@@ -273,4 +273,6 @@ enum E {
}
var r7 = E.abstract;
-var r8 = E.as;
\ No newline at end of file
+var r8 = E.as;
+
+let c1 = new C();
@@ -20,4 +20,6 @@ var r3 = a["a b"];
var b = {
"a b": 1
}
-var r4 = b["a b"];
\ No newline at end of file
+var r4 = b["a b"];
+
+let c1 = new C();
@@ -7,4 +7,4 @@ var x = 1;
var a: string = x.doStuff();
var b: string = x.doOtherStuff('hm');
var c: string = x['doStuff']();
-var d: string = x['doOtherStuff']('hm');
\ No newline at end of file
+var d: string = x['doOtherStuff']('hm');
@@ -28,4 +28,6 @@ x = f;
enum E { A }
x = E;
-x = E.A;
\ No newline at end of file
+x = E.A;
+
+let c1 = new C();
\ No newline at end of file
@@ -20,4 +20,6 @@ var h: { f(): void } = x;
function i<T>(a: T) {
a = x;
-}
\ No newline at end of file
+}
+
+let c1 = new C();
\ No newline at end of file
@@ -19,3 +19,4 @@ function foobar({ bar={}, ...opts }: any = {}) {
foobar();
foobar({ baz: 'hello' });
foobar({ bar: { greeting: 'hello' } });
+let t1 = new C();
\ No newline at end of file
@@ -23,4 +23,6 @@ var c2: { (x: number): number; <T>(x: T): any; };
var z2 = [a2, b2, c2];
var r6 = z2[0];
-var r7 = r6(''); // any not string
\ No newline at end of file
+var r7 = r6(''); // any not string
+
+let c11 = new C();
\ No newline at end of file
@@ -25,4 +25,7 @@ var f2: {
var f3: {
new<T>(x: string): D<T>;
new<T>(x: number): D<T>;
-} = D;
\ No newline at end of file
+} = D;
+
+let c = new C('');
+let d = new D('');
\ No newline at end of file
@@ -53,4 +53,7 @@ class D<T> {
var d: D<string>;
var r3: typeof D;
-var r4: typeof d;
\ No newline at end of file
+var r4: typeof d;
+
+let c1 = new C(1);
+let d1 = new D(1);
\ No newline at end of file
@@ -12,3 +12,4 @@ interface IScope {
delete: typeof Controller.prototype.delete; // Should not error
var: typeof Controller.prototype.var; // Should not error
}
+let c2 = new Controller();
@@ -18,4 +18,7 @@ class D extends C {
var d: D;
var r1: typeof D;
-var r2: typeof d;
\ No newline at end of file
+var r2: typeof d;
+
+let c = new C(1);
+let d1 = new D(1);
\ No newline at end of file
@@ -3,6 +3,7 @@ module M {
class C {
foo: number;
}
+ var c = new C();
}
-var r: typeof M;
\ No newline at end of file
+var r: typeof M;
new file mode 100644
@@ -0,0 +1,146 @@
+// @noImplicitThis: true
+// @strict: true
+
+class Test {
+ data = {};
+ constructor() {
+ var copy: typeof this.data = {};
+ }
+}
+
+class Test1 {
+ data = { foo: '' };
+ ['this'] = '';
+ constructor() {
+ var copy: typeof this.data = { foo: '' };
+ var foo: typeof this.data.foo = '';
+
+ var self: typeof this = this;
+ self.data;
+
+ var str: typeof this.this = '';
+ }
+}
+
+
+function Test2() {
+ let x: typeof this.no = 1;
+}
+
+function Test3(this: { no: number }) {
+ let x: typeof this.no = 1;
+}
+
+function Test4(this: { no: number } | undefined) {
+ let x: typeof this.no = 1;
+}
+
+class Test5 {
+ no = 1;
+
+ f = () => {
+ // should not capture this.
+ let x: typeof this.no = 1;
+ }
+}
+
+namespace Test6 {
+ export let f = () => {
+ let x: typeof this.no = 1;
+ }
+}
+
+module Test7 {
+ export let f = () => {
+ let x: typeof this.no = 1;
+ }
+}
+
+const Test8 = () => {
+ let x: typeof this.no = 1;
+}
+
+class Test9 {
+ no = 0;
+ this = 0;
+
+ f() {
+ if (this instanceof Test9D1) {
+ const d1: typeof this = this;
+ d1.f1();
+ }
+
+ if (this instanceof Test9D2) {
+ const d2: typeof this = this;
+ d2.f2();
+ }
+ }
+
+ g() {
+ if (this.no === 1) {
+ const no: typeof this.no = this.no;
+ }
+
+ if (this.this === 1) {
+ const no: typeof this.this = this.this;
+ }
+ }
+}
+
+class Test9D1 {
+ f1() {}
+}
+
+class Test9D2 {
+ f2() {}
+}
+
+class Test10 {
+ a?: { b?: string }
+
+ foo() {
+ let a: typeof this.a = undefined as any;
+ if (this.a) {
+ let a: typeof this.a = undefined as any; // should narrow to { b?: string }
+ let b: typeof this.a.b = undefined as any;
+
+ if (this.a.b) {
+ let b: typeof this.a.b = undefined as any; // should narrow to string
+ }
+ }
+ }
+}
+
+class Test11 {
+ this?: { x?: string };
+
+ foo() {
+ const o = this;
+ let bar: typeof o.this = {};
+
+ if (o.this && o.this.x) {
+ let y: string = o.this.x; // should narrow to string
+ }
+ }
+}
+
+class Tests12 {
+ test1() { // OK
+ type Test = typeof this;
+ }
+
+ test2() { // OK
+ for (;;) {}
+ type Test = typeof this;
+ }
+
+ test3() { // expected no compile errors
+ for (const dummy in []) {}
+ type Test = typeof this;
+ }
+
+ test4() { // expected no compile errors
+ for (const dummy of []) {}
+ type Test = typeof this;
+ }
+}
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,5 @@
+// @noImplicitThis: false
+
+function Test1() {
+ let x: typeof this.no = 1
+}
new file mode 100644
@@ -0,0 +1,21 @@
+// @strict: true
+// @declaration: true
+
+// Repro from #44438
+
+declare let a: { a: string };
+declare let b: { a?: string };
+declare let c: { a: string | undefined };
+declare let d: { a?: string | undefined };
+
+declare let t: boolean;
+
+let a1 = { a: 123, ...a }; // string (Error)
+let b1 = { a: 123, ...b }; // string | number
+let c1 = { a: 123, ...c }; // string | undefined (Error)
+let d1 = { a: 123, ...d }; // string | number
+
+let a2 = { a: 123, ...(t ? a : {}) }; // string | number
+let b2 = { a: 123, ...(t ? b : {}) }; // string | number
+let c2 = { a: 123, ...(t ? c : {}) }; // string | number
+let d2 = { a: 123, ...(t ? d : {}) }; // string | number
new file mode 100644
@@ -0,0 +1,22 @@
+// @strict: true
+// @exactOptionalPropertyTypes: true
+// @declaration: true
+
+// Repro from #44438
+
+declare let a: { a: string };
+declare let b: { a?: string };
+declare let c: { a: string | undefined };
+declare let d: { a?: string | undefined };
+
+declare let t: boolean;
+
+let a1 = { a: 123, ...a }; // string (Error)
+let b1 = { a: 123, ...b }; // string | number
+let c1 = { a: 123, ...c }; // string | undefined (Error)
+let d1 = { a: 123, ...d }; // string | number | undefined
+
+let a2 = { a: 123, ...(t ? a : {}) }; // string | number
+let b2 = { a: 123, ...(t ? b : {}) }; // string | number
+let c2 = { a: 123, ...(t ? c : {}) }; // string | number | undefined
+let d2 = { a: 123, ...(t ? d : {}) }; // string | number | undefined
new file mode 100644
@@ -0,0 +1,4 @@
+declare const a: { x: () => void }
+declare const b: { x?: () => void }
+
+const c = { ...a, ...b };
@@ -15,3 +15,5 @@ class C extends B {
}
var c: C;
var z = c.foo().bar().baz(); // Fluent pattern
+let b1 = new B();
+let c1 = new C();
@@ -19,3 +19,6 @@ class B<T extends A> {
x = x.self();
}
}
+
+let a = new A();
+let b = new B();
@@ -47,3 +47,9 @@ class C5 {
let x2 = undefined as this;
}
}
+
+let c1 = new C1();
+let c2 = new C2();
+let c3 = new C3();
+let c4 = new C4();
+let c5 = new C5();
@@ -7,3 +7,6 @@ class Test extends Base {
this.check(this);
}
}
+
+let te = new Test();
+
new file mode 100644
@@ -0,0 +1,10 @@
+// @target: esnext
+
+class Foo {
+ static m<T>(this: new () => T, strings: TemplateStringsArray | string) {
+ return new this()
+ }
+}
+
+Foo.m`test`;
+(Foo.m)`test`;
@@ -21,3 +21,5 @@ class A {
@someDec
k: readonly [string, number] = ['foo', 42];
}
+
+let a = new A();
\ No newline at end of file
@@ -15,3 +15,7 @@ type T4 = string | I4;
class I4 {
[x: string]: T4;
}
+
+let i0 = new I0();
+let i3 = new I3();
+let i4 = new I4();
\ No newline at end of file
@@ -9,4 +9,6 @@ var x: StringTree;
if (typeof x !== "string") {
x[0] = "";
x[0] = new StringTreeCollection;
-}
\ No newline at end of file
+}
+
+let s1 = new StringTreeCollection();
@@ -77,4 +77,6 @@ var x: [string, boolean];
f16(x);
var y: StringAndBoolean = ["1", false];
-y[0].toLowerCase();
\ No newline at end of file
+y[0].toLowerCase();
+
+let c7 = new C7();
\ No newline at end of file
@@ -33,4 +33,7 @@ interface I2<T> {
f(x: T): T;
}
var i2: I2<number>;
-var r7 = i2.f(1);
\ No newline at end of file
+var r7 = i2.f(1);
+
+let c1 = new C();
+let c2 = new C2();
\ No newline at end of file
@@ -58,4 +58,7 @@ function foo2<T extends { (): void }, U extends { (): void }>(x: T, y: U) {
//function foo2<T extends { (): void }, U extends T>(x: T, y: U) {
// foo(x);
// foo(y);
-//}
\ No newline at end of file
+//}
+
+let c11 = new C();
+let c12 = new C2();
\ No newline at end of file
@@ -38,4 +38,7 @@ var c2: { <T>(x: T): T; <T>(x: T, y: T): T };
var r9 = foo(function <U>(x: U) { return x; });
var r10 = foo(<U extends string>(x: U) => x);
var r12 = foo(i2);
-var r15 = foo(c2);
\ No newline at end of file
+var r15 = foo(c2);
+
+let c11 = new C();
+let c12 = new C2()
\ No newline at end of file
@@ -34,4 +34,6 @@ class C2<T extends Date, U extends Date> {
// var x: U;
// x.getDate();
// }
-//}
\ No newline at end of file
+//}
+let c1 = new C();
+let c2 = new C2();
\ No newline at end of file
@@ -31,4 +31,5 @@ var b = {
}
}
-var r4 = b.foo(new Date());
\ No newline at end of file
+var r4 = b.foo(new Date());
+let c = new C();
\ No newline at end of file
@@ -61,7 +61,7 @@ var a: {
var r3 = a<A, A>().foo();
var r3b = a()['foo']();
// parameter supplied for type argument inference to succeed
-var aB = new B();
+// var aB = new B();
var r3c = a(aB, aB).foo();
var r3d = a(aB, aB)['foo']();
@@ -78,4 +78,7 @@ var b = {
// }
//}
-var r4 = b.foo(aB, aB); // no inferences for T so constraint isn't satisfied, error
\ No newline at end of file
+var r4 = b.foo(aB, aB); // no inferences for T so constraint isn't satisfied, error
+
+let b1 = new B();
+let c1 = new C();
\ No newline at end of file
@@ -53,4 +53,6 @@ var b = {
}
}
-var r4 = b.foo(new B()); // valid call to an invalid function
\ No newline at end of file
+var r4 = b.foo(new B()); // valid call to an invalid function
+let b1 = new B();
+let c1 = new C();
\ No newline at end of file
@@ -28,4 +28,6 @@ var b = {
}
}
-var r4 = b.foo(1);
\ No newline at end of file
+var r4 = b.foo(1);
+
+let c = new C();
\ No newline at end of file
@@ -32,3 +32,10 @@ var a3: { <T extends Date, U extends T>(): void }
var a4: { <T extends U, U extends Date>(): void }
var a5: { <T extends U, U extends V, V>(): void }
var a6: { <T, U extends T, V extends U>(): void }
+
+let c1 = new C();
+let c2 = new C2();
+let c3 = new C3();
+let c4 = new C4();
+let c5 = new C5();
+let c6 = new C6();
\ No newline at end of file
@@ -85,4 +85,8 @@ var r3 = foo3(a); // any
declare function foo18(x: {}): {};
declare function foo18(x: any): any;
-var r3 = foo3(a); // any
\ No newline at end of file
+var r3 = foo3(a); // any
+
+let aa1 = new A();
+let aa2 = new A2();
+let ccc = new CC();
\ No newline at end of file
@@ -38,6 +38,7 @@ function foo<T, U /*extends T*/, V extends Date>(x: T, y: U, z: V) {
z = a;
}
+let cc = new C();
//function foo<T, U extends T, V extends Date>(x: T, y: U, z: V) {
// x = a;
// y = a;
@@ -127,3 +127,6 @@ interface I20 {
[x: string]: {};
foo: any;
}
+let aa = new A();
+let aa2 = new A2()
+let ccc = new c();
\ No newline at end of file
@@ -40,6 +40,8 @@ module SimpleTypes {
a2 = b;
a2 = t2;
a2 = t;
+ let ss = new S();
+ let tt = new T();
}
module ObjectTypes {
@@ -81,5 +83,6 @@ module ObjectTypes {
a2 = b;
a2 = t2;
a2 = t;
-
+ let ss = new S();
+ let tt = new T();
}
\ No newline at end of file
@@ -39,3 +39,5 @@ b2 = a2;
a2 = b;
a2 = t2;
a2 = t;
+let qu1 = new S();
+let qu2 = new T();
\ No newline at end of file
@@ -39,3 +39,5 @@ b2 = a2;
a2 = b;
a2 = t2;
a2 = t;
+let qi3 = new S();
+let qi4 = new T();
\ No newline at end of file
@@ -39,3 +39,5 @@ b2 = a2;
a2 = b;
a2 = t2;
a2 = t;
+let qi1 = new S();
+let qi2 = new T();
\ No newline at end of file
@@ -66,4 +66,8 @@ interface I extends A {
a16: <T extends Base>(x: T) => number[]; // ok
a17: <T>(x: (a: T) => T) => T[]; // ok
a18: <T>(x: (a: T) => T) => T[]; // ok, no inferences for T but assignable to any
-}
\ No newline at end of file
+}
+
+let qi14 = new Derived();
+let qi15 = new Derived2();
+let qi16 = new OtherDerived();
\ No newline at end of file
@@ -46,4 +46,8 @@ interface I extends A {
a16: <T>(x: { a: T; b: T }) => T[]; // ok, more general parameter type
a17: <T>(x: (a: T) => T) => T[]; // ok
a18: (x: <T>(a: T) => T) => any[]; // ok
-}
\ No newline at end of file
+}
+
+let qi14 = new Derived();
+let qi15 = new Derived2();
+let qi16 = new OtherDerived();
\ No newline at end of file
@@ -45,4 +45,7 @@ interface I extends B {
a12: <T extends Array<Base>>(x: Array<Base>, y: T) => Array<Derived>; // ok, less specific parameter type
a13: <T extends Array<Derived>>(x: Array<Base>, y: T) => T; // ok, T = Array<Derived>, satisfies constraint, contextual signature instantiation succeeds
a14: <T, U>(x: { a: T; b: U }) => T; // ok
-}
\ No newline at end of file
+}
+let qi14 = new Derived();
+let qi15 = new Derived2();
+let qi16 = new OtherDerived();
\ No newline at end of file
@@ -66,4 +66,8 @@ interface I extends A {
a16: new <T extends Base>(x: T) => number[]; // ok
a17: new <T>(x: new (a: T) => T) => T[]; // ok
a18: new <T>(x: new (a: T) => T) => T[]; // ok, no inferences for T but assignable to any
-}
\ No newline at end of file
+}
+
+let qi14 = new Derived();
+let qi15 = new Derived2();
+let qi16 = new OtherDerived();
\ No newline at end of file
@@ -56,4 +56,7 @@ interface I extends A {
a18: new <T extends Base>(x: T) => number[]; // ok, more general parameter type
a19: new <T extends Base>(x: new (a: T) => T) => T[]; // ok
a20: new (x: new <T extends Base>(a: T) => T) => any[]; // ok
-}
\ No newline at end of file
+}
+let qi14 = new Derived();
+let qi15 = new Derived2();
+let qi16 = new OtherDerived();
\ No newline at end of file
@@ -45,4 +45,7 @@ interface I extends B {
a12: new <T extends Array<Base>>(x: Array<Base>, y: T) => Array<Derived>; // ok, less specific parameter type
a13: new <T extends Array<Derived>>(x: Array<Base>, y: T) => T; // ok, T = Array<Derived>, satisfies constraint, contextual signature instantiation succeeds
a14: new <T, U>(x: { a: T; b: U }) => T; // ok
-}
\ No newline at end of file
+}
+let qi14 = new Derived();
+let qi15 = new Derived2();
+let qi16 = new OtherDerived();
\ No newline at end of file
@@ -53,6 +53,8 @@ function foo<T, U /*extends T*/, V extends Date>(x: T, y: U, z: V) {
a = y;
a = z;
}
+
+let ccc = new C();
//function foo<T, U extends T, V extends Date>(x: T, y: U, z: V) {
// a = x;
// a = y;
@@ -35,7 +35,7 @@ function foo<T, U, V extends Date>(x: T, y: U, z: V) {
y = null;
z = null;
}
-
+let cc = new C();
//function foo<T, U extends T, V extends Date>(x: T, y: U, z: V) {
// x = null;
// y = null;
@@ -35,6 +35,7 @@ function foo<T, U, V extends Date>(x: T, y: U, z: V) {
y = undefined;
z = undefined;
}
+let cc = new C();
//function foo<T, U extends T, V extends Date>(x: T, y: U, z: V) {
// x = undefined;
// y = undefined;
@@ -23,4 +23,7 @@ var r11 = true ? base : derived2;
function foo5<T, U>(t: T, u: U): Object {
return true ? t : u; // BCT is Object
-}
\ No newline at end of file
+}
+
+let qy10 = new Derived();
+let qy11 = new Derived2();
\ No newline at end of file
@@ -21,4 +21,6 @@ function foo2<T extends U, U>(t: T, u: U) { // Error for referencing own type pa
function foo3<T extends U, U extends V, V>(t: T, u: U) {
return true ? t : u;
-}
\ No newline at end of file
+}
+let qy8 = new Derived();
+let qy9 = new Derived2();
\ No newline at end of file
@@ -99,6 +99,8 @@ function foo4<T extends Base, U extends Base>(t: T, u: U) {
var k: Base[] = [t, u];
}
+let qy8 = new Derived();
+let qy9 = new Derived2();
//function foo3<T extends U, U extends Derived>(t: T, u: U) {
// var a = [t, t]; // T[]
@@ -34,3 +34,6 @@ function f3<T extends E>(v: T | { x: string }) {
const y: { x: string } = v;
}
}
+let qy5 = new C();
+let qy6 = new D();
+let qy7 = new E();
\ No newline at end of file
@@ -22,4 +22,8 @@ var ys = [list, list2]; // {}[]
var zs = [list, null]; // List<number>[]
var myDerivedList: DerivedList<number>;
-var as = [list, myDerivedList]; // List<number>[]
\ No newline at end of file
+var as = [list, myDerivedList]; // List<number>[]
+
+let li = new List();
+let der = new DerivedList();
+let my = new MyList();
\ No newline at end of file
@@ -10,4 +10,7 @@ class D<T> {
x: G<G<T>>;
}
-var c1 = new Foo<D<string>>(); // ok, circularity in assignment compat check causes success
\ No newline at end of file
+var c1 = new Foo<D<string>>(); // ok, circularity in assignment compat check causes success
+let g = new G();
+let foo = new Foo();
+let d = new D();
\ No newline at end of file
@@ -40,4 +40,7 @@ function other<T extends List<U>, U>() {
var r = foo5(list);
var r2 = foo5(myList);
-}
\ No newline at end of file
+}
+
+let li = new List();
+let my = new MyList();
\ No newline at end of file
@@ -88,3 +88,7 @@ var r19 = true ? null : new Object();
var r20 = true ? {} : null;
var r20 = true ? null : {};
+
+let c11 = new C1();
+let c12 = new C2();
+let c13 = new c();
@@ -97,4 +97,6 @@ function f15<T, U extends T>(x: any) { }
function f16<T extends String, U extends T>(x: 'a');
function f16<T extends String, U extends T>(x: U);
-function f16<T extends String, U extends T>(x: any) { }
\ No newline at end of file
+function f16<T extends String, U extends T>(x: any) { }
+
+let ccc = new C();
\ No newline at end of file
@@ -130,4 +130,7 @@ interface I19 {
interface I20 {
[x: string]: any;
foo: {};
-}
\ No newline at end of file
+}
+let a1 = new A();
+let a2 = new A2();
+let c1 = new c();
\ No newline at end of file
@@ -154,4 +154,7 @@ function f20<T extends Number>(x: T) {
function f21<T extends Number>(x: T) {
var r20 = true ? {} : x; // ok
var r20 = true ? x : {}; // ok
-}
\ No newline at end of file
+}
+
+let c1 = new C1();
+let c2 = new C2();
\ No newline at end of file
@@ -5,6 +5,7 @@ class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
class OtherDerived extends Base { bing: string; }
+
declare function foo1(a: (x: number) => number[]): typeof a;
declare function foo1(a: any): any;
@@ -169,3 +170,8 @@ var r17arg1 = <T>(x: (a: T) => T) => <T[]>null;
var r17 = foo17(r17arg1); // any
var r18arg1 = <T>(x: (a: T) => T) => <T[]>null;
var r18 = foo18(r18arg1);
+
+
+let der1 = new Derived();
+let der2 = new Derived2();
+let oth = new OtherDerived();
\ No newline at end of file
@@ -103,6 +103,10 @@ module Errors {
var r9arg = <T>(x: (a: T) => T) => <any[]>null;
var r9 = foo17(r9arg); // (x: { <T extends Derived >(a: T): T; <T extends Base >(a: T): T; }): any[]; (x: { <T extends Derived2>(a: T): T; <T extends Base>(a: T): T; }): any[];
+ let ba = new Base();
+ let der1 = new Derived();
+ let der2 = new Derived2();
+ let oth = new OtherDerived();
}
module WithGenericSignaturesInBaseType {
@@ -108,4 +108,8 @@ var r17arg = <T>(x: (a: T) => T) => <T[]>null;
var r17 = foo17(r17arg);
var r18arg = (x: <T>(a: T) => T) => <any[]>null;
-var r18 = foo18(r18arg);
\ No newline at end of file
+var r18 = foo18(r18arg);
+
+let der =new Derived();
+let der2 = new Derived2();
+let oth = new OtherDerived();
\ No newline at end of file
@@ -169,3 +169,8 @@ var r17arg1: new <T>(x: (a: T) => T) => T[];
var r17 = foo17(r17arg1); // any
var r18arg1: new <T>(x: (a: T) => T) => T[];
var r18 = foo18(r18arg1);
+
+
+let der =new Derived();
+let der2 = new Derived2();
+let oth = new OtherDerived();
\ No newline at end of file
@@ -105,6 +105,10 @@ module Errors {
var r9arg: new <T>(x: new (a: T) => T) => any[];
var r9 = foo17(r9arg); // // (x: { <T extends Derived >(a: T): T; <T extends Base >(a: T): T; }): any[]; (x: { <T extends Derived2>(a: T): T; <T extends Base>(a: T): T; }): any[];
+ let ba = new Base();
+ let der1 = new Derived();
+ let der2 = new Derived2();
+ let oth = new OtherDerived();
}
module WithGenericSignaturesInBaseType {
@@ -108,4 +108,8 @@ var r17arg: new <T>(x: new (a: T) => T) => T[];
var r17 = foo17(r17arg);
var r18arg: new (x: new <T>(a: T) => T) => any[];
-var r18 = foo18(r18arg);
\ No newline at end of file
+var r18 = foo18(r18arg);
+
+let der =new Derived();
+let der2 = new Derived2();
+let oth = new OtherDerived();
\ No newline at end of file
@@ -6,6 +6,7 @@ class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
class OtherDerived extends Base { bing: string; }
+
interface A { // T
// M's
a: new (x: number) => number[];
@@ -45,4 +46,7 @@ interface I extends B {
a12: new <T extends Array<Base>>(x: Array<Base>, y: T) => Array<Derived>; // ok, less specific parameter type
a13: new <T extends Array<Derived>>(x: Array<Base>, y: T) => T; // ok, T = Array<Derived>, satisfies constraint, contextual signature instantiation succeeds
a14: new <T, U>(x: { a: T; b: U }) => T; // ok
-}
\ No newline at end of file
+}
+let der =new Derived();
+let der2 = new Derived2();
+let oth = new OtherDerived();
@@ -30,4 +30,8 @@ class A3 {
class B3 extends A3 {
'1.1': Derived; // ok, inherits '1'
-}
\ No newline at end of file
+}
+let der = new Derived();
+let b1 = new B();
+let b2 = new B2();
+let b3 = new B3();
\ No newline at end of file
@@ -118,3 +118,28 @@ class D16 extends Base {
class D17 extends Base {
foo: {};
}
+
+
+let d0 = new D0();
+let da = new DA();
+let d1 = new D1()
+let d1a = new D1A()
+let d2 = new D2()
+let d2a = new D2A()
+let d3 = new D3()
+let d3a = new D1A()
+let d4 = new D4()
+let d5 = new D5()
+let d6 = new D6()
+let d7 = new D7()
+let d8 = new D8()
+let d9 = new D9()
+let d10 = new D10()
+let d11 = new D11()
+let d12 = new D12()
+let c1 = new c()
+let d13 = new D13()
+let d14 = new D14()
+let d15 = new D15()
+let d16 = new D16()
+let d17 = new D17()
@@ -85,4 +85,8 @@ function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // error
-function foo14(x: any) { }
\ No newline at end of file
+function foo14(x: any) { }
+
+let a1 = new A();
+let b1 = new B();
+let c1 = new C();
\ No newline at end of file
@@ -62,4 +62,7 @@ function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // ok
-function foo14(x: any) { }
\ No newline at end of file
+function foo14(x: any) { }
+let aa = new A();
+let bb = new B();
+let cc = new C();
\ No newline at end of file
@@ -97,4 +97,7 @@ function foo14(x: any) { }
function foo15(x: I2<string>);
function foo15(x: C<number>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+let qy17 = new A();
+let qy18 = new B();
+let qy19 = new C();
\ No newline at end of file
@@ -97,4 +97,7 @@ function foo14(x: any) { }
function foo15(x: I2<string>);
function foo15(x: C<number>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+let aa = new A();
+let bb = new B();
+let cc = new C();
\ No newline at end of file
@@ -97,4 +97,7 @@ function foo14(x: any) { }
function foo15(x: I2<string>);
function foo15(x: C<number>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+let aa = new A();
+let bb = new B();
+let cc = new C();
\ No newline at end of file
@@ -113,4 +113,8 @@ function foo14(x: any) { }
function foo15(x: I2<string>);
function foo15(x: C<number>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+
+let aa = new A();
+let bb = new B();
+let cc = new C();
\ No newline at end of file
@@ -84,4 +84,8 @@ function foo13(x: any) { }
function foo15(x: I2<string>);
function foo15(x: C<number>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+
+let a1 = new A('1');
+let b1 = new B('1');
+let c1 = new C(1);
\ No newline at end of file
@@ -73,4 +73,6 @@ function foo14(x: any) { }
function foo15(x: I2<string>);
function foo15(x: C<number>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+let qy38 = new B(null);
+let qy39 =new C(null);
\ No newline at end of file
@@ -73,4 +73,6 @@ function foo14(x: any) { }
function foo15(x: I2<string>);
function foo15(x: C<number>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+let qo23 =new B(null,null);
+let qo24 =new C(null,null);
\ No newline at end of file
@@ -97,4 +97,8 @@ function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<number>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+
+let a1 = new A();
+let b1 = new B();
+let c1 = new C();
\ No newline at end of file
@@ -97,4 +97,8 @@ function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<string, number>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+
+let a1 = new A();
+let b1 = new B();
+let c1 = new C();
@@ -99,4 +99,8 @@ function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<String>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+
+let a1 = new A();
+let b1 = new B();
+let c1 = new C();
@@ -111,4 +111,8 @@ function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<String, String>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+let a1 = new A();
+let b1 = new B();
+let c1 = new C();
+let d1 = new D();
\ No newline at end of file
@@ -120,4 +120,11 @@ function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<Three, Three>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+
+let one = new One();
+let two = new Two();
+let a1 = new A();
+let b1 = new B();
+let c1 = new C();
+let d1 = new D();
\ No newline at end of file
@@ -99,4 +99,7 @@ function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<number>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+let qy12 = new A();
+let qy13 = new B();
+let qy14 = new C();
@@ -99,4 +99,8 @@ function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<Date>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+
+let qo27 = new A();
+let qo28 =new B();
+let qo29 =new C();
\ No newline at end of file
@@ -97,4 +97,8 @@ function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<number, B<string, string>, B<number, string>>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+
+let a1 = new A();
+let b1 = new B();
+let c1 = new C();
@@ -97,4 +97,7 @@ function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<number>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+let qo17 = new A();
+let qo18 =new B();
+let qo19 =new C();
\ No newline at end of file
@@ -99,4 +99,7 @@ function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<number>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+let qo9 = new A();
+let qo10 = new B();
+let qo11 = new C();
\ No newline at end of file
@@ -99,4 +99,7 @@ function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<string, number>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+let a1 = new A();
+let b1 = new B();
+let c1 = new C();
\ No newline at end of file
@@ -99,4 +99,8 @@ function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<string, number>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+
+let a1 = new A();
+let b1 = new B();
+let c1 = new C();
\ No newline at end of file
@@ -72,3 +72,5 @@ function foo13(x: any) { }
function foo14(x: I<Number>);
function foo14(x: typeof b); // ok
function foo14(x: any) { }
+let qo15 = new B(null);
+let qo16 = new C(null);
\ No newline at end of file
@@ -83,4 +83,9 @@ function foo13(x: any) { }
function foo14(x: I<Number, Number>);
function foo14(x: typeof b); // ok
-function foo14(x: any) { }
\ No newline at end of file
+function foo14(x: any) { }
+
+var aa = []
+let b1 = new B(aa,aa);
+let c1 = new C('','');
+let d1 = new D(1,1);
\ No newline at end of file
@@ -92,4 +92,9 @@ function foo13(x: any) { }
function foo14(x: I<Five<string>, Five<string>>);
function foo14(x: typeof b); // ok
-function foo14(x: any) { }
\ No newline at end of file
+function foo14(x: any) { }
+let qo1 = new One();
+let qo2 = new Two();
+let qo3 = new B(null,null);
+let qo4 = new C(null,null);
+let qo5 = new D(null,null);
\ No newline at end of file
@@ -79,4 +79,6 @@ function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<number>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+let qy49 =new B(null);
+let qy50 =new C(null);
\ No newline at end of file
@@ -75,4 +75,8 @@ function foo14(x: any) { }
function foo15(x: I2);
function foo15(x: C<Date>); // ok
-function foo15(x: any) { }
\ No newline at end of file
+function foo15(x: any) { }
+
+var aa;
+let b1 = new B(aa);
+let c1 = new C(aa);
\ No newline at end of file
@@ -69,4 +69,6 @@ function foo13(x: any) { }
function foo14(x: I<string, Date, RegExp, boolean>);
function foo14(x: typeof b); // ok
-function foo14(x: any) { }
\ No newline at end of file
+function foo14(x: any) { }
+let qo6 = new B(null);
+let qo7 = new C(null);
\ No newline at end of file
@@ -69,4 +69,8 @@ function foo13(x: any) { }
function foo14(x: I<string>);
function foo14(x: typeof b); // ok
-function foo14(x: any) { }
\ No newline at end of file
+function foo14(x: any) { }
+
+
+let b1 = new B(a);
+let c1 = new C(a);
@@ -71,4 +71,7 @@ function foo13(x: any) { }
function foo14(x: I<string>);
function foo14(x: typeof b); // ok
-function foo14(x: any) { }
\ No newline at end of file
+function foo14(x: any) { }
+
+let b1 = new B(a);
+let c1 = new C(a);
@@ -71,4 +71,7 @@ function foo13(x: any) { }
function foo14(x: I<string, number>);
function foo14(x: typeof b); // ok
-function foo14(x: any) { }
\ No newline at end of file
+function foo14(x: any) { }
+
+let b1 = new B(a);
+let c1 = new C(a);
@@ -71,4 +71,6 @@ function foo13(x: any) { }
function foo14(x: I<string, number>);
function foo14(x: typeof b); // ok
-function foo14(x: any) { }
\ No newline at end of file
+function foo14(x: any) { }
+let qy15 = new B(null,null);
+let qy16 = new C(null,null);
\ No newline at end of file
@@ -119,3 +119,6 @@ function foo16(x: I);
function foo16(x: PB); // error
function foo16(x: any) { }
+let c1 = new C();
+let pa = new PA();
+let pb = new PB();
\ No newline at end of file
@@ -122,3 +122,8 @@ function foo16(x: I);
function foo16(x: PB); // error
function foo16(x: any) { }
+
+let der = new Derived()
+let c1 = new C();
+let pa = new PA();
+let pb = new PB();
\ No newline at end of file
@@ -119,3 +119,6 @@ function foo16(x: I);
function foo16(x: PB); // error
function foo16(x: any) { }
+let qo32 =new C();
+let qo30 = new PA();
+let qo31 =new PB();
@@ -53,4 +53,8 @@ function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // ok
-function foo14(x: any) { }
\ No newline at end of file
+function foo14(x: any) { }
+
+let a1 = new A();
+let b1 = new B();
+let c1 = new C();
@@ -116,4 +116,6 @@ function foo15(x: any) { }
function foo16(x: I);
function foo16(x: PB); // no error
function foo16(x: any) { }
-
+let qo26 =new C();
+let qo24 = new PA();
+let qo25 =new PB();
@@ -35,3 +35,4 @@ function foo6(x: D<number>): string; // error
function foo6(x: any): any { }
+let d1 = new D();
@@ -85,4 +85,7 @@ function foo13(x: any) { }
function foo14(x: I);
function foo14(x: typeof b); // error
-function foo14(x: any) { }
\ No newline at end of file
+function foo14(x: any) { }
+let qy41 = new A();
+let qy42 =new B();
+let qy43 =new C();
\ No newline at end of file
@@ -119,3 +119,6 @@ function foo16(x: I);
function foo16(x: PB); // error
function foo16(x: any) { }
+let qo35 =new C();
+let qo33 = new PA();
+let qo34 =new PB();
@@ -122,3 +122,8 @@ function foo16(x: I);
function foo16(x: PB); // error
function foo16(x: any) { }
+
+let der = new Derived();
+let c1 = new C();
+let pa = new PA();
+let pb = new PB();
@@ -73,4 +73,6 @@ interface I2<T extends Date> {
foo3<T>(x: T);
foo3<T>(x: T); // no error, different declaration for each T
-}
\ No newline at end of file
+}
+let qy36 = new C();
+let qy37 =new C2();
\ No newline at end of file
@@ -104,3 +104,6 @@ var r8b = i.foo5(d2, d2); // Derived2
var r9 = i.foo6(); // Derived
var r10 = i.foo7(d1); // Base
var r11 = i.foo8(); // Base
+
+let qu12 = new Derived();
+let qu13 = new Derived2();
\ No newline at end of file
@@ -19,4 +19,6 @@ var b: {
new<T>(x: T): any;
}
-var r2 = foo4(b); // T is {} (candidates boolean and {}), U is any (candidates any and {})
\ No newline at end of file
+var r2 = foo4(b); // T is {} (candidates boolean and {}), U is any (candidates any and {})
+let qy3 = new C();
+let qy4 =new D();
\ No newline at end of file
@@ -29,4 +29,6 @@ interface I<T, U> {
}
var i: I<Base, Derived>;
-var r4 = f2(i); // Base => Derived
\ No newline at end of file
+var r4 = f2(i); // Base => Derived
+let qy0 = new Derived();
+let qy1 = new Derived2();
\ No newline at end of file
@@ -19,8 +19,8 @@ function foo<T extends { x: string }>(t: X<T>, t2: X<T>) {
return x;
}
-var c1 = new X<C>();
-var d1 = new X<D>();
+// var c1 = new X<C>();
+// var d1 = new X<D>();
var r = foo(c1, d1);
var r2 = foo(c1, c1);
@@ -30,4 +30,8 @@ function foo2<T extends C>(t: X<T>, t2: X<T>) {
}
var r = foo2(c1, d1);
-var r2 = foo2(c1, c1);
\ No newline at end of file
+var r2 = foo2(c1, c1);
+
+let qu4 = new C();
+let qu5 = new D();
+let qu6 = new X();
\ No newline at end of file
@@ -35,3 +35,4 @@ var r5 = f3(new Derived(), x => x);
var r6 = f3(null, null); // any
var r7 = f3(null, x => x); // any
+let qu8 = new Derived();
\ No newline at end of file
@@ -37,6 +37,8 @@ module Class {
var g2: G2<D>;
var r = g2.foo2(c1, d1);
var r2 = g2.foo2(c1, c1);
+ var gg1 = new G();
+ var gg2 = new G2();
}
module Interface {
@@ -57,4 +59,7 @@ module Interface {
var g2: G2<D>;
var r = g2.foo2(c1, d1);
var r2 = g2.foo2(c1, c1);
-}
\ No newline at end of file
+}
+let c = new C();
+let d = new D();
+let x = new X();
\ No newline at end of file
@@ -44,3 +44,7 @@ function insertOnConflictDoNothing<Req extends object, Def extends object>(_tabl
function f() {
insertOnConflictDoNothing(bookTable, ConflictTarget.tableColumns(["serial"])); // <-- No error here; should use the type inferred for the return type of `tableColumns`
}
+let qu9 = new Write();
+let qu10 = new Col();
+let qu11 =new Table();
+let qu12 =new ConflictTarget();
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,19 @@
+// @strict: true
+
+// Repro from #44435
+
+type Correct = {
+ code: string
+ property: true
+ err: undefined
+}
+type Err = {
+ err: `${string} is wrong!`
+}
+type SomeReturnType = Correct | Err;
+
+const example: SomeReturnType = {} as SomeReturnType;
+
+if (example.err === undefined) {
+ example.property; // true
+}
\ No newline at end of file
--
2.17.1