Open
Description
When declaring a symbol-indexed property on an existing interface, attempting to use it gives error TS7017 in VSCode. tsc
, however, compiles it without complaint, implying a bug in tsserver
.
TypeScript Version: 3.3.0-dev.20190119
Search Terms: TS7017 tsserver symbol property
Code
const additionalProp = Symbol();
interface Document {
[additionalProp]?: number;
}
document[additionalProp] = 42; // TS7017 in tsserver/vscode (but not tsc)
console.log(document[additionalProp]); // same
tsconfig.json
:
{
"compilerOptions": {
"strict": true,
"charset": "UTF-8",
"target": "es6",
"module": "es6",
"lib": ["es6", "dom"]
}
}
Expected behavior:
The above code does not have any error highlights.
Actual behavior:
There is an error highlight. The hover says: “Element implicitly has an 'any' type because 'Document' has no index signature. ts (7017)”
Playground Link — The Playground also shows the incorrect error highlight.
Related Issues: None, as far as I can tell.