Skip to content

TS2739: Type is missing the following properties from type #29197

@bluelovers

Description

@bluelovers

TypeScript Version: 3.3.0-dev.201xxxxx

Search Terms:

Code

export const sp = '_@_';

export interface IWordsOutput
{
	_source?: any,

	s?: RegExp,
	r?: string | IRegExpCallback,

	flags?: string,
}

export interface IRegExpCallback
{
	($0: string, $1?: string, $2?: string, $3?: string, ...argv): string;
}

export interface IWords extends IWordsOutput
{
	[0]: string | RegExp,
	[1]: string | IRegExpCallback,
	[2]?: string,
}

export const words_source: IWords[] = [

	// this is work
	['HP', 'HP'],

	// Error:TS2739: Type 'string[]' is missing the following properties from type 'IWords': [0], [1]
	(function ()
	{
		let jobclass = '(?:A|B|C)';

		return [`${jobclass}${sp}${jobclass}`, '$1・$2'];
	})(),

];

Expected behavior:

no error

Actual behavior:

Error:TS2739: Type 'string[]' is missing the following properties from type 'IWords': [0], [1]

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Contextual TypesThe issue relates to contextual types

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions