mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-13 02:45:24 -05:00
feat(49385): forbid inlay hints for some kind of initialized declarations (#49412)
.
This commit is contained in:
@@ -1,15 +1,25 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// const a/*a*/ = 123;
|
||||
////class C {}
|
||||
////namespace N { export class Foo {} }
|
||||
////interface Foo {}
|
||||
|
||||
const markers = test.markers();
|
||||
verify.getInlayHints([
|
||||
{
|
||||
text: ': 123',
|
||||
position: markers[0].position,
|
||||
kind: ts.InlayHintKind.Type,
|
||||
whitespaceBefore: true
|
||||
},
|
||||
], undefined, {
|
||||
////const a = "a";
|
||||
////const b = 1;
|
||||
////const c = true;
|
||||
////
|
||||
////const d = {} as Foo;
|
||||
////const e = <Foo>{};
|
||||
////const f = {} as const;
|
||||
////const g = (({} as const));
|
||||
////
|
||||
////const h = new C();
|
||||
////const i = new N.C();
|
||||
////const j = ((((new C()))));
|
||||
////
|
||||
////const k = { a: 1, b: 1 };
|
||||
////const l = ((({ a: 1, b: 1 })));
|
||||
|
||||
verify.getInlayHints([], undefined, {
|
||||
includeInlayVariableTypeHints: true
|
||||
});
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// const a/*a*/ = 123;
|
||||
|
||||
const markers = test.markers();
|
||||
verify.getInlayHints([
|
||||
{
|
||||
text: ': 123',
|
||||
position: markers[0].position,
|
||||
kind: ts.InlayHintKind.Type,
|
||||
whitespaceBefore: true
|
||||
},
|
||||
], undefined, {
|
||||
includeInlayVariableTypeHints: true
|
||||
});
|
||||
@@ -1,15 +1,7 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// const a/*a*/ = { a: 123 };
|
||||
//// const a = { a: 123 };
|
||||
|
||||
const markers = test.markers();
|
||||
verify.getInlayHints([
|
||||
{
|
||||
text: ': { a: number; }',
|
||||
position: markers[0].position,
|
||||
kind: ts.InlayHintKind.Type,
|
||||
whitespaceBefore: true
|
||||
},
|
||||
], undefined, {
|
||||
verify.getInlayHints([], undefined, {
|
||||
includeInlayVariableTypeHints: true
|
||||
});
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// class Class {}
|
||||
//// const a/*a*/ = new Class();
|
||||
//// const a = new Class();
|
||||
|
||||
const markers = test.markers();
|
||||
verify.getInlayHints([
|
||||
{
|
||||
text: ': Class',
|
||||
position: markers[0].position,
|
||||
kind: ts.InlayHintKind.Type,
|
||||
whitespaceBefore: true
|
||||
},
|
||||
], undefined, {
|
||||
verify.getInlayHints([], undefined, {
|
||||
includeInlayVariableTypeHints: true
|
||||
});
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// const a/*a*/ = "I'm very very very very very very very very very long";
|
||||
////const a = "I'm very very very very very very very very very long";
|
||||
|
||||
const markers = test.markers();
|
||||
verify.getInlayHints([
|
||||
{
|
||||
text: `: "I'm very very very very ve...`,
|
||||
position: markers[0].position,
|
||||
kind: ts.InlayHintKind.Type,
|
||||
whitespaceBefore: true
|
||||
},
|
||||
], undefined, {
|
||||
verify.getInlayHints([], undefined, {
|
||||
includeInlayVariableTypeHints: true
|
||||
});
|
||||
|
||||
@@ -1,37 +1,31 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// const object/*a*/ = { foo: 1, bar: 2 }
|
||||
//// const array/*b*/ = [1, 2]
|
||||
//// const a/*c*/ = object;
|
||||
//// const object = { foo: 1, bar: 2 }
|
||||
//// const array/*a*/ = [1, 2]
|
||||
//// const a/*b*/ = object;
|
||||
//// const { foo, bar } = object;
|
||||
//// const {} = object;
|
||||
//// const b/*d*/ = array;
|
||||
//// const b/*c*/ = array;
|
||||
//// const [ first, second ] = array;
|
||||
//// const [] = array;
|
||||
|
||||
const markers = test.markers();
|
||||
verify.getInlayHints([
|
||||
{
|
||||
text: ': { foo: number; bar: number; }',
|
||||
text: ': number[]',
|
||||
position: markers[0].position,
|
||||
kind: ts.InlayHintKind.Type,
|
||||
whitespaceBefore: true
|
||||
},
|
||||
{
|
||||
text: ': number[]',
|
||||
text: ': { foo: number; bar: number; }',
|
||||
position: markers[1].position,
|
||||
kind: ts.InlayHintKind.Type,
|
||||
whitespaceBefore: true
|
||||
},
|
||||
{
|
||||
text: ': { foo: number; bar: number; }',
|
||||
position: markers[2].position,
|
||||
kind: ts.InlayHintKind.Type,
|
||||
whitespaceBefore: true
|
||||
},
|
||||
{
|
||||
text: ': number[]',
|
||||
position: markers[3].position,
|
||||
position: markers[2].position,
|
||||
kind: ts.InlayHintKind.Type,
|
||||
whitespaceBefore: true
|
||||
}
|
||||
|
||||
@@ -1,21 +1,15 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// type F = (a: string, b: number) => void
|
||||
//// const f: F = (a/*a*/, b/*b*/ = 1) => { }
|
||||
//// const f: F = (a/*a*/, b = 1) => { }
|
||||
|
||||
const [a, b] = test.markers();
|
||||
const [a] = test.markers();
|
||||
verify.getInlayHints([
|
||||
{
|
||||
text: ': string',
|
||||
position: a.position,
|
||||
kind: ts.InlayHintKind.Type,
|
||||
whitespaceBefore: true
|
||||
},
|
||||
{
|
||||
text: ': number',
|
||||
position: b.position,
|
||||
kind: ts.InlayHintKind.Type,
|
||||
whitespaceBefore: true
|
||||
}
|
||||
], undefined, {
|
||||
includeInlayFunctionParameterTypeHints: true
|
||||
|
||||
25
tests/cases/fourslash/inlayHintsShouldWork69.ts
Normal file
25
tests/cases/fourslash/inlayHintsShouldWork69.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////class C {}
|
||||
////namespace N { export class Foo {} }
|
||||
////interface Foo {}
|
||||
|
||||
////function f1(a = 1) {}
|
||||
////function f2(a = "a") {}
|
||||
////function f3(a = true) {}
|
||||
|
||||
////function f4(a = { } as Foo) {}
|
||||
////function f5(a = <Foo>{}) {}
|
||||
////function f6(a = {} as const) {}
|
||||
////function f7(a = (({} as const))) {}
|
||||
|
||||
////function f8(a = new C()) {}
|
||||
////function f9(a = new N.C()) {}
|
||||
////function f10(a = ((((new C()))))) {}
|
||||
|
||||
////function f11(a = { a: 1, b: 1 }) {}
|
||||
////function f12(a = ((({ a: 1, b: 1 })))) {}
|
||||
|
||||
verify.getInlayHints([], undefined, {
|
||||
includeInlayFunctionParameterTypeHints: true
|
||||
});
|
||||
Reference in New Issue
Block a user