File tree Expand file tree Collapse file tree 2 files changed +25
-9
lines changed Expand file tree Collapse file tree 2 files changed +25
-9
lines changed Original file line number Diff line number Diff line change @@ -25,3 +25,10 @@ export type { AliasType } from '@alias/type'
2525
2626export type * from './namespace'
2727export type * from './modules'
28+
29+ declare module '@/test' {
30+ interface TestBase {
31+ name : string ,
32+ mail ?: string
33+ }
34+ }
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ function transformAlias(
5353 aliasesExclude : ( string | RegExp ) [ ]
5454) {
5555 if (
56- aliases . length &&
56+ aliases ? .length &&
5757 ! aliasesExclude . some ( e => ( isRegExp ( e ) ? e . test ( importer ) : String ( e ) === importer ) )
5858 ) {
5959 const matchedAlias = aliases . find ( alias => isAliasMatch ( alias , importer ) )
@@ -245,14 +245,23 @@ export function transformCode(options: {
245245 node . body . statements . some ( isVLSNode )
246246 ) {
247247 s . remove ( node . pos , node . end )
248- } else if (
249- node . modifiers ?. [ 0 ] &&
250- node . modifiers [ 0 ] . kind === ts . SyntaxKind . DeclareKeyword &&
251- ! node . body . statements . some (
252- s => ts . isExportAssignment ( s ) || ts . isExportDeclaration ( s ) || ts . isImportDeclaration ( s )
253- )
254- ) {
255- declareModules . push ( s . slice ( node . pos , node . end + 1 ) )
248+ } else if ( ts . isStringLiteral ( node . name ) ) {
249+ const libName = toLibName ( node . name . text )
250+
251+ if ( libName !== node . name . text ) {
252+ s . update ( node . name . pos , node . name . end , ` '${ libName } '` )
253+ }
254+
255+ if (
256+ ! libName . startsWith ( '.' ) &&
257+ node . modifiers ?. [ 0 ] &&
258+ node . modifiers [ 0 ] . kind === ts . SyntaxKind . DeclareKeyword &&
259+ ! node . body . statements . some (
260+ s => ts . isExportAssignment ( s ) || ts . isExportDeclaration ( s ) || ts . isImportDeclaration ( s )
261+ )
262+ ) {
263+ declareModules . push ( s . slice ( node . pos , node . end + 1 ) )
264+ }
256265 }
257266
258267 return false
You can’t perform that action at this time.
0 commit comments