Skip to content

Commit

Permalink
Revert "feat: enabled experimentalShamefullySupportOptionsApi by de…
Browse files Browse the repository at this point in the history
…fault but show warning"

This reverts commit e361bdd.
#1291
  • Loading branch information
johnsoncodehk committed May 11, 2022
1 parent b1c6b34 commit 3e434c7
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 31 deletions.
Expand Up @@ -17,11 +17,7 @@
"markdownDescription": "https://github.com/johnsoncodehk/volar/pull/351"
},
"experimentalShamefullySupportOptionsApi": {
"enum": [
true,
false,
"warning"
],
"type": "boolean",
"markdownDescription": "Support intellisense components that export options without `Vue.extend` and `defineComponent`. This is essentially a hack and not recommended to use it."
},
"experimentalTemplateCompilerOptions": {
Expand Down
3 changes: 0 additions & 3 deletions packages/vue-code-gen/src/generators/script.ts
Expand Up @@ -32,7 +32,6 @@ export function generate(
mergePropDefaults: false,
ConstructorOverloads: false,
};
let shimedComponentOptions = false;

if (lsType === 'template') {
codeGen.addText('// @ts-nocheck\n');
Expand Down Expand Up @@ -126,7 +125,6 @@ export function generate(
return {
codeGen,
teleports,
shimedComponentOptions,
};

function writeScriptSrc() {
Expand Down Expand Up @@ -174,7 +172,6 @@ export function generate(
isExportRawObject = script.content.substring(scriptRanges.exportDefault.expression.start, scriptRanges.exportDefault.expression.end).startsWith('{');
}
if (isExportRawObject && shimComponentOptions && scriptRanges?.exportDefault) {
shimedComponentOptions = true;
addVirtualCode('script', 0, scriptRanges.exportDefault.expression.start);
codeGen.addText(`(await import('${vueLibName}')).defineComponent(`);
addVirtualCode('script', scriptRanges.exportDefault.expression.start, scriptRanges.exportDefault.expression.end);
Expand Down
1 change: 0 additions & 1 deletion packages/vue-language-service/src/documentService.ts
Expand Up @@ -47,7 +47,6 @@ export function getDocumentService(
const vuePlugin = useVuePlugin({
getVueDocument,
tsLs: undefined,
vueCompilerOptions: {},
});
const htmlPlugin = useHtmlPlugin({
fileSystemProvider,
Expand Down
1 change: 0 additions & 1 deletion packages/vue-language-service/src/languageService.ts
Expand Up @@ -104,7 +104,6 @@ export function createLanguageService(
const vuePlugin = useVuePlugin({
getVueDocument: (document) => vueDocuments.get(document.uri),
tsLs,
vueCompilerOptions: vueLsHost.getVueCompilationSettings(),
});
const vueTemplateHtmlPlugin = _useVueTemplateLanguagePlugin(
'html',
Expand Down
17 changes: 0 additions & 17 deletions packages/vue-language-service/src/plugins/vue.ts
@@ -1,7 +1,6 @@
import * as shared from '@volar/shared';
import type * as ts2 from '@volar/typescript-language-service';
import { EmbeddedLanguageServicePlugin } from '@volar/vue-language-service-types';
import type { VueCompilerOptions } from '@volar/vue-typescript';
import * as html from 'vscode-html-languageservice';
import * as vscode from 'vscode-languageserver-protocol';
import { TextDocument } from 'vscode-languageserver-textdocument';
Expand Down Expand Up @@ -96,7 +95,6 @@ const dataProvider = html.newHTMLDataProvider('vue', {
export default function (options: {
getVueDocument(document: TextDocument): VueDocument | undefined,
tsLs: ts2.LanguageService | undefined,
vueCompilerOptions: VueCompilerOptions,
}): EmbeddedLanguageServicePlugin {

const htmlPlugin = useHtmlPlugin({
Expand Down Expand Up @@ -165,21 +163,6 @@ export default function (options: {
result.push(error);
}

const scriptRanges = vueDocument.file.getScriptRanges();
if (sfc.script && scriptRanges?.exportDefault && vueDocument.file.refs.sfcScriptForScriptLs.codeGen.value.shimedComponentOptions && (options.vueCompilerOptions.experimentalShamefullySupportOptionsApi ?? 'warning') === 'warning') {
const error = vscode.Diagnostic.create(
{
start: document.positionAt(sfc.script.startTagEnd + scriptRanges.exportDefault.expression.start),
end: document.positionAt(sfc.script.startTagEnd + scriptRanges.exportDefault.expression.start),
},
'Component options are wrapped by `defineComponent()` internally to support intellisense on IDE for backward compatible, but this is an hacking which lead to this component type inconsistent with same script code on .js / .ts. Recommended wrap component options by `Vue.extends()` or `defineComponent()`. Or you can configure `"experimentalShamefullySupportOptionsApi": true / false` in `"vueCompilerOptions"` property in tsconfig / jsconfig to disable this warning.',
vscode.DiagnosticSeverity.Warning,
undefined,
'volar',
);
result.push(error);
}

return result;
});
},
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-typescript/src/types.ts
Expand Up @@ -12,7 +12,7 @@ export interface ITemplateScriptData {

export interface VueCompilerOptions {
experimentalCompatMode?: 2 | 3;
experimentalShamefullySupportOptionsApi?: boolean | 'warning';
experimentalShamefullySupportOptionsApi?: boolean;
experimentalTemplateCompilerOptions?: any;
experimentalTemplateCompilerOptionsRequirePath?: string;
experimentalDisableTemplateSupport?: boolean;
Expand Down
3 changes: 1 addition & 2 deletions packages/vue-typescript/src/use/useSfcScriptGen.ts
Expand Up @@ -46,7 +46,7 @@ export function useSfcScriptGen<T extends 'template' | 'script'>(
return bindTexts;
},
getVueLibraryName(compilerOptions.experimentalCompatMode === 2),
compilerOptions.experimentalShamefullySupportOptionsApi === undefined ? true : !!compilerOptions.experimentalShamefullySupportOptionsApi,
!!compilerOptions.experimentalShamefullySupportOptionsApi,
)
);
const file = computed(() => {
Expand Down Expand Up @@ -112,7 +112,6 @@ export function useSfcScriptGen<T extends 'template' | 'script'>(
});

return {
codeGen,
lang,
file: file as T extends 'script' ? ComputedRef<EmbeddedFile<undefined>> : ComputedRef<EmbeddedFile<undefined> | undefined>,
embedded,
Expand Down
1 change: 0 additions & 1 deletion packages/vue-typescript/src/vueFile.ts
Expand Up @@ -355,7 +355,6 @@ export function createVueFile(
getEmbeddeds: untrack(() => embeddeds.value),
getAllEmbeddeds: untrack(() => allEmbeddeds.value),
getLastUpdated: untrack(() => unref(lastUpdated)),
getScriptRanges: untrack(() => scriptRanges.value),
getScriptSetupRanges: untrack(() => scriptSetupRanges.value),
getSfcTemplateDocument: untrack(() => sfcTemplate.file.value),
isJsxMissing: () => !compilerOptions.experimentalDisableTemplateSupport && !(tsHost?.getCompilationSettings().jsx === ts.JsxEmit.Preserve),
Expand Down

0 comments on commit 3e434c7

Please sign in to comment.