1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
=== tests/cases/conformance/es2019/importMeta/example.ts ===
// Adapted from https://github.com/tc39/proposal-import-meta/tree/c3902a9ffe2e69a7ac42c19d7ea74cbdcea9b7fb#example
(async () => {
>(async () => { const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString()); const blob = await response.blob(); const size = import.meta.scriptElement.dataset.size || 300; const image = new Image(); image.src = URL.createObjectURL(blob); image.width = image.height = size; document.body.appendChild(image);})() : Promise<void>
>(async () => { const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString()); const blob = await response.blob(); const size = import.meta.scriptElement.dataset.size || 300; const image = new Image(); image.src = URL.createObjectURL(blob); image.width = image.height = size; document.body.appendChild(image);}) : () => Promise<void>
>async () => { const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString()); const blob = await response.blob(); const size = import.meta.scriptElement.dataset.size || 300; const image = new Image(); image.src = URL.createObjectURL(blob); image.width = image.height = size; document.body.appendChild(image);} : () => Promise<void>
const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString());
>response : Response
>await fetch(new URL("../hamsters.jpg", import.meta.url).toString()) : Response
>fetch(new URL("../hamsters.jpg", import.meta.url).toString()) : Promise<Response>
>fetch : (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>
>new URL("../hamsters.jpg", import.meta.url).toString() : string
>new URL("../hamsters.jpg", import.meta.url).toString : () => string
>new URL("../hamsters.jpg", import.meta.url) : URL
>URL : { new (url: string | URL, base?: string | URL): URL; prototype: URL; createObjectURL(obj: Blob | MediaSource): string; revokeObjectURL(url: string): void; }
>"../hamsters.jpg" : "../hamsters.jpg"
>import.meta.url : string
>import.meta : ImportMeta
>meta : any
>url : string
>toString : () => string
const blob = await response.blob();
>blob : Blob
>await response.blob() : Blob
>response.blob() : Promise<Blob>
>response.blob : () => Promise<Blob>
>response : Response
>blob : () => Promise<Blob>
const size = import.meta.scriptElement.dataset.size || 300;
>size : any
>import.meta.scriptElement.dataset.size || 300 : any
>import.meta.scriptElement.dataset.size : any
>import.meta.scriptElement.dataset : any
>import.meta.scriptElement : any
>import.meta : ImportMeta
>meta : any
>scriptElement : any
>dataset : any
>size : any
>300 : 300
const image = new Image();
>image : HTMLImageElement
>new Image() : HTMLImageElement
>Image : new (width?: number, height?: number) => HTMLImageElement
image.src = URL.createObjectURL(blob);
>image.src = URL.createObjectURL(blob) : string
>image.src : string
>image : HTMLImageElement
>src : string
>URL.createObjectURL(blob) : string
>URL.createObjectURL : (obj: Blob | MediaSource) => string
>URL : { new (url: string | URL, base?: string | URL): URL; prototype: URL; createObjectURL(obj: Blob | MediaSource): string; revokeObjectURL(url: string): void; }
>createObjectURL : (obj: Blob | MediaSource) => string
>blob : Blob
image.width = image.height = size;
>image.width = image.height = size : any
>image.width : number
>image : HTMLImageElement
>width : number
>image.height = size : any
>image.height : number
>image : HTMLImageElement
>height : number
>size : any
document.body.appendChild(image);
>document.body.appendChild(image) : HTMLImageElement
>document.body.appendChild : <T extends Node>(node: T) => T
>document.body : HTMLElement
>document : Document
>body : HTMLElement
>appendChild : <T extends Node>(node: T) => T
>image : HTMLImageElement
})();
=== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts ===
export let x = import.meta;
>x : ImportMeta
>import.meta : ImportMeta
>meta : any
export let y = import.metal;
>y : any
>import.metal : any
>metal : any
export let z = import.import.import.malkovich;
>z : any
>import.import.import.malkovich : any
>import.import.import : any
>import.import : any
>import : any
>import : any
>malkovich : any
=== tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts ===
let globalA = import.meta;
>globalA : ImportMeta
>import.meta : ImportMeta
>meta : any
let globalB = import.metal;
>globalB : any
>import.metal : any
>metal : any
let globalC = import.import.import.malkovich;
>globalC : any
>import.import.import.malkovich : any
>import.import.import : any
>import.import : any
>import : any
>import : any
>malkovich : any
=== tests/cases/conformance/es2019/importMeta/assignmentTargets.ts ===
export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta;
>foo : ImportMeta
>import.meta.blah = import.meta.blue = import.meta : ImportMeta
>import.meta.blah : any
>import.meta : ImportMeta
>meta : any
>blah : any
>import.meta.blue = import.meta : ImportMeta
>import.meta.blue : any
>import.meta : ImportMeta
>meta : any
>blue : any
>import.meta : ImportMeta
>meta : any
import.meta = foo;
>import.meta = foo : ImportMeta
>import.meta : ImportMeta
>meta : any
>foo : ImportMeta
// @Filename augmentations.ts
declare global {
>global : any
interface ImportMeta {
wellKnownProperty: { a: number, b: string, c: boolean };
>wellKnownProperty : { a: number; b: string; c: boolean; }
>a : number
>b : string
>c : boolean
}
}
const { a, b, c } = import.meta.wellKnownProperty;
>a : number
>b : string
>c : boolean
>import.meta.wellKnownProperty : { a: number; b: string; c: boolean; }
>import.meta : ImportMeta
>meta : any
>wellKnownProperty : { a: number; b: string; c: boolean; }
|