Skip to content

Commit

Permalink
Categorized ts that sill have 9007 errors even after having been modi…
Browse files Browse the repository at this point in the history
…fied with the codemod
  • Loading branch information
dragomirtitian committed Sep 8, 2023
1 parent 0fd182e commit cf61980
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 7 deletions.
163 changes: 163 additions & 0 deletions external-declarations/fixed-tests.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"with-isolated-declaration-errors": [
9007, // Declaration_emit_for_this_file_requires_type_resolution_An_explicit_type_annotation_may_unblock_declaration_emit
9008, // Declaration_emit_for_this_file_requires_adding_a_type_reference_directive_Add_a_type_reference_directive_to_0_to_unblock_declaration_emit
9009, // Assigning_properties_to_functions_without_declaring_them_is_not_supported_with_isolatedDeclarations_Add_an_explicit_declaration_for_the_properties_assigned_to_this_function
],
"with-unreliable-errors": [
2314, // Generic type '{0}' requires {1} type argument(s)
Expand All @@ -12,6 +13,164 @@
]
},
"test-categories": {
"enum-issues": [
"collisionCodeGenEnumWithEnumMemberConflict",
"constEnumDeclarations",
"constEnumErrors",
"constEnums",
"constantEnumAssert",
"declFileEnums",
"ambientEnum1",
"enumAssignmentCompat5",
"enumBasics2",
"enumBasics3",
"enumLiteralAssignableToEnumInsideUnion",
"enumNumbering1",
"enumPropertyAccessBeforeInitalisation",
"enumWithComputedMember",
"enumWithExport",
"enumWithParenthesizedInitializer1",
"enumWithoutInitializerAfterComputedMember",
"exactSpellingSuggestion",
"forwardRefInEnum",
"initializersInAmbientEnums",
"isolatedModulesGlobalNamespacesAndEnums",
"mergedDeclarations2",
"mergedEnumDeclarationCodeGen",
"preserveConstEnums",
"underscoreEscapedNameInEnum",
"ambientEnumDeclaration1",
"constEnum1",
"constEnum2",
"constEnumPropertyAccess1",
"constEnumPropertyAccess2",
"constEnumPropertyAccess3",
"enumBasics",
"enumClassification",
"enumConstantMemberWithString",
"enumConstantMemberWithStringEmitDeclaration",
"enumConstantMemberWithTemplateLiterals",
"enumConstantMemberWithTemplateLiteralsEmitDeclaration",
"enumConstantMembers",
"enumErrors",
"enumExportMergingES6",
"enumMerging",
"enumMergingErrors",
"parserRealSource10",
"parserRealSource14",
"parserRealSource2",
"parserRealSource3",
"parserEnum1",
"parserEnum2",
"parserEnumDeclaration6",
"templateLiteralTypes4",
"numericEnumMappedType",
"equalityWithEnumTypes",
"computedEnumTypeWidening",
"strictModeOctalLiterals",
"verbatimModuleSyntaxConstEnumUsage",
"ambientConstLiterals",
],
"computed-enum-values-non-const": [
// Some enum member values will need to be inlined when we can't compute them
"methodContainingLocalFunction",
"mixedTypeEnumComparison"
],
"expando-not-detected": [
"declarationEmitExpandoWithGenericConstraint",
"expandoFunctionExpressionsWithDynamicNames",
"propertyAssignmentUseParentType1",
],
"code-fixer-issues" : [
// Only one fix is applied per line, fix need to be applied to both another issue (params, default exports) and return type
"ambiguousGenericAssertion1",
"arrowFunctionWithObjectLiteralBody1",
"arrowFunctionWithObjectLiteralBody2",
"arrowFunctionWithObjectLiteralBody3",
"arrowFunctionWithObjectLiteralBody4",
"commentsAfterFunctionExpression1",
"fatarrowfunctions",
"genericTypeAssertions3",
"taggedTemplateStringsWithCurriedFunction",
"unusedParametersWithUnderscore",
"arrowFunctionWithParameterNameAsync_es2017",
"arrowFunctionWithParameterNameAsync_es5",
"arrowFunctionWithParameterNameAsync_es6",
"importCallExpressionInExportEqualsAMD",
"importCallExpressionInExportEqualsCJS",
"importCallExpressionInExportEqualsUMD",
"declarationEmitMixinPrivateProtected",
"disallowLineTerminatorBeforeArrow",
"emitArrowFunctionAsIs",
"emitArrowFunctionAsIsES6",
"emitArrowFunctionsAsIs",
"emitArrowFunctionsAsIsES6",
"declarationEmitObjectAssignedDefaultExport",
"templateStringInArrowFunction",
"templateStringInArrowFunctionES6",
"exportAssignDottedName",
"exportAssignNonIdentifier",
// return type missing
"arrayFakeFlatNoCrashInferenceDeclarations",
"mixingApparentTypeOverrides",
"noCrashOnMixin",
"overrideBaseIntersectionMethod",
"unusedFunctionsinNamespaces6",
"mixinAbstractClasses",
"mixinAbstractClassesReturnTypeInference",
"mixinAccessModifiers",
"override1",
"override19",
"declarationFiles",
// Crash on export = in language service. Test not fixed
"commonJsImportClassExpression",
"constEnumNamespaceReferenceCausesNoImport2",
"declarationEmitInferredDefaultExportType2",
"exportAssignmentWithoutIdentifier1",
"exportEqualsProperty",
"exportEqualsProperty2",
"namedEvaluation",
"thisInInvalidContextsExternalModule",
"reexportClassDefinition",
"esDecorators-classExpression-namedEvaluation.9",
// Members return types are not fixed
"declarationEmitClassMemberWithComputedPropertyName",
"declarationEmitLocalClassDeclarationMixin",
"thisInPropertyBoundDeclarations",
"thisIndexOnExistingReadonlyFieldIsNotNever",
// Constant is not fixed
"declarationEmitCommonJsModuleReferencedType",
// Mixin not fixed. Not sure we can fix them
"mixinPrivateAndProtected",
"doubleMixinConditionalTypeBaseClassWorks",
"emitClassExpressionInDeclarationFile2",
// any, non initialized variable is not fixed
"moduleAugmentationDisallowedExtensions",
"moduleAugmentationNoNewNames",
// ?
"parserEqualsGreaterThanAfterFunction1",
"declarationEmitPrivatePromiseLikeInterface",
// Parser errors
"parserSkippedTokens16",
// Symbol const not annotated
"declarationEmitPrivateNameCausesError"
],
"not-fixed-with-unreliable-errors": [
"classMemberWithMissingIdentifier",
"classMemberWithMissingIdentifier2",
"commonMissingSemicolons",
"reservedWords3",
"negateOperator",
"negateOperatorInvalidOperations",
"destructuringObjectBindingPatternAndAssignment3",
"objectBindingPatternKeywordIdentifiers01",
"objectBindingPatternKeywordIdentifiers02",
"objectBindingPatternKeywordIdentifiers03",
"objectBindingPatternKeywordIdentifiers04",
"arrowFunctionExpressions",
"declarationEmitDestructuringParameterProperties",
"destructuringParameterProperties4",
],
"with-unreliable-errors": [
"thisTypeErrors", // Assertion to this in static context produces this in DTE and any in TSC
"parseInvalidNonNullableTypes", // Prefix ! operator
Expand Down Expand Up @@ -73,6 +232,9 @@
"decoratorMetadataWithImportDeclarationNameCollision7", // Import does not have the accessed member. TS removes the import as unused. A DTE will keep it as it is syntactically used.
"classExtendingNonConstructor", // Not reported as isolated declaration error, but the extends clause is invalid.
"nodeModulesImportTypeModeDeclarationEmitErrors1", // Invalid import asserts
"this_inside-enum-should-not-be-allowed", // strange things in enum initializers
"ambientErrors", // Has errors from ambient declarations on enums
"arrowFunctionContexts", // Function assigned to enum member
],
"with-isolated-declaration-errors/9008": [
"declarationEmitHasTypesRefOnNamespaceUse",
Expand Down Expand Up @@ -227,6 +389,7 @@
"templateLiteralsSourceMap", // template literal is evaluated in constant value.
"nodeModulesImportTypeModeDeclarationEmit1", // resolution-mode in assert from type assertion is preserved
"declarationEmitPrefersPathKindBasedOnBundling2", // Import path has .. in it. A similar type written by hand would not.
"computedPropertiesNarrowed",
],
"bug-binding-pattern-inference": [
"destructuringWithLiteralInitializers",
Expand Down
2 changes: 1 addition & 1 deletion external-declarations/src/code-mod/code-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function findNearestParentWithTypeAnnotation(node: ts.Node): ts.Node | undefined
export function addTypeAnnotationTransformer(sourceFile: ts.SourceFile, program: ts.Program, moduleResolutionHost?: ts.ModuleResolutionHost) {
const typeChecker = program.getTypeChecker();
const nodesToFix = new Map(program.getDeclarationDiagnostics(sourceFile).
filter((diag) => diag.code === 9007).
filter((diag) => diag.code === 9007 || diag.code === 9009).
map((diag) => {
const nodeWithDiag = (ts as any).getTokenAtPosition(sourceFile, diag.start)! as ts.Node;
return [findNearestParentWithTypeAnnotation(nodeWithDiag), nodeWithDiag];
Expand Down
3 changes: 2 additions & 1 deletion external-declarations/src/code-mod/test-updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ async function main() {
}
})();
if(result instanceof Error) {
fs.writeFile(updatedTestFileName, `
await ensureDir(fsPath.dirname(updatedTestFileName));
await fs.writeFile(updatedTestFileName, `
================= CODE MOD ERROR ==============
${result.message}
${result.stack}
Expand Down
15 changes: 10 additions & 5 deletions external-declarations/src/test-runner/test-runner-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,16 @@ async function main() {
);
} else {

const error = firstDefined(results.diagnostics, d => {
const category = errorCategories.get(d.code);
return category ? { category, code: d.code }: undefined;
});
const category = error? path.join(error.category, error.code.toString()) : testCategories.get(testName);
let category = testCategories.get(testName);
if(!category) {
const error = firstDefined(results.diagnostics, d => {
const category = errorCategories.get(d.code);
return category ? { category, code: d.code }: undefined;
});
if(error) {
category = path.join(error.category, error.code.toString());
}
}
if(category) {
file = path.join(
path.dirname(file),
Expand Down

0 comments on commit cf61980

Please sign in to comment.