From 6c7d337960b3745a7b614a18150862279ef1c942 Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Fri, 23 Aug 2019 02:05:01 +1000 Subject: Support .d.ts files (#2746) Fixes #1432 --- tests/error_type_definitions.test | 4 ++++ tests/error_type_definitions.ts | 5 +++++ tests/error_type_definitions.ts.out | 4 ++++ tests/type_definitions.test | 2 ++ tests/type_definitions.ts | 4 ++++ tests/type_definitions.ts.out | 1 + tests/type_definitions/bar.d.ts | 7 +++++++ tests/type_definitions/foo.d.ts | 2 ++ tests/type_definitions/foo.js | 1 + 9 files changed, 30 insertions(+) create mode 100644 tests/error_type_definitions.test create mode 100644 tests/error_type_definitions.ts create mode 100644 tests/error_type_definitions.ts.out create mode 100644 tests/type_definitions.test create mode 100644 tests/type_definitions.ts create mode 100644 tests/type_definitions.ts.out create mode 100644 tests/type_definitions/bar.d.ts create mode 100644 tests/type_definitions/foo.d.ts create mode 100644 tests/type_definitions/foo.js (limited to 'tests') diff --git a/tests/error_type_definitions.test b/tests/error_type_definitions.test new file mode 100644 index 000000000..367edacc5 --- /dev/null +++ b/tests/error_type_definitions.test @@ -0,0 +1,4 @@ +args: run --reload tests/error_type_definitions.ts +check_stderr: true +exit_code: 1 +output: tests/error_type_definitions.ts.out diff --git a/tests/error_type_definitions.ts b/tests/error_type_definitions.ts new file mode 100644 index 000000000..ceb11787e --- /dev/null +++ b/tests/error_type_definitions.ts @@ -0,0 +1,5 @@ +// @deno-types="./type_definitions/bar.d.ts" +import { Bar } from "./type_definitions/bar.js"; + +const bar = new Bar(); +console.log(bar); diff --git a/tests/error_type_definitions.ts.out b/tests/error_type_definitions.ts.out new file mode 100644 index 000000000..4b29b5b83 --- /dev/null +++ b/tests/error_type_definitions.ts.out @@ -0,0 +1,4 @@ +[WILDCARD]error: Uncaught TypeError: Automatic type resolution not supported +[WILDCARD]js/compiler.ts:[WILDCARD] + at fileExists (js/compiler.ts:[WILDCARD]) +[WILDCARD] \ No newline at end of file diff --git a/tests/type_definitions.test b/tests/type_definitions.test new file mode 100644 index 000000000..7ce8d896d --- /dev/null +++ b/tests/type_definitions.test @@ -0,0 +1,2 @@ +args: run --reload tests/type_definitions.ts +output: tests/type_definitions.ts.out diff --git a/tests/type_definitions.ts b/tests/type_definitions.ts new file mode 100644 index 000000000..372501166 --- /dev/null +++ b/tests/type_definitions.ts @@ -0,0 +1,4 @@ +// @deno-types="./type_definitions/foo.d.ts" +import { foo } from "./type_definitions/foo.js"; + +console.log(foo); diff --git a/tests/type_definitions.ts.out b/tests/type_definitions.ts.out new file mode 100644 index 000000000..291e85a7b --- /dev/null +++ b/tests/type_definitions.ts.out @@ -0,0 +1 @@ +[WILDCARD]foo diff --git a/tests/type_definitions/bar.d.ts b/tests/type_definitions/bar.d.ts new file mode 100644 index 000000000..d43335dbb --- /dev/null +++ b/tests/type_definitions/bar.d.ts @@ -0,0 +1,7 @@ +/// + +declare namespace bar { + export class Bar { + baz: string; + } +} diff --git a/tests/type_definitions/foo.d.ts b/tests/type_definitions/foo.d.ts new file mode 100644 index 000000000..ce39201e1 --- /dev/null +++ b/tests/type_definitions/foo.d.ts @@ -0,0 +1,2 @@ +/** An exported value. */ +export const foo: string; diff --git a/tests/type_definitions/foo.js b/tests/type_definitions/foo.js new file mode 100644 index 000000000..61d366eb2 --- /dev/null +++ b/tests/type_definitions/foo.js @@ -0,0 +1 @@ +export const foo = "foo"; -- cgit v1.2.3