Skip to content

Commit

Permalink
handle shorthand property assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
skarim committed Sep 1, 2024
1 parent 3c3ae93 commit 924d2d4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flisk/analyze-tracking",
"version": "0.2.2",
"version": "0.2.3",
"description": "Analyzes tracking code in a project and generates data schemas",
"main": "src/index.js",
"bin": {
Expand Down
8 changes: 7 additions & 1 deletion src/analyze/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,13 @@ function extractTsProperties(checker, node) {
const key = prop.name ? prop.name.text : prop.key.text || prop.key.value;
let valueType = 'any';

if (prop.initializer) {
if (ts.isShorthandPropertyAssignment(prop)) {
const symbol = checker.getSymbolAtLocation(prop.name);
if (symbol) {
valueType = getTypeOfNode(checker, symbol.valueDeclaration);
properties[key] = { type: valueType };
}
} else if (prop.initializer) {
if (ts.isObjectLiteralExpression(prop.initializer)) {
properties[key] = {
type: 'object',
Expand Down

0 comments on commit 924d2d4

Please sign in to comment.