Skip to content
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

Underlines in baselines should not consider nodes with .original set synthetic #58086

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 5 additions & 1 deletion src/harness/typeWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,15 @@ function* forEachASTNode(node: ts.Node) {
}
}

function nodeIsFullySynthetic(node: ts.Node) {
return ts.nodeIsSynthesized(node) && !node.original;
}

const createSyntheticNodeUnderliningPrinter = memoize((): { printer: ts.Printer; writer: ts.EmitTextWriter; underliner: ts.EmitTextWriter; reset(): void; } => {
let underlining = false;
const printer = createPrinter({ removeComments: true }, {
onEmitNode: (hint, node, cb) => {
if (ts.nodeIsSynthesized(node) !== underlining) {
if (nodeIsFullySynthetic(node) !== underlining) {
// either node is synthetic and underlining needs to be enabled, or node is not synthetic and
// underlining needs to be disabled
underlining = !underlining;
Expand Down
344 changes: 172 additions & 172 deletions tests/baselines/reference/1.0lib-noErrors.types

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/baselines/reference/2dArrays.types
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ class Board {
>this.ships.every(function (val) { return val.isSunk; }) : boolean
> : ^^^^^^^
>this.ships.every : { <S extends Ship>(predicate: (value: Ship, index: number, array: Ship[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: Ship, index: number, array: Ship[]) => unknown, thisArg?: any): boolean; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are great example - these parameters all come from Array.prototype.every, which is declared in the lib (obviously), so while we can copy the parameter name nodes to create this signature node, we can't copy the position on the nodes, since that would try and pull gibberish text from this file, if it didn't crash for violating some invariant somewhere.

>this.ships : Ship[]
> : ^^^^^^
>this : this
> : ^^^^
>ships : Ship[]
> : ^^^^^^
>every : { <S extends Ship>(predicate: (value: Ship, index: number, array: Ship[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: Ship, index: number, array: Ship[]) => unknown, thisArg?: any): boolean; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
>function (val) { return val.isSunk; } : (val: Ship) => boolean
> : ^^^^^^^^^^^^^^^^^^^^^^
> : ^ ^^^^^^^^^^^^^^^^^^
>val : Ship
> : ^^^^
>val.isSunk : boolean
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/ArrowFunction1.types
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
=== ArrowFunction1.ts ===
var v = (a: ) => {
>v : (a: any) => void
> : ^^^^^^^^^^^^^^^^
> : ^ ^^^^^^^^^^^^^^
>(a: ) => { } : (a: any) => void
> : ^^^^^^^^^^^^^^^^
> :
>a : any
> : ^^^

Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/ArrowFunction4.types
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
=== ArrowFunction4.ts ===
var v = (a, b) => {
>v : (a: any, b: any) => void
> : ^^^^^^^^^^^^^^^^^^^^^^^^
> : ^ ^^^^^^^ ^^^^^^^^^^^^^^
>(a, b) => { } : (a: any, b: any) => void
> : ^^^^^^^^^^^^^^^^^^^^^^^^
> :
>a : any
>b : any

Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/ArrowFunctionExpression1.types
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
=== ArrowFunctionExpression1.ts ===
var v = (public x: string) => { };
>v : (x: string) => void
> : ^^^^ ^^^^^^^^^
> : ^ ^^ ^^^^^^^^^
>(public x: string) => { } : (x: string) => void
> : ^^^^ ^^^^^^^^^
> :
>x : string
> : ^^^^^^

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module clodule1 {

function f(x: T) { }
>f : (x: T) => void
> : ^^^^^^^^^^^^^^
> : ^ ^^^^^^^^^^^^
>x : T
> : ^
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class clodule<T> {

static fn<U>(id: U) { }
>fn : <U>(id: U) => void
> : ^ ^^^^^^ ^^^^^^^^^
> : ^ ^^ ^^ ^^^^^^^^^
>id : U
> : ^
}
Expand All @@ -27,7 +27,7 @@ module clodule {
// error: duplicate identifier expected
export function fn<T>(x: T, y: T): T {
>fn : <T>(x: T, y: T) => T
> : ^ ^^^^^ ^^^^^ ^^^^^
> : ^ ^^ ^^ ^^ ^^ ^^^^^
>x : T
> : ^
>y : T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class clodule<T> {

static fn(id: string) { }
>fn : (id: string) => void
> : ^^^^^ ^^^^^^^^^
> : ^ ^^ ^^^^^^^^^
>id : string
> : ^^^^^^
}
Expand All @@ -27,7 +27,7 @@ module clodule {
// error: duplicate identifier expected
export function fn<T>(x: T, y: T): T {
>fn : <T>(x: T, y: T) => T
> : ^ ^^^^^ ^^^^^ ^^^^^
> : ^ ^^ ^^ ^^ ^^ ^^^^^
>x : T
> : ^
>y : T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class clodule<T> {

private static sfn(id: string) { return 42; }
>sfn : (id: string) => number
> : ^^^^^ ^^^^^^^^^^^
> : ^ ^^ ^^^^^^^^^^^
>id : string
> : ^^^^^^
>42 : 42
Expand All @@ -29,7 +29,7 @@ module clodule {
// error: duplicate identifier expected
export function fn<T>(x: T, y: T): number {
>fn : <T>(x: T, y: T) => number
> : ^ ^^^^^ ^^^^^ ^^^^^
> : ^ ^^ ^^ ^^ ^^ ^^^^^
>x : T
> : ^
>y : T
Expand All @@ -39,11 +39,11 @@ module clodule {
>clodule.sfn('a') : number
> : ^^^^^^
>clodule.sfn : (id: string) => number
> : ^^^^^^^^^^^^^^^^^^^^^^
> : ^ ^^^^^^^^^^^^^^^^^^^
>clodule : typeof clodule
> : ^^^^^^^^^^^^^^
>sfn : (id: string) => number
> : ^^^^^^^^^^^^^^^^^^^^^^
> : ^ ^^^^^^^^^^^^^^^^^^^
>'a' : "a"
> : ^^^
}
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/ES5For-of1.types
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ for (var v of ['a', 'b', 'c']) {
>console.log(v) : void
> : ^^^^
>console.log : (...data: any[]) => void
> : ^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^ ^^^^^^^^^^^^^^^^
>console : Console
> : ^^^^^^^
>log : (...data: any[]) => void
> : ^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^ ^^^^^^^^^^^^^^^^
>v : string
> : ^^^^^^
}
4 changes: 2 additions & 2 deletions tests/baselines/reference/ES5For-of22.types
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ for (var x of [1, 2, 3]) {
>console.log(x) : void
> : ^^^^
>console.log : (...data: any[]) => void
> : ^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^ ^^^^^^^^^^^^^^^^
>console : Console
> : ^^^^^^^
>log : (...data: any[]) => void
> : ^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^ ^^^^^^^^^^^^^^^^
>x : number
> : ^^^^^^
}
4 changes: 2 additions & 2 deletions tests/baselines/reference/ES5For-of23.types
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ for (var x of [1, 2, 3]) {
>console.log(x) : void
> : ^^^^
>console.log : (...data: any[]) => void
> : ^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^ ^^^^^^^^^^^^^^^^
>console : Console
> : ^^^^^^^
>log : (...data: any[]) => void
> : ^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^ ^^^^^^^^^^^^^^^^
>x : number
> : ^^^^^^
}
4 changes: 2 additions & 2 deletions tests/baselines/reference/ES5For-of33.types
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ for (var v of ['a', 'b', 'c']) {
>console.log(v) : void
> : ^^^^
>console.log : (...data: any[]) => void
> : ^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^ ^^^^^^^^^^^^^^^^
>console : Console
> : ^^^^^^^
>log : (...data: any[]) => void
> : ^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^ ^^^^^^^^^^^^^^^^
>v : string
> : ^^^^^^
}
8 changes: 4 additions & 4 deletions tests/baselines/reference/ES5For-of37.types
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ for (const i of [0, 1, 2, 3, 4]) {
>console.log(i) : void
> : ^^^^
>console.log : (...data: any[]) => void
> : ^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^ ^^^^^^^^^^^^^^^^
>console : Console
> : ^^^^^^^
>log : (...data: any[]) => void
> : ^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^ ^^^^^^^^^^^^^^^^
>i : number
> : ^^^^^^

Expand All @@ -69,11 +69,11 @@ for (const i of [0, 1, 2, 3, 4]) {
>console.log('E %s %s', i, err) : void
> : ^^^^
>console.log : (...data: any[]) => void
> : ^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^ ^^^^^^^^^^^^^^^^
>console : Console
> : ^^^^^^^
>log : (...data: any[]) => void
> : ^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^ ^^^^^^^^^^^^^^^^
>'E %s %s' : "E %s %s"
> : ^^^^^^^^^
>i : number
Expand Down
8 changes: 4 additions & 4 deletions tests/baselines/reference/ES5For-ofTypeCheck13.types
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ strSet.add('Hello')
>strSet.add('Hello') : Set<string>
> : ^^^^^^^^^^^
>strSet.add : (value: string) => Set<string>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^
>strSet : Set<string>
> : ^^^^^^^^^^^
>add : (value: string) => Set<string>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^
>'Hello' : "Hello"
> : ^^^^^^^

strSet.add('World')
>strSet.add('World') : Set<string>
> : ^^^^^^^^^^^
>strSet.add : (value: string) => Set<string>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^
>strSet : Set<string>
> : ^^^^^^^^^^^
>add : (value: string) => Set<string>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^
>'World' : "World"
> : ^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module A {

fromOrigin(p: Point): number;
>fromOrigin : (p: Point) => number
> : ^^^^ ^^^^^
> : ^ ^^ ^^^^^
>p : Point
> : ^^^^^
}
Expand All @@ -33,7 +33,7 @@ module A {

fromOrigin(p: Point) {
>fromOrigin : (p: Point) => number
> : ^^^^ ^^^^^^^^^^^
> : ^ ^^ ^^^^^^^^^^^
>p : Point
> : ^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module A {

static fromorigin2d(p: Point): Line<Point>{
>fromorigin2d : (p: Point) => Line<Point>
> : ^^^^ ^^^^^
> : ^ ^^ ^^^^^
>p : Point
> : ^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module A {

export function fromOrigin(p: Point): Line {
>fromOrigin : (p: Point) => Line
> : ^^^^ ^^^^^
> : ^ ^^ ^^^^^
>p : Point
> : ^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module A {

export function fromOrigin(p: Point): Line {
>fromOrigin : (p: Point) => Line
> : ^^^^ ^^^^^
> : ^ ^^ ^^^^^
>p : Point
> : ^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module A {

export function fromOrigin(p: Point): Line {
>fromOrigin : (p: Point) => Line
> : ^^^^ ^^^^^
> : ^ ^^ ^^^^^
>p : Point
> : ^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module A {

static fromOrigin(p: Point) {
>fromOrigin : (p: Point) => Line
> : ^^^^ ^^^^^^^^^
> : ^ ^^ ^^^^^^^^^
>p : Point
> : ^^^^^

Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/FunctionDeclaration10_es6.types
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=== FunctionDeclaration10_es6.ts ===
function * foo(a = yield => yield) {
>foo : (a: any, yield: any) => Generator<never, void, unknown>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^ ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>a : any
> : ^^^
>yield : any
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/FunctionDeclaration12_es6.types
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var v = function * yield() { }
>v : () => Generator<never, void, unknown>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>function * yield() { } : () => Generator<never, void, unknown>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> :
>yield : () => Generator<never, void, unknown>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2 changes: 1 addition & 1 deletion tests/baselines/reference/FunctionDeclaration2_es6.types
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
=== FunctionDeclaration2_es6.ts ===
function f(yield) {
>f : (yield: any) => void
> : ^^^^^^^^^^^^^^^^^^^^
> : ^ ^^^^^^^^^^^^^^
>yield : any
}
2 changes: 1 addition & 1 deletion tests/baselines/reference/FunctionDeclaration3_es6.types
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=== FunctionDeclaration3_es6.ts ===
function f(yield = yield) {
>f : (yield?: any) => void
> : ^^^^^^^^^^^^^^^^^^^^^
> : ^ ^^^^^^^^^^^^^^^
>yield : any
> : ^^^
>yield : any
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/FunctionDeclaration5_es6.types
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=== FunctionDeclaration5_es6.ts ===
function*foo(yield) {
>foo : (yield: any) => Generator<never, void, unknown>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>yield : any
> : ^^^
}
2 changes: 1 addition & 1 deletion tests/baselines/reference/FunctionDeclaration6_es6.types
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=== FunctionDeclaration6_es6.ts ===
function*foo(a = yield) {
>foo : (a?: any) => Generator<never, void, unknown>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>a : any
> : ^^^
>yield : any
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/FunctionDeclaration7_es6.types
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function*bar() {
// 'yield' here is an identifier, and not a yield expression.
function*foo(a = yield) {
>foo : (a?: any) => Generator<never, void, unknown>
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>a : any
> : ^^^
>yield : any
Expand Down
Loading