Skip to content

Commit 12869dd

Browse files
committed
Add a fixer to fix type errors for --isolatedDeclarations
This code fixer fixes the following patterns. 1. Adding missing types on places that type can be explicitly annotated 2. Adding satisfies with type assertion on a value. 3. Create a namespace for expando functions and declare the property on the namespace. 4. Factor out expressions in heritage clauses (class B extends <expression>) and give them separate names. Signed-off-by: Hana Joo <hanajoo@google.com>
1 parent ee7a872 commit 12869dd

File tree

52 files changed

+2564
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2564
-0
lines changed

src/compiler/diagnosticMessages.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7184,6 +7184,46 @@
71847184
"category": "Message",
71857185
"code": 90061
71867186
},
7187+
"Add annotation of type '{0}'": {
7188+
"category": "Message",
7189+
"code": 90062
7190+
},
7191+
"Add return type '{0}'": {
7192+
"category": "Message",
7193+
"code": 90063
7194+
},
7195+
"Extract base class to variable": {
7196+
"category": "Message",
7197+
"code": 90064
7198+
},
7199+
"Extract default export to variable": {
7200+
"category": "Message",
7201+
"code": 90065
7202+
},
7203+
"Extract binding expressions to variable": {
7204+
"category": "Message",
7205+
"code": 90066
7206+
},
7207+
"Add all missing type annotations": {
7208+
"category": "Message",
7209+
"code": 90067
7210+
},
7211+
"Add satisfies and an inline type assertion with '{0}'": {
7212+
"category": "Message",
7213+
"code": 90068
7214+
},
7215+
"Extract to variable and replace with '{0} typeof {0}'": {
7216+
"category": "Message",
7217+
"code": 90069
7218+
},
7219+
"Mark array literal as const": {
7220+
"category": "Message",
7221+
"code": 90070
7222+
},
7223+
"Annotate types of properties expando function in a namespace": {
7224+
"category": "Message",
7225+
"code": 90071
7226+
},
71877227

71887228
"Convert function to an ES2015 class": {
71897229
"category": "Message",

src/services/_namespaces/ts.codefix.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export * from "../codefixes/fixUnreachableCode";
5050
export * from "../codefixes/fixUnusedLabel";
5151
export * from "../codefixes/fixJSDocTypes";
5252
export * from "../codefixes/fixMissingCallParentheses";
53+
export * from "../codefixes/fixMissingTypeAnnotationOnExports";
5354
export * from "../codefixes/fixAwaitInSyncFunction";
5455
export * from "../codefixes/fixPropertyOverrideAccessor";
5556
export * from "../codefixes/inferFromUsage";

src/services/codeFixProvider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ function getDiagnostics({ program, sourceFile, cancellationToken }: CodeFixConte
127127
return [
128128
...program.getSemanticDiagnostics(sourceFile, cancellationToken),
129129
...program.getSyntacticDiagnostics(sourceFile, cancellationToken),
130+
...program.getDeclarationDiagnostics(sourceFile, cancellationToken),
130131
...computeSuggestionDiagnostics(sourceFile, program, cancellationToken),
131132
];
132133
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy