summaryrefslogtreecommitdiff
path: root/deno_typescript
diff options
context:
space:
mode:
Diffstat (limited to 'deno_typescript')
-rw-r--r--deno_typescript/Cargo.toml14
-rw-r--r--deno_typescript/amd_runtime.js1
-rw-r--r--deno_typescript/compiler_main.js5
-rw-r--r--deno_typescript/globals.d.ts13
-rw-r--r--deno_typescript/jsconfig.json6
-rw-r--r--deno_typescript/lib.deno_core.d.ts6
-rw-r--r--deno_typescript/lib.rs24
-rw-r--r--deno_typescript/ops.rs8
m---------deno_typescript/typescript0
9 files changed, 37 insertions, 40 deletions
diff --git a/deno_typescript/Cargo.toml b/deno_typescript/Cargo.toml
index ebab2a327..ddda684b2 100644
--- a/deno_typescript/Cargo.toml
+++ b/deno_typescript/Cargo.toml
@@ -1,16 +1,24 @@
[package]
name = "deno_typescript"
-version = "0.18.0"
+version = "0.18.3"
license = "MIT"
description = "To compile TypeScript to a snapshot during build.rs"
repository = "https://github.com/ry/deno_typescript"
-authors = ["Ryan Dahl <ry@tinyclouds.org>"]
+authors = ["the Deno authors"]
edition = "2018"
+exclude = [
+ "typescript/tests/*",
+ "typescript/src/*",
+ "typescript/scripts/*",
+ "typescript/doc/*",
+ "typescript/lib/*/*.json",
+]
+
[lib]
path = "lib.rs"
[dependencies]
-deno = { path = "../core" }
+deno = { path = "../core", version = "0.18.0" }
serde_json = "1.0.40"
serde = { version = "1.0.100", features = ["derive"] }
diff --git a/deno_typescript/amd_runtime.js b/deno_typescript/amd_runtime.js
index dac8b46fb..1c4f0007a 100644
--- a/deno_typescript/amd_runtime.js
+++ b/deno_typescript/amd_runtime.js
@@ -11,6 +11,7 @@ let require;
/**
* @type {(name: string, deps: ReadonlyArray<string>, factory: (...deps: any[]) => void) => void}
*/
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
let define;
(function() {
diff --git a/deno_typescript/compiler_main.js b/deno_typescript/compiler_main.js
index 8288306f3..0d51479d5 100644
--- a/deno_typescript/compiler_main.js
+++ b/deno_typescript/compiler_main.js
@@ -44,7 +44,10 @@ function main(configText, rootNames) {
const emitResult = program.emit();
handleDiagnostics(host, emitResult.diagnostics);
- dispatch("setEmitResult", emitResult);
+ dispatch(
+ "setEmitResult",
+ Object.assign(emitResult, { tsVersion: ts.version })
+ );
}
/**
diff --git a/deno_typescript/globals.d.ts b/deno_typescript/globals.d.ts
deleted file mode 100644
index b087c5552..000000000
--- a/deno_typescript/globals.d.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-
-// This scopes the `ts` namespace globally, which is where it exists at runtime
-// when building Deno, but the `typescript/lib/typescript.d.ts` is defined as a
-// module
-
-import * as _ts from "typescript";
-
-declare global {
- namespace ts {
- export = _ts;
- }
-}
diff --git a/deno_typescript/jsconfig.json b/deno_typescript/jsconfig.json
deleted file mode 100644
index 3338b50e9..000000000
--- a/deno_typescript/jsconfig.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "compilerOptions": {
- "strict": true,
- "target": "esnext"
- }
-}
diff --git a/deno_typescript/lib.deno_core.d.ts b/deno_typescript/lib.deno_core.d.ts
index 18583fadd..0bd3b6415 100644
--- a/deno_typescript/lib.deno_core.d.ts
+++ b/deno_typescript/lib.deno_core.d.ts
@@ -21,7 +21,7 @@ interface EvalErrorInfo {
}
declare interface DenoCore {
- print(s: string, is_err?: boolean);
+ print(s: string, isErr?: boolean);
dispatch(
opId: number,
control: Uint8Array,
@@ -45,8 +45,6 @@ declare interface DenoCore {
data?: ArrayBufferView
): null | Uint8Array;
- print(x: string, isErr?: boolean): void;
-
shared: SharedArrayBuffer;
/** Evaluate provided code in the current context.
@@ -63,4 +61,4 @@ declare interface DenoCore {
declare interface DenoInterface {
core: DenoCore;
}
-declare var Deno: DenoInterface;
+declare let Deno: DenoInterface;
diff --git a/deno_typescript/lib.rs b/deno_typescript/lib.rs
index a9b95421d..3d5ab6b15 100644
--- a/deno_typescript/lib.rs
+++ b/deno_typescript/lib.rs
@@ -18,11 +18,16 @@ use std::path::PathBuf;
use std::sync::Arc;
use std::sync::Mutex;
-static TYPESCRIPT_CODE: &str =
- include_str!("../third_party/node_modules/typescript/lib/typescript.js");
+static TYPESCRIPT_CODE: &str = include_str!("typescript/lib/typescript.js");
static COMPILER_CODE: &str = include_str!("compiler_main.js");
static AMD_RUNTIME_CODE: &str = include_str!("amd_runtime.js");
+pub fn ts_version() -> String {
+ let data = include_str!("typescript/package.json");
+ let pkg: serde_json::Value = serde_json::from_str(data).unwrap();
+ pkg["version"].as_str().unwrap().to_string()
+}
+
#[derive(Debug)]
pub struct TSState {
bundle: bool,
@@ -196,15 +201,6 @@ fn write_snapshot(
Ok(())
}
-macro_rules! inc {
- ($e:expr) => {
- Some(include_str!(concat!(
- "../third_party/node_modules/typescript/lib/",
- $e
- )))
- };
-}
-
/// Same as get_asset() but returns NotFound intead of None.
pub fn get_asset2(name: &str) -> Result<&'static str, ErrBox> {
match get_asset(name) {
@@ -217,8 +213,14 @@ pub fn get_asset2(name: &str) -> Result<&'static str, ErrBox> {
}
pub fn get_asset(name: &str) -> Option<&'static str> {
+ macro_rules! inc {
+ ($e:expr) => {
+ Some(include_str!(concat!("typescript/lib/", $e)))
+ };
+ }
match name {
"lib.deno_core.d.ts" => Some(include_str!("lib.deno_core.d.ts")),
+ "typescript.d.ts" => inc!("typescript.d.ts"),
"lib.esnext.d.ts" => inc!("lib.esnext.d.ts"),
"lib.es2019.d.ts" => inc!("lib.es2019.d.ts"),
"lib.es2018.d.ts" => inc!("lib.es2018.d.ts"),
diff --git a/deno_typescript/ops.rs b/deno_typescript/ops.rs
index f1c7840f9..ca7c08548 100644
--- a/deno_typescript/ops.rs
+++ b/deno_typescript/ops.rs
@@ -108,8 +108,12 @@ fn resolve_module_names(_s: &mut TSState, v: Value) -> Result<Value, ErrBox> {
let mut resolved = Vec::<String>::new();
let referrer = ModuleSpecifier::resolve_url_or_path(&v.containing_file)?;
for specifier in v.module_names {
- let ms = ModuleSpecifier::resolve_import(&specifier, referrer.as_str())?;
- resolved.push(ms.as_str().to_string());
+ if specifier.starts_with("$asset$/") {
+ resolved.push(specifier.clone());
+ } else {
+ let ms = ModuleSpecifier::resolve_import(&specifier, referrer.as_str())?;
+ resolved.push(ms.as_str().to_string());
+ }
}
Ok(json!(resolved))
}
diff --git a/deno_typescript/typescript b/deno_typescript/typescript
new file mode 160000
+Subproject cf7b2d4ae91c4f27ba9ae7137ddf9a407815e59