-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Integrate TypeScript 2.9+ into deno #120
Conversation
It appears I didn't understand module resolution in deno. It always expects fully qualified module names, including extensions. So updating the test case to import As a side note though, in IDE's powered by TypeScript services, TypeScript supports two forms of module resolution, in which both do not expect module IDs to include extensions, which means in IDEs, this always errors and you do not get the intellisense and type help from imports. I can understand the desire for safety by specifying the full file name, but I think it will be a challenge ongoing, unless the TypeScript team considers a new literal module resolution mode. Still trying to figure out why the importing of JSON isn't working, but it seems to be the internals of TypeScript at the moment in thinking it is a source code module, but I need to understand how it dealing with resolving JSON files in the first place. |
With resolving the loading of JSON files, the compiler host function of When the support for loading JSON was added, it was assumed the host would identify it and the legacy code support for identifying these as JSON was not included. I currently have it at least loading the message, but need to deal with the |
I have added functionality now, that when the module ID ends in import helloWorld from "./subdir/hello_world.json";
function logHelloWorld(item: typeof helloWorld) {
console.log(helloWorld);
}
logHelloWorld(helloWorld); |
|
It will be at least 6 weeks until 3.0.0 and as Ryan has asked to keep the noise down a bit, which I respect, I will close this. When deno gets a little bit further down the line, this could be revisited, and the importing of JSON added. I would be glad to do the work once TS 3 is here and Ryan thinks it is the right thing to do. I won't delete my branch though if anyone is curious. |
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
This is a work in progress PR to integrate 2.9 and later into deno.
It is currently using a special build of TypeScript which incorporates microsoft/TypeScript#24641 (refs: #117 and microsoft/TypeScript#24638). This address an issue where since TypeScript 2.9 there are some changes to some of the compiler utilities which assumes that
ts.sys
is always defined, which it currently isn't when deno is the host.TypeScript 2.9 introduces 3 new features which all have value to deno, IMO:
keyof
type operator.import()
of types.Currently, the following problems are occuring:
At runtime, TypeScript via deno is complaining that it cannot resolve type modules viaimport()
:Though at development time, in vscode, I am not receiving this error, and other modules via theimport
keyword are fine.When importing of a JSON file, the following occurs:Which I am not sure what the problem is, except that maybe that TypeScript has flipped into a browser mode at runtime instead of expecting some modules to be resolved by the host, and then runs into this issue of not directly supporting it. At design time, with a properly configured compiler flags (--resolveJsonModule
and--esModuleInterop
) tsservices does not report any errors and can resolve the module.