Skip to content

Add invalid comment re-use test case #2

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

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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions tests/baselines/reference/declarationEmitNoInvalidCommentReuse3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
//// [tests/cases/compiler/declarationEmitNoInvalidCommentReuse3.ts] ////

//// [a.ts]
import { object } from "./obj";
import { id } from "./id";
export const _ = object;
/**
*/
//// [obj.d.ts]
import { id } from "./id";
// ----
export declare const object: id.A<{
foo: id.A<1>
}>;

//// [id.d.ts]
export declare namespace id {
type A<T> = T;
}



//// [a.d.ts]
import { id } from "./id";
export declare const _: {
foo: id.
/**
*/ A /**
*/<1>;
};
/**
*/


//// [DtsFileErrors]


a.d.ts(3,10): error TS2314: Generic type 'A' requires 1 type argument(s).
a.d.ts(6,7): error TS7020: Call signature, which lacks return-type annotation, implicitly has an 'any' return type.
a.d.ts(6,8): error TS1139: Type parameter declaration expected.
a.d.ts(6,10): error TS1109: Expression expected.
a.d.ts(7,1): error TS1128: Declaration or statement expected.


==== a.d.ts (5 errors) ====
import { id } from "./id";
export declare const _: {
foo: id.
~~~
/**
~~~~~~~
*/ A /**
~~~~~~~~
!!! error TS2314: Generic type 'A' requires 1 type argument(s).
*/<1>;
~
!!! error TS7020: Call signature, which lacks return-type annotation, implicitly has an 'any' return type.
~
!!! error TS1139: Type parameter declaration expected.
~
!!! error TS1109: Expression expected.
};
~
!!! error TS1128: Declaration or statement expected.
/**
*/

==== obj.d.ts (0 errors) ====
import { id } from "./id";
// ----
export declare const object: id.A<{
foo: id.A<1>
}>;

==== id.d.ts (0 errors) ====
export declare namespace id {
type A<T> = T;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//// [tests/cases/compiler/declarationEmitNoInvalidCommentReuse3.ts] ////

=== a.ts ===
import { object } from "./obj";
>object : Symbol(object, Decl(a.ts, 0, 8))

import { id } from "./id";
>id : Symbol(id, Decl(a.ts, 1, 8))

export const _ = object;
>_ : Symbol(_, Decl(a.ts, 2, 12))
>object : Symbol(object, Decl(a.ts, 0, 8))

/**
*/
=== obj.d.ts ===
import { id } from "./id";
>id : Symbol(id, Decl(obj.d.ts, 0, 8))

// ----
export declare const object: id.A<{
>object : Symbol(object, Decl(obj.d.ts, 2, 20))
>id : Symbol(id, Decl(obj.d.ts, 0, 8))
>A : Symbol(id.A, Decl(id.d.ts, 0, 29))

foo: id.A<1>
>foo : Symbol(foo, Decl(obj.d.ts, 2, 35))
>id : Symbol(id, Decl(obj.d.ts, 0, 8))
>A : Symbol(id.A, Decl(id.d.ts, 0, 29))

}>;

=== id.d.ts ===
export declare namespace id {
>id : Symbol(id, Decl(id.d.ts, 0, 0))

type A<T> = T;
>A : Symbol(A, Decl(id.d.ts, 0, 29))
>T : Symbol(T, Decl(id.d.ts, 1, 11))
>T : Symbol(T, Decl(id.d.ts, 1, 11))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//// [tests/cases/compiler/declarationEmitNoInvalidCommentReuse3.ts] ////

=== a.ts ===
import { object } from "./obj";
>object : { foo: id.A<1>; }
> : ^^^^^^^ ^^^

import { id } from "./id";
>id : any
> : ^^^

export const _ = object;
>_ : { foo: id.A<1>; }
> : ^^^^^^^ ^^^
>object : { foo: id.A<1>; }
> : ^^^^^^^ ^^^

/**
*/
=== obj.d.ts ===
import { id } from "./id";
>id : any
> : ^^^

// ----
export declare const object: id.A<{
>object : { foo: id.A<1>; }
> : ^^^^^^^ ^^^
>id : any
> : ^^^

foo: id.A<1>
>foo : 1
> : ^
>id : any
> : ^^^

}>;

=== id.d.ts ===
export declare namespace id {
type A<T> = T;
>A : T
> : ^
}
21 changes: 21 additions & 0 deletions tests/cases/compiler/declarationEmitNoInvalidCommentReuse3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// @strict: true
// @declaration: true
// @emitDeclarationOnly: true

// @filename: a.ts
import { object } from "./obj";
import { id } from "./id";
export const _ = object;
/**
*/
// @filename: obj.d.ts
import { id } from "./id";
// ----
export declare const object: id.A<{
foo: id.A<1>
}>;

// @filename: id.d.ts
export declare namespace id {
type A<T> = T;
}