TypeScript/tests/baselines/reference/importAssertion1(module=commonjs).types
Wenlu Wang ec114b8931
Import assertion (#40698)
* Add parsing

* fix all api

* check gramma of import call

* Add more part of assertion

* Add some case

* Add baseline

* use module insted of target

* strip assertion in d.ts

* Update new baseline

* accept baseline

* Revert error number changes

* Update diagnostic message

* Accept baseline

* rename path

* Fix cr issues

* Accept baseline

* Accept baseline

* Error if assertion and typeonly import

* Accept baseline

* Make lint happy

* Add some comment

* Fix cr issues

* Fix more issue

* Incorporate PR feedback, fix module resolution for import()

* Add contextual type and completions for ImportCall options argument

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
2021-09-20 14:15:22 -07:00

138 lines
3.5 KiB
Plaintext

=== tests/cases/conformance/importAssertion/0.ts ===
export const a = 1;
>a : 1
>1 : 1
export const b = 2;
>b : 2
>2 : 2
=== tests/cases/conformance/importAssertion/1.ts ===
import './0' assert { type: "json" }
>type : any
import { a, b } from './0' assert { "type": "json" }
>a : 1
>b : 2
import * as foo from './0' assert { type: "json" }
>foo : typeof foo
>type : any
a;
>a : 1
b;
>b : 2
foo.a;
>foo.a : 1
>foo : typeof foo
>a : 1
foo.b;
>foo.b : 2
>foo : typeof foo
>b : 2
=== tests/cases/conformance/importAssertion/2.ts ===
import { a, b } from './0' assert {}
>a : 1
>b : 2
import { a as c, b as d } from './0' assert { a: "a", b: "b", c: "c" }
>a : 1
>c : 1
>b : 2
>d : 2
>a : any
>b : any
>c : any
a;
>a : 1
b;
>b : 2
c;
>c : 1
d;
>d : 2
=== tests/cases/conformance/importAssertion/3.ts ===
const a = import('./0')
>a : Promise<typeof import("tests/cases/conformance/importAssertion/0")>
>import('./0') : Promise<typeof import("tests/cases/conformance/importAssertion/0")>
>'./0' : "./0"
const b = import('./0', { assert: { type: "json" } })
>b : Promise<typeof import("tests/cases/conformance/importAssertion/0")>
>import('./0', { assert: { type: "json" } }) : Promise<typeof import("tests/cases/conformance/importAssertion/0")>
>'./0' : "./0"
>{ assert: { type: "json" } } : { assert: { type: string; }; }
>assert : { type: string; }
>{ type: "json" } : { type: string; }
>type : string
>"json" : "json"
const c = import('./0', { assert: { type: "json", ttype: "typo" } })
>c : Promise<typeof import("tests/cases/conformance/importAssertion/0")>
>import('./0', { assert: { type: "json", ttype: "typo" } }) : Promise<typeof import("tests/cases/conformance/importAssertion/0")>
>'./0' : "./0"
>{ assert: { type: "json", ttype: "typo" } } : { assert: { type: string; ttype: string; }; }
>assert : { type: string; ttype: string; }
>{ type: "json", ttype: "typo" } : { type: string; ttype: string; }
>type : string
>"json" : "json"
>ttype : string
>"typo" : "typo"
const d = import('./0', { assert: {} })
>d : Promise<typeof import("tests/cases/conformance/importAssertion/0")>
>import('./0', { assert: {} }) : Promise<typeof import("tests/cases/conformance/importAssertion/0")>
>'./0' : "./0"
>{ assert: {} } : { assert: {}; }
>assert : {}
>{} : {}
const dd = import('./0', {})
>dd : Promise<typeof import("tests/cases/conformance/importAssertion/0")>
>import('./0', {}) : Promise<typeof import("tests/cases/conformance/importAssertion/0")>
>'./0' : "./0"
>{} : {}
declare function foo(): any;
>foo : () => any
const e = import('./0', foo())
>e : Promise<typeof import("tests/cases/conformance/importAssertion/0")>
>import('./0', foo()) : Promise<typeof import("tests/cases/conformance/importAssertion/0")>
>'./0' : "./0"
>foo() : any
>foo : () => any
const f = import()
>f : Promise<any>
>import() : Promise<any>
const g = import('./0', {}, {})
>g : Promise<typeof import("tests/cases/conformance/importAssertion/0")>
>import('./0', {}, {}) : Promise<typeof import("tests/cases/conformance/importAssertion/0")>
>'./0' : "./0"
>{} : {}
>{} : {}
const h = import('./0', { assert: { type: "json" }},)
>h : Promise<typeof import("tests/cases/conformance/importAssertion/0")>
>import('./0', { assert: { type: "json" }},) : Promise<typeof import("tests/cases/conformance/importAssertion/0")>
>'./0' : "./0"
>{ assert: { type: "json" }} : { assert: { type: string; }; }
>assert : { type: string; }
>{ type: "json" } : { type: string; }
>type : string
>"json" : "json"