Typing broken when file has syntax error
Closed this issue · 0 comments
Chnapy commented
When part of file cannot be type-checked because of syntax error, gql typing does not work anymore even if gql part is not in the broken part.
This is an issue for on-going development when code can temporary breaks, and error comprehension.
Example
export const Comment: React.FC = () => {
const { data, loading } = useQuery(
gql(`
query FypRequestItem($id: Int!) {
requestItem(id: $id) {
id
itemId
type
comment
}
}
`),
{ variables: { id: 12 } }
);
const requestItem = data?.requestItem;
// next line is a "`" which breaks all the next code, but should not affect previous gql-related lines
// right now it does: data is typed as unknown, type deduction is not done
`
return <div>{requestItem?.comment}</div>;
Code part to check: https://github.com/Chnapy/ts-gql-plugin/blob/master/src/source-update/parse-literal-occurence-list.ts#L20-L22