Skip to content
This repository has been archived by the owner on Jun 27, 2018. It is now read-only.

Reference external modules #15

Open
Maxim-Filimonov opened this issue Apr 2, 2015 · 22 comments
Open

Reference external modules #15

Maxim-Filimonov opened this issue Apr 2, 2015 · 22 comments

Comments

@Maxim-Filimonov
Copy link

Is it possible to use this module to compile source code which is using external modules?
I can't figure out how to make this simple file to work

/// <reference path="typings/tsd.d.ts"/>
import $ = require("jquery");

Keep getting

L1: File 'typings/tsd.d.ts' not found.
L2: Cannot find external module 'jquery'.
@basarat
Copy link
Collaborator

basarat commented Apr 2, 2015

Disable semantic checks. It's an option.

@Maxim-Filimonov
Copy link
Author

@basarat
Copy link
Collaborator

basarat commented Apr 2, 2015

@teppeis
Copy link
Owner

teppeis commented Apr 2, 2015

@Maxim-Filimonov I've added about doSemanticChecks to README!

@teppeis
Copy link
Owner

teppeis commented Apr 2, 2015

Resolving reference path in typescript-simple is not simple.
Because typescript-simple doesn't know the path of source code, it cannot resolve the relative reference path.
It requires another option.

@Maxim-Filimonov
Copy link
Author

Yeah I'm not an expert but maybe this can be adopted somehow:
https://github.com/ivogabe/gulp-typescript/blob/3422fbff06532ccc57368f3b4c8801de8f72ef27/lib/project.ts#L263
I feel like I am using typescript-simple for the case it's not supposed to be used:

I'm using jest test framework to test react components written in typescript. I'm trying to use typescript-simple to compile *.ts files into .js so that jest can require them. Is that a valid use case or not?

@basarat
Copy link
Collaborator

basarat commented Apr 2, 2015

Is that a valid use case or not

Valid use case. Its used by atom to allow it to require .ts files atom/atom#5898

@basarat
Copy link
Collaborator

basarat commented Apr 2, 2015

gulp / grunt etc are great for complete validation of your code. Jest doesn't care.

@teppeis
Copy link
Owner

teppeis commented Apr 2, 2015

@Maxim-Filimonov

I'm trying to use typescript-simple to compile *.ts files into .js

typescript-simple doesn't compile multiple file structure, because of the simplicity.
I think official tsc or other full-featured tool is better for your case.

@blakeembrey
Copy link

@teppeis @basarat I appear to be having the same issue. I just discovered that atom uses this module to transpile TypeScript (https://github.com/atom/atom/blob/a70be30ee7017b86114592800d9d4bdccff88aa8/src/typescript.coffee#L60-L62) but I get At L1: File '../../typings/tsd.d.ts' not found.

@basarat
Copy link
Collaborator

basarat commented Apr 16, 2015

@blakeembrey can you share the src code that atom is trying to compile? You shouldn't be getting this error because we have semantic checks switched of new TypeScriptSimple(options, false) i.e. false in the second option

@basarat
Copy link
Collaborator

basarat commented Apr 16, 2015

@blakeembrey I just did a quick test : this package works fine : https://github.com/basarat/atom-typescript-test/blob/master/index.ts#L1

@blakeembrey
Copy link

Ok, I'm trying to update now just in case (turns out I'm using Atom 0.190.0 but I didn't see any commits in between that changed things).

@basarat
Copy link
Collaborator

basarat commented Apr 16, 2015

Hmm sorry. I just hit it

image

@blakeembrey
Copy link

@basarat That looks like it 👍 What did you do different? On that note, updating didn't change anything for me either.

@basarat
Copy link
Collaborator

basarat commented Apr 16, 2015

What did you do different?

I did reload atom with ctrl+alt+r somehow that didn't capture it. Quiting and reopening atom triggered it

@basarat
Copy link
Collaborator

basarat commented Apr 16, 2015

@teppeis Issue is that reference imports are considered a syntactic error.

@basarat
Copy link
Collaborator

basarat commented Apr 16, 2015

@teppeis added failing test : #18

@basarat
Copy link
Collaborator

basarat commented Apr 16, 2015

@blakeembrey note that the current workaround is not to use reference imports.

NOTE: reference imports should not be used and are not needed if you are using external modules with tsconfig.json : https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md

basarat added a commit to basarat/typescript-simple that referenced this issue Apr 16, 2015
basarat added a commit to basarat/typescript-simple that referenced this issue Apr 16, 2015
@basarat
Copy link
Collaborator

basarat commented Apr 16, 2015

@teppeis We have a passing build + fix with TypeScript 1.5 : #19

@teppeis
Copy link
Owner

teppeis commented Apr 16, 2015

@basarat thanks!
@blakeembrey sorry, please wait for TypeScript 1.5.

@LiJinyao
Copy link

This change broke the getScriptSnapshot behavior which lead to this issue power-assert-js/espower-typescript#35

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

5 participants