[Regression]Type definition problem with observable
patheticcockroach opened this issue ยท 8 comments
Description
When "compiling" my TypeScript project, I get the following error with AVA 2.0:
[...]/npm/node_modules/ava/index.d.ts:3:10 - error TS2339: Property 'observable' does not exist on type 'SymbolConstructor'.
3 [Symbol.observable](): ObservableLike;
~~~~~~~~~~
Found 1 error.
AVA 1.4.1 used to work fine. I noticed this error when Travis suddenly started to fail (it installs the latest AVA version every time it runs, while locally I update just from time to time).
Test Source
All it takes is the import:
import test from 'ava';Error Message & Stack Trace
Cf above, that's all I get
Config
I don't have anything special for AVA's config in package.json, all I have is this part:
{
"scripts": {
"test": "ava ./tests/*.js -v -s"
},
}Command-Line Arguments
Just compiling, no arguments:
tsc
Here's my tsconfig.json though:
{
"compileOnSave": true,
"compilerOptions": {
"target": "es5",
"allowSyntheticDefaultImports": true,
"noImplicitAny" : true,
"strictPropertyInitialization": false,
"strictNullChecks": true,
"esModuleInterop": true,
"lib": [
"es5",
"es2015.promise",
"esnext.asynciterable"
],
"skipLibCheck": false,
"alwaysStrict": true,
"removeComments": true,
"typeRoots": [
"node_modules/@types",
"../node_modules/@types"
],
"moduleResolution": "node",
"baseUrl": ".",
"paths": {
"*": [
"*",
"[...]/npm/node_modules/*",
"/usr/local/lib/node_modules/*"
]
}
},
"exclude": [
"node_modules"
]
}
Relevant Links
Found a similar issue here on another project. Apparently it's because @types/node is required. If I install it, it does work. The previously-mentioned issue was solved by doing this.
Environment
Locally Win 10 x64, Node 10.16.0 LTS, AVA 2.0.0
Remotely, whatever Travis runs (some Linux, same Node and AVA version)
Why are you not using @types/node? AVA is a Node.js test runner. Tests are Node.js scripts.
Well, this particular project contains multiple micro-services, with the top folder containing common dev dependencies. Like this:
- project_root
|- node_module
|- @types
|- node
|- service_1
|- node_modules
|- /service_2
|- node_modules
@types/node is actually in the ../node_modules folder that you see mentioned in typeRoots in tsconfig.json. Which used to cause no issue. Now, compiling from the top still works, but compiling from subfolders doesn't anymore (unless I install @types/node in each of them)
@types/nodeis actually in the../node_modulesfolder that you see mentioned intypeRootsintsconfig.json. Which used to cause no issue. Now, compiling from the top still works, but compiling from subfolders doesn't anymore (unless I install@types/nodein each of them)
I imagine you can tweak your tsconfig.json to work better for monorepos, or you can extend a parent config to share the types. But I've never done this before.
(I'm closing this issue for housekeeping purposes, but let's keep the conversation going.)
It seems like observable is not a property of SymbolConstructor in Node 8:
Does this mean Ava no longer supports Node 8?
Oops, looks like I overlooked the previous reply notification ๐
I'm not really a Node package specialist, but shouldn't packages be able to run on their own, without making any assumption on whether or not a project that uses them also includes, by itself, dependencies that they require?
I'm not really a Node package specialist, but shouldn't packages be able to run on their own, without making any assumption on whether or not a project that uses them also includes, by itself, dependencies that they require?
Yes, but TypeScript plays by different rules.
I'm having the exact same issue with a very similar setup just trying to compile typescript - several projects all in the same repository and all are using typescript.
I just saw that someone had a "workaround" from the mention above which solved the immediate problem for me right now.
bitjson/typescript-starter#221 (comment)
Some basic notes on my environment:
- node: 10.17.0
- ava 2.4.0
- typescript 3.7.4
project root
| client
\ ava tests and other code
| server
\ ava tests and other code
Originally, I was having this issue in my server folder, but I switched to webpack to minify and no longer have the issue unless I use tsc -b. I'm now having this issue in my client folder because I need to compile the typescript to run the tests (it is for a VSCode extension). Running tests as documented is fine since it loads the ts files on the fly.
I decided to lock into patch-level updating using the tilde constraint:
"ava": "~2.2.0",
instead of the caret that permitted the problematic 2.4 update:
"ava": "^2.2.0",
I inadvertently ran yarn against the project causing a variety of unexpected updates.