Skip to content

ts.transpile() doesn't seem to do type check #7402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fatcerberus opened this issue Mar 5, 2016 · 3 comments
Closed

ts.transpile() doesn't seem to do type check #7402

fatcerberus opened this issue Mar 5, 2016 · 3 comments
Labels
API Relates to the public API for TypeScript Question An issue which isn't directly actionable in code

Comments

@fatcerberus
Copy link

TypeScript Version:
1.8.5

Code

function FeedPig(what:number)
{
    print("the pig ate " + what + " pigs at 8:12");
}

FeedPig([1,2,3]);

Compiler Invocation
Using typescriptServices.js:
ts.transpile(source, null, filename)

Expected behavior:
Type error

Actual behavior:
Code compiles successfully and produces the output:

the pig ate 1,2,3 pigs at 8:12
@mhegazy
Copy link
Contributor

mhegazy commented Mar 5, 2016

That is correct. The transpile AP, is just for transpilation, I.e. generating JavaScript from typescript code. This only works on a single file, and does not load any files other than the ones needed.
Type checking is done as part of a full program compilation. You can use the ts.createProgram API for that.

@mhegazy mhegazy closed this as completed Mar 5, 2016
@mhegazy mhegazy added Question An issue which isn't directly actionable in code API Relates to the public API for TypeScript labels Mar 5, 2016
@acdcjunior
Copy link

@mhegazy This means what you said at this comment is already happening:

ts.transpile is the correct entry point. we are looking of slimming it down. for the short term it still needs the checker code, but in the future it should be possible to do it with just the parser and the emitter, which is much smaller.

In other words: is .transpile() now the smaller version or still the same?

@mhegazy
Copy link
Contributor

mhegazy commented Mar 21, 2016

it still needs the code in the checker. no errors are reported, no files are loaded. the comment was mainly about the internals of the API call, and is not related to this question.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API Relates to the public API for TypeScript Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

3 participants