权限没有,则隐藏 function forum_list_access_filter($forumlist, $gid, $allow = 'allowread') { global $grouplist; if (empty($forumlist)) return array(); if (1 == $gid) return $forumlist; $forumlist_filter = $forumlist; $group = $grouplist[$gid]; foreach ($forumlist_filter as $fid => $forum) { if (empty($forum['accesson']) && empty($group[$allow]) || !empty($forum['accesson']) && empty($forum['accesslist'][$gid][$allow])) { unset($forumlist_filter[$fid]); } unset($forumlist_filter[$fid]['accesslist']); } return $forumlist_filter; } function forum_filter_moduid($moduids) { $moduids = trim($moduids); if (empty($moduids)) return ''; $arr = explode(',', $moduids); $r = array(); foreach ($arr as $_uid) { $_uid = intval($_uid); $_user = user_read($_uid); if (empty($_user)) continue; if ($_user['gid'] > 4) continue; $r[] = $_uid; } return implode(',', $r); } function forum_safe_info($forum) { //unset($forum['moduids']); return $forum; } function forum_filter($forumlist) { foreach ($forumlist as &$val) { unset($val['brief'], $val['announcement'], $val['seo_title'], $val['seo_keywords'], $val['create_date_fmt'], $val['icon_url'], $val['modlist']); } return $forumlist; } function forum_format_url($forum) { global $conf; if (0 == $forum['category']) { // 列表URL $url = url('list-' . $forum['fid'], '', FALSE); } elseif (1 == $forum['category']) { // 频道 $url = url('category-' . $forum['fid'], '', FALSE); } elseif (2 == $forum['category']) { // 单页 $url = url('read-' . trim($forum['brief']), '', FALSE); } if ($conf['url_rewrite_on'] > 1 && $forum['well_alias']) { if (0 == $forum['category'] || 1 == $forum['category']) { $url = url($forum['well_alias'], '', FALSE); } elseif (2 == $forum['category']) { // 单页 $url = ($forum['threads'] && $forum['brief']) ? url($forum['well_alias'] . '-' . trim($forum['brief']), '', FALSE) : url($forum['well_alias'], '', FALSE); } } return $url; } function well_forum_alias() { $forumlist = forum_list_cache(); if (empty($forumlist)) return ''; $key = 'forum-alias'; static $cache = array(); if (isset($cache[$key])) return $cache[$key]; $cache[$key] = array(); foreach ($forumlist as $val) { if ($val['well_alias']) $cache[$key][$val['fid']] = $val['well_alias']; } return array_flip($cache[$key]); } function well_forum_alias_cache() { global $conf; $key = 'forum-alias-cache'; static $cache = array(); // 用静态变量只能在当前 request 生命周期缓存,跨进程需要再加一层缓存:redis/memcached/xcache/apc if (isset($cache[$key])) return $cache[$key]; if ('mysql' == $conf['cache']['type']) { $arr = well_forum_alias(); } else { $arr = cache_get($key); if (NULL === $arr) { $arr = well_forum_alias(); !empty($arr) AND cache_set($key, $arr); } } $cache[$key] = empty($arr) ? '' : $arr; return $cache[$key]; } ?>node.js - Codegen enums trigger error "Typescript enum is not supported in strip-only mode" after updating nod
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

node.js - Codegen enums trigger error "Typescript enum is not supported in strip-only mode" after updating nod

programmeradmin9浏览0评论

After upgrading from node 23.5.0 to 23.6.0, our Playwright test suites stopped working. It looks like it's related to an "--experimental-strip-types" setting.

We've fixed our code by updating type imports, but we still have problems with enums from the graphql codegen. When the test suite is run, an error appears for each enum in the generated graphql file (examples below).

Is there an environment flag I can set or a config setting I can add to codegen.ts?

Errors sample:

SyntaxError:   x TypeScript enum is not supported in strip-only mode
    ,-[23:1]
 20 |       UInt: { input: any; output: any; }
 21 |     };
 22 |     
 23 | ,-> export enum AccountTemplateStatus {
 24 | |     Active = 'ACTIVE',
 25 | |     Inactive = 'INACTIVE'
 26 | `-> }
 27 |     
 28 |     export type ActionItem = {
 29 |       __typename?: 'ActionItem';
    `----
  x TypeScript enum is not supported in strip-only mode
    ,-[69:1]
 66 |       stateId?: InputMaybe<Scalars['Int']['input']>;
 67 |     };
 68 |     
 69 | ,-> export enum AdjustmentCode {
 70 | |     Active = 'ACTIVE',
 71 | |     Adjusted = 'ADJUSTED',
 72 | |     Reversal = 'REVERSAL',
 73 | |     Voided = 'VOIDED'
 74 | `-> }
 75 |     
 76 |     export enum AdjustmentStatus {
 77 |       Executed = 'EXECUTED',
    `----

codegen.ts:

import './dotenv.js'

module.exports = {
  generates: {
    'src/generated/our-team-graphql.ts': {
      schema: [process.env.GRAPHQL_URL],
      plugins: ['typescript', 'typescript-operations', 'typescript-document-nodes'],
      overwrite: true,
    },
    'src/generated/our-mobile-graphql.ts': {
      schema: {
        [process.env.MOBILE_GRAPHQL_URL]: {
          headers: {
            Authorization: `${process.env.MOBILE_GRAPHQL_AUTH_HEADER}`,
          },
        },
      },

      plugins: ['typescript', 'typescript-operations', 'typescript-document-nodes'],
      overwrite: true,
      config: {
        withMutationFn: true,
        withResultType: true,
      },
    },
  },
}

Dependencies from package.json:

"devDependencies": {
    "@eslint/js": "^9.15.0",
    "@faker-js/faker": "^9.0.0",
    "@graphql-eslint/eslint-plugin": "^3.20.1",
    "@playwright/test": "^1.36.1",
    "apollo-upload-client": "^18.0.1",
    "eslint": "^8.57.1",
    "eslint-plugin-import": "^2.31.0",
    "eslint-plugin-playwright": "^2.1.0",
    "eslint-plugin-prettier": "^5.2.1",
    "husky": "^9.1.5",
    "prettier": "3.2.5",
    "typescript": "^5.7.2",
    "typescript-eslint": "^8.16.0"
  },
  "dependencies": {
    "@alex_neo/playwright-azure-reporter": "^1.12.0",
    "@apollo/client": "^3.11.8",
    "@dotenvx/dotenvx": "^1.21.1",
    "@graphql-codegen/cli": "^5.0.2",
    "@graphql-codegen/client-preset": "^4.5.1",
    "@graphql-codegen/typescript": "4.0.9",
    "@graphql-codegen/typescript-document-nodes": "4.0.9",
    "@graphql-codegen/typescript-resolvers": "^4.4.1",
    "@graphql-codegen/typescript-type-graphql": "^3.0.0",
    "@graphql-typed-document-node/core": "^3.2.0",
    "@swc/types": "^0.1.17",
    "@types/luxon": "^3.4.2",
    "@types/prop-types": "^15.7.12",
    "@types/react": "^18.3.5",
    "@types/shelljs": "^0.8.15",
    "@typescript-eslint/parser": "^7.9.0",
    "csv-parse": "^5.5.6",
    "currency-master": "^1.1.0",
    "date-fns": "^3.6.0",
    "detect-secrets": "^1.0.6",
    "dotenv": "^16.4.5",
    "eslint-config-prettier": "^9.1.0",
    "eslint-import-resolver-typescript": "^3.6.3",
    "glob": "^11.0.0",
    "graphql": "^16.9.0",
    "graphql-upload": "^17.0.0",
    "luxon": "^3.5.0",
    "npm": "^10.5.2",
    "pdf-parse": "^1.1.1",
    "playwright": "^1.47.0",
    "shelljs": "^0.8.5"
  }

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论