Browse Source

chore: prefer 'as const' syntax

David Sanders 6 months ago
parent
commit
09df62b103
3 changed files with 5 additions and 5 deletions
  1. 3 3
      lib/node/asar-fs-wrapper.ts
  2. 1 1
      script/release/notes/notes.ts
  3. 1 1
      spec/api-session-spec.ts

+ 3 - 3
lib/node/asar-fs-wrapper.ts

@@ -64,7 +64,7 @@ const { URL: NodeURL } = __non_webpack_require__('internal/url');
 // Separate asar package's path from full path.
 const splitPath = (archivePathOrBuffer: string | Buffer | URL) => {
   // Shortcut for disabled asar.
-  if (isAsarDisabled()) return { isAsar: <const>false };
+  if (isAsarDisabled()) return { isAsar: false } as const;
 
   // Check for a bad argument type.
   let archivePath = archivePathOrBuffer;
@@ -74,8 +74,8 @@ const splitPath = (archivePathOrBuffer: string | Buffer | URL) => {
   if (archivePath instanceof NodeURL) {
     archivePath = getValidatedPath(archivePath);
   }
-  if (typeof archivePath !== 'string') return { isAsar: <const>false };
-  if (!asarRe.test(archivePath)) return { isAsar: <const>false };
+  if (typeof archivePath !== 'string') return { isAsar: false } as const;
+  if (!asarRe.test(archivePath)) return { isAsar: false } as const;
 
   return asar.splitPath(path.normalize(archivePath));
 };

+ 1 - 1
script/release/notes/notes.ts

@@ -467,7 +467,7 @@ async function getMergedTrops (commit: Commit, pool: Pool) {
           backportRegex
         );
         return match
-          ? <const>[match[1], new GHKey(ghKey.owner, ghKey.repo, parseInt(match[2]))]
+          ? [match[1], new GHKey(ghKey.owner, ghKey.repo, parseInt(match[2]))] as const
           : null;
       };
 

+ 1 - 1
spec/api-session-spec.ts

@@ -101,7 +101,7 @@ describe('session module', () => {
       expect(c.value).to.equal(value);
     });
 
-    for (const sameSite of <const>['unspecified', 'no_restriction', 'lax', 'strict']) {
+    for (const sameSite of ['unspecified', 'no_restriction', 'lax', 'strict'] as const) {
       it(`sets cookies with samesite=${sameSite}`, async () => {
         const { cookies } = session.defaultSession;
         const value = 'hithere';