TS2739: Type is missing the following properties from type
See original GitHub issueTypeScript 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:
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Type 'X' is missing the following properties from type 'Y'
The error "Type is missing the following properties from type" occurs when the type we assign to a variable is missing some of...
Read more >React with Typescript - Type { } is missing the following ...
As you are passing card to ProfileCard component, its passing 4 values in props. {login: string, name: string, key: number, id: number}.
Read more >Solved - Type x is missing the following properties from type y ...
This error occurs when you are not passing all the required props or only passing some of the required props to the component....
Read more >ts2740: type 'collection ' is missing the following properties ...
ts2740: type 'collection ' is missing the following properties from type 'record ': set, merge, mergedeep, mergewith, and 14 more. Favicon for stackoverflow.com ......
Read more >Type 'typeof IdleState' is missing the following properties.
Type 'typeof IdleState' is missing the following properties. abstract class State { constructor() { } abstract Name(): void; abstract Enter ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, I have the same error but slightly different scenario. I have a functional component wrapped with a redux connect function. Some props are provided via mapStateToProps. However, When calling a component without adding all the props gives me TS2739 error.
Sample code
button.tsx
canPost and postMethod are provided via connect function as follow:
index.ts
Then when i call the button component somewhere else, i only want to pass in the name as prop. Not anything else, however, i received
TS2739: Type is missing the following properties from type
for canPost and postMethod.otherComponent.tsx
For now i have to type canPost and postMethod as undefined. that will fixed the issue. But it is not actually undefined. Anyone could suggest me how to handle this properly? What’s the best approach?
Many thanks in advance 😃