03dff41c9f
* Fix getting completion details for meta properties. * Move inside the worker. * Move ImportMeta handling to completions.ts * Fix property type name for new.target. * Use symbols for ImportMeta completions. * Accept baselines. * Revert lib change. * Revert needless parser change. * Missed these reverts. * Remove now unused `isMetaPropertyExpression` * Move up meta property keyword check to be done in `getSymbolAtLocation` and `getTypeOfNode` * Call `checkNewTargetMetaProperty` directly and handle when it's an error type. * Make meta property expression types synthetic. * Make event.target and import.meta properties readonly * Add a test for go to definition (I think?) * Copy built-in types/values test for go to definition. * Add tests for go to definition when not a module. * Fix "go to definition" for new.target
113 lines
5.8 KiB
Plaintext
113 lines
5.8 KiB
Plaintext
=== tests/cases/conformance/es2019/importMeta/example.ts ===
|
|
// Adapted from https://github.com/tc39/proposal-import-meta/tree/c3902a9ffe2e69a7ac42c19d7ea74cbdcea9b7fb#example
|
|
(async () => {
|
|
const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString());
|
|
>response : Symbol(response, Decl(example.ts, 2, 7))
|
|
>fetch : Symbol(fetch, Decl(lib.dom.d.ts, --, --))
|
|
>new URL("../hamsters.jpg", import.meta.url).toString : Symbol(URL.toString, Decl(lib.dom.d.ts, --, --))
|
|
>URL : Symbol(URL, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
|
|
>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --))
|
|
>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16))
|
|
>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --))
|
|
>toString : Symbol(URL.toString, Decl(lib.dom.d.ts, --, --))
|
|
|
|
const blob = await response.blob();
|
|
>blob : Symbol(blob, Decl(example.ts, 3, 7))
|
|
>response.blob : Symbol(Body.blob, Decl(lib.dom.d.ts, --, --))
|
|
>response : Symbol(response, Decl(example.ts, 2, 7))
|
|
>blob : Symbol(Body.blob, Decl(lib.dom.d.ts, --, --))
|
|
|
|
const size = import.meta.scriptElement.dataset.size || 300;
|
|
>size : Symbol(size, Decl(example.ts, 5, 7))
|
|
>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16))
|
|
|
|
const image = new Image();
|
|
>image : Symbol(image, Decl(example.ts, 7, 7))
|
|
>Image : Symbol(Image, Decl(lib.dom.d.ts, --, --))
|
|
|
|
image.src = URL.createObjectURL(blob);
|
|
>image.src : Symbol(HTMLImageElement.src, Decl(lib.dom.d.ts, --, --))
|
|
>image : Symbol(image, Decl(example.ts, 7, 7))
|
|
>src : Symbol(HTMLImageElement.src, Decl(lib.dom.d.ts, --, --))
|
|
>URL.createObjectURL : Symbol(createObjectURL, Decl(lib.dom.d.ts, --, --))
|
|
>URL : Symbol(URL, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
|
|
>createObjectURL : Symbol(createObjectURL, Decl(lib.dom.d.ts, --, --))
|
|
>blob : Symbol(blob, Decl(example.ts, 3, 7))
|
|
|
|
image.width = image.height = size;
|
|
>image.width : Symbol(HTMLImageElement.width, Decl(lib.dom.d.ts, --, --))
|
|
>image : Symbol(image, Decl(example.ts, 7, 7))
|
|
>width : Symbol(HTMLImageElement.width, Decl(lib.dom.d.ts, --, --))
|
|
>image.height : Symbol(HTMLImageElement.height, Decl(lib.dom.d.ts, --, --))
|
|
>image : Symbol(image, Decl(example.ts, 7, 7))
|
|
>height : Symbol(HTMLImageElement.height, Decl(lib.dom.d.ts, --, --))
|
|
>size : Symbol(size, Decl(example.ts, 5, 7))
|
|
|
|
document.body.appendChild(image);
|
|
>document.body.appendChild : Symbol(Node.appendChild, Decl(lib.dom.d.ts, --, --))
|
|
>document.body : Symbol(Document.body, Decl(lib.dom.d.ts, --, --))
|
|
>document : Symbol(document, Decl(lib.dom.d.ts, --, --))
|
|
>body : Symbol(Document.body, Decl(lib.dom.d.ts, --, --))
|
|
>appendChild : Symbol(Node.appendChild, Decl(lib.dom.d.ts, --, --))
|
|
>image : Symbol(image, Decl(example.ts, 7, 7))
|
|
|
|
})();
|
|
|
|
=== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts ===
|
|
export let x = import.meta;
|
|
>x : Symbol(x, Decl(moduleLookingFile01.ts, 0, 10))
|
|
>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16))
|
|
|
|
export let y = import.metal;
|
|
>y : Symbol(y, Decl(moduleLookingFile01.ts, 1, 10))
|
|
|
|
export let z = import.import.import.malkovich;
|
|
>z : Symbol(z, Decl(moduleLookingFile01.ts, 2, 10))
|
|
|
|
=== tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts ===
|
|
let globalA = import.meta;
|
|
>globalA : Symbol(globalA, Decl(scriptLookingFile01.ts, 0, 3))
|
|
>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16))
|
|
|
|
let globalB = import.metal;
|
|
>globalB : Symbol(globalB, Decl(scriptLookingFile01.ts, 1, 3))
|
|
|
|
let globalC = import.import.import.malkovich;
|
|
>globalC : Symbol(globalC, Decl(scriptLookingFile01.ts, 2, 3))
|
|
|
|
=== tests/cases/conformance/es2019/importMeta/assignmentTargets.ts ===
|
|
export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta;
|
|
>foo : Symbol(foo, Decl(assignmentTargets.ts, 0, 12))
|
|
>ImportMeta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16))
|
|
>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16))
|
|
>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16))
|
|
>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16))
|
|
|
|
import.meta = foo;
|
|
>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16))
|
|
>foo : Symbol(foo, Decl(assignmentTargets.ts, 0, 12))
|
|
|
|
// @Filename augmentations.ts
|
|
declare global {
|
|
>global : Symbol(global, Decl(assignmentTargets.ts, 1, 18))
|
|
|
|
interface ImportMeta {
|
|
>ImportMeta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16))
|
|
|
|
wellKnownProperty: { a: number, b: string, c: boolean };
|
|
>wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24))
|
|
>a : Symbol(a, Decl(assignmentTargets.ts, 6, 24))
|
|
>b : Symbol(b, Decl(assignmentTargets.ts, 6, 35))
|
|
>c : Symbol(c, Decl(assignmentTargets.ts, 6, 46))
|
|
}
|
|
}
|
|
|
|
const { a, b, c } = import.meta.wellKnownProperty;
|
|
>a : Symbol(a, Decl(assignmentTargets.ts, 10, 7))
|
|
>b : Symbol(b, Decl(assignmentTargets.ts, 10, 10))
|
|
>c : Symbol(c, Decl(assignmentTargets.ts, 10, 13))
|
|
>import.meta.wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24))
|
|
>import.meta : Symbol(ImportMeta, Decl(lib.es5.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(assignmentTargets.ts, 4, 16))
|
|
>wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24))
|
|
|