In an effort to tighten up my own coding practices, I have enabled exactOptionalPropertyTypes
for the TypeScript compiler. In setting up CodeMirror extensions, I have the following:
private readonly _extensions: Extension[] = [
// ...
syntaxHighlighting(defaultHighlightStyle, {
fallback: true
}),
//...
];
That generates the following error:
TS2379: Argument of type HighlightStyle
is not assignable to parameter of type Highlighter
with ‘exactOptionalPropertyTypes: true’. Consider adding undefined
to the types of the target’s properties.
Types of property scope
are incompatible.
Type ((type: NodeType) => boolean) | undefined
is not assignable to type (node: NodeType) => boolean
Type undefined
is not assignable to type (node: NodeType) => boolean
I can work around it with defaultHighlightStyle as Omit<HighlightStyle, "scope">
, but I thought it best to raise it here.