-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Subsequent variable declarations must have same type: Mention location of other declaration #19356
Conversation
…n of other declaration
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.
Just some minor naming/formatting changes.
src/compiler/checker.ts
Outdated
const valueDeclarationSourceFile = getSourceFileOfNode(firstDeclaration); | ||
const otherSpan = getErrorSpanForNode(valueDeclarationSourceFile, getNameOfDeclaration(firstDeclaration) || firstDeclaration); | ||
const otherLocation = getLineAndCharacterOfPosition(valueDeclarationSourceFile, otherSpan.start); | ||
const otherLocationDescription = `${valueDeclarationSourceFile.fileName} ${otherLocation.line}:${otherLocation.character}`; |
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.
is the chrome debugger issue with template literals fixed? It doesn't look like it, so probably it's better not avoid template literals for now.
src/compiler/checker.ts
Outdated
@@ -20803,6 +20802,21 @@ namespace ts { | |||
} | |||
} | |||
|
|||
function errorSubsequentVariableDeclarationMustHaveSameType(firstDeclaration: Declaration, firstType: Type, nextDeclaration: Declaration, subsequentType: Type): void { |
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.
I'd use 'Next' consistently for the function name and for -Type and -Declaration. It's easier to type than subsequent.
src/compiler/checker.ts
Outdated
@@ -20803,6 +20802,21 @@ namespace ts { | |||
} | |||
} | |||
|
|||
function errorSubsequentVariableDeclarationMustHaveSameType(firstDeclaration: Declaration, firstType: Type, nextDeclaration: Declaration, subsequentType: Type): void { | |||
const valueDeclarationSourceFile = getSourceFileOfNode(firstDeclaration); | |||
const otherSpan = getErrorSpanForNode(valueDeclarationSourceFile, getNameOfDeclaration(firstDeclaration) || firstDeclaration); |
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 'first/next' for local names too.
Fixes #19339