Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Strange issue, related to module resolution most likely #6

Closed
jacobdr opened this issue Mar 28, 2016 · 10 comments
Closed

Strange issue, related to module resolution most likely #6

jacobdr opened this issue Mar 28, 2016 · 10 comments

Comments

@jacobdr
Copy link

jacobdr commented Mar 28, 2016

I am getting the below compilation issues when trying to get up and running with barbatus:typescript@0.2.0...

@barbatus since you are the TS legend I was hoping that you might be able to provide some guidance.

Essentially, any npm packages that I have installed I can import without issue, but when it comes to the meteor core or other meteor install packages (like meteor-accounts-ui-bootstrap I get these issues. Might it have to do with my tsconfig.json?

Thanks in advance.
Jacob

client/Utils/AccountsUIWrapper.tsx (6, 26): Cannot find module 'meteor/template'.
client/Utils/AccountsUIWrapper.tsx (7, 23): Cannot find module 'meteor/blaze'.
@barbatus
Copy link
Owner

See related issue meteor/meteor#6177. Particular this comment will give more explanation meteor/meteor#6177 (comment).
Current Meteor declaration file is built for Meteor1.2. In other words, it doesn't contain namespaces like meteor/template etc, which are of Meteor 1.3. I think situation will change soon after Meteor 1.3 release.

@jacobdr
Copy link
Author

jacobdr commented Mar 28, 2016

Thanks for the quick reply. As a temporary workaround I:

  1. Download this very handy Gist made by @tomitrescak (so curl -o temp_meteor_defs.d.ts https://gist.githubusercontent.com/tomitrescak/8366ce98f1857e202ea8/raw/4c8850ad8174de2662f92c87328280838e0ab5fd/meteor.d.ts)

  2. Temporarily swap out the typings/main.d.ts reference to the ambient meteor definitions with the downloaded Gist (so the reference path is: /// <reference path="temp_meteor_defs.d.ts" />)

  3. Then I am able to have the statement import { Meteor } from 'meteor/meteor'; compile without error

However, this doesn't really help for the other core meteor packages (like templating -- import {Template} from 'meteor/templating'; is still throwing a compile error).

Do you have any suggested workaround or is it easiest to just let the temperature cool down since 1.3 just came out of the oven.

@barbatus
Copy link
Owner

As I can see in this file, Template is in meteor/blaze namespace. If it's not right then you can send PR correcting definitions.

@omeid
Copy link

omeid commented Mar 31, 2016

typings can download over http/s.

So instead of keeping a local copy you can just swap the value of meteor in typings.json after doing typings install meteor --save --ambient.

This was referenced Apr 7, 2016
@dagatsoin
Copy link

dagatsoin commented Apr 15, 2016

I am a bit lost with this issue in 1.3
Where have I to put this temp .d file? At the root?
As I typed install meteor --save --ambient first I have a main/ambiant/meteor/index.d.ts and a browser/ambiant/meteor/index.d.ts. Should I keep those files?

For now I have errors like

imports/lib/logicLayer/rules/sources/source.ts (4, 22): Cannot find module '../../../dataLayer/state/IStore'.
imports/lib/classes/player/Player.ts (42, 32): Property '_startedAt' does not exist on type '{}'.
imports/lib/classes/player/Player.ts (43, 34): Property '_mutatorType' does not exist on type '{}'.
imports/lib/classes/source/Source.ts (66, 5): The '^=' operator is not allowed for boolean types. Consider using '!==' instead.
imports/lib/logicLayer/gameMaster/GameMaster.singleton.ts (1, 24): Cannot find module '../../../client/lib/dataLayer/localState/LocalStore.singleton'.
imports/lib/logicLayer/gameMaster/GameMaster.singleton.ts (2, 25): Cannot find module '../../dataLayer/state/LocalStore.singleton'.
imports/lib/logicLayer/rules/sources/source.ts (4, 22): Cannot find module '../../../dataLayer/state/IStore'.
imports/lib/classes/entity/Entity.ts (70, 5): Cannot find name 'console'.
imports/lib/classes/entity/Entity.ts (105, 5): Cannot find name 'console'.
imports/lib/classes/entity/Entity.ts (110, 5): Cannot find name 'console'.
imports/lib/classes/player/Player.ts (42, 32): Property '_startedAt' does not exist on type '{}'.
imports/lib/classes/player/Player.ts (43, 34): Property '_mutatorType' does not exist on type '{}'.
imports/lib/classes/player/Player.ts (169, 5): Cannot find name 'console'.
imports/lib/classes/source/Source.ts (66, 5): The '^=' operator is not allowed for boolean types. Consider using '!==' instead.
imports/lib/dataLayer/localState/GlobalStore.ts (215, 10): Cannot find name 'console'.
imports/lib/logicLayer/gameMaster/GameMaster.singleton.ts (1, 24): Cannot find module '../../../client/lib/dataLayer/localState/LocalStore.singleton'.
imports/lib/logicLayer/gameMaster/GameMaster.singleton.ts (2, 25): Cannot find module '../../dataLayer/state/LocalStore.singleton'.
imports/lib/logicLayer/gameMaster/GameMaster.singleton.ts (20, 5): Cannot find name 'console'.

@jacobdr
Copy link
Author

jacobdr commented Apr 15, 2016

Try this (NB: temporary solution, real answer should involve an official typescript contribution):

typings rm --save meteor
typings install --save --ambient meteor=https://gist.githubusercontent.com/jacobdr/6010b922d449e4aa1b001862f200e3ef/raw/d2baf474c271ff1c9d77961ae11750cdcbc30abb/meteor.d.ts

At the end, your typings.json should look something like this (obviously look at the meteor section, the rest are my other dependencies):

{
  "version": false,
  "dependencies": {
    "griddle-react": "registry:npm/griddle-react#0.3.1+20160318031623",
    "immutable": "registry:npm/immutable#3.7.6+20160411060006",
    "lodash": "registry:npm/lodash#4.0.0+20160412191219",
    "mongodb": "registry:npm/mongodb#2.1.0+20160329101818",
    "react-addons-update": "registry:npm/react-addons-update#0.14.0+20160324044346"
  },
  "ambientDependencies": {
    "aws-sdk": "registry:dt/aws-sdk#0.0.0+20160316155526",
    "bluebird": "registry:dt/bluebird#2.0.0+20160319051630",
    "meteor": "https://gist.githubusercontent.com/jacobdr/6010b922d449e4aa1b001862f200e3ef/raw/d2baf474c271ff1c9d77961ae11750cdcbc30abb/meteor.d.ts",
  }
}

@jacobdr
Copy link
Author

jacobdr commented Apr 15, 2016

^^ Edited, initial answer had the wrong typings install command ^^

@dagatsoin
Copy link

Thw @jacobdr, indeed the typings.json contains the meteor line. But I have still the same errors. Do you know which type definitions I have to use?

@dagatsoin
Copy link

How can be sure if lib.d.ts is imported ?

@jacobdr
Copy link
Author

jacobdr commented Apr 15, 2016

Im not really sure what you mean, but this line should in your main.d.ts file:

/// <reference path="main/ambient/meteor/index.d.ts" />

And your tsconfig.json file (at the root of the project) should have something like the following (I use Atom as my IDE):

{
    "compilerOptions": {
        "target": "es5",
        "sourceMap": true,
        "module": "commonjs",
        "jsx": "react",
        "listFiles": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators":true,
        "moduleResolution": "node"
    },
    "compileOnSave": false,
    "buildOnSave": false,
    "exclude": [
        "node_modules",
        ".meteor",
        "typings/browser.d.ts",
        "typings/browser",
        "typings/main",
        "public"
    ]
}

Or, if you are using the tsconfig.json "include" syntax, you would want to make sure that your include has something like the following:

"include": [" typings/main.d.ts "]

Let me know if that helps -- and if it doesn't, I would ask you to please re-open a new issue as this one is closed and its a little hard to keep track of your ongoing issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants