Skip to content

Commit

Permalink
Preserve range on copied identifiers (#57965)
Browse files Browse the repository at this point in the history
  • Loading branch information
weswigham authored Mar 27, 2024
1 parent c87b5bc commit ed5eeaf
Show file tree
Hide file tree
Showing 2,554 changed files with 15,038 additions and 15,038 deletions.
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8611,7 +8611,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
const type = getDeclaredTypeOfSymbol(sym);
const name = sym.flags & SymbolFlags.TypeParameter ? typeParameterToName(type, context) : factory.cloneNode(node);
name.symbol = sym; // for quickinfo, which uses identifier symbol information
return { introducesError, node: setEmitFlags(setOriginalNode(name, node), EmitFlags.NoAsciiEscaping) };
return { introducesError, node: setTextRange(setEmitFlags(setOriginalNode(name, node), EmitFlags.NoAsciiEscaping), node) };
}
}

Expand Down
120 changes: 60 additions & 60 deletions tests/baselines/reference/1.0lib-noErrors.types

Large diffs are not rendered by default.

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 @@ -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 @@ -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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Point {

static Origin(): Point { return { x: 0, y: 0 }; } // unexpected error here bug 840246
>Origin : () => Point
> : ^^^^^^^^^^^
> : ^^^^^^
>{ x: 0, y: 0 } : { x: number; y: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
>x : number
Expand Down Expand Up @@ -52,7 +52,7 @@ module A {

static Origin(): Point { return { x: 0, y: 0 }; } // unexpected error here bug 840246
>Origin : () => Point
> : ^^^^^^^^^^^
> : ^^^^^^
>{ x: 0, y: 0 } : { x: number; y: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
>x : number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Point {

static Origin(): Point { return { x: 0, y: 0 }; }
>Origin : () => Point
> : ^^^^^^^^^^^
> : ^^^^^^
>{ x: 0, y: 0 } : { x: number; y: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
>x : number
Expand Down Expand Up @@ -54,7 +54,7 @@ module A {

static Origin(): Point { return { x: 0, y: 0 }; }
>Origin : () => Point
> : ^^^^^^^^^^^
> : ^^^^^^
>{ x: 0, y: 0 } : { x: number; y: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
>x : number
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/ClassDeclaration25.types
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
interface IList<T> {
data(): T;
>data : () => T
> : ^^^^^^^
> : ^^^^^^

next(): string;
>next : () => string
Expand All @@ -16,7 +16,7 @@ class List<U> implements IList<U> {

data(): U;
>data : () => U
> : ^^^^^^^
> : ^^^^^^

next(): string;
>next : () => string
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ module A {

export var UnitSquare : {
>UnitSquare : { top: { left: Point; right: Point; }; bottom: { left: Point; right: Point; }; }
> : ^^^^^^^ ^^^^^ ^^^^^ ^^^^^^^^^^ ^^^^^ ^^^^^ ^^^
> : ^^^^^^^ ^^^^^^^^^^ ^^^

top: { left: Point, right: Point },
>top : { left: Point; right: Point; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^^^^^ ^^^^^^^^^ ^^^
>left : Point
> : ^^^^^
>right : Point
> : ^^^^^

bottom: { left: Point, right: Point }
>bottom : { left: Point; right: Point; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^^^^^ ^^^^^^^^^ ^^^
>left : Point
> : ^^^^^
>right : Point
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module A {

export function fng<T, U>(s: T): U {
>fng : <T, U>(s: T) => U
> : ^^^^^^^^^^^^^^^^^
> : ^ ^^ ^^^^^ ^^^^^
>s : T
> : ^

Expand All @@ -38,7 +38,7 @@ module A {

function fng2<T, U>(s: T): U {
>fng2 : <T, U>(s: T) => U
> : ^^^^^^^^^^^^^^^^^
> : ^ ^^ ^^^^^ ^^^^^
>s : T
> : ^

Expand All @@ -65,7 +65,7 @@ var fn = A.fn;

var fng: <T, U>(s: T) => U;
>fng : <T, U>(s: T) => U
> : ^^^^^^^^^^^^^^^^^
> : ^ ^^ ^^^^^ ^^^^^
>s : T
> : ^

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

fromCarthesian(p: A.Point) {
>fromCarthesian : (p: A.Point) => { x: number; y: number; }
> : ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>p : A.Point
> : ^^^^^^^
>A : any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ module A {

toCarth(): Point;
>toCarth : () => Point
> : ^^^^^^^^^^^
> : ^^^^^^
}
}

module A {
interface Point {
fromCarth(): Point;
>fromCarth : () => Point
> : ^^^^^^^^^^^
> : ^^^^^^
}
}

// ensure merges as expected
var p: { x: number; y: number; toCarth(): A.Point; };
>p : { x: number; y: number; toCarth(): A.Point; }
> : ^^^^^ ^^^^^ ^^^^^^^^^^^^^^ ^^^
> : ^^^^^ ^^^^^ ^^^^^^^^^^^^^ ^^^
>x : number
> : ^^^^^^
>y : number
> : ^^^^^^
>toCarth : () => A.Point
> : ^^^^^^^
> : ^^^^^^
>A : any
> : ^^^

Expand Down Expand Up @@ -79,7 +79,7 @@ module X {
// ensure merges as expected
var l: { new (s: A.Point, e: A.Point); }
>l : new (s: A.Point, e: A.Point) => any
> : ^^^^^^^^^ ^^^^^^ ^^^^^^^^
> : ^^^^^^^^ ^^^^^ ^^^^^^^^
>s : A.Point
> : ^^^^^^^
>A : any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module A {

export function mirror<T extends Point>(p: T) {
>mirror : <T extends Point>(p: T) => { x: number; y: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^ ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>p : T
> : ^

Expand Down Expand Up @@ -137,7 +137,7 @@ var o = A.Utils.mirror(o);

var p: { tl: A.Point; br: A.Point };
>p : { tl: A.Point; br: A.Point; }
> : ^^^^^^^ ^^^^^^^ ^^^
> : ^^^^^^ ^^^^^^ ^^^
>tl : A.Point
> : ^^^^^^^
>A : any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,32 @@ module A {

toCarth(): Point;
>toCarth : () => Point
> : ^^^^^^^^^^^
> : ^^^^^^
}
}

module A {
export interface Point {
fromCarth(): Point;
>fromCarth : () => Point
> : ^^^^^^^^^^^
> : ^^^^^^
}
}

// ensure merges as expected
var p: { x: number; y: number; toCarth(): A.Point; fromCarth(): A.Point; };
>p : { x: number; y: number; toCarth(): A.Point; fromCarth(): A.Point; }
> : ^^^^^ ^^^^^ ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^^
> : ^^^^^ ^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^
>x : number
> : ^^^^^^
>y : number
> : ^^^^^^
>toCarth : () => A.Point
> : ^^^^^^^
> : ^^^^^^
>A : any
> : ^^^
>fromCarth : () => A.Point
> : ^^^^^^^
> : ^^^^^^
>A : any
> : ^^^

Expand Down Expand Up @@ -83,7 +83,7 @@ module X {
// ensure merges as expected
var l: { start: A.Point; end: A.Point; new (s: A.Point, e: A.Point); }
>l : { new (s: A.Point, e: A.Point): any; start: A.Point; end: A.Point; }
> : ^^^^^^^^^^^ ^^^^^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^
> : ^^^^^^^^^^ ^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^ ^^^
>start : A.Point
> : ^^^^^^^
>A : any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export module A {

export function mirror<T extends Point>(p: T) {
>mirror : <T extends Point>(p: T) => { x: number; y: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^ ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>p : T
> : ^

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

export function mirror<T extends Point>(p: T) {
>mirror : <T extends Point>(p: T) => { x: number; y: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^ ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>p : T
> : ^

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

export function mirror<T extends Point>(p: T) {
>mirror : <T extends Point>(p: T) => { x: number; y: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> : ^ ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>p : T
> : ^

Expand Down Expand Up @@ -131,7 +131,7 @@ var o = A.Utils.mirror(o);

var p: { tl: A.Point; br: A.Point };
>p : { tl: A.Point; br: A.Point; }
> : ^^^^^^^ ^^^^^^^ ^^^
> : ^^^^^^ ^^^^^^ ^^^
>tl : A.Point
> : ^^^^^^^
>A : any
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/TypeGuardWithArrayUnion.types
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Message {

function saySize(message: Message | Message[]) {
>saySize : (message: Message | Message[]) => number
> : ^^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^^^^^^^^
> : ^^^^^^^^^^ ^^^^^^^^^^^
>message : Message | Message[]
> : ^^^^^^^^^^^^^^^^^^^

Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/TypeGuardWithEnumUnion.types
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ enum Color { R, G, B }

function f1(x: Color | string) {
>f1 : (x: Color | string) => void
> : ^^^^^^^^^ ^^^^^^^^^
> : ^^^^ ^^^^^^^^^
>x : string | Color
> : ^^^^^^^^^^^^^^

Expand Down Expand Up @@ -52,7 +52,7 @@ function f1(x: Color | string) {

function f2(x: Color | string | string[]) {
>f2 : (x: Color | string | string[]) => void
> : ^^^^^^^^^ ^^^^^^^^^
> : ^^^^ ^^^^^^^^^
>x : string | Color | string[]
> : ^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Test24554 {
}
function test24554(x: Test24554) {
>test24554 : (x: Test24554) => any
> : ^^^^^^^^^^^^^^^^^^^^^
> : ^^^^ ^^^^^^^^
>x : Test24554
> : ^^^^^^^^^

Expand Down
Loading

0 comments on commit ed5eeaf

Please sign in to comment.