Skip to content

Commit 47cb307

Browse files
committed
add a basic generic test case
1 parent 2284f68 commit 47cb307

5 files changed

+67
-0
lines changed

tests/baselines/reference/computedPropertyNamesTemplateLiteralTypes.errors.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,11 @@ computedPropertyNamesTemplateLiteralTypes.ts(94,7): error TS2322: Type '{ [x: st
112112
name: "",
113113
[`added_${tech1_46309.uuid}` as const]: [19700101],
114114
};
115+
116+
function genericFn1<T extends string>(input: T) {
117+
const genericPattern = `get${input}` as const;
118+
return {
119+
[genericPattern]: 1,
120+
};
121+
}
115122

tests/baselines/reference/computedPropertyNamesTemplateLiteralTypes.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ const doc2_46309: IDocument_46309 = {
103103
name: "",
104104
[`added_${tech1_46309.uuid}` as const]: [19700101],
105105
};
106+
107+
function genericFn1<T extends string>(input: T) {
108+
const genericPattern = `get${input}` as const;
109+
return {
110+
[genericPattern]: 1,
111+
};
112+
}
106113

107114

108115
//// [computedPropertyNamesTemplateLiteralTypes.js]
@@ -181,3 +188,9 @@ const doc2_46309 = {
181188
name: "",
182189
[`added_${tech1_46309.uuid}`]: [19700101],
183190
};
191+
function genericFn1(input) {
192+
const genericPattern = `get${input}`;
193+
return {
194+
[genericPattern]: 1,
195+
};
196+
}

tests/baselines/reference/computedPropertyNamesTemplateLiteralTypes.symbols

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,3 +257,22 @@ const doc2_46309: IDocument_46309 = {
257257

258258
};
259259

260+
function genericFn1<T extends string>(input: T) {
261+
>genericFn1 : Symbol(genericFn1, Decl(computedPropertyNamesTemplateLiteralTypes.ts, 101, 2))
262+
>T : Symbol(T, Decl(computedPropertyNamesTemplateLiteralTypes.ts, 103, 20))
263+
>input : Symbol(input, Decl(computedPropertyNamesTemplateLiteralTypes.ts, 103, 38))
264+
>T : Symbol(T, Decl(computedPropertyNamesTemplateLiteralTypes.ts, 103, 20))
265+
266+
const genericPattern = `get${input}` as const;
267+
>genericPattern : Symbol(genericPattern, Decl(computedPropertyNamesTemplateLiteralTypes.ts, 104, 7))
268+
>input : Symbol(input, Decl(computedPropertyNamesTemplateLiteralTypes.ts, 103, 38))
269+
>const : Symbol(const)
270+
271+
return {
272+
[genericPattern]: 1,
273+
>[genericPattern] : Symbol([genericPattern], Decl(computedPropertyNamesTemplateLiteralTypes.ts, 105, 10))
274+
>genericPattern : Symbol(genericPattern, Decl(computedPropertyNamesTemplateLiteralTypes.ts, 104, 7))
275+
276+
};
277+
}
278+

tests/baselines/reference/computedPropertyNamesTemplateLiteralTypes.types

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,3 +315,24 @@ const doc2_46309: IDocument_46309 = {
315315

316316
};
317317

318+
function genericFn1<T extends string>(input: T) {
319+
>genericFn1 : <T extends string>(input: T) => { [x: string]: number; }
320+
>input : T
321+
322+
const genericPattern = `get${input}` as const;
323+
>genericPattern : `get${T}`
324+
>`get${input}` as const : `get${T}`
325+
>`get${input}` : `get${T}`
326+
>input : T
327+
328+
return {
329+
>{ [genericPattern]: 1, } : { [x: string]: number; }
330+
331+
[genericPattern]: 1,
332+
>[genericPattern] : number
333+
>genericPattern : `get${T}`
334+
>1 : 1
335+
336+
};
337+
}
338+

tests/cases/conformance/es6/computedProperties/computedPropertyNamesTemplateLiteralTypes.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,10 @@ const doc2_46309: IDocument_46309 = {
103103
name: "",
104104
[`added_${tech1_46309.uuid}` as const]: [19700101],
105105
};
106+
107+
function genericFn1<T extends string>(input: T) {
108+
const genericPattern = `get${input}` as const;
109+
return {
110+
[genericPattern]: 1,
111+
};
112+
}

0 commit comments

Comments
 (0)