-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Report error if class uses extended type before its declaration #4343
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
@@ -0,0 +1,15 @@ | |||
var c = class A extends B { // error | |||
} |
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 would also add a test with an expression in an extend clause, class A extends foo(0)<string> {}
and one for module aliases
import d from "mod";
class B extends d { // no error here
}
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.
added this
… report error Fixes #4244
I am still working on reporting error if alias is declared before it is referencing entity(internal alias only) |
let file1 = getSourceFileOfNode(node1); | ||
let file2 = getSourceFileOfNode(node2); | ||
if (file1 === file2) { | ||
return node1.pos <= node2.pos; | ||
return node1.pos <= node2.pos || !isInSameLexicalScope(); |
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 are they allowed to be in different lexical scopes?
@@ -393,9 +398,28 @@ namespace ts { | |||
} | |||
|
|||
let sourceFiles = host.getSourceFiles(); | |||
return sourceFiles.indexOf(file1) <= sourceFiles.indexOf(file2); | |||
} | |||
return sourceFiles.indexOf(referenceDeclarationFile) <= sourceFiles.indexOf(locationNodeFile) || !isInSameLexicalScope(); |
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.
use ts.indexOf instead of array.prototype.indexof
return; | ||
} | ||
|
||
let meaning = node.parent.kind === SyntaxKind.QualifiedName || node.parent.kind === SyntaxKind.PropertyAccessExpression? |
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.
Fix spacing at the end of the line
let file2 = getSourceFileOfNode(node2); | ||
if (file1 === file2) { | ||
return node1.pos <= node2.pos; | ||
function isDefinedBefore(referenceDeclaration: Node, locationNode: Node): 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.
isDefinedBeforeOrAt
This PR is superseded by #8636 which has been successfully merged, right? |
closing in favor of #8636 |
Fixes #4341