Skip to content

Commit

Permalink
Bug repro - asymmetry in Memento API when using Date object
Browse files Browse the repository at this point in the history
  • Loading branch information
hyangah committed Apr 3, 2024
1 parent f4e09a3 commit 194f02e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion helloworld-sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"categories": [
"Other"
],
"activationEvents": [],
"activationEvents": ["onStartupFinished"],
"main": "./out/extension.js",
"contributes": {
"commands": [
Expand Down
32 changes: 32 additions & 0 deletions helloworld-sample/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,37 @@ export function activate(context: vscode.ExtensionContext) {
vscode.window.showInformationMessage('Hello World!');
});

const now = new Date();
console.log(JSON.stringify(now));
const KEY = 'TEST_TIMESTAMP_KEY';
let value = context.globalState.get<Date>(KEY);
if (value === undefined) {
context.globalState.update(KEY, new Date());
value = context.globalState.get<Date>(KEY);
}
console.log(`TEST_TIMESTAMP_KEY = ${value} type=${typeof value}`);
if (value === undefined || !(value instanceof Date)) {
throw Error(`unexpected date - ${value}`);
}
context.subscriptions.push(disposable);
}

/*
# First Round
Congratulations, your extension "helloworld-sample" is now active!
extensionHostProcess.js:144
"2024-04-03T19:24:17.476Z"
extensionHostProcess.js:144
TEST_TIMESTAMP_KEY = Wed Apr 03 2024 15:24:17 GMT-0400 (Eastern Daylight Time) type=object
--
# Second Round
Congratulations, your extension "helloworld-sample" is now active!
extensionHostProcess.js:144
"2024-04-03T19:25:06.045Z"
extensionHostProcess.js:144
TEST_TIMESTAMP_KEY = 2024-04-03T19:24:17.478Z type=string
(and crash)
*/

0 comments on commit 194f02e

Please sign in to comment.