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

allow set Property not same as index type for object and array #24823

Closed
2 of 4 tasks
bluelovers opened this issue Jun 9, 2018 · 2 comments
Closed
2 of 4 tasks

allow set Property not same as index type for object and array #24823

bluelovers opened this issue Jun 9, 2018 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@bluelovers
Copy link
Contributor

Search Terms

Suggestion

allow set Property not same as index type for object and array

Error:(6, 2) TS2411: Property ''$$'' of type 'T' is not assignable to string index type 'ITrieNode1'.
Error:(11, 2) TS2411: Property ''$$'' of type 'T' is not assignable to string index type 'ITrieNode2'.
Error:(22, 2) TS2412: Property '0' of type 'true' is not assignable to numeric index type 'string'.

export interface ITrieNode1<T = number>
{
	[k: string]: ITrieNode1<T>,

	'$$'?: T,
}

export interface ITrieNode2<T = number> extends _ITrieNode<T>
{
	[k: string]: ITrieNode2<T>,
}

export interface _ITrieNode<T = number>
{
	'$$'?: T,
}

export interface IArrayOnlyFirstIsBool
{
	[index: number]: string;
	0: true;
}

Use Cases

for only wanna special property has other type

Examples

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript / JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. new expression-level syntax)
@mhegazy
Copy link
Contributor

mhegazy commented Jun 11, 2018

Duplicate of #17867

@mhegazy mhegazy marked this as a duplicate of #17867 Jun 11, 2018
@mhegazy mhegazy added the Duplicate An existing issue was already created label Jun 11, 2018
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

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