Skip to content

Commit 224dca3

Browse files
authored
fix: type errors (#1935)
* fix: type errors * chore: update lock file * refactor: remove comments
1 parent 2752f95 commit 224dca3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2462
-1899
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -107,34 +107,6 @@ jobs:
107107
run: |
108108
pnpm test:cover
109109
110-
test-type:
111-
name: Type checking
112-
strategy:
113-
matrix:
114-
os: [ubuntu-latest]
115-
node: [18]
116-
117-
runs-on: ${{ matrix.os }}
118-
119-
steps:
120-
- name: Checkout codes
121-
uses: actions/checkout@v4
122-
123-
- name: Enable corepack
124-
run: corepack enable
125-
126-
- name: Setup node
127-
uses: actions/setup-node@v4
128-
with:
129-
node-version: ${{ matrix.node }}
130-
cache: 'pnpm'
131-
132-
- name: Install dependencies
133-
run: pnpm install --no-frozen-lockfile
134-
135-
- name: Run type checking
136-
run: pnpm test:type
137-
138110
test-e2e:
139111
name: E2E test
140112

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@
6767
"test": "run-s lint test:cover test:type check-install test:e2e",
6868
"test:cover": "pnpm test:unit --coverage",
6969
"test:e2e": "cross-env TZ=UTC vitest run -c ./vitest.e2e.config.ts",
70-
"test:type": "tsc -p ./test-dts/tsconfig.json",
71-
"test:unit": "cross-env TZ=UTC vitest run -c ./vitest.unit.config.ts"
70+
"test:unit": "cross-env TZ=UTC vitest run -c ./vitest.unit.config.ts --typecheck"
7271
},
7372
"devDependencies": {
7473
"@eslint/js": "^9.9.1",
@@ -143,7 +142,7 @@
143142
"trash-cli": "^6.0.0",
144143
"tslib": "^2.6.2",
145144
"tsx": "^4.11.2",
146-
"typescript": "^5.3.3",
145+
"typescript": "^5.5.3",
147146
"typescript-eslint": "^8.4.0",
148147
"vitepress": "1.3.4",
149148
"vitest": "^2.0.4",

packages/core-base/src/index.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@ import { initFeatureFlags } from './misc'
33
export {
44
CompileError,
55
CompileErrorCodes,
6-
ResourceNode,
7-
createCompileError
6+
createCompileError,
7+
ResourceNode
88
} from '@intlify/message-compiler'
9-
export * from './resolver'
10-
export * from './runtime'
11-
export * from './context'
12-
export * from './fallbacker'
139
export * from './compilation'
14-
export * from './translate'
10+
export * from './context'
1511
export * from './datetime'
16-
export * from './number'
17-
export {
18-
getWarnMessage,
19-
CoreWarnCodes,
20-
CORE_WARN_CODES_EXTEND_POINT
21-
} from './warnings'
12+
export * from './devtools'
2213
export {
14+
CORE_ERROR_CODES_EXTEND_POINT,
2315
CoreError,
2416
CoreErrorCodes,
25-
createCoreError,
26-
CORE_ERROR_CODES_EXTEND_POINT
17+
createCoreError
2718
} from './errors'
19+
export * from './fallbacker'
20+
export * from './number'
21+
export * from './resolver'
22+
export * from './runtime'
23+
export * from './translate'
2824
export * from './types'
29-
export * from './devtools'
25+
export {
26+
CORE_WARN_CODES_EXTEND_POINT,
27+
CoreWarnCodes,
28+
getWarnMessage
29+
} from './warnings'
3030

3131
if (__ESM_BUNDLER__ && !__TEST__) {
3232
initFeatureFlags()

packages/core-base/src/runtime.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,9 @@ import {
1010
join,
1111
toDisplayString
1212
} from '@intlify/shared'
13-
import { Path } from './resolver'
14-
import { IsNever } from './types'
1513

16-
type ExtractToStringKey<T> = Extract<keyof T, 'toString'>
17-
type ExtractToStringFunction<T> = T[ExtractToStringKey<T>]
18-
// prettier-ignore
19-
type StringConvertable<T> = ExtractToStringKey<T> extends never
20-
? unknown
21-
: ExtractToStringFunction<T> extends (...args: any) => string // eslint-disable-line @typescript-eslint/no-explicit-any
22-
? T
23-
: unknown
14+
import type { Path } from './resolver'
15+
import type { IsNever, StringConvertable } from './types'
2416

2517
/**
2618
*

packages/core-base/src/translate.ts

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,65 @@
11
import {
2-
isString,
3-
isNumber,
4-
isFunction,
5-
isBoolean,
6-
isArray,
7-
isPlainObject,
8-
isEmptyObject,
9-
generateFormatCacheKey,
10-
generateCodeFrame,
2+
assign,
113
escapeHtml,
4+
generateCodeFrame,
5+
generateFormatCacheKey,
126
inBrowser,
13-
warn,
7+
isArray,
8+
isBoolean,
9+
isEmptyObject,
10+
isFunction,
11+
isNumber,
12+
isObject,
13+
isPlainObject,
14+
isString,
1415
mark,
1516
measure,
16-
assign,
17-
isObject
17+
warn
1818
} from '@intlify/shared'
1919
import { isMessageAST } from './compilation'
20-
import { createMessageContext } from './runtime'
2120
import {
22-
isTranslateFallbackWarn,
21+
CoreContext,
22+
getAdditionalMeta,
23+
handleMissing,
2324
isAlmostSameLocale,
2425
isImplicitFallback,
25-
handleMissing,
26-
NOT_REOSLVED,
27-
getAdditionalMeta,
28-
CoreContext
26+
isTranslateFallbackWarn,
27+
NOT_REOSLVED
2928
} from './context'
30-
import { CoreWarnCodes, getWarnMessage } from './warnings'
31-
import { CoreErrorCodes, createCoreError } from './errors'
3229
import { translateDevTools } from './devtools'
30+
import { CoreErrorCodes, createCoreError } from './errors'
3331
import { getLocale } from './fallbacker'
32+
import { createMessageContext } from './runtime'
33+
import { CoreWarnCodes, getWarnMessage } from './warnings'
3434

35-
import type { CompileError, ResourceNode } from '@intlify/message-compiler'
3635
import type { AdditionalPayloads } from '@intlify/devtools-types'
37-
import type { Path, PathValue } from './resolver'
38-
import type {
39-
Locale,
40-
FallbackLocale,
41-
NamedValue,
42-
MessageFunction,
43-
MessageFunctionReturn,
44-
MessageFunctionInternal,
45-
MessageContextOptions,
46-
MessageContext
47-
} from './runtime'
36+
import type { CompileError, ResourceNode } from '@intlify/message-compiler'
4837
import type {
38+
CoreInternalContext,
39+
DefineCoreLocaleMessage,
4940
LocaleMessages,
5041
LocaleMessageValue,
51-
CoreInternalContext,
5242
MessageCompilerContext
5343
} from './context'
5444
import type { LocaleOptions } from './fallbacker'
45+
import type { Path, PathValue } from './resolver'
46+
import type {
47+
FallbackLocale,
48+
Locale,
49+
MessageContext,
50+
MessageContextOptions,
51+
MessageFunction,
52+
MessageFunctionInternal,
53+
MessageFunctionReturn,
54+
NamedValue
55+
} from './runtime'
5556
import type {
56-
PickupKeys,
5757
IsEmptyObject,
58-
RemovedIndexResources,
58+
IsNever,
59+
PickupKeys,
5960
PickupPaths,
60-
IsNever
61+
RemovedIndexResources
6162
} from './types'
62-
import type { DefineCoreLocaleMessage } from './context'
6363

6464
const NOOP_MESSAGE_FUNCTION = () => ''
6565

0 commit comments

Comments
 (0)