typescript icon indicating copy to clipboard operation
typescript copied to clipboard

Inconsistent generated output

Open ssilve1989 opened this issue 7 years ago • 4 comments

Hi,

Given the following import statement

import { promisifyMeteorCall } from 'imports/utils/meteor';

and the following tsconfig.json

{
  "compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "alwaysStrict": true,
    "baseUrl": ".",
    "jsx": "react",
    "lib": [
      "es2017",
      "dom"
    ],
    "paths": {
      "*": ["*"],
      "imports/*": ["imports/*"]
    },
    "module": "commonjs",
    "moduleResolution": "node",
    "noImplicitAny": false,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "pretty": true,
    "removeComments": true,
    
    "sourceMap": true,
    "target": "es5"
  },
  "include": [
    "client/**/*",
    "server/**/*"
  ],
  "exclude": [
    "node_modules",
    ".meteor"
  ]
}

An error occurs saying

Unable to resolve some modules:

  "imports/utils/meteor" in /Users/ssilvestri/dev/trumid/studio/packages/ui/imports/components/Buttons/SystemRefresh.js (web.browser)

What's interesting here is the generated code, for the imports look as follows:

var React = require("react");
var meteor_1 = require("imports/utils/meteor"); // <---- the outlier
var Button_1 = require("material-ui/Button");
var Dialog_1 = require("material-ui/Dialog");
var Typography_1 = require("material-ui/Typography");
var styles_1 = require("material-ui/styles");

which of course makes sense, imports/utils/meteor doesn't make sense here so of course it can't resolve it. But if we look at all the other modules that have been generated from TypeScript we see this imports similar to this

var FieldComponents_1 = require("/imports/components/Form/FieldComponents");

where the statement has been translated to have a / in front, which meteor understands.

Why are some being transformed into the statements with a leading slash and others not?

ssilve1989 avatar Apr 24 '18 12:04 ssilve1989

Likely a bug. What if you test this import from a file with another name (say imports/utils/test i.e. not meteor) does it work?

barbatus avatar May 21 '18 05:05 barbatus

Hm, the initial import statement seems to work now, I'm not sure what dependencies have been updated since I opened this that would change the behavior 😕

ssilve1989 avatar May 21 '18 13:05 ssilve1989

@barbatus now failing again with other import statements that look like imports/logger

ssilve1989 avatar May 28 '18 12:05 ssilve1989

sorry was not following issues in this repo last month if still an issue what if you put one level deeper i.e. imports/../logger is it still failing?

barbatus avatar Jul 06 '18 17:07 barbatus