mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
fix(48418): allow using empty tuple (#48420)
This commit is contained in:
@@ -192,7 +192,12 @@ namespace ts.codefix {
|
||||
const program = context.program;
|
||||
const checker = program.getTypeChecker();
|
||||
const scriptTarget = getEmitScriptTarget(program.getCompilerOptions());
|
||||
const flags = NodeBuilderFlags.NoTruncation | NodeBuilderFlags.NoUndefinedOptionalParameterType | NodeBuilderFlags.SuppressAnyReturnType | (quotePreference === QuotePreference.Single ? NodeBuilderFlags.UseSingleQuotesForStringLiteralType : 0);
|
||||
const flags =
|
||||
NodeBuilderFlags.NoTruncation
|
||||
| NodeBuilderFlags.NoUndefinedOptionalParameterType
|
||||
| NodeBuilderFlags.SuppressAnyReturnType
|
||||
| NodeBuilderFlags.AllowEmptyTuple
|
||||
| (quotePreference === QuotePreference.Single ? NodeBuilderFlags.UseSingleQuotesForStringLiteralType : NodeBuilderFlags.None);
|
||||
const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, kind, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)) as ArrowFunction | FunctionExpression | MethodDeclaration;
|
||||
if (!signatureDeclaration) {
|
||||
return undefined;
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////export interface Foo<T> {
|
||||
//// z(...args: T extends unknown[] ? T : [T]);
|
||||
////}
|
||||
////export interface Bar {
|
||||
//// a(foo: Foo<[number]>): void;
|
||||
//// b(foo: Foo<[]>): void;
|
||||
//// c(foo: Foo<number>): void;
|
||||
////}
|
||||
////[|const bar: Bar = {};|]
|
||||
|
||||
verify.codeFix({
|
||||
index: 0,
|
||||
description: ts.Diagnostics.Add_missing_properties.message,
|
||||
newRangeContent:
|
||||
`const bar: Bar = {
|
||||
a: function(foo: Foo<[number]>): void {
|
||||
throw new Error("Function not implemented.");
|
||||
},
|
||||
b: function(foo: Foo<[]>): void {
|
||||
throw new Error("Function not implemented.");
|
||||
},
|
||||
c: function(foo: Foo<number>): void {
|
||||
throw new Error("Function not implemented.");
|
||||
}
|
||||
};`,
|
||||
});
|
||||
Reference in New Issue
Block a user