-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
When can body be undefined or null in vanilla espree? #734
Comments
in vanilla espree? In typescript there are a number of places, such as: // declarations
declare function foo(): void;
// overloads
function bar(): void;
function bar(arg?:string) {}
// abstract
abstract class Foo {
abstract meth(): string;
// class method overloads
meth2(): void
meth2(arg?: string) {}
} |
That's what my investigation reveals as well, except that at those points the node type stops being It's all sounding to me like the For reference:
|
I'm not actually sure tbh. The type of I didn't realise it, but in #156, it added handling to convert function declarations with no body into So it looks like there's no case now that a
typescript-eslint/packages/parser/src/parser.ts Lines 94 to 98 in 93f72e3
Maybe we should move that conversion into |
Any progress on this? I'm happy to help if there's anything I can do 🙂 |
Happy to accept a PR, I hadn't looked into it any further. |
note. why it stayed in this way Initially there was a lot of additional conversions from AST produced by ts-estree in parser, most of them was cleared out, and looks like i forgot about this one. this is part of legacy code from: https://github.com/eslint/typescript-eslint-parser/blob/master/parser.js#L46-L58 and last change to this was done in PR https://github.com/eslint/typescript-eslint-parser/pull/596/files#diff-09461573a85e2d94f056dd6814769042 those changes was done before mono-repo, and at that time there was a lot of misalignment's between projects, and pushing any breaking changes was way way harder than now. |
I'm working on converting
eslint-plugin-jest
to typescript, and have come across a type definition that I can't reproduce at runtime.While converting
no-test-callbacks
, I found out that it's apparently possible for thebody
of aFunctionDeclaration
to benull
.This has required me to add a null check in order to please typescript.
This in turn upsets our coverage b/c that branch is never tested, leading me here as I've not been able to write any code that reproduces the defined type.
Hence: how can I have a
FunctionDeclaration
w/ abody
ofnull
at runtime?I suspect this heavily relates to #420, but theres too many moving parts for me to properly track :)
The text was updated successfully, but these errors were encountered: