Skip to content

Commit 2131034

Browse files
committed
style: [sdk-1556] convert example to ts
1 parent 9df4b3a commit 2131034

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

packages/sdk/shopify-oxygen/example/app.js renamed to packages/sdk/shopify-oxygen/example/app.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {createMiniOxygen} from '@shopify/mini-oxygen';
77
* For the actual example implementation, see the src/index.ts file.
88
*/
99

10-
const printValueAndBanner = (flagKey, flagValue) => {
10+
const printValueAndBanner = (flagKey: string, flagValue: string) => {
1111
console.log(`*** The '${flagKey}' feature flag evaluates to ${flagValue}.`);
1212

1313
if (flagValue) {
@@ -48,8 +48,8 @@ const main = async () => {
4848
const interval = setInterval(() => {
4949
// NOTE: This is a bogus URL and will not be used in the actual fetch handler.
5050
// please see the src/index.ts file for the actual fetch handler.
51-
miniOxygen.dispatchFetch('https://localhost:8000')
52-
.then(d => d.json())
51+
miniOxygen.dispatchFetch('https://localhost:8000' as any)
52+
.then(d => d.json() as Promise<any>)
5353
.then(({flagValue, flagKey}) => {
5454
console.clear();
5555
printValueAndBanner(flagKey, flagValue);
@@ -65,7 +65,7 @@ const main = async () => {
6565
process.stdin.resume();
6666
process.stdin.setEncoding('utf8');
6767

68-
process.stdin.on('data', async (key) => {
68+
process.stdin.on('data', async (key: string) => {
6969
// Handle Ctrl+C
7070
if (key === '\u0003') {
7171
clearInterval(interval);

packages/sdk/shopify-oxygen/example/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
"scripts": {
55
"build": "tsup",
66
"clean": "rm -rf dist",
7-
"start": "yarn clean && yarn build && yarn node app.js"
7+
"start": "yarn clean && yarn build && ts-node app.ts"
88
},
99
"type": "module",
1010
"dependencies": {
1111
"@launchdarkly/shopify-oxygen-sdk": "latest",
12-
"@shopify/mini-oxygen": "^4.0.0"
12+
"@shopify/mini-oxygen": "^4.0.0",
13+
"ts-node": "^10.9.2",
14+
"typescript": "^5.9.3"
1315
},
1416
"devDependencies": {
1517
"tsup": "^8.5.1"

0 commit comments

Comments
 (0)