Skip to content
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

Extends a Class will make losing and corrupted types in a child class. #42541

Closed
jonlepage opened this issue Jan 28, 2021 · 2 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@jonlepage
Copy link

jonlepage commented Jan 28, 2021

When we add types on properties base class, if a child class extends this base class, we will lost types and get corrupted behavior.
Actually is seem affected by keyof T, i not tested all others types, but this one make coruptions.
From what i understand, the child class seem ignore the type from parent !
Or maybe i miss understand the logic here ? if you have alternative to suggest ?

sample js:

const TypesEnum = {
	abc: 'abc',
	abcd: 'abcd',
	abcde: 'abcde',
};

export class Base {
	/**@type {keyof TypesEnum} - all work fine here, default null for the example purpose */
	_test = null;
	constructor(data) {}
}

export class A extends Base {
       /** type are corrupted with vscode Intelisence , we should see and allowed to use the result of keyof TypesEnum ! */
	_test = 'abc'; //lint a error and we lost intellisense in Vscode (ctrl+space)!
	constructor(data) {
		super();
	}
}

🙁 Actual behavior

image
we lost intellisence in Vscode ! and type become corupted.
image

🙂 Expected behavior

type keyof should be heritate in the child class !
image
Without write again /**@type {keyof TypesEnum} */ in the child class !


tsc versions: 4.1.3 and 4.2.0-dev.20210128
Version : 1.52.1 (user setup)
Commit : ea3859d4ba2f3e577a159bc91e3074c5d85c0523
Date : 2020-12-16T16:34:46.910Z
Electron : 9.3.5
Chrome : 83.0.4103.122
Node.js : 12.14.1
V8 : 8.3.110.13-electron.0
OS : Windows_NT x64 10.0.19042

@MartinJohns
Copy link
Contributor

Duplicate of #10570.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jan 28, 2021
@jonlepage
Copy link
Author

jonlepage commented Jan 28, 2021

Duplicate of #10570.

i may use bad word for search thanks , i close
also : #36165
#10570
#15660
#2000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants