Skip to content
Open
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
2 changes: 1 addition & 1 deletion tsc/internal/checker/nodebuilderimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2713,7 +2713,7 @@ func (b *NodeBuilderImpl) addPropertyToElementList(propertySymbol *ast.Symbol, t
}
propertySignature := b.f.NewPropertySignatureDeclaration(modifiers, propertyName, optionalToken, propertyTypeNode, nil)

b.setCommentRange(propertySignature, propertySymbol.ValueDeclaration())
b.setCommentRange(propertySignature, core.Coalesce(propertySymbol.ValueDeclaration(), core.FirstOrNil(propertySymbol.Declarations())))
typeElements = append(typeElements, propertySignature)

return typeElements
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//// [tests/cases/compiler/declarationEmitMappedTypePropertyJSDoc.ts] ////

//// [declarationEmitMappedTypePropertyJSDoc.ts]
type Writeable<T> = { -readonly [P in keyof T]: T[P] } & {};
declare function make<T>(shape: T): { shape: Writeable<T> };
export const a = make({
/** doc for x */
x: 1,
});
declare function pick<T, K extends keyof T>(t: T, k: K): { [P in K]: T[P] };
export const b = pick({
/** doc for v */
v: 1,
w: 2,
}, "v");


//// [declarationEmitMappedTypePropertyJSDoc.js]
export const a = make({
/** doc for x */
x: 1,
});
export const b = pick({
/** doc for v */
v: 1,
w: 2,
}, "v");


//// [declarationEmitMappedTypePropertyJSDoc.d.ts]
export declare const a: {
shape: {
/** doc for x */
x: number;
};
};
export declare const b: {
/** doc for v */
v: number;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//// [tests/cases/compiler/declarationEmitMappedTypePropertyJSDoc.ts] ////

=== declarationEmitMappedTypePropertyJSDoc.ts ===
type Writeable<T> = { -readonly [P in keyof T]: T[P] } & {};
>Writeable : Symbol(Writeable, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 0, 0))
>T : Symbol(T, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 0, 15))
>P : Symbol(P, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 0, 33))
>T : Symbol(T, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 0, 15))
>T : Symbol(T, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 0, 15))
>P : Symbol(P, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 0, 33))

declare function make<T>(shape: T): { shape: Writeable<T> };
>make : Symbol(make, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 0, 60))
>T : Symbol(T, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 1, 22))
>shape : Symbol(shape, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 1, 25))
>T : Symbol(T, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 1, 22))
>shape : Symbol(shape, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 1, 37))
>Writeable : Symbol(Writeable, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 0, 0))
>T : Symbol(T, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 1, 22))

export const a = make({
>a : Symbol(a, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 2, 12))
>make : Symbol(make, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 0, 60))

/** doc for x */
x: 1,
>x : Symbol(x, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 2, 23))

});
declare function pick<T, K extends keyof T>(t: T, k: K): { [P in K]: T[P] };
>pick : Symbol(pick, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 5, 3))
>T : Symbol(T, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 6, 22))
>K : Symbol(K, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 6, 24))
>T : Symbol(T, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 6, 22))
>t : Symbol(t, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 6, 44))
>T : Symbol(T, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 6, 22))
>k : Symbol(k, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 6, 49))
>K : Symbol(K, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 6, 24))
>P : Symbol(P, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 6, 60))
>K : Symbol(K, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 6, 24))
>T : Symbol(T, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 6, 22))
>P : Symbol(P, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 6, 60))

export const b = pick({
>b : Symbol(b, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 7, 12))
>pick : Symbol(pick, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 5, 3))

/** doc for v */
v: 1,
>v : Symbol(v, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 7, 23))

w: 2,
>w : Symbol(w, Decl(declarationEmitMappedTypePropertyJSDoc.ts, 9, 7))

}, "v");

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//// [tests/cases/compiler/declarationEmitMappedTypePropertyJSDoc.ts] ////

=== declarationEmitMappedTypePropertyJSDoc.ts ===
type Writeable<T> = { -readonly [P in keyof T]: T[P] } & {};
>Writeable : { -readonly [P in keyof T]: T[P]; }

declare function make<T>(shape: T): { shape: Writeable<T> };
>make : <T>(shape: T) => { shape: Writeable<T>; }
>shape : T
>shape : { -readonly [P in keyof T]: T[P]; }

export const a = make({
>a : { shape: { x: number; }; }
>make({ /** doc for x */ x: 1,}) : { shape: { x: number; }; }
>make : <T>(shape: T) => { shape: Writeable<T>; }
>{ /** doc for x */ x: 1,} : { x: number; }

/** doc for x */
x: 1,
>x : number
>1 : 1

});
declare function pick<T, K extends keyof T>(t: T, k: K): { [P in K]: T[P] };
>pick : <T, K extends keyof T>(t: T, k: K) => { [P in K]: T[P]; }
>t : T
>k : K

export const b = pick({
>b : { v: number; }
>pick({ /** doc for v */ v: 1, w: 2,}, "v") : { v: number; }
>pick : <T, K extends keyof T>(t: T, k: K) => { [P in K]: T[P]; }
>{ /** doc for v */ v: 1, w: 2,} : { v: number; w: number; }

/** doc for v */
v: 1,
>v : number
>1 : 1

w: 2,
>w : number
>2 : 2

}, "v");
>"v" : "v"

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// @declaration: true
type Writeable<T> = { -readonly [P in keyof T]: T[P] } & {};
declare function make<T>(shape: T): { shape: Writeable<T> };
export const a = make({
/** doc for x */
x: 1,
});
declare function pick<T, K extends keyof T>(t: T, k: K): { [P in K]: T[P] };
export const b = pick({
/** doc for v */
v: 1,
w: 2,
}, "v");