166 lines
5.7 KiB
Text
166 lines
5.7 KiB
Text
=== 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, 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, base?: string | URL): URL; prototype: URL; createObjectURL(object: any): string; revokeObjectURL(url: string): void; }
|
|
>"../hamsters.jpg" : "../hamsters.jpg"
|
|
>import.meta.url : any
|
|
>import.meta : ImportMeta
|
|
>meta : any
|
|
>url : any
|
|
>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 : (object: any) => string
|
|
>URL : { new (url: string, base?: string | URL): URL; prototype: URL; createObjectURL(object: any): string; revokeObjectURL(url: string): void; }
|
|
>createObjectURL : (object: any) => 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>(newChild: T) => T
|
|
>document.body : HTMLElement
|
|
>document : Document
|
|
>body : HTMLElement
|
|
>appendChild : <T extends Node>(newChild: 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; }
|
|
|