Skip to content

Commit 4f497e6

Browse files
Added tests around ES5, assigning to 'import.meta' and properties, global augmentations.
1 parent 56f4b2e commit 4f497e6

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

tests/cases/conformance/es2019/importMeta/importMeta.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,16 @@ export let z = import.import.import.malkovich;
2626
let globalA = import.meta;
2727
let globalB = import.metal;
2828
let globalC = import.import.import.malkovich;
29+
30+
// @Filename: assignmentTargets.ts
31+
export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta;
32+
import.meta = foo;
33+
34+
// @Filename augmentations.ts
35+
declare global {
36+
interface ImportMeta {
37+
wellKnownProperty: { a: number, b: string, c: boolean };
38+
}
39+
}
40+
41+
const { a, b, c } = import.meta.wellKnownProperty;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
// @target: es5
3+
// @module: commonjs
4+
// @lib: es5,dom
5+
6+
// @Filename: example.ts
7+
// Adapted from https://github.com/tc39/proposal-import-meta/tree/c3902a9ffe2e69a7ac42c19d7ea74cbdcea9b7fb#example
8+
(async () => {
9+
const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString());
10+
const blob = await response.blob();
11+
12+
const size = import.meta.scriptElement.dataset.size || 300;
13+
14+
const image = new Image();
15+
image.src = URL.createObjectURL(blob);
16+
image.width = image.height = size;
17+
18+
document.body.appendChild(image);
19+
})();
20+
21+
// @Filename: moduleLookingFile01.ts
22+
export let x = import.meta;
23+
export let y = import.metal;
24+
export let z = import.import.import.malkovich;
25+
26+
// @Filename: scriptLookingFile01.ts
27+
let globalA = import.meta;
28+
let globalB = import.metal;
29+
let globalC = import.import.import.malkovich;
30+
31+
// @Filename: assignmentTargets.ts
32+
export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta;
33+
import.meta = foo;
34+
35+
// @Filename augmentations.ts
36+
declare global {
37+
interface ImportMeta {
38+
wellKnownProperty: { a: number, b: string, c: boolean };
39+
}
40+
}
41+
42+
const { a, b, c } = import.meta.wellKnownProperty;

0 commit comments

Comments
 (0)