mirror of
https://github.com/denoland/deno
synced 2024-08-25 02:57:22 +00:00
Fix type directive parsing (#2954)
This commit is contained in:
parent
686b86edb1
commit
c30decab77
|
@ -39,9 +39,9 @@ const typeDirectiveRegEx = /@deno-types\s*=\s*(["'])((?:(?=(\\?))\3.)*?)\1/gi;
|
|||
* import * as foo from "./foo.js"
|
||||
* export { a, b, c } from "./bar.js"
|
||||
*
|
||||
* [See Diagram](https://bit.ly/2lK0izL)
|
||||
* [See Diagram](http://bit.ly/2lOsp0K)
|
||||
*/
|
||||
const importExportRegEx = /(?:import|export)\s+(?:[\s\S]*?from\s+)?(["'])((?:(?=(\\?))\3.)*?)\1/;
|
||||
const importExportRegEx = /(?:import|export)(?:\s+|\s+[\s\S]*?from\s+)?(["'])((?:(?=(\\?))\3.)*?)\1/;
|
||||
|
||||
/** Parses out any Deno type directives that are part of the source code, or
|
||||
* returns `undefined` if there are not any.
|
||||
|
|
|
@ -3,4 +3,8 @@ import { foo } from "./type_definitions/foo.js";
|
|||
// @deno-types="./type_definitions/fizz.d.ts"
|
||||
import "./type_definitions/fizz.js";
|
||||
|
||||
import * as qat from "./type_definitions/qat.ts";
|
||||
|
||||
console.log(foo);
|
||||
console.log(fizz);
|
||||
console.log(qat.qat);
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
[WILDCARD]foo
|
||||
fizz
|
||||
qat
|
||||
|
|
4
tests/type_definitions/fizz.d.ts
vendored
4
tests/type_definitions/fizz.d.ts
vendored
|
@ -1,2 +1,2 @@
|
|||
/** An exported value. */
|
||||
export const fizz: string;
|
||||
/** A global value. */
|
||||
declare const fizz: string;
|
||||
|
|
|
@ -1 +1 @@
|
|||
export const fizz = "fizz";
|
||||
globalThis.fizz = "fizz";
|
||||
|
|
1
tests/type_definitions/qat.ts
Normal file
1
tests/type_definitions/qat.ts
Normal file
|
@ -0,0 +1 @@
|
|||
export const qat = "qat";
|
Loading…
Reference in a new issue