I’m trying the most basic example from lit doc as is but tsc
throws a bunch of errors.
npm i lit
tsc --version
Version 5.1.6
tsconfig.json
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
}
}
tsc .my-elements.ts
my-elements.ts(6,4): error TS1240: Unable to resolve signature of property decorator when called as an expression.
No overload matches this call.
Overload 1 of 3, '(target: ClassAccessorDecoratorTarget<MyElement, string>, context: ClassAccessorDecoratorContext<MyElement, string>): ClassAccessorDecoratorResult<...>', gave the following error.
Argument of type 'ClassFieldDecoratorContext<MyElement, string> & { name: "version"; private: false; static: false; }' is not assignable to parameter of type 'ClassAccessorDecoratorContext<MyElement, string>'.
Types of property 'kind' are incompatible.
Type '"field"' is not assignable to type '"accessor"'.
Overload 2 of 3, '(target: (value: string) => void, context: ClassSetterDecoratorContext<MyElement, string>): (this: MyElement, value: string) => void', gave the following error.
Argument of type 'ClassFieldDecoratorContext<MyElement, string> & { name: "version"; private: false; static: false; }' is not assignable to parameter of type 'ClassSetterDecoratorContext<MyElement, string>'.
Types of property 'kind' are incompatible.
Type '"field"' is not assignable to type '"setter"'.
Overload 3 of 3, '(protoOrDescriptor: Object, name: PropertyKey, descriptor?: PropertyDescriptor): any', gave the following error.
Argument of type 'ClassFieldDecoratorContext<MyElement, string> & { name: "version"; private: false; static: false; }' is not assignable to parameter of type 'PropertyKey'.
my-elements.ts(6,4): error TS1270: Decorator function return type 'ClassAccessorDecoratorResult<MyElement, string>' is not assignable to type 'void | ((this: MyElement, value: string) => string)'.
node_modules/@lit/reactive-element/reactive-element.d.ts(128,31): error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later.
node_modules/@lit/reactive-element/reactive-element.d.ts(140,80): error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later.
node_modules/@lit/reactive-element/reactive-element.d.ts(144,46): error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later.
node_modules/@lit/reactive-element/reactive-element.d.ts(170,30): error TS2583: Cannot find name 'WeakMap'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later.
node_modules/@lit/reactive-element/reactive-element.d.ts(170,46): error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later.
node_modules/@lit/reactive-element/reactive-element.d.ts(417,12): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.
node_modules/@lit/reactive-element/reactive-element.d.ts(417,13): error TS2585: 'Symbol' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later.
node_modules/lit-html/lit-html.d.ts(359,32): error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later.
node_modules/lit-html/lit-html.d.ts(546,47): error TS2304: Cannot find name 'Iterable'.