🌐 AI搜索 & 代理 主页
Skip to content
Open
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
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/no-unsafe-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default createRule<[], MessageIds>({
node: reportingNode,
messageId,
data: {
type: isErrorType ? '`error` type' : '`any`',
type: isErrorType ? 'unresolved due to error' : '`any`',
Copy link
Member

Choose a reason for hiding this comment

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

Not the most natural phrasing

🤔 yeah, I'm not sure that this specific change is better for users. Looking at the deploy preview playground, the report message is:

Unsafe call of a(n) unresolved due to error typed value.

It took me a few tries to parse out the English grammar in that sentence, and I had to rely on already knowing the rule & this PR.

I'm drawing a blank here (and am a little swamped), but let's bikeshed. What's a more clear phrase we could go with?

Copy link
Author

Choose a reason for hiding this comment

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

Using an entirely new message would be best. Something along the lines of "Unsafe call of a type that could not be resolved." That's what I originally started doing in this PR, but then I had to touch more files than I wanted to, so I changed to the kludgy phrasing.

Copy link
Member

Choose a reason for hiding this comment

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

FWIW I like that phrasing more. I can't think of a way to more concisely tell the user "this type could not be resolved" than just saying so.

},
});
return;
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/no-unsafe-member-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const enum State {
Chained = 3,
}

function createDataType(type: ts.Type): '`any`' | '`error` typed' {
function createDataType(type: ts.Type): '`any`' | 'unresolved due to error' {
const isErrorType = tsutils.isIntrinsicErrorType(type);
return isErrorType ? '`error` typed' : '`any`';
return isErrorType ? 'unresolved due to error' : '`any`';
}

export type Options = [
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/tests/rules/no-unsafe-call.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ value();
{
column: 1,
data: {
type: '`error` type',
type: 'unresolved due to error',
},
endColumn: 6,
line: 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ value.property;
column: 7,
data: {
property: '.property',
type: '`error` typed',
type: 'unresolved due to error',
},
endColumn: 15,
line: 4,
Expand Down Expand Up @@ -340,7 +340,7 @@ function foo(x: { a: number }, y: NotKnown) {
column: 5,
data: {
property: '[y]',
type: '`error` typed',
type: 'unresolved due to error',
},
endColumn: 6,
line: 3,
Expand Down Expand Up @@ -515,7 +515,7 @@ function foo(x: { a: number }, y: NotKnown) {
column: 5,
data: {
property: '[y]',
type: '`error` typed',
type: 'unresolved due to error',
},
endColumn: 6,
line: 3,
Expand Down
Loading