@rightcapital/phpdoc-parser 0.4.134--.1829.1.0 → 0.4.134--.1841.1.0
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.
|
@@ -3,18 +3,24 @@ import type { TypeNode as PhpDocTypeNode } from '../ast/type/type-node';
|
|
|
3
3
|
export type NameNodePathResolver<T> = (this: T, nodeParts: string[]) => {
|
|
4
4
|
path: string;
|
|
5
5
|
name: string;
|
|
6
|
+
importName: string;
|
|
6
7
|
isTypeOnly: boolean;
|
|
8
|
+
typeIdentifiers: string[];
|
|
7
9
|
};
|
|
8
10
|
export declare class PhpDocTypeNodeToTypescriptTypeNodeTranspiler {
|
|
9
11
|
nameNodePathResolver: (nodeParts: string[]) => {
|
|
10
12
|
path: string;
|
|
11
13
|
name: string;
|
|
14
|
+
importName: string;
|
|
12
15
|
isTypeOnly: boolean;
|
|
16
|
+
typeIdentifiers: string[];
|
|
13
17
|
};
|
|
14
18
|
constructor(nameNodePathResolver: (nodeParts: string[]) => {
|
|
15
19
|
path: string;
|
|
16
20
|
name: string;
|
|
21
|
+
importName: string;
|
|
17
22
|
isTypeOnly: boolean;
|
|
23
|
+
typeIdentifiers: string[];
|
|
18
24
|
});
|
|
19
25
|
transpile(sourceTypeNode: PhpDocTypeNode): TypeNode;
|
|
20
26
|
beforeTranspile(): void;
|
|
@@ -37,6 +37,7 @@ class PhpDocTypeNodeToTypescriptTypeNodeTranspiler {
|
|
|
37
37
|
'non-empty-array',
|
|
38
38
|
'list',
|
|
39
39
|
'non-empty-list',
|
|
40
|
+
'\\Illuminate\\Support\\Collection',
|
|
40
41
|
'\\Illuminate\\Database\\Eloquent\\Collection',
|
|
41
42
|
].includes(sourceTypeNode.type.name)) {
|
|
42
43
|
if (sourceTypeNode.genericTypes.length === 1) {
|
|
@@ -84,18 +85,22 @@ class PhpDocTypeNodeToTypescriptTypeNodeTranspiler {
|
|
|
84
85
|
if (sourceTypeNode.name === 'void') {
|
|
85
86
|
return typescript_1.factory.createToken(typescript_1.SyntaxKind.VoidKeyword);
|
|
86
87
|
}
|
|
87
|
-
if (
|
|
88
|
+
if (['\\Illuminate\\Http\\Resources\\MissingValue', 'null'].includes(sourceTypeNode.name)) {
|
|
88
89
|
return typescript_1.factory.createLiteralTypeNode(typescript_1.factory.createNull());
|
|
89
90
|
}
|
|
90
91
|
if (/^[A-Z\\]/.test(sourceTypeNode.name)) {
|
|
91
92
|
const nameNodeParts = sourceTypeNode.name.split('\\');
|
|
92
|
-
const {
|
|
93
|
-
if (
|
|
93
|
+
const { path, isTypeOnly, importName, typeIdentifiers } = this.nameNodePathResolver(nameNodeParts);
|
|
94
|
+
if (importName !== 'string' && path !== '') {
|
|
94
95
|
this.importDeclarations.push(typescript_1.factory.createImportDeclaration(undefined, typescript_1.factory.createImportClause(isTypeOnly, undefined, typescript_1.factory.createNamedImports([
|
|
95
|
-
typescript_1.factory.createImportSpecifier(false, undefined, typescript_1.factory.createIdentifier(
|
|
96
|
+
typescript_1.factory.createImportSpecifier(false, undefined, typescript_1.factory.createIdentifier(importName)),
|
|
96
97
|
])), typescript_1.factory.createStringLiteral(path), undefined));
|
|
97
98
|
}
|
|
98
|
-
|
|
99
|
+
let typeNameNode = typescript_1.factory.createIdentifier(typeIdentifiers[0]);
|
|
100
|
+
for (let i = 1; i < typeIdentifiers.length; i += 1) {
|
|
101
|
+
typeNameNode = typescript_1.factory.createQualifiedName(typeNameNode, typescript_1.factory.createIdentifier(typeIdentifiers[i]));
|
|
102
|
+
}
|
|
103
|
+
return typescript_1.factory.createTypeReferenceNode(typeNameNode, undefined);
|
|
99
104
|
}
|
|
100
105
|
}
|
|
101
106
|
return typescript_1.factory.createKeywordTypeNode(typescript_1.SyntaxKind.AnyKeyword);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rightcapital/phpdoc-parser",
|
|
3
|
-
"version": "0.4.134-.
|
|
3
|
+
"version": "0.4.134-.1841.1.0",
|
|
4
4
|
"description": "TypeScript version of PHPDoc parser with support for intersection types and generics",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"PHP",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@types/node": "22.
|
|
28
|
+
"@types/node": "22.15.12",
|
|
29
29
|
"lodash": "4.17.21",
|
|
30
30
|
"typescript": "5.8.3"
|
|
31
31
|
},
|