Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
more fixes
  • Loading branch information
gabritto committed Sep 9, 2025
commit b0eba8bda60a42ee28b9e211c4f244d72cfdc8ca
2 changes: 1 addition & 1 deletion internal/fourslash/_scripts/convertFourslash.mts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function getTestInput(content: string): string {
}

// chomp leading spaces
if (!testInput.some(line => line.length != 0 && !line.startsWith(" ") && !line.startsWith("// "))) {
if (!testInput.some(line => line.length != 0 && !line.startsWith(" ") && !line.startsWith("// ") && !line.startsWith("//@"))) {
testInput = testInput.map(line => {
if (line.startsWith(" ")) return line.substring(1);
return line;
Expand Down
2 changes: 1 addition & 1 deletion internal/fourslash/baselineutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func getBaselineOptions(command string) baseline.Options {
IsSubmodule: true,
DiffFixupOld: func(s string) string {
var commandLines []string
commandPrefix := regexp.MustCompile(`// === ([a-z\sA-Z]*) ===`)
commandPrefix := regexp.MustCompile(`^// === ([a-z\sA-Z]*) ===`)
testFilePrefix := "/tests/cases/fourslash"
contextSpanOpening := "<|"
contextSpanClosing := "|>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ func TestJsxElementMissingOpeningTagNoCrash(t *testing.T) {

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `//@Filename: file.tsx
declare function Foo(): any;
let x = <></Fo/*$*/o>;`
declare function Foo(): any;
let x = <></Fo/*$*/o>;`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyQuickInfoAt(t, "$", "let Foo: any", "")
}
14 changes: 7 additions & 7 deletions internal/fourslash/tests/gen/tsxCompletion10_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ func TestTsxCompletion10(t *testing.T) {

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `//@Filename: file.tsx
declare module JSX {
interface Element { }
interface IntrinsicElements {
div: { ONE: string; TWO: number; }
}
}
var x1 = <div><//**/`
declare module JSX {
interface Element { }
interface IntrinsicElements {
div: { ONE: string; TWO: number; }
}
}
var x1 = <div><//**/`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{
IsIncomplete: false,
Expand Down
6 changes: 3 additions & 3 deletions internal/fourslash/tests/gen/tsxCompletion11_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ func TestTsxCompletion11(t *testing.T) {
const content = `//@module: commonjs
//@jsx: preserve
//@Filename: exporter.tsx
export class Thing { }
export class Thing { }
//@Filename: file.tsx
import {Thing} from './exporter';
var x1 = <div></**/`
import {Thing} from './exporter';
var x1 = <div></**/`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{
IsIncomplete: false,
Expand Down
34 changes: 17 additions & 17 deletions internal/fourslash/tests/gen/tsxCompletion12_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ func TestTsxCompletion12(t *testing.T) {
const content = `//@Filename: file.tsx
// @jsx: preserve
// @noLib: true
declare module JSX {
interface Element { }
interface IntrinsicElements {
}
interface ElementAttributesProperty { props; }
}
interface OptionPropBag {
propx: number
propString: "hell"
optional?: boolean
}
declare function Opt(attributes: OptionPropBag): JSX.Element;
let opt = <Opt /*1*/ />;
let opt1 = <Opt prop/*2*/ />;
let opt2 = <Opt propx={100} /*3*/ />;
let opt3 = <Opt propx={100} optional /*4*/ />;
let opt4 = <Opt wrong /*5*/ />;`
declare module JSX {
interface Element { }
interface IntrinsicElements {
}
interface ElementAttributesProperty { props; }
}
interface OptionPropBag {
propx: number
propString: "hell"
optional?: boolean
}
declare function Opt(attributes: OptionPropBag): JSX.Element;
let opt = <Opt /*1*/ />;
let opt1 = <Opt prop/*2*/ />;
let opt2 = <Opt propx={100} /*3*/ />;
let opt3 = <Opt propx={100} optional /*4*/ />;
let opt4 = <Opt wrong /*5*/ />;`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyCompletions(t, []string{"1", "2", "5"}, &fourslash.CompletionsExpectedList{
IsIncomplete: false,
Expand Down
50 changes: 25 additions & 25 deletions internal/fourslash/tests/gen/tsxCompletion13_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,31 @@ func TestTsxCompletion13(t *testing.T) {
const content = `//@Filename: file.tsx
// @jsx: preserve
// @skipLibCheck: true
declare module JSX {
interface Element { }
interface IntrinsicElements {
}
interface ElementAttributesProperty { props; }
}
interface ClickableProps {
children?: string;
className?: string;
}
interface ButtonProps extends ClickableProps {
onClick(event?: React.MouseEvent<HTMLButtonElement>): void;
}
interface LinkProps extends ClickableProps {
goTo: string;
}
declare function MainButton(buttonProps: ButtonProps): JSX.Element;
declare function MainButton(linkProps: LinkProps): JSX.Element;
declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
let opt = <MainButton /*1*/ />;
let opt = <MainButton children="chidlren" /*2*/ />;
let opt = <MainButton onClick={()=>{}} /*3*/ />;
let opt = <MainButton onClick={()=>{}} ignore-prop /*4*/ />;
let opt = <MainButton goTo="goTo" /*5*/ />;
let opt = <MainButton wrong /*6*/ />;`
declare module JSX {
interface Element { }
interface IntrinsicElements {
}
interface ElementAttributesProperty { props; }
}
interface ClickableProps {
children?: string;
className?: string;
}
interface ButtonProps extends ClickableProps {
onClick(event?: React.MouseEvent<HTMLButtonElement>): void;
}
interface LinkProps extends ClickableProps {
goTo: string;
}
declare function MainButton(buttonProps: ButtonProps): JSX.Element;
declare function MainButton(linkProps: LinkProps): JSX.Element;
declare function MainButton(props: ButtonProps | LinkProps): JSX.Element;
let opt = <MainButton /*1*/ />;
let opt = <MainButton children="chidlren" /*2*/ />;
let opt = <MainButton onClick={()=>{}} /*3*/ />;
let opt = <MainButton onClick={()=>{}} ignore-prop /*4*/ />;
let opt = <MainButton goTo="goTo" /*5*/ />;
let opt = <MainButton wrong /*6*/ />;`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyCompletions(t, []string{"1", "6"}, &fourslash.CompletionsExpectedList{
IsIncomplete: false,
Expand Down
30 changes: 15 additions & 15 deletions internal/fourslash/tests/gen/tsxCompletion14_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ func TestTsxCompletion14(t *testing.T) {
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `//@module: commonjs
//@jsx: preserve
declare module JSX {
interface Element { }
interface IntrinsicElements {
}
interface ElementAttributesProperty { props; }
}
declare module JSX {
interface Element { }
interface IntrinsicElements {
}
interface ElementAttributesProperty { props; }
}
//@Filename: exporter.tsx
export class Thing { props: { ONE: string; TWO: number } }
export module M {
export declare function SFCComp(props: { Three: number; Four: string }): JSX.Element;
}
export class Thing { props: { ONE: string; TWO: number } }
export module M {
export declare function SFCComp(props: { Three: number; Four: string }): JSX.Element;
}
//@Filename: file.tsx
import * as Exp from './exporter';
var x1 = <Exp.Thing /*1*/ />;
var x2 = <Exp.M.SFCComp /*2*/ />;
var x3 = <Exp.Thing /*3*/ ></Exp.Thing>;
var x4 = <Exp.M.SFCComp /*4*/ ></Exp.M.SFCComp>;`
import * as Exp from './exporter';
var x1 = <Exp.Thing /*1*/ />;
var x2 = <Exp.M.SFCComp /*2*/ />;
var x3 = <Exp.Thing /*3*/ ></Exp.Thing>;
var x4 = <Exp.M.SFCComp /*4*/ ></Exp.M.SFCComp>;`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyCompletions(t, []string{"1", "3"}, &fourslash.CompletionsExpectedList{
IsIncomplete: false,
Expand Down
44 changes: 22 additions & 22 deletions internal/fourslash/tests/gen/tsxCompletion15_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@ func TestTsxCompletion15(t *testing.T) {
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `//@module: commonjs
//@jsx: preserve
declare module JSX {
interface Element { }
interface IntrinsicElements {
}
interface ElementAttributesProperty { props; }
}
declare module JSX {
interface Element { }
interface IntrinsicElements {
}
interface ElementAttributesProperty { props; }
}
//@Filename: exporter.tsx
export module M {
export declare function SFCComp(props: { Three: number; Four: string }): JSX.Element;
}
export module M {
export declare function SFCComp(props: { Three: number; Four: string }): JSX.Element;
}
//@Filename: file.tsx
import * as Exp from './exporter';
var x1 = <Exp.M.SFCComp></[|/*1*/|]>;
var x2 = <Exp.M.SFCComp></[|Exp./*2*/|]>;
var x3 = <Exp.M.SFCComp></[|Exp.M./*3*/|]>;
var x4 = <Exp.M.SFCComp></[|Exp.M.SFCComp/*4*/|]
var x5 = <Exp.M.SFCComp></[|Exp.M.SFCComp/*5*/|]>;
var x6 = <Exp.M.SFCComp></ [|Exp./*6*/|]>;
var x7 = <Exp.M.SFCComp></[|/*7*/Exp.M.SFCComp|]>;
var x8 = <Exp.M.SFCComp></[|Exp/*8*/|]>;
var x9 = <Exp.M.SFCComp></[|Exp.M./*9*/|]>;
var x10 = <Exp.M.SFCComp></ [|/*10*/Exp.M.Foo.Bar.Baz.Wut|]>;
var x11 = <Exp.M.SFCComp></[|Exp./*11*/M.SFCComp|]>;
var x12 = <Exp.M.SFCComp><div><span /></div></[|Exp.M./*12*/SFCComp|]>;`
import * as Exp from './exporter';
var x1 = <Exp.M.SFCComp></[|/*1*/|]>;
var x2 = <Exp.M.SFCComp></[|Exp./*2*/|]>;
var x3 = <Exp.M.SFCComp></[|Exp.M./*3*/|]>;
var x4 = <Exp.M.SFCComp></[|Exp.M.SFCComp/*4*/|]
var x5 = <Exp.M.SFCComp></[|Exp.M.SFCComp/*5*/|]>;
var x6 = <Exp.M.SFCComp></ [|Exp./*6*/|]>;
var x7 = <Exp.M.SFCComp></[|/*7*/Exp.M.SFCComp|]>;
var x8 = <Exp.M.SFCComp></[|Exp/*8*/|]>;
var x9 = <Exp.M.SFCComp></[|Exp.M./*9*/|]>;
var x10 = <Exp.M.SFCComp></ [|/*10*/Exp.M.Foo.Bar.Baz.Wut|]>;
var x11 = <Exp.M.SFCComp></[|Exp./*11*/M.SFCComp|]>;
var x12 = <Exp.M.SFCComp><div><span /></div></[|Exp.M./*12*/SFCComp|]>;`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyCompletions(t, "1", &fourslash.CompletionsExpectedList{
IsIncomplete: false,
Expand Down
14 changes: 7 additions & 7 deletions internal/fourslash/tests/gen/tsxCompletion1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ func TestTsxCompletion1(t *testing.T) {

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `//@Filename: file.tsx
declare module JSX {
interface Element { }
interface IntrinsicElements {
div: { ONE: string; TWO: number; }
}
}
var x = <div /**//>;`
declare module JSX {
interface Element { }
interface IntrinsicElements {
div: { ONE: string; TWO: number; }
}
}
var x = <div /**//>;`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{
IsIncomplete: false,
Expand Down
16 changes: 8 additions & 8 deletions internal/fourslash/tests/gen/tsxCompletion2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ func TestTsxCompletion2(t *testing.T) {

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `//@Filename: file.tsx
declare module JSX {
interface Element { }
interface IntrinsicElements {
}
interface ElementAttributesProperty { props; }
}
class MyComp { props: { ONE: string; TWO: number } }
var x = <MyComp /**//>;`
declare module JSX {
interface Element { }
interface IntrinsicElements {
}
interface ElementAttributesProperty { props; }
}
class MyComp { props: { ONE: string; TWO: number } }
var x = <MyComp /**//>;`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{
IsIncomplete: false,
Expand Down
14 changes: 7 additions & 7 deletions internal/fourslash/tests/gen/tsxCompletion3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ func TestTsxCompletion3(t *testing.T) {

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `//@Filename: file.tsx
declare module JSX {
interface Element { }
interface IntrinsicElements {
div: { one; two; }
}
}
<div one={1} /**//>;`
declare module JSX {
interface Element { }
interface IntrinsicElements {
div: { one; two; }
}
}
<div one={1} /**//>;`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{
IsIncomplete: false,
Expand Down
16 changes: 8 additions & 8 deletions internal/fourslash/tests/gen/tsxCompletion4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ func TestTsxCompletion4(t *testing.T) {

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `//@Filename: file.tsx
declare namespace JSX {
interface Element { }
interface IntrinsicElements {
div: { one; two; }
}
}
let bag = { x: 100, y: 200 };
<div {.../**/`
declare namespace JSX {
interface Element { }
interface IntrinsicElements {
div: { one; two; }
}
}
let bag = { x: 100, y: 200 };
<div {.../**/`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{
IsIncomplete: false,
Expand Down
14 changes: 7 additions & 7 deletions internal/fourslash/tests/gen/tsxCompletion5_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ func TestTsxCompletion5(t *testing.T) {

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `//@Filename: file.tsx
declare module JSX {
interface Element { }
interface IntrinsicElements {
div: { ONE: string; TWO: number; }
}
}
var x = <div ONE/**//>;`
declare module JSX {
interface Element { }
interface IntrinsicElements {
div: { ONE: string; TWO: number; }
}
}
var x = <div ONE/**//>;`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{
IsIncomplete: false,
Expand Down
14 changes: 7 additions & 7 deletions internal/fourslash/tests/gen/tsxCompletion6_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ func TestTsxCompletion6(t *testing.T) {

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `//@Filename: file.tsx
declare module JSX {
interface Element { }
interface IntrinsicElements {
div: { ONE: string; TWO: number; }
}
}
var x = <div ONE='hello' /**/ />;`
declare module JSX {
interface Element { }
interface IntrinsicElements {
div: { ONE: string; TWO: number; }
}
}
var x = <div ONE='hello' /**/ />;`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{
IsIncomplete: false,
Expand Down
Loading