You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using typescript 3.7.2 & useDefineClassFields flag.
I think the field with declare modifier should not emit to js code.
but, the field with declare modifier emitting to js code (Object.defineProperty).
Is it normal?
The typescript 3.7 document explain like this. Am I misunderstanding?
"To help mitigate the second issue, you can either add an explicit initializer or add a declare modifier to indicate that a property should have no emit."
TypeScript Version: 3.7.2
Code
interfaceAnimal{animalStuff: any}interfaceDogextendsAnimal{dogStuff: any}classAnimalHouse{resident: Animal;constructor(animal: Animal){this.resident=animal;}}classDogHouseextendsAnimalHouse{declareresident: Dog;// ^^^^^^^// 'resident' now has a 'declare' modifier,// and won't produce any output code.constructor(dog: Dog){super(dog);}}
Expected behavior:
"use strict";classAnimalHouse{constructor(animal){Object.defineProperty(this,"resident",{enumerable: true,configurable: true,writable: true,value: void0});this.resident=animal;}}classDogHouseextendsAnimalHouse{// ^^^^^^^// 'resident' now has a 'declare' modifier,// and won't produce any output code.constructor(dog){super(dog);}}
Actual behavior:
"use strict";classAnimalHouse{constructor(animal){Object.defineProperty(this,"resident",{enumerable: true,configurable: true,writable: true,value: void0});this.resident=animal;}}classDogHouseextendsAnimalHouse{// ^^^^^^^// 'resident' now has a 'declare' modifier,// and won't produce any output code.constructor(dog){super(dog);Object.defineProperty(this,"resident",{enumerable: true,configurable: true,writable: true,value: void0});}}
Looks like duplicate of #34972
Should be fixed in Nightly (see #35058), but playground is broken at this moment.
And may be in 3.7.3 (see #35058 (comment))
I'm using typescript 3.7.2 & useDefineClassFields flag.
I think the field with declare modifier should not emit to js code.
but, the field with declare modifier emitting to js code (Object.defineProperty).
Is it normal?
The typescript 3.7 document explain like this. Am I misunderstanding?
"To help mitigate the second issue, you can either add an explicit initializer or add a declare modifier to indicate that a property should have no emit."
TypeScript Version: 3.7.2
Code
Expected behavior:
Actual behavior:
Playground Link: http://www.typescriptlang.org/play/?useDefineForClassFields=true&target=5&ssl=1&ssc=1&pln=20&pc=2#code/JYOwLgpgTgZghgYwgAgIImAWzgG2Qb2Tg2xwGUwBXGGALiJAE9kBfAKFElkRQBEB7AObIIAD0ggAJgGc0JXAWSShFanQbN2bBDjjTZ6LLgAS-StJT42yG8igRpwSRHD1DpANzXbCfiGlgUJQIYPxQABTERjhu8jgAlATetrZgABbA0gB09o7O4MgAvAzRXinsWjp6sgKCpuYoYhIyctH1FkkpzlX2dg5OLmD0tV4A9KM2AHrTM5Ns48gA5LkD4IvIIPwA7shpekRL3br265j8ksAwwNAANPMTxJLIW36LYMgADlDnwSjEzGYwB9KO9fM4smxkshfP5AsFQhFlIJhkJElYUilpJQPtBwkj4mVbBUgA
The text was updated successfully, but these errors were encountered: