File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed
packages/language-core/lib
test-workspace/tsc/vue3/defineOptions Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ function* generateConstNameOption(options: ScriptCodegenOptions): Generator<Code
66
66
yield endOfLine ;
67
67
}
68
68
else if ( options . sfc . scriptSetup ) {
69
- yield `let __VLS_name!: '${ options . fileBaseName . substring ( 0 , options . fileBaseName . lastIndexOf ( '.' ) ) } '${ endOfLine } ` ;
69
+ yield `let __VLS_name!: '${ options . scriptSetupRanges ?. options . name ?? options . fileBaseName . substring ( 0 , options . fileBaseName . lastIndexOf ( '.' ) ) } '${ endOfLine } ` ;
70
70
}
71
71
else {
72
72
yield `const __VLS_name = undefined${ endOfLine } ` ;
Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ export function parseScriptSetupRanges(
34
34
name ?: string ;
35
35
define ?: ReturnType < typeof parseDefineFunction > ;
36
36
} = { } ;
37
+ const options : {
38
+ name ?: string ;
39
+ } = { } ;
37
40
38
41
const definePropProposalA = vueCompilerOptions . experimentalDefinePropProposal === 'kevinEdition' || ast . text . trimStart ( ) . startsWith ( '// @experimentalDefinePropProposal=kevinEdition' ) ;
39
42
const definePropProposalB = vueCompilerOptions . experimentalDefinePropProposal === 'johnsonEdition' || ast . text . trimStart ( ) . startsWith ( '// @experimentalDefinePropProposal=johnsonEdition' ) ;
@@ -95,6 +98,7 @@ export function parseScriptSetupRanges(
95
98
emits,
96
99
expose,
97
100
defineProp,
101
+ options,
98
102
} ;
99
103
100
104
function _getStartEnd ( node : ts . Node ) {
@@ -259,6 +263,15 @@ export function parseScriptSetupRanges(
259
263
props . name = getNodeText ( ts , parent . name , ast ) ;
260
264
}
261
265
}
266
+ else if ( vueCompilerOptions . macros . defineOptions . includes ( callText ) ) {
267
+ if ( node . arguments . length && ts . isObjectLiteralExpression ( node . arguments [ 0 ] ) ) {
268
+ for ( const prop of node . arguments [ 0 ] . properties ) {
269
+ if ( ( ts . isPropertyAssignment ( prop ) ) && getNodeText ( ts , prop . name , ast ) === 'name' && ts . isStringLiteral ( prop . initializer ) ) {
270
+ options . name = prop . initializer . text ;
271
+ }
272
+ }
273
+ }
274
+ }
262
275
}
263
276
ts . forEachChild ( node , child => {
264
277
parents . push ( node ) ;
Original file line number Diff line number Diff line change
1
+ <script setup lang="tsx">
2
+ import { exactType } from ' tsc/shared' ;
3
+
4
+ defineOptions ({
5
+ name: ' Foo' ,
6
+ });
7
+
8
+ defineSlots <{
9
+ default: (props : { foo: 0 }) => any
10
+ }>();
11
+ </script >
12
+
13
+ <template >
14
+ <Foo v-slot =" { foo }" >
15
+ {{ exactType(foo, 0) }}
16
+ </Foo >
17
+ </template >
You can’t perform that action at this time.
0 commit comments