@cap-js/cds-typer 0.20.0 → 0.20.2
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/CHANGELOG.md +8 -0
- package/lib/visitor.js +4 -3
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
|
6
6
|
|
|
7
7
|
## Version 0.21.0 - TBD
|
|
8
8
|
|
|
9
|
+
## Version 0.20.2 - 2024-04-29
|
|
10
|
+
### Fixed
|
|
11
|
+
- Referring to a property's type in a function/ action parameter no longer refers to the enclosing entity
|
|
12
|
+
|
|
13
|
+
## Version 0.20.1 - 2024-04-24
|
|
14
|
+
### Fixed
|
|
15
|
+
- Void actions no longer crash the type generation process
|
|
16
|
+
|
|
9
17
|
## Version 0.20.0 - 2024-04-23
|
|
10
18
|
### Added
|
|
11
19
|
- Types for actions and functions now expose a `.kind` property which holds the string `'function'` or `'action'` respectively
|
package/lib/visitor.js
CHANGED
|
@@ -353,7 +353,7 @@ class Visitor {
|
|
|
353
353
|
const paramType = this.resolver.resolveAndRequire(type, file)
|
|
354
354
|
return this.inlineDeclarationResolver.getPropertyDatatype(
|
|
355
355
|
paramType,
|
|
356
|
-
paramType.typeInfo.isArray ? paramType.typeName : paramType.typeInfo.inflection.singular
|
|
356
|
+
paramType.typeInfo.isArray || paramType.typeInfo.isDeepRequire ? paramType.typeName : paramType.typeInfo.inflection.singular
|
|
357
357
|
)
|
|
358
358
|
}
|
|
359
359
|
|
|
@@ -363,12 +363,13 @@ class Visitor {
|
|
|
363
363
|
* @param {'function' | 'action'} kind
|
|
364
364
|
*/
|
|
365
365
|
#printOperation(name, operation, kind) {
|
|
366
|
-
// FIXME: mostly duplicate of printAction -> reuse
|
|
367
366
|
this.logger.debug(`Printing operation ${name}:\n${JSON.stringify(operation, null, 2)}`)
|
|
368
367
|
const ns = this.resolver.resolveNamespace(name.split('.'))
|
|
369
368
|
const file = this.fileRepository.getNamespaceFile(ns)
|
|
370
369
|
const params = this.#stringifyFunctionParams(operation.params, file)
|
|
371
|
-
const returnType =
|
|
370
|
+
const returnType = operation.returns
|
|
371
|
+
? this.resolver.resolveAndRequire(operation.returns, file)
|
|
372
|
+
: { typeName: 'void', typeInfo: { isArray: false, inflection: { singular: 'void', plural: 'void' } } }
|
|
372
373
|
const returns = this.inlineDeclarationResolver.getPropertyDatatype(
|
|
373
374
|
returnType,
|
|
374
375
|
returnType.typeInfo.isArray ? returnType.typeName : returnType.typeInfo.inflection.singular
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cap-js/cds-typer",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.2",
|
|
4
4
|
"description": "Generates .ts files for a CDS model to receive code completion in VS Code",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "github:cap-js/cds-typer",
|
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"test:unit": "jest --projects test/unit.jest.config.js",
|
|
17
17
|
"test:integration": "jest --projects test/int.jest.config.js",
|
|
18
|
+
"test:smoke": "jest --projects test/smoke.jest.config.js",
|
|
18
19
|
"test:all": "jest",
|
|
19
|
-
"test": "npm run test:unit",
|
|
20
|
+
"test": "npm run test:smoke && npm run test:unit",
|
|
20
21
|
"lint": "npx eslint .",
|
|
21
22
|
"cli": "node lib/cli.js",
|
|
22
23
|
"doc:clean": "rm -rf ./doc",
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
},
|
|
50
51
|
"jest": {
|
|
51
52
|
"projects": [
|
|
53
|
+
"test/smoke.jest.config.js",
|
|
52
54
|
"test/unit.jest.config.js"
|
|
53
55
|
]
|
|
54
56
|
}
|