@playcanvas/attribute-parser 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createSystem, createDefaultMapFromNodeModules, createVirtualTypeScriptE
|
|
|
2
2
|
import * as ts from 'typescript';
|
|
3
3
|
|
|
4
4
|
import { ScriptParser } from './parsers/script-parser.js';
|
|
5
|
-
import { isInterface } from './utils/attribute-utils.js';
|
|
5
|
+
import { isInterface, isStaticMember } from './utils/attribute-utils.js';
|
|
6
6
|
import { createDefaultMapFromCDN, flatMapAnyNodes, getExportedNodes, getType, inheritsFrom, isAliasedClassDeclaration } from './utils/ts-utils.js';
|
|
7
7
|
|
|
8
8
|
const toLowerCamelCase = str => str[0].toLowerCase() + str.substring(1);
|
|
@@ -147,7 +147,7 @@ export class JSDocParser {
|
|
|
147
147
|
ts.isPropertyDeclaration(member) && // Is a property declaration
|
|
148
148
|
ts.isIdentifier(member.name) &&
|
|
149
149
|
member.name.text === 'scriptName' &&
|
|
150
|
-
(
|
|
150
|
+
isStaticMember(member) &&
|
|
151
151
|
ts.isStringLiteral(member.initializer)
|
|
152
152
|
);
|
|
153
153
|
|
|
@@ -235,7 +235,7 @@ export class JSDocParser {
|
|
|
235
235
|
const members = [];
|
|
236
236
|
|
|
237
237
|
for (const member of node.members) {
|
|
238
|
-
if (member.kind !== ts.SyntaxKind.PropertyDeclaration) {
|
|
238
|
+
if (member.kind !== ts.SyntaxKind.PropertyDeclaration || isStaticMember(member)) {
|
|
239
239
|
continue;
|
|
240
240
|
}
|
|
241
241
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getCombinedModifierFlags, ModifierFlags } from 'typescript';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @file Utility functions for parsing Script attributes.
|
|
3
5
|
*/
|
|
@@ -42,3 +44,10 @@ export const hasTag = (tag, node) => {
|
|
|
42
44
|
export const isInterface = (node) => {
|
|
43
45
|
return hasTag('interface', node);
|
|
44
46
|
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Checks if a node is a scriptName property
|
|
50
|
+
* @param {import('typescript').Node} member - The node to analyze
|
|
51
|
+
* @returns {boolean} - True if the node is a scriptName property
|
|
52
|
+
*/
|
|
53
|
+
export const isStaticMember = member => (getCombinedModifierFlags(member) & ModifierFlags.Static) !== 0;
|
|
@@ -20,6 +20,10 @@ describe('VALID: Intellisense Parsing', function () {
|
|
|
20
20
|
expect(data[0]?.example).to.exist;
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
+
it('does not return static members', function () {
|
|
24
|
+
expect(data[0].example[0].name).to.not.equal('scriptName');
|
|
25
|
+
});
|
|
26
|
+
|
|
23
27
|
it('attributes have correct types', function () {
|
|
24
28
|
expect(data[0].folder[0].type).to.equal('any');
|
|
25
29
|
expect(data[0].folder[1].type).to.equal('number');
|