From 924d2d411998f1380233bcd80efe19e8efd40265 Mon Sep 17 00:00:00 2001 From: Sameen Karim Date: Sun, 1 Sep 2024 10:42:18 -0400 Subject: [PATCH] handle shorthand property assignment --- package-lock.json | 4 ++-- package.json | 2 +- src/analyze/helpers.js | 8 +++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index af026a4..790fb42 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@flisk/analyze-tracking", - "version": "0.2.2", + "version": "0.2.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@flisk/analyze-tracking", - "version": "0.2.2", + "version": "0.2.3", "license": "MIT", "dependencies": { "@typescript-eslint/parser": "^8.1.0", diff --git a/package.json b/package.json index e5ff0fd..2dd27b4 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/analyze/helpers.js b/src/analyze/helpers.js index fa6c796..eb34b2e 100644 --- a/src/analyze/helpers.js +++ b/src/analyze/helpers.js @@ -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',