Open cjbarth opened 5 years ago
Hmmm... Not sure what's going on now. Scratching my head... It worked before. Maybe something changed in the latest TypeScript that's breaking this now.
As an FYI, I found a way around this by just exposing any type in source files that weren't getting exported by importing them into the module's index.js file:
export { h } from './h'
export { render } from './render'
export { run } from './runtime'
export { union } from './union'
export { batchEffects } from './effects'
export { Fragment } from './fragment'
/**
* Make types available to programs that use them.
*/
/**
* Type of virutal node used to define elements to create.
* @typedef { import('./vnode').VNode } VNode
*/
/**
* A program which is executed by the `run` function.
* @typedef { import('./runtime').Program } Program
*/
/**
* Message dispatched by the `send` function to the program's `update` method.
* @typedef { import('./runtime').Message } Message
*/
/**
* Type of state, which can be of any type.
* @typedef { import('./runtime').State } State
*/
/**
* Function for sending messages to the program's `update` method.
* @typedef { import('./runtime').Send } Send
*/
This makes these imported types available when you import the module into a project. The fact that I have to do this shows that it's a bug in how TypeScript is garnering type information from a JavaScript file with JSDoc type information.
@rbiggs If it is a TypeScript bug, did you, or, if not, should we, open a bug with TypeScript? I can probably play with this a little to help determine the version of TypeScript that regressed this if needed.
I'm particularly confused. I see your first commit has this at TypeScript@2.9.2. I tested that and it doesn't work. I also see version 3.0.3, which also doesn't work for me. I then tested the latest version, 3.6.4, and that also doesn't work for me. I also checked version 2.3.0, which is the first version to support the --checkJs
flag, and that also doesn't work for me.
Clearly something isn't as it seems. I'm trying to do a simple import * as package from "@scope/package"
in a TypeScript project, for a package that was installed from NPM using npm install --save @scope/package
, and I can't escape this error. This seems like a very trivial problem. Any thoughts?
I'm actually not sure either. Initially this worked fine to illustrate the problem it was having. Not sure why TypeScript isn't finding the installed module now. I'm gonna need some time to dig into this, especially since I don't have a clue what happened.
I downloaded this repo and ran
npm install
and thennpm run checkjs
and recieved:My environment is as such:
npm --version
: 6.9.0node --version
: v10.16.0Is there something that I'm doing wrong, or is this sample no longer working? For reference, I found this because I'm having the same problem as https://github.com/Microsoft/TypeScript/issues/27126.