Skip to content

Commit 14d868c

Browse files
committed
feat: enable isolatedDeclarations
1 parent c14ccee commit 14d868c

File tree

190 files changed

+532
-327
lines changed

Some content is hidden

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

190 files changed

+532
-327
lines changed

macros/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function getPkgName(filePath: string) {
1212
return pkgName
1313
}
1414

15-
export const generatePluginName = defineMacro(function () {
15+
export const generatePluginName: () => string = defineMacro(function () {
1616
const pkgName = getPkgName(this.id)
1717
return `unplugin-vue-${pkgName}`
1818
})

macros/repo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export const docsLink = 'https://vue-macros.dev'
22
export const githubRepo = 'vue-macros/vue-macros'
3-
export const githubLink = `https://github.com/${githubRepo}`
3+
export const githubLink: 'https://github.com/vue-macros/vue-macros' = `https://github.com/${githubRepo}`

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"tsx": "^4.15.7",
6161
"typescript": "~5.5.2",
6262
"unocss": "^0.61.0",
63-
"unplugin-macros": "^0.13.0",
63+
"unplugin-macros": "^0.13.1",
6464
"unplugin-raw": "^0.2.0",
6565
"vite": "^5.3.1",
6666
"vitest": "^1.6.0",

packages/api/src/resolve.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ import { type ResolveTSFileIdImpl, tsFileCache } from './ts'
77
import type { PluginContext } from 'rollup'
88
import type { ModuleNode, Plugin } from 'vite'
99

10-
export const deepImportRE = /^([^@][^/]*)\/|^(@[^/]+\/[^/]+)\//
10+
export const deepImportRE: RegExp = /^([^@][^/]*)\/|^(@[^/]+\/[^/]+)\//
1111

12-
export const RollupResolve = () => {
12+
export const RollupResolve = (): {
13+
resolve: (ctx: PluginContext) => ResolveTSFileIdImpl
14+
handleHotUpdate: NonNullable<Plugin['handleHotUpdate']>
15+
} => {
1316
const referencedFiles = new Map<
1417
string /* file */,
1518
Set<string /* importer */>

packages/api/src/ts/namespace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { type TSScope, getTSFile, resolveTSScope } from './scope'
66
import { isTSDeclaration } from './is'
77
import { resolveTSFileId } from './resolve-file'
88

9-
export const namespaceSymbol = Symbol('namespace')
9+
export const namespaceSymbol: unique symbol = Symbol('namespace')
1010
export type TSNamespace = {
1111
[K in string]: TSResolvedType | TSNamespace | undefined
1212
} & { [namespaceSymbol]: true }

packages/api/src/ts/property.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export async function resolveTSProperties({
206206
}
207207
}
208208

209-
export function getTSPropertiesKeys(properties: TSProperties) {
209+
export function getTSPropertiesKeys(properties: TSProperties): string[] {
210210
return [
211211
...new Set([
212212
...Object.keys(properties.properties),

packages/api/src/ts/resolve-file.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@ export type ResolveTSFileIdImpl = (
55
id: string,
66
importer: string,
77
) => Promise<string | undefined> | string | undefined
8-
let resolveTSFileIdImpl: ResolveTSFileIdImpl = resolveTSFileIdNode
9-
export function resolveTSFileId(id: string, importer: string) {
8+
9+
export const resolveTSFileId: ResolveTSFileIdImpl = (id, importer) => {
1010
return resolveTSFileIdImpl(id, importer)
1111
}
1212

1313
/**
1414
* @limitation don't node_modules and JavaScript file
1515
*/
16-
export function resolveTSFileIdNode(id: string, importer: string) {
16+
export const resolveTSFileIdNode: ResolveTSFileIdImpl = (
17+
id: string,
18+
importer: string,
19+
) => {
1720
function tryResolve(id: string, importer: string) {
1821
const filePath = path.resolve(importer, '..', id)
1922
if (!existsSync(filePath)) return
@@ -29,6 +32,8 @@ export function resolveTSFileIdNode(id: string, importer: string) {
2932
)
3033
}
3134

32-
export function setResolveTSFileIdImpl(impl: ResolveTSFileIdImpl) {
35+
let resolveTSFileIdImpl: ResolveTSFileIdImpl = resolveTSFileIdNode
36+
37+
export function setResolveTSFileIdImpl(impl: ResolveTSFileIdImpl): void {
3338
resolveTSFileIdImpl = impl
3439
}

packages/api/src/ts/resolve.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export async function resolveTSLiteralType({
114114
export function resolveTypeElements(
115115
scope: TSScope,
116116
elements: Array<TSTypeElement>,
117-
) {
117+
): TSProperties {
118118
const properties: TSProperties = {
119119
callSignatures: [],
120120
constructSignatures: [],
@@ -278,7 +278,7 @@ export async function resolveTSIndexedAccessType(
278278
export async function resolveTSTypeOperator(
279279
{ scope, type }: TSResolvedType<TSTypeOperator>,
280280
stacks: TSResolvedType<any>[] = [],
281-
) {
281+
): Promise<StringLiteral[] | undefined> {
282282
if (type.operator !== 'keyof') return undefined
283283

284284
const resolved = await resolveTSReferencedType(

packages/api/src/vue/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export async function inferRuntimeType(
136136
return [UNKNOWN_TYPE]
137137
}
138138

139-
export function attachNodeLoc(node: Node, newNode: Node) {
139+
export function attachNodeLoc(node: Node, newNode: Node): void {
140140
newNode.start = node.start
141141
newNode.end = node.end
142142
}
@@ -145,7 +145,7 @@ export function genRuntimePropDefinition(
145145
types: string[] | undefined,
146146
isProduction: boolean,
147147
properties: string[],
148-
) {
148+
): string {
149149
let type: string | undefined
150150
let skipCheck = false
151151

packages/better-define/src/core/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
type CodeTransform,
23
DEFINE_EMITS,
34
MagicStringAST,
45
escapeKey,
@@ -17,7 +18,7 @@ export async function transformBetterDefine(
1718
code: string,
1819
id: string,
1920
isProduction = false,
20-
) {
21+
): Promise<CodeTransform | undefined> {
2122
const s = new MagicStringAST(code)
2223
const sfc = parseSFC(code, id)
2324
if (!sfc.scriptSetup) return

0 commit comments

Comments
 (0)