Comments (4)
ast-parser 0.0.6 is released. Thank you for finding the typo. :)
from ast-parser.
@daybrush unfortunately this change is not enough to fix displaying function body, and I am not really sure where to look to fix that.
In general now when you run above code you will see something like this:
NODE: {
callee: {
typeAnnotation: {
string: '',
html: '',
nodeType: '',
typeId: [Function: getTypeId]
},
name: 'map',
optional: '',
id: 'map',
template: '${id}$if{optional, "?"}$if{typeAnnotation, ": " + typeAnnotation}',
nodeType: 'Identifier',
string: 'map',
html: 'map',
typeId: [Function: getTypeId]
},
arguments: [
{
params: [Array],
async: false,
expression: '',
generator: false,
returnType: [Object],
typeParameters: [Object],
body: [Object],
template: '$if{async, "async "}${typeParameters}(${params}) => ${body}',
nodeType: 'ArrowFunctionExpression',
string: '({defaultNoteFilter: defaultNoteFilter}: {defaultNoteFilter: NotesFiltersInterface}) => {}',
html: '({defaultNoteFilter: defaultNoteFilter}: {defaultNoteFilter: NotesFiltersInterface}) => {}',
typeId: [Function: getTypeId]
}
],
optional: '',
typeArguments: { string: '', html: '', nodeType: '', typeId: [Function: getTypeId] },
typeParameters: { string: '', html: '', nodeType: '', typeId: [Function: getTypeId] },
template: '${callee}${typeParameters}(${arguments})',
nodeType: 'CallExpression',
string: 'map(({defaultNoteFilter: defaultNoteFilter}: {defaultNoteFilter: NotesFiltersInterface}) => {})',
html: 'map(({defaultNoteFilter: defaultNoteFilter}: {defaultNoteFilter: NotesFiltersInterface}) => {})',
typeId: [Function: getTypeId]
}
MISING FUNCTION BODY: map(({defaultNoteFilter: defaultNoteFilter}: {defaultNoteFilter: NotesFiltersInterface}) => {})
and I would expect the last line to contain something like this:
MISING FUNCTION BODY: map(({defaultNoteFilter}: { defaultNoteFilter: NotesFiltersInterface}) => {
let existingNoteFilter: NotesFiltersInterface | null = JSON.parse(localStorage.getItem(defaultNoteFilter.id));
if (!existingNoteFilter) {
return getNotesFiltersFromLocalStorageFail({defaultNoteFilter});
} else {
if (!existingNoteFilter.searchPhrases) {
existingNoteFilter = {
...existingNoteFilter,
searchPhrases: []
};
}
return getNotesFiltersFromLocalStorageSuccess({existingNoteFilter});
}
})
You can download project from here: https://stackblitz.com/edit/ast-parser-issue and run:
npm i
npm run test
from ast-parser.
I'm sorry. You're right, but the reason I made ast-parser is to omit it. I thought the content in the blockstatement was unnecessary.
from ast-parser.
@daybrush Maybe it's worth adding some documentation about this behavior as I kind of expected full AST as result and after using this one I had to rewrite it to different parser.
I have managed to resolve my use case using ts-morph
. It kind of felt a little bit harder to use but I've got the data I needed.
from ast-parser.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ast-parser.