Skip to content

Commit

Permalink
fix: write globalTypes into dist for correct export (#4740)
Browse files Browse the repository at this point in the history
  • Loading branch information
KazariEX authored Aug 29, 2024
1 parent ecaa9f9 commit 194e77c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/language-core/lib/codegen/script/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface ScriptCodegenOptions {
export function* generateScript(options: ScriptCodegenOptions): Generator<Code, ScriptCodegenContext> {
const ctx = createScriptCodegenContext(options);

yield `/// <reference types="${options.vueCompilerOptions.lib}/__globalTypes_${options.vueCompilerOptions.target}_${options.vueCompilerOptions.strictTemplates}" />${newLine}`;
yield `/// <reference types="${options.vueCompilerOptions.lib}/dist/__globalTypes_${options.vueCompilerOptions.target}_${options.vueCompilerOptions.strictTemplates}.d.ts" />${newLine}`;

if (options.sfc.script?.src) {
yield* generateSrc(options.sfc.script, options.sfc.script.src);
Expand Down
2 changes: 1 addition & 1 deletion packages/tsc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function run(tscPath = require.resolve('typescript/lib/tsc')) {
: options.host?.getCurrentDirectory() ?? ts.sys.getCurrentDirectory();
const libDir = require.resolve(`${vueOptions.lib}/package.json`, { paths: [rootDir] })
.slice(0, -'package.json'.length);
const globalTypesPath = `${libDir}__globalTypes_${vueOptions.target}_${vueOptions.strictTemplates}.d.ts`;
const globalTypesPath = `${libDir}dist/__globalTypes_${vueOptions.target}_${vueOptions.strictTemplates}.d.ts`;
const globalTypesContents = vue.generateGlobalTypes(vueOptions.lib, vueOptions.target, vueOptions.strictTemplates);
ts.sys.writeFile(globalTypesPath, globalTypesContents);
} catch { }
Expand Down
2 changes: 1 addition & 1 deletion packages/tsc/tests/dts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('vue-tsc-dts', () => {
: options.host?.getCurrentDirectory() ?? ts.sys.getCurrentDirectory();
const libDir = require.resolve(`${vueOptions.lib}/package.json`, { paths: [rootDir] })
.slice(0, -'package.json'.length);
const globalTypesPath = `${libDir}__globalTypes_${vueOptions.target}_${vueOptions.strictTemplates}.d.ts`;
const globalTypesPath = `${libDir}dist/__globalTypes_${vueOptions.target}_${vueOptions.strictTemplates}.d.ts`;
const globalTypesContents = vue.generateGlobalTypes(vueOptions.lib, vueOptions.target, vueOptions.strictTemplates);
ts.sys.writeFile(globalTypesPath, globalTypesContents);
} catch { }
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript-plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const plugin: ts.server.PluginModuleFactory = mods => {
try {
const libDir = require.resolve(`${options.lib}/package.json`, { paths: [proj.getCurrentDirectory()] })
.slice(0, -'package.json'.length);
const globalTypesPath = `${libDir}__globalTypes_${options.target}_${options.strictTemplates}.d.ts`;
const globalTypesPath = `${libDir}dist/__globalTypes_${options.target}_${options.strictTemplates}.d.ts`;
const globalTypesContents = vue.generateGlobalTypes(options.lib, options.target, options.strictTemplates);
proj.writeFile(globalTypesPath, globalTypesContents);
} catch { }
Expand Down

0 comments on commit 194e77c

Please sign in to comment.