Skip to content

Commit 209f747

Browse files
Merge pull request #1073 from Indy-rbo/bugfix/fix-object.values-shim
[vrotsc]: Fix shimming for Object.values
2 parents 14c2afe + b9e779f commit 209f747

File tree

10 files changed

+34
-5
lines changed

10 files changed

+34
-5
lines changed

docs/versions/latest/Components/Archetypes/typescript/General/Known Issues.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ A list of known typescript archetype issues.
66

77
1. [Array functions are not transpiled to vRO code](#array-functions-are-not-transpiled-to-vro-code)
88
2. [VROTSC config](#vrotsc-config)
9+
3. [`Object.entries` not supported](#objectentries-not-supported)
910

1011
### Array functions are not transpiled to vRO code
1112

@@ -160,3 +161,7 @@ e.g.
160161
ignoreDeprecations: "5.0"
161162
};
162163
```
164+
165+
### `Object.entries` not supported
166+
167+
The `Object.entries` function is not supported in vRO's Rhino JavaScript engine and currently does not have a Shim replacement, which results in a runtime error when used.

docs/versions/latest/Release.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@ Add the following new definitions:
5353
### *Update type definitions for `FileReader` from `o11n-core` plugin*
5454
Add `close()` method.
5555

56+
### *Bugfix for Shimming `Object.values`*
57+
58+
#### Previous Behavior
59+
60+
Using `Object.values` would not be replaced by a Shim call and would result in a runtime error when ran inside of vRO's Rhino JavaScript engine.
61+
62+
#### New Behavior
63+
64+
Using `Object.values` now correctly gets replaced by a Shim call (`VROES.Shims.objectValues`), preventing runtime errors when executed inside of vRO's Rhino JavaScript engine.
65+
66+
#### Known Issues
67+
68+
* The `Object.entries` function is not supported in vRO's Rhino JavaScript engine and currently does not have a Shim replacement, which results in a runtime error when used.
69+
5670
## Upgrade procedure
5771

5872
[//]: # (Explain in details if something needs to be done)

maven/archetypes/ts-vra-ng/src/main/resources/archetype-resources/vro/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
"ES2015.Collection",
1010
"ES2015.Iterable",
1111
"ES2015.Promise",
12+
"ES2016.Array.Include",
1213
"ES2017.String",
13-
"ES2016.Array.Include"
14+
"ES2017.Object"
1415
],
1516
"experimentalDecorators": true
1617
}

maven/archetypes/ts/src/main/resources/archetype-resources/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
"ES2015.Collection",
1010
"ES2015.Iterable",
1111
"ES2015.Promise",
12+
"ES2016.Array.Include",
1213
"ES2017.String",
13-
"ES2016.Array.Include"
14+
"ES2017.Object"
1415
],
1516
"experimentalDecorators": true
1617
}

packages/ecmascript/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
"ES2015.Collection",
1010
"ES2015.Iterable",
1111
"ES2015.Promise",
12+
"ES2016.Array.Include",
1213
"ES2017.String",
13-
"ES2016.Array.Include"
14+
"ES2017.Object"
1415
],
1516
"experimentalDecorators": true
1617
}

typescript/vrotsc/e2e/cases/es6-shims/action1.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ var obj = {
3838
obj.startsWith("test");
3939
obj.find("test");
4040
obj.findIndex("test");
41+
Object.assign({}, obj);
42+
Object.values(obj);

typescript/vrotsc/e2e/expect/es6-shims/actions/action1.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,7 @@
4343
obj.startsWith("test");
4444
obj.find("test");
4545
obj.findIndex("test");
46+
VROES.Shims.objectAssign({}, obj);
47+
VROES.Shims.objectValues(obj);
4648
return exports;
4749
});

typescript/vrotsc/e2e/expect/es6-shims/maps/action1.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typescript/vrotsc/src/compiler/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ export function createCompilerOptions(rootDir: string, projectPath?: string): ts
4141
"lib.es2015.collection.d.ts",
4242
"lib.es2015.iterable.d.ts",
4343
"lib.es2015.promise.d.ts",
44+
"lib.es2016.array.include.d.ts",
4445
"lib.es2017.string.d.ts",
45-
"lib.es2016.array.include.d.ts"
46+
"lib.es2017.object.d.ts"
4647
],
4748
strict: false,
4849
allowUnreachableCode: true,

typescript/vrotsc/src/compiler/transformer/codeTransformers/shims.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ export function transformShims(sourceFile: ts.SourceFile, context: ScriptTransfo
173173
return shimStaticCall("arrayOf", node);
174174
case "ObjectConstructor.assign":
175175
return shimStaticCall("objectAssign", node);
176+
case "ObjectConstructor.values":
177+
return shimStaticCall("objectValues", node);
176178
}
177179
}
178180

0 commit comments

Comments
 (0)