Skip to content

Switches the bundlePackageName error message to be a suggestion, and not a compiler error #41510

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1192,8 +1192,8 @@
"category": "Message",
"code": 1390
},
"The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit.": {
"category": "Error",
"The `bundledPackageName` option should be provided when using outFile and node module resolution with declaration emit.": {
"category": "Suggestion",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is currently not desirable i think... because we do not distinguish between suggestion or error and build will fail with corresponding exit code instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's fair, we do kinda have a separate suggestionDiagnostics list in the checker.
I don't think we have one in program yet, but we'd need to add one and concatenate it with the checker's suggestions. (Inside getSuggestionDiagnostics in program.ts)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but that means it would reported only in editor ... and not in build i am not sure thats desirable either... program construction messages should be consistent in my opinion..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, suggestions are only actionable in the editor at present, no? We don't have a --showSuggestions compiler flag or anything to print them on the command line at present?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently suggestions are errors under noUnusedLocals like flags as far as i know so there is way to get those.

Copy link
Member

@weswigham weswigham Nov 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diagnostics.await_has_no_effect_on_the_type_of_this_expression is unconditionally a suggestion (see its usage in checkAwaitExpression), as is Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers in checkNumericLiteralValueSize, so we do already have suggestions you can never see on the command line by conversion into an error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(And these still have value because we use them to trigger quickfixes!)

"code": 1391
},
"The types of '{0}' are incompatible between these types.": {
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3221,9 +3221,9 @@ namespace ts {
}
}

// Without a package name, for multiple files being bundled into a .d.ts file you basically get a file which doesn't wrk
// Without a package name, for multiple files being bundled into a .d.ts file you basically get a file which doesn't work
if (outputFile && getEmitDeclarations(options) && getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeJs && !options.bundledPackageName) {
createDiagnosticForOptionName(Diagnostics.The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit, options.out ? "out" : "outFile");
createDiagnosticForOptionName(Diagnostics.The_bundledPackageName_option_should_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit, options.out ? "out" : "outFile");
}

if (options.resolveJsonModule) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error TS1391: The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit.
suggestion TS1391: The `bundledPackageName` option should be provided when using outFile and node module resolution with declaration emit.


!!! error TS1391: The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit.
!!! suggestion TS1391: The `bundledPackageName` option should be provided when using outFile and node module resolution with declaration emit.
==== tests/cases/compiler/index.ts (0 errors) ====
export * from "./nested";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error TS1391: The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit.
suggestion TS1391: The `bundledPackageName` option should be provided when using outFile and node module resolution with declaration emit.


!!! error TS1391: The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit.
!!! suggestion TS1391: The `bundledPackageName` option should be provided when using outFile and node module resolution with declaration emit.
==== tests/cases/conformance/declarationEmit/index.ts (0 errors) ====
export * from "./nested";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error TS1391: The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit.
suggestion TS1391: The `bundledPackageName` option should be provided when using outFile and node module resolution with declaration emit.
/main.ts(1,14): error TS6131: Cannot compile modules using option 'out' unless the '--module' flag is 'amd' or 'system'.


!!! error TS1391: The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit.
!!! suggestion TS1391: The `bundledPackageName` option should be provided when using outFile and node module resolution with declaration emit.
==== /mod2.ts (0 errors) ====
import { Cls } from "./main";
import "./mod1";
Expand Down