Skip to content

Commit

Permalink
fix: type errors (#1935)
Browse files Browse the repository at this point in the history
* fix: type errors

* chore: update lock file

* refactor: remove comments
  • Loading branch information
kazupon committed Sep 5, 2024
1 parent 2752f95 commit 224dca3
Show file tree
Hide file tree
Showing 41 changed files with 2,462 additions and 1,899 deletions.
28 changes: 0 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,34 +107,6 @@ jobs:
run: |
pnpm test:cover
test-type:
name: Type checking
strategy:
matrix:
os: [ubuntu-latest]
node: [18]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout codes
uses: actions/checkout@v4

- name: Enable corepack
run: corepack enable

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --no-frozen-lockfile

- name: Run type checking
run: pnpm test:type

test-e2e:
name: E2E test

Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@
"test": "run-s lint test:cover test:type check-install test:e2e",
"test:cover": "pnpm test:unit --coverage",
"test:e2e": "cross-env TZ=UTC vitest run -c ./vitest.e2e.config.ts",
"test:type": "tsc -p ./test-dts/tsconfig.json",
"test:unit": "cross-env TZ=UTC vitest run -c ./vitest.unit.config.ts"
"test:unit": "cross-env TZ=UTC vitest run -c ./vitest.unit.config.ts --typecheck"
},
"devDependencies": {
"@eslint/js": "^9.9.1",
Expand Down Expand Up @@ -143,7 +142,7 @@
"trash-cli": "^6.0.0",
"tslib": "^2.6.2",
"tsx": "^4.11.2",
"typescript": "^5.3.3",
"typescript": "^5.5.3",
"typescript-eslint": "^8.4.0",
"vitepress": "1.3.4",
"vitest": "^2.0.4",
Expand Down
32 changes: 16 additions & 16 deletions packages/core-base/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@ import { initFeatureFlags } from './misc'
export {
CompileError,
CompileErrorCodes,
ResourceNode,
createCompileError
createCompileError,
ResourceNode
} from '@intlify/message-compiler'
export * from './resolver'
export * from './runtime'
export * from './context'
export * from './fallbacker'
export * from './compilation'
export * from './translate'
export * from './context'
export * from './datetime'
export * from './number'
export {
getWarnMessage,
CoreWarnCodes,
CORE_WARN_CODES_EXTEND_POINT
} from './warnings'
export * from './devtools'
export {
CORE_ERROR_CODES_EXTEND_POINT,
CoreError,
CoreErrorCodes,
createCoreError,
CORE_ERROR_CODES_EXTEND_POINT
createCoreError
} from './errors'
export * from './fallbacker'
export * from './number'
export * from './resolver'
export * from './runtime'
export * from './translate'
export * from './types'
export * from './devtools'
export {
CORE_WARN_CODES_EXTEND_POINT,
CoreWarnCodes,
getWarnMessage
} from './warnings'

if (__ESM_BUNDLER__ && !__TEST__) {
initFeatureFlags()
Expand Down
12 changes: 2 additions & 10 deletions packages/core-base/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,9 @@ import {
join,
toDisplayString
} from '@intlify/shared'
import { Path } from './resolver'
import { IsNever } from './types'

type ExtractToStringKey<T> = Extract<keyof T, 'toString'>
type ExtractToStringFunction<T> = T[ExtractToStringKey<T>]
// prettier-ignore
type StringConvertable<T> = ExtractToStringKey<T> extends never
? unknown
: ExtractToStringFunction<T> extends (...args: any) => string // eslint-disable-line @typescript-eslint/no-explicit-any
? T
: unknown
import type { Path } from './resolver'
import type { IsNever, StringConvertable } from './types'

/**
*
Expand Down
74 changes: 37 additions & 37 deletions packages/core-base/src/translate.ts
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
import {
isString,
isNumber,
isFunction,
isBoolean,
isArray,
isPlainObject,
isEmptyObject,
generateFormatCacheKey,
generateCodeFrame,
assign,
escapeHtml,
generateCodeFrame,
generateFormatCacheKey,
inBrowser,
warn,
isArray,
isBoolean,
isEmptyObject,
isFunction,
isNumber,
isObject,
isPlainObject,
isString,
mark,
measure,
assign,
isObject
warn
} from '@intlify/shared'
import { isMessageAST } from './compilation'
import { createMessageContext } from './runtime'
import {
isTranslateFallbackWarn,
CoreContext,
getAdditionalMeta,
handleMissing,
isAlmostSameLocale,
isImplicitFallback,
handleMissing,
NOT_REOSLVED,
getAdditionalMeta,
CoreContext
isTranslateFallbackWarn,
NOT_REOSLVED
} from './context'
import { CoreWarnCodes, getWarnMessage } from './warnings'
import { CoreErrorCodes, createCoreError } from './errors'
import { translateDevTools } from './devtools'
import { CoreErrorCodes, createCoreError } from './errors'
import { getLocale } from './fallbacker'
import { createMessageContext } from './runtime'
import { CoreWarnCodes, getWarnMessage } from './warnings'

import type { CompileError, ResourceNode } from '@intlify/message-compiler'
import type { AdditionalPayloads } from '@intlify/devtools-types'
import type { Path, PathValue } from './resolver'
import type {
Locale,
FallbackLocale,
NamedValue,
MessageFunction,
MessageFunctionReturn,
MessageFunctionInternal,
MessageContextOptions,
MessageContext
} from './runtime'
import type { CompileError, ResourceNode } from '@intlify/message-compiler'
import type {
CoreInternalContext,
DefineCoreLocaleMessage,
LocaleMessages,
LocaleMessageValue,
CoreInternalContext,
MessageCompilerContext
} from './context'
import type { LocaleOptions } from './fallbacker'
import type { Path, PathValue } from './resolver'
import type {
FallbackLocale,
Locale,
MessageContext,
MessageContextOptions,
MessageFunction,
MessageFunctionInternal,
MessageFunctionReturn,
NamedValue
} from './runtime'
import type {
PickupKeys,
IsEmptyObject,
RemovedIndexResources,
IsNever,
PickupKeys,
PickupPaths,
IsNever
RemovedIndexResources
} from './types'
import type { DefineCoreLocaleMessage } from './context'

const NOOP_MESSAGE_FUNCTION = () => ''

Expand Down
Loading

0 comments on commit 224dca3

Please sign in to comment.