Skip to content

feat(language-core): add options for fine-grained configuration of strictTemplates #5138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
326c42b
feat: split `strictTemplates`
KazariEX Sep 25, 2024
13ce8c4
fix: resolve file name
KazariEX Sep 25, 2024
01fc1b8
chore: add schema
KazariEX Sep 25, 2024
08e22d9
Merge branch 'master' of https://github.com/vuejs/language-tools into…
KazariEX Oct 25, 2024
710976a
refactor: merge options
KazariEX Oct 25, 2024
25c2684
chore: lint
KazariEX Oct 25, 2024
44ca0e1
fix: typo
KazariEX Dec 8, 2024
cb3fc1c
Merge branch 'master' of https://github.com/vuejs/language-tools into…
KazariEX Jan 22, 2025
f9584ba
Merge branch 'feat/split-strictTemplates' of https://github.com/Kazar…
KazariEX Jan 22, 2025
5543ae7
fix(language-core): resolve vue compiler options correctly
KazariEX Jan 22, 2025
c5ef97c
refactor: rename
KazariEX Jan 22, 2025
297305a
fix: not export
KazariEX Jan 22, 2025
073afe8
refactor: rename resolveGlobalTypesName to getGlobalTypesFileName
johnsoncodehk Jan 22, 2025
33b6dcf
refactor: move default value of `experimentalModelPropName`
KazariEX Jan 22, 2025
0773d89
Merge branch 'feat/split-strictTemplates' of https://github.com/Kazar…
KazariEX Jan 22, 2025
08ee40f
Merge branch 'master' into pr/4880
johnsoncodehk Jan 22, 2025
885b315
refactor(language-core): replace strictTemplates with checkUnknownPro…
johnsoncodehk Jan 22, 2025
9dec893
refactor(language-core): simplify global types filename generation
johnsoncodehk Jan 22, 2025
9499f41
refactor(language-core): shorter global types filename
johnsoncodehk Jan 22, 2025
fa83057
Update vue-tsconfig.schema.json
johnsoncodehk Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/component-meta/lib/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export function baseCreate(
const directoryExists = languageServiceHost.directoryExists?.bind(languageServiceHost);
const fileExists = languageServiceHost.fileExists.bind(languageServiceHost);
const getScriptSnapshot = languageServiceHost.getScriptSnapshot.bind(languageServiceHost);
const globalTypesName = vue.resolveGlobalTypesName(commandLine.vueOptions);
const globalTypesName = vue.getGlobalTypesFileName(commandLine.vueOptions);
const globalTypesContents = `// @ts-nocheck\nexport {};\n` + vue.generateGlobalTypes(commandLine.vueOptions);
const globalTypesSnapshot: ts.IScriptSnapshot = {
getText: (start, end) => globalTypesContents.slice(start, end),
Expand Down
2 changes: 1 addition & 1 deletion packages/language-core/lib/codegen/globalTypes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { VueCompilerOptions } from '../types';
import { getSlotsPropertyName } from '../utils/shared';

export function resolveGlobalTypesName(options: VueCompilerOptions) {
export function getGlobalTypesFileName(options: VueCompilerOptions) {
const { lib, target, strictTemplates } = options;
return `${lib}_${target}_${strictTemplates.attributes}_${strictTemplates.components}.d.ts`;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/language-core/lib/codegen/script/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type * as ts from 'typescript';
import type { ScriptRanges } from '../../parsers/scriptRanges';
import type { ScriptSetupRanges } from '../../parsers/scriptSetupRanges';
import type { Code, Sfc, VueCodeInformation, VueCompilerOptions } from '../../types';
import { generateGlobalTypes, resolveGlobalTypesName } from '../globalTypes';
import { generateGlobalTypes, getGlobalTypesFileName } from '../globalTypes';
import type { TemplateCodegenContext } from '../template/context';
import { endOfLine, generateSfcBlockSection, newLine } from '../utils';
import { generateComponentSelf } from './componentSelf';
Expand Down Expand Up @@ -68,7 +68,7 @@ export function* generateScript(options: ScriptCodegenOptions): Generator<Code,
yield `/// <reference types="${relativePath}" />${newLine}`;
}
else {
yield `/// <reference types=".vue-global-types/${resolveGlobalTypesName(options.vueCompilerOptions)}" />${newLine}`;
yield `/// <reference types=".vue-global-types/${getGlobalTypesFileName(options.vueCompilerOptions)}" />${newLine}`;
}
}
else {
Expand Down
4 changes: 2 additions & 2 deletions packages/language-core/lib/utils/ts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { camelize } from '@vue/shared';
import { posix as path } from 'path-browserify';
import type * as ts from 'typescript';
import { generateGlobalTypes, resolveGlobalTypesName } from '../codegen/globalTypes';
import { generateGlobalTypes, getGlobalTypesFileName } from '../codegen/globalTypes';
import { getAllExtensions } from '../languagePlugin';
import type { RawVueCompilerOptions, VueCompilerOptions, VueLanguagePlugin } from '../types';

Expand Down Expand Up @@ -318,7 +318,7 @@ export function setupGlobalTypes(rootDir: string, vueOptions: VueCompilerOptions
}
dir = parentDir;
}
const globalTypesPath = path.join(dir, 'node_modules', '.vue-global-types', resolveGlobalTypesName(vueOptions));
const globalTypesPath = path.join(dir, 'node_modules', '.vue-global-types', getGlobalTypesFileName(vueOptions));
const globalTypesContents = `// @ts-nocheck\nexport {};\n` + generateGlobalTypes(vueOptions);
host.writeFile(globalTypesPath, globalTypesContents);
return { absolutePath: globalTypesPath };
Expand Down
4 changes: 2 additions & 2 deletions packages/language-server/lib/initialize.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { LanguageServer } from '@volar/language-server';
import { createTypeScriptProject } from '@volar/language-server/node';
import { createParsedCommandLine, createVueLanguagePlugin, generateGlobalTypes, getAllExtensions, resolveGlobalTypesName, resolveVueCompilerOptions, VueCompilerOptions } from '@vue/language-core';
import { createParsedCommandLine, createVueLanguagePlugin, generateGlobalTypes, getAllExtensions, getGlobalTypesFileName, resolveVueCompilerOptions, VueCompilerOptions } from '@vue/language-core';
import { Disposable, getFullLanguageServicePlugins, InitializeParams } from '@vue/language-service';
import type * as ts from 'typescript';

Expand Down Expand Up @@ -55,7 +55,7 @@ export function initialize(
const directoryExists = project.typescript.languageServiceHost.directoryExists?.bind(project.typescript.languageServiceHost);
const fileExists = project.typescript.languageServiceHost.fileExists.bind(project.typescript.languageServiceHost);
const getScriptSnapshot = project.typescript.languageServiceHost.getScriptSnapshot.bind(project.typescript.languageServiceHost);
const globalTypesName = resolveGlobalTypesName(vueCompilerOptions);
const globalTypesName = getGlobalTypesFileName(vueCompilerOptions);
const globalTypesContents = `// @ts-nocheck\nexport {};\n` + generateGlobalTypes(vueCompilerOptions);
const globalTypesSnapshot: ts.IScriptSnapshot = {
getText: (start, end) => globalTypesContents.slice(start, end),
Expand Down
Loading