-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Convert 'installTypesForPackge' refactor to a suggestion #22267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/compiler/program.ts
Outdated
} | ||
} | ||
|
||
export function willAllowImplicitAnyJsModule(options: CompilerOptions): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* @internal */
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider moving this to untilities next to getAllowSyntheticDefaultImports
and getStricitOptionValue
src/compiler/program.ts
Outdated
return options.allowJs || !getStrictOptionValue(options, "noImplicitAny"); | ||
} | ||
|
||
export function createDiagnosticForModuleMissingTypes(errorNode: Node, { packageId, resolvedFileName }: ResolvedModuleFull, moduleReference: string, diag: DiagnosticMessage): Diagnostic { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here too /* @internal */
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider moving them to utilities
src/compiler/diagnosticMessages.json
Outdated
@@ -3818,6 +3818,10 @@ | |||
"category": "Suggestion", | |||
"code": 80001 | |||
}, | |||
"Did not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type.": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably should take your suggestion of converting an error diagnostic to a suggestion diagnostic.
src/compiler/program.ts
Outdated
@@ -2416,10 +2416,26 @@ namespace ts { | |||
return options.jsx ? undefined : Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set; | |||
} | |||
function needAllowJs() { | |||
return options.allowJs || !getStrictOptionValue(options, "noImplicitAny") ? undefined : Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type; | |||
return willAllowImplicitAnyJsModule(options) ? undefined : Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do not we instead log the diagnostic in a different list, a suggestions list. the command line compiler will never report them, but we can query them in the services and add additional messages there as well..
…ing work in calculateSuggestionDiagnostics
In #19130, had to add duplicate code fix and refactor -- now it's just a code fix and we give a suggestion instead of error diagnostic if
--noImplicitAny
isn't enabled.Note that I had to make a separate diagnostic for the suggestion; this is because each diagnostic is hard-coded with its category. It seems like we could base that on where the diagnostic is coming from instead? Something coming from the parser/checker is an error, something coming from
computeSuggestionDiagnostics
is a suggestion. This will be a bigger problem when I add suggestion diagnostics for unused variables, since we have a lot of different diagnostics for those.