bitjson / typescript-starter

Quickly create and configure a new library or Node.js project
https://bitjson.github.io/typescript-starter/
MIT License
3.48k stars 245 forks source link

npm run watch does not work on node 12. node_modules/ava/index.d.ts:5:10 - error TS2339: Property 'observable' does not exist on type 'SymbolConstructor'. #221

Closed samirspatel closed 4 years ago

samirspatel commented 4 years ago
node_modules/ava/index.d.ts:5:10 - error TS2339: Property 'observable' does not exist on type 'SymbolConstructor'.

I ran npx typescript-starter to install the project and got the error right after that

SchemeSonic commented 4 years ago

node_modules/ava/index.d.ts:5:10 - error TS2339: Property 'observable' does not exist on type 'SymbolConstructor'. As seen abow Error is generated by AVA. Here is the related issue: https://github.com/avajs/ava/issues/2151

SchemeSonic commented 4 years ago

Extending SymbolConstructor fixes the issue declare global { interface SymbolConstructor { readonly observable: symbol; } }

yurivyatkin commented 4 years ago

I fixed it by creating a new file 'src/types/ava.d.ts' with the following content:

export {};

declare global {
  interface SymbolConstructor {
    readonly observable: symbol;
  }
}

See https://stackoverflow.com/a/59499895/1008341 regarding the first line here.

I am not too sure if this is a correct file placement and naming, though.

caroso1222 commented 4 years ago

A simpler src/types/ava.d.ts:

interface SymbolConstructor {
    readonly observable: symbol;
}

You don't need to import that definition anywhere so it doesn't necessarily need to be a module (i.e. export {}). Now you can ignore global because, as it's not a module anymore, "everything in such a file is in the global scope anyways".

bitjson commented 4 years ago

Hey all – sorry to keep you waiting on this!

The latest version of typescript-starter now upgrades all dependencies, so this issue should be fixed. 🚀

bitjson commented 4 years ago

There are a few new improvements 🚀

Please open an issue if you notice any problems!