Skip to content

Commit 8fe3ad4

Browse files
refactor(core): rename common.d.ts into types.ts
1 parent cd0a14b commit 8fe3ad4

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

src/createVue3SFCModule.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
compileTemplate as sfc_compileTemplate,
77
SFCAsyncStyleCompileOptions,
88
SFCTemplateCompileOptions,
9-
// SFCBlock
9+
SFCBlock
1010
} from '@vue/compiler-sfc'
1111

1212
import {
@@ -30,7 +30,7 @@ import babelPluginTransformModulesCommonjs from '@babel/plugin-transform-modules
3030

3131
import { formatError, withCache, hash, renameDynamicImport, parseDeps, interopRequireDefault, transformJSCode, loadDeps, createModule } from './tools.ts'
3232

33-
import { Options, LoadModule, ModuleExport, CustomBlockCallback } from './common.d.ts'
33+
import { Options, LoadModule, ModuleExport, CustomBlockCallback } from './types.ts'
3434

3535

3636
/**
@@ -74,7 +74,7 @@ export async function createSFCModule(source : string, filename : string, option
7474
});
7575

7676

77-
const customBlockCallbacks : CustomBlockCallback[] = customBlockHandler !== undefined ? await Promise.all( descriptor.customBlocks.map(block => customBlockHandler(block, filename, options)) ) : [];
77+
const customBlockCallbacks : CustomBlockCallback[] = customBlockHandler !== undefined ? await Promise.all( descriptor.customBlocks.map((block : SFCBlock) => customBlockHandler(block, filename, options)) ) : [];
7878

7979
const componentHash = hash(filename, version);
8080
const scopeId = `data-v-${componentHash}`;

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { posix as Path } from 'path'
33
import { createJSModule } from './tools.ts'
44
import { createSFCModule } from './createSFCModule.ts'
55

6-
import { ModuleExport, ModuleHandler, PathHandlers, Options } from './common.d.ts'
6+
import { ModuleExport, ModuleHandler, PathHandlers, Options } from './types.ts'
77

88
/**
99
* the version of the library (process.env.VERSION is set by webpack, at compile-time)

src/tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import babelPluginTransformModulesCommonjs from '@babel/plugin-transform-modules
2525
import SparkMD5 from 'spark-md5'
2626

2727

28-
import { Cache, ValueFactory, Options, LoadModule, ModuleExport } from './common.d.ts'
28+
import { Cache, ValueFactory, Options, LoadModule, ModuleExport } from './types.ts'
2929

3030

3131
/**

src/common.d.ts renamed to src/types.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22
/**
33
* @internal
44
*/
5-
interface ValueFactoryApi {
5+
export interface ValueFactoryApi {
66
preventCache() : void,
77
}
88

99

1010
/**
1111
* @internal
1212
*/
13-
interface ValueFactory {
13+
export interface ValueFactory {
1414
(api : ValueFactoryApi): Promise<any>;
1515
}
1616

1717

18-
interface Cache {
18+
export interface Cache {
1919
get(key : string) : Promise<string>,
2020
set(key : string, value : string) : Promise<void>,
2121
}
2222

2323

24-
interface PathHandlers {
24+
export interface PathHandlers {
2525
extname(filepath : string) : string,
2626
/*
2727
* relative to absolute module path resolution.
@@ -49,21 +49,22 @@ interface PathHandlers {
4949
* ...
5050
* ```
5151
*/
52-
interface ModuleHandler {
52+
export interface ModuleHandler {
5353
(source : string, path : string, options : Options) : Promise<ModuleExport>;
5454
}
5555

5656

5757
/**
5858
* Represents the content of the file or the content and the extension name.
5959
*/
60-
type File = string | { content : string, extname : string };
60+
export type File = string | { content : string, extname : string };
6161

6262

6363
/**
6464
* CustomBlockCallback function type
6565
*/
66-
type CustomBlockCallback = ( component : any ) => undefined;
66+
export type CustomBlockCallback = ( component : ModuleExport ) => void;
67+
6768

6869
/**
6970
* This just represents a loaded js module exports
@@ -74,7 +75,7 @@ export interface ModuleExport {
7475
/**
7576
* This just represents a loaded js module
7677
*/
77-
interface Module {
78+
export interface Module {
7879
exports : ModuleExport,
7980
}
8081

@@ -314,4 +315,4 @@ export interface Options {
314315
}
315316

316317

317-
type LoadModule = (path : string, options : Options) => Promise<ModuleExport>;
318+
export type LoadModule = (path : string, options : Options) => Promise<ModuleExport>;

0 commit comments

Comments
 (0)