mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
//// [tests/cases/compiler/classAttributeInferenceTemplate.ts] ////
|
|
|
|
//// [classAttributeInferenceTemplate.ts]
|
|
class MyClass {
|
|
property;
|
|
property2;
|
|
|
|
constructor() {
|
|
const variable = 'something'
|
|
|
|
this.property = `foo`; // Correctly inferred as `string`
|
|
this.property2 = `foo-${variable}`; // Causes an error
|
|
|
|
const localProperty = `foo-${variable}`; // Correctly inferred as `string`
|
|
}
|
|
}
|
|
|
|
class MyClass2 {
|
|
accessor property;
|
|
accessor property2;
|
|
|
|
constructor() {
|
|
const variable = 'something'
|
|
|
|
this.property = `foo`; // Correctly inferred as `string`
|
|
this.property2 = `foo-${variable}`; // Causes an error
|
|
|
|
const localProperty = `foo-${variable}`; // Correctly inferred as `string`
|
|
}
|
|
}
|
|
|
|
|
|
//// [classAttributeInferenceTemplate.js]
|
|
"use strict";
|
|
class MyClass {
|
|
property;
|
|
property2;
|
|
constructor() {
|
|
const variable = 'something';
|
|
this.property = `foo`; // Correctly inferred as `string`
|
|
this.property2 = `foo-${variable}`; // Causes an error
|
|
const localProperty = `foo-${variable}`; // Correctly inferred as `string`
|
|
}
|
|
}
|
|
class MyClass2 {
|
|
accessor property;
|
|
accessor property2;
|
|
constructor() {
|
|
const variable = 'something';
|
|
this.property = `foo`; // Correctly inferred as `string`
|
|
this.property2 = `foo-${variable}`; // Causes an error
|
|
const localProperty = `foo-${variable}`; // Correctly inferred as `string`
|
|
}
|
|
}
|