Add support for import.meta in System modules (#32797)
This commit is contained in:
parent
2a2866c3a9
commit
bf054ae796
|
@ -23161,8 +23161,8 @@ namespace ts {
|
|||
}
|
||||
|
||||
function checkImportMetaProperty(node: MetaProperty) {
|
||||
if (languageVersion < ScriptTarget.ESNext || moduleKind < ModuleKind.ESNext) {
|
||||
error(node, Diagnostics.The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options);
|
||||
if (moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System) {
|
||||
error(node, Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system);
|
||||
}
|
||||
const file = getSourceFileOfNode(node);
|
||||
Debug.assert(!!(file.flags & NodeFlags.PossiblyContainsImportMeta), "Containing file is missing import meta node flag.");
|
||||
|
|
|
@ -979,7 +979,7 @@
|
|||
"category": "Error",
|
||||
"code": 1342
|
||||
},
|
||||
"The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.": {
|
||||
"The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.": {
|
||||
"category": "Error",
|
||||
"code": 1343
|
||||
},
|
||||
|
|
|
@ -24,12 +24,14 @@ namespace ts {
|
|||
context.enableSubstitution(SyntaxKind.BinaryExpression); // Substitutes assignments to exported symbols.
|
||||
context.enableSubstitution(SyntaxKind.PrefixUnaryExpression); // Substitutes updates to exported symbols.
|
||||
context.enableSubstitution(SyntaxKind.PostfixUnaryExpression); // Substitutes updates to exported symbols.
|
||||
context.enableSubstitution(SyntaxKind.MetaProperty); // Substitutes 'import.meta'
|
||||
context.enableEmitNotification(SyntaxKind.SourceFile); // Restore state when substituting nodes in a file.
|
||||
|
||||
const moduleInfoMap: ExternalModuleInfo[] = []; // The ExternalModuleInfo for each file.
|
||||
const deferredExports: (Statement[] | undefined)[] = []; // Exports to defer until an EndOfDeclarationMarker is found.
|
||||
const exportFunctionsMap: Identifier[] = []; // The export function associated with a source file.
|
||||
const noSubstitutionMap: boolean[][] = []; // Set of nodes for which substitution rules should be ignored for each file.
|
||||
const contextObjectMap: Identifier[] = []; // The context object associated with a source file.
|
||||
|
||||
let currentSourceFile: SourceFile; // The current file.
|
||||
let moduleInfo: ExternalModuleInfo; // ExternalModuleInfo for the current file.
|
||||
|
@ -75,7 +77,7 @@ namespace ts {
|
|||
// existing identifiers.
|
||||
exportFunction = createUniqueName("exports");
|
||||
exportFunctionsMap[id] = exportFunction;
|
||||
contextObject = createUniqueName("context");
|
||||
contextObject = contextObjectMap[id] = createUniqueName("context");
|
||||
|
||||
// Add the body of the module.
|
||||
const dependencyGroups = collectDependencyGroups(moduleInfo.externalImports);
|
||||
|
@ -1586,6 +1588,7 @@ namespace ts {
|
|||
moduleInfo = moduleInfoMap[id];
|
||||
exportFunction = exportFunctionsMap[id];
|
||||
noSubstitution = noSubstitutionMap[id];
|
||||
contextObject = contextObjectMap[id];
|
||||
|
||||
if (noSubstitution) {
|
||||
delete noSubstitutionMap[id];
|
||||
|
@ -1596,6 +1599,7 @@ namespace ts {
|
|||
currentSourceFile = undefined!;
|
||||
moduleInfo = undefined!;
|
||||
exportFunction = undefined!;
|
||||
contextObject = undefined!;
|
||||
noSubstitution = undefined;
|
||||
}
|
||||
else {
|
||||
|
@ -1641,6 +1645,7 @@ namespace ts {
|
|||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Substitution for a ShorthandPropertyAssignment whose name that may contain an imported or exported symbol.
|
||||
*
|
||||
|
@ -1694,6 +1699,8 @@ namespace ts {
|
|||
case SyntaxKind.PrefixUnaryExpression:
|
||||
case SyntaxKind.PostfixUnaryExpression:
|
||||
return substituteUnaryExpression(<PrefixUnaryExpression | PostfixUnaryExpression>node);
|
||||
case SyntaxKind.MetaProperty:
|
||||
return substituteMetaProperty(<MetaProperty>node);
|
||||
}
|
||||
|
||||
return node;
|
||||
|
@ -1830,6 +1837,13 @@ namespace ts {
|
|||
return node;
|
||||
}
|
||||
|
||||
function substituteMetaProperty(node: MetaProperty) {
|
||||
if (isImportMeta(node)) {
|
||||
return createPropertyAccess(contextObject, createIdentifier("meta"));
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the exports of a name.
|
||||
*
|
||||
|
|
|
@ -1864,6 +1864,12 @@ namespace ts {
|
|||
name: Identifier;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export interface ImportMetaProperty extends MetaProperty {
|
||||
keywordToken: SyntaxKind.ImportKeyword;
|
||||
name: Identifier & { escapedText: __String & "meta" };
|
||||
}
|
||||
|
||||
/// A JSX expression of the form <TagName attrs>...</TagName>
|
||||
export interface JsxElement extends PrimaryExpression {
|
||||
kind: SyntaxKind.JsxElement;
|
||||
|
|
|
@ -987,6 +987,12 @@ namespace ts {
|
|||
return n.kind === SyntaxKind.CallExpression && (<CallExpression>n).expression.kind === SyntaxKind.ImportKeyword;
|
||||
}
|
||||
|
||||
export function isImportMeta(n: Node): n is ImportMetaProperty {
|
||||
return isMetaProperty(n)
|
||||
&& n.keywordToken === SyntaxKind.ImportKeyword
|
||||
&& n.name.escapedText === "meta";
|
||||
}
|
||||
|
||||
export function isLiteralImportTypeNode(n: Node): n is LiteralImportTypeNode {
|
||||
return isImportTypeNode(n) && isLiteralTypeNode(n.argument) && isStringLiteral(n.argument.literal);
|
||||
}
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
error TS2468: Cannot find global value 'Promise'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,32): error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,32): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,44): error TS2339: Property 'blah' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,51): error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,51): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,63): error TS2339: Property 'blue' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(3,71): error TS2339: Property 'url' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(6,28): error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(1,16): error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,16): error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(1,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,23): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,16): error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,23): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(1,15): error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,15): error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(1,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,22): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,15): error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
|
||||
|
||||
|
@ -32,14 +32,14 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS
|
|||
!!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.
|
||||
const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString());
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
~~~
|
||||
!!! error TS2339: Property 'url' does not exist on type 'ImportMeta'.
|
||||
const blob = await response.blob();
|
||||
|
||||
const size = import.meta.scriptElement.dataset.size || 300;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'.
|
||||
|
||||
|
@ -53,48 +53,48 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS
|
|||
==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (5 errors) ====
|
||||
export let x = import.meta;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
export let y = import.metal;
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
~~~~~
|
||||
!!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
export let z = import.import.import.malkovich;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
~~~~~~
|
||||
!!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
|
||||
==== tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts (5 errors) ====
|
||||
let globalA = import.meta;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
let globalB = import.metal;
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
~~~~~
|
||||
!!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
let globalC = import.import.import.malkovich;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
~~~~~~
|
||||
!!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
|
||||
==== tests/cases/conformance/es2019/importMeta/assignmentTargets.ts (8 errors) ====
|
||||
export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
~~~~
|
||||
!!! error TS2339: Property 'blah' does not exist on type 'ImportMeta'.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
~~~~
|
||||
!!! error TS2339: Property 'blue' does not exist on type 'ImportMeta'.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
import.meta = foo;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
|
@ -107,4 +107,4 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS
|
|||
|
||||
const { a, b, c } = import.meta.wellKnownProperty;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
|
@ -1,4 +1,4 @@
|
|||
//// [tests/cases/conformance/es2019/importMeta/importMetaES5.ts] ////
|
||||
//// [tests/cases/conformance/es2019/importMeta/importMeta.ts] ////
|
||||
|
||||
//// [example.ts]
|
||||
// Adapted from https://github.com/tc39/proposal-import-meta/tree/c3902a9ffe2e69a7ac42c19d7ea74cbdcea9b7fb#example
|
|
@ -0,0 +1,110 @@
|
|||
error TS2468: Cannot find global value 'Promise'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,32): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,44): error TS2339: Property 'blah' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,51): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,63): error TS2339: Property 'blue' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(3,71): error TS2339: Property 'url' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(6,28): error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(1,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,23): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,23): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(1,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,22): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
|
||||
|
||||
!!! error TS2468: Cannot find global value 'Promise'.
|
||||
==== tests/cases/conformance/es2019/importMeta/example.ts (5 errors) ====
|
||||
// Adapted from https://github.com/tc39/proposal-import-meta/tree/c3902a9ffe2e69a7ac42c19d7ea74cbdcea9b7fb#example
|
||||
(async () => {
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.
|
||||
const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString());
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
~~~
|
||||
!!! error TS2339: Property 'url' does not exist on type 'ImportMeta'.
|
||||
const blob = await response.blob();
|
||||
|
||||
const size = import.meta.scriptElement.dataset.size || 300;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'.
|
||||
|
||||
const image = new Image();
|
||||
image.src = URL.createObjectURL(blob);
|
||||
image.width = image.height = size;
|
||||
|
||||
document.body.appendChild(image);
|
||||
})();
|
||||
|
||||
==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (5 errors) ====
|
||||
export let x = import.meta;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
export let y = import.metal;
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
~~~~~
|
||||
!!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
export let z = import.import.import.malkovich;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
~~~~~~
|
||||
!!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
|
||||
==== tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts (5 errors) ====
|
||||
let globalA = import.meta;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
let globalB = import.metal;
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
~~~~~
|
||||
!!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
let globalC = import.import.import.malkovich;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
~~~~~~
|
||||
!!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
|
||||
==== tests/cases/conformance/es2019/importMeta/assignmentTargets.ts (8 errors) ====
|
||||
export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
~~~~
|
||||
!!! error TS2339: Property 'blah' does not exist on type 'ImportMeta'.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
~~~~
|
||||
!!! error TS2339: Property 'blue' does not exist on type 'ImportMeta'.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
import.meta = foo;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
// @Filename augmentations.ts
|
||||
declare global {
|
||||
interface ImportMeta {
|
||||
wellKnownProperty: { a: number, b: string, c: boolean };
|
||||
}
|
||||
}
|
||||
|
||||
const { a, b, c } = import.meta.wellKnownProperty;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
|
|
@ -0,0 +1,71 @@
|
|||
//// [tests/cases/conformance/es2019/importMeta/importMeta.ts] ////
|
||||
|
||||
//// [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());
|
||||
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);
|
||||
})();
|
||||
|
||||
//// [moduleLookingFile01.ts]
|
||||
export let x = import.meta;
|
||||
export let y = import.metal;
|
||||
export let z = import.import.import.malkovich;
|
||||
|
||||
//// [scriptLookingFile01.ts]
|
||||
let globalA = import.meta;
|
||||
let globalB = import.metal;
|
||||
let globalC = import.import.import.malkovich;
|
||||
|
||||
//// [assignmentTargets.ts]
|
||||
export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta;
|
||||
import.meta = foo;
|
||||
|
||||
// @Filename augmentations.ts
|
||||
declare global {
|
||||
interface ImportMeta {
|
||||
wellKnownProperty: { a: number, b: string, c: boolean };
|
||||
}
|
||||
}
|
||||
|
||||
const { a, b, c } = import.meta.wellKnownProperty;
|
||||
|
||||
//// [example.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// 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());
|
||||
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);
|
||||
})();
|
||||
//// [moduleLookingFile01.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.x = (import.meta);
|
||||
exports.y = (import.metal);
|
||||
exports.z = import.import.import.malkovich;
|
||||
//// [scriptLookingFile01.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
let globalA = import.meta;
|
||||
let globalB = import.metal;
|
||||
let globalC = import.import.import.malkovich;
|
||||
//// [assignmentTargets.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.foo = import.meta.blah = import.meta.blue = import.meta;
|
||||
import.meta = exports.foo;
|
||||
const { a, b, c } = import.meta.wellKnownProperty;
|
|
@ -0,0 +1,110 @@
|
|||
//// [tests/cases/conformance/es2019/importMeta/importMeta.ts] ////
|
||||
|
||||
//// [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());
|
||||
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);
|
||||
})();
|
||||
|
||||
//// [moduleLookingFile01.ts]
|
||||
export let x = import.meta;
|
||||
export let y = import.metal;
|
||||
export let z = import.import.import.malkovich;
|
||||
|
||||
//// [scriptLookingFile01.ts]
|
||||
let globalA = import.meta;
|
||||
let globalB = import.metal;
|
||||
let globalC = import.import.import.malkovich;
|
||||
|
||||
//// [assignmentTargets.ts]
|
||||
export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta;
|
||||
import.meta = foo;
|
||||
|
||||
// @Filename augmentations.ts
|
||||
declare global {
|
||||
interface ImportMeta {
|
||||
wellKnownProperty: { a: number, b: string, c: boolean };
|
||||
}
|
||||
}
|
||||
|
||||
const { a, b, c } = import.meta.wellKnownProperty;
|
||||
|
||||
//// [example.js]
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var _this = this;
|
||||
// Adapted from https://github.com/tc39/proposal-import-meta/tree/c3902a9ffe2e69a7ac42c19d7ea74cbdcea9b7fb#example
|
||||
(function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var response, blob, size, image;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, fetch(new URL("../hamsters.jpg", import.meta.url).toString())];
|
||||
case 1:
|
||||
response = _a.sent();
|
||||
return [4 /*yield*/, response.blob()];
|
||||
case 2:
|
||||
blob = _a.sent();
|
||||
size = import.meta.scriptElement.dataset.size || 300;
|
||||
image = new Image();
|
||||
image.src = URL.createObjectURL(blob);
|
||||
image.width = image.height = size;
|
||||
document.body.appendChild(image);
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); })();
|
||||
//// [moduleLookingFile01.js]
|
||||
export var x = import.meta;
|
||||
export var y = import.metal;
|
||||
export var z = import.import.import.malkovich;
|
||||
//// [scriptLookingFile01.js]
|
||||
var globalA = import.meta;
|
||||
var globalB = import.metal;
|
||||
var globalC = import.import.import.malkovich;
|
||||
//// [assignmentTargets.js]
|
||||
export var foo = import.meta.blah = import.meta.blue = import.meta;
|
||||
import.meta = foo;
|
||||
var _a = import.meta.wellKnownProperty, a = _a.a, b = _a.b, c = _a.c;
|
|
@ -0,0 +1,101 @@
|
|||
=== 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(Object.toString, Decl(lib.es5.d.ts, --, --))
|
||||
>URL : Symbol(URL, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
|
||||
>toString : Symbol(Object.toString, Decl(lib.es5.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))
|
||||
|
||||
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))
|
||||
|
||||
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))
|
||||
|
||||
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(assignmentTargets.ts, 4, 16))
|
||||
|
||||
import.meta = foo;
|
||||
>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(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))
|
||||
>wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24))
|
||||
|
|
@ -0,0 +1,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, 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; }
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
error TS2468: Cannot find global value 'Promise'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,44): error TS2339: Property 'blah' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,63): error TS2339: Property 'blue' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(3,71): error TS2339: Property 'url' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(6,28): error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,23): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,23): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,22): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
|
||||
|
||||
!!! error TS2468: Cannot find global value 'Promise'.
|
||||
==== tests/cases/conformance/es2019/importMeta/example.ts (3 errors) ====
|
||||
// Adapted from https://github.com/tc39/proposal-import-meta/tree/c3902a9ffe2e69a7ac42c19d7ea74cbdcea9b7fb#example
|
||||
(async () => {
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.
|
||||
const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString());
|
||||
~~~
|
||||
!!! error TS2339: Property 'url' does not exist on type 'ImportMeta'.
|
||||
const blob = await response.blob();
|
||||
|
||||
const size = import.meta.scriptElement.dataset.size || 300;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'.
|
||||
|
||||
const image = new Image();
|
||||
image.src = URL.createObjectURL(blob);
|
||||
image.width = image.height = size;
|
||||
|
||||
document.body.appendChild(image);
|
||||
})();
|
||||
|
||||
==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (2 errors) ====
|
||||
export let x = import.meta;
|
||||
export let y = import.metal;
|
||||
~~~~~
|
||||
!!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
export let z = import.import.import.malkovich;
|
||||
~~~~~~
|
||||
!!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
|
||||
==== tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts (2 errors) ====
|
||||
let globalA = import.meta;
|
||||
let globalB = import.metal;
|
||||
~~~~~
|
||||
!!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
let globalC = import.import.import.malkovich;
|
||||
~~~~~~
|
||||
!!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
|
||||
==== tests/cases/conformance/es2019/importMeta/assignmentTargets.ts (3 errors) ====
|
||||
export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta;
|
||||
~~~~
|
||||
!!! error TS2339: Property 'blah' does not exist on type 'ImportMeta'.
|
||||
~~~~
|
||||
!!! error TS2339: Property 'blue' does not exist on type 'ImportMeta'.
|
||||
import.meta = foo;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
// @Filename augmentations.ts
|
||||
declare global {
|
||||
interface ImportMeta {
|
||||
wellKnownProperty: { a: number, b: string, c: boolean };
|
||||
}
|
||||
}
|
||||
|
||||
const { a, b, c } = import.meta.wellKnownProperty;
|
|
@ -0,0 +1,101 @@
|
|||
=== 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(Object.toString, Decl(lib.es5.d.ts, --, --))
|
||||
>URL : Symbol(URL, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
|
||||
>toString : Symbol(Object.toString, Decl(lib.es5.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))
|
||||
|
||||
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))
|
||||
|
||||
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))
|
||||
|
||||
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(assignmentTargets.ts, 4, 16))
|
||||
|
||||
import.meta = foo;
|
||||
>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(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))
|
||||
>wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24))
|
||||
|
|
@ -0,0 +1,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, 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; }
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
error TS2468: Cannot find global value 'Promise'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,44): error TS2339: Property 'blah' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,63): error TS2339: Property 'blue' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(3,71): error TS2339: Property 'url' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(6,28): error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,23): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,23): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,22): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
|
||||
|
||||
!!! error TS2468: Cannot find global value 'Promise'.
|
||||
==== tests/cases/conformance/es2019/importMeta/example.ts (3 errors) ====
|
||||
// Adapted from https://github.com/tc39/proposal-import-meta/tree/c3902a9ffe2e69a7ac42c19d7ea74cbdcea9b7fb#example
|
||||
(async () => {
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.
|
||||
const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString());
|
||||
~~~
|
||||
!!! error TS2339: Property 'url' does not exist on type 'ImportMeta'.
|
||||
const blob = await response.blob();
|
||||
|
||||
const size = import.meta.scriptElement.dataset.size || 300;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'.
|
||||
|
||||
const image = new Image();
|
||||
image.src = URL.createObjectURL(blob);
|
||||
image.width = image.height = size;
|
||||
|
||||
document.body.appendChild(image);
|
||||
})();
|
||||
|
||||
==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (2 errors) ====
|
||||
export let x = import.meta;
|
||||
export let y = import.metal;
|
||||
~~~~~
|
||||
!!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
export let z = import.import.import.malkovich;
|
||||
~~~~~~
|
||||
!!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
|
||||
==== tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts (2 errors) ====
|
||||
let globalA = import.meta;
|
||||
let globalB = import.metal;
|
||||
~~~~~
|
||||
!!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
let globalC = import.import.import.malkovich;
|
||||
~~~~~~
|
||||
!!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
|
||||
==== tests/cases/conformance/es2019/importMeta/assignmentTargets.ts (3 errors) ====
|
||||
export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta;
|
||||
~~~~
|
||||
!!! error TS2339: Property 'blah' does not exist on type 'ImportMeta'.
|
||||
~~~~
|
||||
!!! error TS2339: Property 'blue' does not exist on type 'ImportMeta'.
|
||||
import.meta = foo;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
// @Filename augmentations.ts
|
||||
declare global {
|
||||
interface ImportMeta {
|
||||
wellKnownProperty: { a: number, b: string, c: boolean };
|
||||
}
|
||||
}
|
||||
|
||||
const { a, b, c } = import.meta.wellKnownProperty;
|
|
@ -0,0 +1,150 @@
|
|||
//// [tests/cases/conformance/es2019/importMeta/importMeta.ts] ////
|
||||
|
||||
//// [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());
|
||||
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);
|
||||
})();
|
||||
|
||||
//// [moduleLookingFile01.ts]
|
||||
export let x = import.meta;
|
||||
export let y = import.metal;
|
||||
export let z = import.import.import.malkovich;
|
||||
|
||||
//// [scriptLookingFile01.ts]
|
||||
let globalA = import.meta;
|
||||
let globalB = import.metal;
|
||||
let globalC = import.import.import.malkovich;
|
||||
|
||||
//// [assignmentTargets.ts]
|
||||
export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta;
|
||||
import.meta = foo;
|
||||
|
||||
// @Filename augmentations.ts
|
||||
declare global {
|
||||
interface ImportMeta {
|
||||
wellKnownProperty: { a: number, b: string, c: boolean };
|
||||
}
|
||||
}
|
||||
|
||||
const { a, b, c } = import.meta.wellKnownProperty;
|
||||
|
||||
//// [example.js]
|
||||
System.register([], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var _this;
|
||||
_this = this;
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
// Adapted from https://github.com/tc39/proposal-import-meta/tree/c3902a9ffe2e69a7ac42c19d7ea74cbdcea9b7fb#example
|
||||
(function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var response, blob, size, image;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, fetch(new URL("../hamsters.jpg", context_1.meta.url).toString())];
|
||||
case 1:
|
||||
response = _a.sent();
|
||||
return [4 /*yield*/, response.blob()];
|
||||
case 2:
|
||||
blob = _a.sent();
|
||||
size = context_1.meta.scriptElement.dataset.size || 300;
|
||||
image = new Image();
|
||||
image.src = URL.createObjectURL(blob);
|
||||
image.width = image.height = size;
|
||||
document.body.appendChild(image);
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); })();
|
||||
}
|
||||
};
|
||||
});
|
||||
//// [moduleLookingFile01.js]
|
||||
System.register([], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var x, y, z;
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
exports_1("x", x = (context_1.meta));
|
||||
exports_1("y", y = (import.metal));
|
||||
exports_1("z", z = import.import.import.malkovich);
|
||||
}
|
||||
};
|
||||
});
|
||||
//// [scriptLookingFile01.js]
|
||||
System.register([], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var globalA, globalB, globalC;
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
globalA = (context_1.meta);
|
||||
globalB = (import.metal);
|
||||
globalC = import.import.import.malkovich;
|
||||
}
|
||||
};
|
||||
});
|
||||
//// [assignmentTargets.js]
|
||||
System.register([], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var foo, _a, a, b, c;
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
exports_1("foo", foo = context_1.meta.blah = context_1.meta.blue = context_1.meta);
|
||||
context_1.meta = foo;
|
||||
_a = context_1.meta.wellKnownProperty, a = _a.a, b = _a.b, c = _a.c;
|
||||
}
|
||||
};
|
||||
});
|
|
@ -0,0 +1,101 @@
|
|||
=== 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(Object.toString, Decl(lib.es5.d.ts, --, --))
|
||||
>URL : Symbol(URL, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
|
||||
>toString : Symbol(Object.toString, Decl(lib.es5.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))
|
||||
|
||||
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))
|
||||
|
||||
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))
|
||||
|
||||
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(assignmentTargets.ts, 4, 16))
|
||||
|
||||
import.meta = foo;
|
||||
>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(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))
|
||||
>wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24))
|
||||
|
|
@ -0,0 +1,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, 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; }
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
error TS2468: Cannot find global value 'Promise'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,44): error TS2339: Property 'blah' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,63): error TS2339: Property 'blue' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(3,71): error TS2339: Property 'url' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/example.ts(6,28): error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'.
|
||||
tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,23): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,23): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,22): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
|
||||
|
||||
!!! error TS2468: Cannot find global value 'Promise'.
|
||||
==== tests/cases/conformance/es2019/importMeta/example.ts (3 errors) ====
|
||||
// Adapted from https://github.com/tc39/proposal-import-meta/tree/c3902a9ffe2e69a7ac42c19d7ea74cbdcea9b7fb#example
|
||||
(async () => {
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.
|
||||
const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString());
|
||||
~~~
|
||||
!!! error TS2339: Property 'url' does not exist on type 'ImportMeta'.
|
||||
const blob = await response.blob();
|
||||
|
||||
const size = import.meta.scriptElement.dataset.size || 300;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'.
|
||||
|
||||
const image = new Image();
|
||||
image.src = URL.createObjectURL(blob);
|
||||
image.width = image.height = size;
|
||||
|
||||
document.body.appendChild(image);
|
||||
})();
|
||||
|
||||
==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (2 errors) ====
|
||||
export let x = import.meta;
|
||||
export let y = import.metal;
|
||||
~~~~~
|
||||
!!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
export let z = import.import.import.malkovich;
|
||||
~~~~~~
|
||||
!!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
|
||||
==== tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts (2 errors) ====
|
||||
let globalA = import.meta;
|
||||
let globalB = import.metal;
|
||||
~~~~~
|
||||
!!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
let globalC = import.import.import.malkovich;
|
||||
~~~~~~
|
||||
!!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'?
|
||||
|
||||
==== tests/cases/conformance/es2019/importMeta/assignmentTargets.ts (3 errors) ====
|
||||
export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta;
|
||||
~~~~
|
||||
!!! error TS2339: Property 'blah' does not exist on type 'ImportMeta'.
|
||||
~~~~
|
||||
!!! error TS2339: Property 'blue' does not exist on type 'ImportMeta'.
|
||||
import.meta = foo;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
|
||||
|
||||
// @Filename augmentations.ts
|
||||
declare global {
|
||||
interface ImportMeta {
|
||||
wellKnownProperty: { a: number, b: string, c: boolean };
|
||||
}
|
||||
}
|
||||
|
||||
const { a, b, c } = import.meta.wellKnownProperty;
|
|
@ -0,0 +1,102 @@
|
|||
//// [tests/cases/conformance/es2019/importMeta/importMeta.ts] ////
|
||||
|
||||
//// [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());
|
||||
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);
|
||||
})();
|
||||
|
||||
//// [moduleLookingFile01.ts]
|
||||
export let x = import.meta;
|
||||
export let y = import.metal;
|
||||
export let z = import.import.import.malkovich;
|
||||
|
||||
//// [scriptLookingFile01.ts]
|
||||
let globalA = import.meta;
|
||||
let globalB = import.metal;
|
||||
let globalC = import.import.import.malkovich;
|
||||
|
||||
//// [assignmentTargets.ts]
|
||||
export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta;
|
||||
import.meta = foo;
|
||||
|
||||
// @Filename augmentations.ts
|
||||
declare global {
|
||||
interface ImportMeta {
|
||||
wellKnownProperty: { a: number, b: string, c: boolean };
|
||||
}
|
||||
}
|
||||
|
||||
const { a, b, c } = import.meta.wellKnownProperty;
|
||||
|
||||
//// [example.js]
|
||||
System.register([], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
// Adapted from https://github.com/tc39/proposal-import-meta/tree/c3902a9ffe2e69a7ac42c19d7ea74cbdcea9b7fb#example
|
||||
(async () => {
|
||||
const response = await fetch(new URL("../hamsters.jpg", context_1.meta.url).toString());
|
||||
const blob = await response.blob();
|
||||
const size = context_1.meta.scriptElement.dataset.size || 300;
|
||||
const image = new Image();
|
||||
image.src = URL.createObjectURL(blob);
|
||||
image.width = image.height = size;
|
||||
document.body.appendChild(image);
|
||||
})();
|
||||
}
|
||||
};
|
||||
});
|
||||
//// [moduleLookingFile01.js]
|
||||
System.register([], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var x, y, z;
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
exports_1("x", x = (context_1.meta));
|
||||
exports_1("y", y = (import.metal));
|
||||
exports_1("z", z = import.import.import.malkovich);
|
||||
}
|
||||
};
|
||||
});
|
||||
//// [scriptLookingFile01.js]
|
||||
System.register([], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var globalA, globalB, globalC;
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
globalA = (context_1.meta);
|
||||
globalB = (import.metal);
|
||||
globalC = import.import.import.malkovich;
|
||||
}
|
||||
};
|
||||
});
|
||||
//// [assignmentTargets.js]
|
||||
System.register([], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var foo, _a, a, b, c;
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
exports_1("foo", foo = context_1.meta.blah = context_1.meta.blue = context_1.meta);
|
||||
context_1.meta = foo;
|
||||
_a = context_1.meta.wellKnownProperty, a = _a.a, b = _a.b, c = _a.c;
|
||||
}
|
||||
};
|
||||
});
|
|
@ -0,0 +1,101 @@
|
|||
=== 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(Object.toString, Decl(lib.es5.d.ts, --, --))
|
||||
>URL : Symbol(URL, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
|
||||
>toString : Symbol(Object.toString, Decl(lib.es5.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))
|
||||
|
||||
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))
|
||||
|
||||
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))
|
||||
|
||||
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(assignmentTargets.ts, 4, 16))
|
||||
|
||||
import.meta = foo;
|
||||
>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(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))
|
||||
>wellKnownProperty : Symbol(ImportMeta.wellKnownProperty, Decl(assignmentTargets.ts, 5, 24))
|
||||
|
|
@ -0,0 +1,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, 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; }
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
// @target: esnext
|
||||
// @module: esnext
|
||||
// @target: esnext,es5
|
||||
// @module: esnext,commonjs,system
|
||||
// @lib: es5,dom
|
||||
|
||||
// @Filename: example.ts
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
// @lib: es5,dom
|
||||
|
||||
// @Filename: 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());
|
||||
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);
|
||||
})();
|
||||
|
||||
// @Filename: moduleLookingFile01.ts
|
||||
export let x = import.meta;
|
||||
export let y = import.metal;
|
||||
export let z = import.import.import.malkovich;
|
||||
|
||||
// @Filename: scriptLookingFile01.ts
|
||||
let globalA = import.meta;
|
||||
let globalB = import.metal;
|
||||
let globalC = import.import.import.malkovich;
|
||||
|
||||
// @Filename: assignmentTargets.ts
|
||||
export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta;
|
||||
import.meta = foo;
|
||||
|
||||
// @Filename augmentations.ts
|
||||
declare global {
|
||||
interface ImportMeta {
|
||||
wellKnownProperty: { a: number, b: string, c: boolean };
|
||||
}
|
||||
}
|
||||
|
||||
const { a, b, c } = import.meta.wellKnownProperty;
|
Loading…
Reference in a new issue