I have the following chunk of code :
const createRecordMapping = () : unknown => mapper.createMap(Record, RecordDto)
.forMember((d) => d.value,
mapFrom((s) => GraphQLJSON.parseValue(s.value)));
Eslint error i am getting for it is :
Unsafe return of an any typed value @typescript-eslint/no-unsafe-return
What am I missing here?
I have the following chunk of code :
const createRecordMapping = () : unknown => mapper.createMap(Record, RecordDto)
.forMember((d) => d.value,
mapFrom((s) => GraphQLJSON.parseValue(s.value)));
Eslint error i am getting for it is :
Unsafe return of an any typed value @typescript-eslint/no-unsafe-return
What am I missing here?
Share Improve this question asked Jan 27, 2021 at 12:08 GammerGammer 5,62420 gold badges82 silver badges132 bronze badges 1-
2
Either
d.value
orGraphQLJSON.parseValue(s.value)
producesany
. The linting rule you have forbids returningany
. – VLAZ Commented Jan 27, 2021 at 12:11
1 Answer
Reset to default -1The code you wrote translates to this:
const createRecordMapping = (): unknown => mapper.createMap(Record, RecordDto)
.forMember((d) => /*d.value, */mapFrom((s) => GraphQLJSON.parseValue(s.value)));
You probably wanted to chain the functions:
const createRecordMapping = (): unknown => mapper.createMap(Record, RecordDto)
.forMember((d) => d.value)
.mapFrom((s) => GraphQLJSON.parseValue(s.value) as unknown);
Also, the GraphQLJSON.parseValue
probably does return any
type, as it is parsing JSON.