Skip to content

Import assertion #40698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e1b3b78
Add parsing
Kingwl Sep 22, 2020
66d2273
fix all api
Kingwl Sep 22, 2020
5f3cea6
check gramma of import call
Kingwl Sep 22, 2020
5a1af04
Add more part of assertion
Kingwl Sep 22, 2020
4b51ca9
Add some case
Kingwl Sep 22, 2020
375b433
Add baseline
Kingwl Sep 22, 2020
41a881c
use module insted of target
Kingwl Sep 23, 2020
46a3eb1
strip assertion in d.ts
Kingwl Sep 23, 2020
a484ea2
Merge branch 'master' into import_assertion
Kingwl Sep 23, 2020
d64f7ba
Merge branch 'master' into import_assertion
Kingwl Nov 12, 2020
68c8c5d
Merge branch 'master' into import_assertion
Kingwl Dec 31, 2020
29fe0d3
Merge branch 'master' into import_assertion
Kingwl Jan 7, 2021
adcfd1b
Update new baseline
Kingwl Jan 7, 2021
fb01eb3
Merge branch 'master' into import_assertion
Kingwl Mar 8, 2021
4f22a60
accept baseline
Kingwl Mar 8, 2021
f5e594d
Revert error number changes
Kingwl Mar 9, 2021
60434d1
Update diagnostic message
Kingwl Mar 9, 2021
ff87d3e
Accept baseline
Kingwl Mar 9, 2021
43b67b9
Merge branch 'master' into import_assertion
Kingwl Mar 15, 2021
c69a05b
rename path
Kingwl Mar 15, 2021
d1c48b5
Fix cr issues
Kingwl Mar 15, 2021
d14f93a
Accept baseline
Kingwl Mar 15, 2021
aa8b856
Accept baseline
Kingwl Mar 15, 2021
7a5ec34
Merge branch 'master' into import_assertion
Kingwl Mar 18, 2021
9cea9cf
Error if assertion and typeonly import
Kingwl Mar 18, 2021
6337a7e
Merge branch 'main' into import_assertion
Kingwl Jun 17, 2021
eee2cab
Accept baseline
Kingwl Jun 17, 2021
2857d69
Merge branch 'main' into import_assertion
Kingwl Jul 9, 2021
88e39d5
Make lint happy
Kingwl Jul 9, 2021
f941d92
Merge branch 'main' into import_assertion
Kingwl Aug 13, 2021
106ff06
Add some comment
Kingwl Aug 13, 2021
7df4964
Merge branch 'main' into import_assertion
Kingwl Sep 14, 2021
6ea3c55
Fix cr issues
Kingwl Sep 14, 2021
fc51c42
Fix more issue
Kingwl Sep 14, 2021
bf7ca71
Incorporate PR feedback, fix module resolution for import()
rbuckton Sep 17, 2021
463138a
Merge branch 'main' into import_assertion
rbuckton Sep 17, 2021
b07c6e9
Add contextual type and completions for ImportCall options argument
rbuckton Sep 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into import_assertion
  • Loading branch information
Kingwl committed Sep 14, 2021
commit 7df49642abbd141dbdeef65de865809dd2f42f68
18 changes: 17 additions & 1 deletion src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1372,9 +1372,25 @@
"category": "Error",
"code": 1443
},
"'{0}' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.": {
"category": "Error",
"code": 1444
},
"'{0}' resolves to a type-only declaration and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.": {
"category": "Error",
"code": 1446
},
"'{0}' resolves to a type-only declaration and must be re-exported using a type-only re-export when 'isolatedModules' is enabled.": {
"category": "Error",
"code": 1448
},
"Preserve unused imported values in the JavaScript output that would otherwise be removed.": {
"category": "Message",
"code": 1449
},
"Dynamic import must only have a specifier and an optional assertion as arguments": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Dynamic import must only have a specifier and an optional assertion as arguments": {
"Dynamic imports can only accept a path and an optional assertion as arguments": {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, but I think module specifier is a more correct term than path

"category": "Message",
"code": 1444
"code": 1450
},

"The types of '{0}' are incompatible between these types.": {
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4368,7 +4368,7 @@ declare namespace ts {
function isTemplateLiteralToken(node: Node): node is TemplateLiteralToken;
function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail;
function isImportOrExportSpecifier(node: Node): node is ImportSpecifier | ExportSpecifier;
function isTypeOnlyImportOrExportDeclaration(node: Node): node is TypeOnlyCompatibleAliasDeclaration;
function isTypeOnlyImportOrExportDeclaration(node: Node): node is TypeOnlyAliasDeclaration;
function isAssertionKey(node: Node): node is AssertionKey;
function isStringTextContainingNode(node: Node): node is StringLiteral | TemplateLiteralToken;
function isModifier(node: Node): node is Modifier;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4368,7 +4368,7 @@ declare namespace ts {
function isTemplateLiteralToken(node: Node): node is TemplateLiteralToken;
function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail;
function isImportOrExportSpecifier(node: Node): node is ImportSpecifier | ExportSpecifier;
function isTypeOnlyImportOrExportDeclaration(node: Node): node is TypeOnlyCompatibleAliasDeclaration;
function isTypeOnlyImportOrExportDeclaration(node: Node): node is TypeOnlyAliasDeclaration;
function isAssertionKey(node: Node): node is AssertionKey;
function isStringTextContainingNode(node: Node): node is StringLiteral | TemplateLiteralToken;
function isModifier(node: Node): node is Modifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tests/cases/conformance/importAssertion/3.ts(3,25): error TS1324: Dynamic import
tests/cases/conformance/importAssertion/3.ts(4,25): error TS1324: Dynamic import only supports a second argument when the '--module' option is set to 'esnext'.
tests/cases/conformance/importAssertion/3.ts(5,26): error TS1324: Dynamic import only supports a second argument when the '--module' option is set to 'esnext'.
tests/cases/conformance/importAssertion/3.ts(7,25): error TS1324: Dynamic import only supports a second argument when the '--module' option is set to 'esnext'.
tests/cases/conformance/importAssertion/3.ts(8,11): message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
tests/cases/conformance/importAssertion/3.ts(8,11): message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments
tests/cases/conformance/importAssertion/3.ts(9,25): error TS1324: Dynamic import only supports a second argument when the '--module' option is set to 'esnext'.
tests/cases/conformance/importAssertion/3.ts(10,25): error TS1324: Dynamic import only supports a second argument when the '--module' option is set to 'esnext'.
tests/cases/conformance/importAssertion/3.ts(10,52): error TS1009: Trailing comma not allowed.
Expand Down Expand Up @@ -65,7 +65,7 @@ tests/cases/conformance/importAssertion/3.ts(10,52): error TS1009: Trailing comm
!!! error TS1324: Dynamic import only supports a second argument when the '--module' option is set to 'esnext'.
const f = import()
~~~~~~~~
!!! message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
!!! message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments
const g = import('./0', {}, {})
~~
!!! error TS1324: Dynamic import only supports a second argument when the '--module' option is set to 'esnext'.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
tests/cases/conformance/importAssertion/3.ts(2,11): message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
tests/cases/conformance/importAssertion/3.ts(3,11): message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
tests/cases/conformance/importAssertion/3.ts(4,11): message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
tests/cases/conformance/importAssertion/3.ts(5,12): message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
tests/cases/conformance/importAssertion/3.ts(7,11): message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
tests/cases/conformance/importAssertion/3.ts(8,11): message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
tests/cases/conformance/importAssertion/3.ts(9,11): message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
tests/cases/conformance/importAssertion/3.ts(10,11): message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
tests/cases/conformance/importAssertion/3.ts(2,11): message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments
tests/cases/conformance/importAssertion/3.ts(3,11): message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments
tests/cases/conformance/importAssertion/3.ts(4,11): message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments
tests/cases/conformance/importAssertion/3.ts(5,12): message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments
tests/cases/conformance/importAssertion/3.ts(7,11): message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments
tests/cases/conformance/importAssertion/3.ts(8,11): message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments
tests/cases/conformance/importAssertion/3.ts(9,11): message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments
tests/cases/conformance/importAssertion/3.ts(10,11): message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments


==== tests/cases/conformance/importAssertion/0.ts (0 errors) ====
Expand Down Expand Up @@ -33,28 +33,28 @@ tests/cases/conformance/importAssertion/3.ts(10,11): message TS1444: Dynamic imp
const a = import('./0')
const b = import('./0', { assert: { type: "json" } })
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
!!! message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments
const c = import('./0', { assert: { type: "json", ttype: "typo" } })
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
!!! message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments
const d = import('./0', { assert: {} })
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
!!! message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments
const dd = import('./0', {})
~~~~~~~~~~~~~~~~~
!!! message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
!!! message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments
declare function foo(): any;
const e = import('./0', foo())
~~~~~~~~~~~~~~~~~~~~
!!! message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
!!! message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments
const f = import()
~~~~~~~~
!!! message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
!!! message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments
const g = import('./0', {}, {})
~~~~~~~~~~~~~~~~~~~~~
!!! message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
!!! message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments
const h = import('./0', { assert: { type: "json" }},)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
!!! message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments


Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(5,8): error TS1325: Specifier of dynamic import cannot be spread element.
tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(7,17): error TS1325: Specifier of dynamic import cannot be spread element.
tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(8,12): message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(8,12): message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments
tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,19): error TS2307: Cannot find module 'pathToModule' or its corresponding type declarations.
tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,35): error TS1324: Dynamic import only supports a second argument when the '--module' option is set to 'esnext'.

Expand All @@ -19,7 +19,7 @@ tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,35):
!!! error TS1325: Specifier of dynamic import cannot be spread element.
const p2 = import();
~~~~~~~~
!!! message TS1444: Dynamic import must only have a specifier and an optional assertion as arguments
!!! message TS1450: Dynamic import must only have a specifier and an optional assertion as arguments
const p4 = import("pathToModule", "secondModule");
~~~~~~~~~~~~~~
!!! error TS2307: Cannot find module 'pathToModule' or its corresponding type declarations.
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy